# Replay Stream

`POST /data-streams/user/{streamSlug}/replay` · Core · Realtime Feeds & Streams

Reads a page of a user stream's retained messages, oldest first, between two sequence numbers. Pass the page's `nextCursor` as `fromSequence` to read the next page; `hasMore` is true while pages come back full. Needs PROJECT_ADMIN or PROJECT_AUDITOR.

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `streamSlug` | path | yes | The stream's slug, unique in the project. Example: `"order-events"`. |
| `projectSlug` | path | yes | The project's slug: the path segment after `@`. It is unique within the org. Example: `"storefront"`. |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `fromSequence` | object | no | Return messages after this stream sequence (exclusive). Pass the previous page's `nextCursor` to continue. Omitted or 0, the read starts at the oldest retained message. An integer or a string of digits. |
| _one of_ | | |  |
| _or_ | | |  |
| `untilSequence` | object | no | Stop at this stream sequence (inclusive). An integer or a string of digits. |
| _one of_ | | |  |
| _or_ | | |  |
| `limit` | integer | no | The most messages to return, 1 to 10000. Default 100. |

## Responses

- **200**: Success

| Field | Type | Required | Description |
|---|---|---|---|
| `data` | object | yes | One page of the stream's retained messages. |
| `data.streamSlug` | string | yes | The stream that was read. |
| `data.events` | array of object | yes | The messages in the range, in ascending sequence order. |
| `data.events.[]sequence` | string | yes | The message's stream sequence number, as a string of digits. It is the resume cursor. |
| `data.events.[]subject` | string | yes | The full subject the message was published on: the stream's `subjectPrefix` plus the publish `subject` suffix (or `_`). |
| `data.events.[]data` | object | yes | The published payload, decoded from JSON: any JSON value. A message whose bytes are not JSON is delivered as `{ "_raw": "<base64>" }`. |
| `data.events.[]publishedAt` | string (date-time) | yes | When the broker accepted the message. |
| `data.nextCursor` | object | yes | The sequence of the last message returned; pass it as `fromSequence` for the next page. When the page is empty it echoes the request's `fromSequence`, or is null if none was sent. |
| _one of_ | | |  |
| _or_ | | |  |
| `data.hasMore` | boolean | yes | True when the page is full (as many messages as `limit`), so more may follow. |
| `meta` | object | yes |  |


## Errors

| HTTP | Code | When |
|---|---|---|
| 503 | `K9O_STREAM_UNAVAILABLE` | Pulse Stream messaging is not configured in this deployment, or the project's stream account is not provisioned, so no messages can be read. Retry later. |
| 403 | `K9O_RBAC_DENY` | Reading Pulse Streams requires PROJECT_ADMIN or PROJECT_AUDITOR. |
| 404 | `K9O_STREAM_NOT_FOUND` | No active Pulse Stream with that slug in this project. |

## Code samples

### cURL

```bash
curl -X POST 'https://<org>.api-<region>.k9o.io/@storefront/data-streams/user/<streamSlug>/replay' \
  -H 'Authorization: Bearer $K9O_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{}'
```

### fetch

```javascript
const res = await fetch('https://<org>.api-<region>.k9o.io/@storefront/data-streams/user/<streamSlug>/replay', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.K9O_TOKEN}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({}),
});
const { data, meta } = await res.json();
```

### k9o CLI

```bash
k9o stream replay <slug>
```

### @k9o/core

```typescript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.streams.replay('<streamSlug>', {})
```

### k9o

```python
# k9o = create_client(org_slug="playground", project_slug="storefront", api_key="k9o_…")
response = k9o.streams.replay("<streamSlug>", {})
```

### sdk-go

```go
// ctx := context.Background()
// client, _ := k9o.NewClient(k9o.ClientOpts{OrgSlug: "playground", ProjectSlug: "storefront", APIKey: "k9o_…"})
data, _, kerr := client.Streams.Replay(ctx, "<streamSlug>", map[string]any{})
```

### k9o

```rust
// let k9o = Client::new(ClientOpts { org_slug: "playground".into(), project_slug: "storefront".into(), api_key: "k9o_…".into() })?;
let resp = k9o.streams.replay("<streamSlug>", json!({})).await?
```

### dev.k9o:core

```java
// K9o k9o = K9o.createClient(K9o.Opts.builder().orgSlug("playground").projectSlug("storefront").apiKey("k9o_…").build());
var response = k9o.streams().replay("<streamSlug>", Map.of())
```

### K9o.Core

```c#
// var k9o = K9oClient.Create(new K9oOptions { OrgSlug = "playground", ProjectSlug = "storefront", ApiKey = "k9o_…" });
var response = await k9o.Streams.ReplayAsync("<streamSlug>", new Dictionary<string, object> {  })
```

### k9o

```ruby
# k9o = K9o.create_client(org_slug: "playground", project_slug: "storefront", api_key: "k9o_…")
response = k9o.streams.replay("<streamSlug>", {  })
```

### k9o/sdk

```php
// $k9o = K9oClient::create(['org_slug' => 'playground', 'project_slug' => 'storefront', 'api_key' => 'k9o_…']);
$response = $k9o->streams->replay('<streamSlug>', [])
```

### K9o

```swift
// let k9o = try K9o.createClient(orgSlug: "playground", projectSlug: "storefront", apiKey: "k9o_…")
let result = try await k9o.streams.replay("<streamSlug>", {})
```

### core-kotlin

```kotlin
// val k9o = createClient { orgSlug = "playground"; projectSlug = "storefront"; apiKey = "k9o_…" }
val result = k9o.streams.replay("<streamSlug>", {})
```

### k9o (Flutter)

```dart
// final k9o = K9o.createClient(orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…');
final result = await k9o.streams.replay('<streamSlug>', {})
```

### @k9o/react-native

```javascript
// const k9o = createClient({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })  // RN, secure storage
const { data } = await k9o.streams.replay('<streamSlug>', {})
```


Canonical page: https://docs.kilimanjaro.dev/api-playground/core/replay-stream
