Rename a stream
Edit this pageStream · Related pages
Posted: 2026-09-16 · Report this thread
Rename(ctx context.Context, newName string) (*Stream, error)Changes the stream’s registered name. Its id, settings, messages, and consumer groups are preserved. The old name becomes available for another registration.
Example
Rename the payments.requested stream to payments.pending using an
initialized client.
payments := client.Stream[sqlstreams.RawPayload]("payments.requested")renamed, err := payments.Rename(ctx, "payments.pending")if err != nil { return err}fmt.Println(renamed.Id, renamed.Name)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context |
Yes | Cancellation or its deadline interrupts the operation. |
newName |
string |
Yes | An unused name matching ^[a-z0-9._-]+$, different from the current name. |
Returns
| Condition | Return value |
|---|---|
| Rename succeeds | (stream, nil), containing the updated stream object. |
| Rename fails | (nil, err). |
CLI
sqlstreams stream rename payments.requested payments.pendingPrints the old name, new name, and preserved id. --output json returns the
updated registration.
Errors
| Error | When |
|---|---|
| Validation error | A name is empty, the new name is invalid, or both names are identical. |
ErrReservedStreamName |
Either name starts with __system.. |
ErrStreamNotFound |
The original stream is absent. |
ErrStreamNameTaken |
The new name is already registered. |
| Database or context error | The rename fails or is interrupted. |
Related topics
- Retrieve a stream — Read the registration by its current name.
- Register a stream — Declare stream settings.