# Subscribe to Stream

`GET /data-streams/user/{streamSlug}/subscribe` · Core · Realtime Feeds & Streams

Opens a Server-Sent Events stream of a user stream's messages, starting after a sequence number and following new messages as they arrive. The connection closes after about 25 seconds; reconnect with `Last-Event-ID` to continue where it stopped. 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"`. |
| `fromSequence` | query | no | Start after the message with this sequence. The `Last-Event-ID` header wins when both are sent. Omit it, or send 0, to start at the oldest retained message. Example: `"1200"`. |
| `projectSlug` | path | yes | The project's slug: the path segment after `@`. It is unique within the org. Example: `"storefront"`. |

## Responses

- **200**: A Server-Sent Events stream of the stream's messages.

## 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 GET 'https://<org>.api-<region>.k9o.io/@storefront/data-streams/user/<streamSlug>/subscribe' \
  -H 'Authorization: Bearer $K9O_TOKEN'
```

### fetch

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

### k9o CLI

```bash
k9o stream tail <slug>
```

### @k9o/core

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

### k9o

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

### sdk-go

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

### k9o

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

### dev.k9o:core

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

### K9o.Core

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

### k9o

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

### k9o/sdk

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

### K9o

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

### core-kotlin

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

### k9o (Flutter)

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

### @k9o/react-native

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


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