# Reconnect to Shared Thread Stream

Reconnects to the active (or recently completed) response stream of the live-shared thread behind a share link, for the recipient who joined via this slug — the slug-scoped twin of [Reconnect to Response Stream](/api-reference/responses/reconnect-stream). It replays missed events from `last_event_id`, then live-tails if the response is still streaming. If the stream buffer has expired, it synthesizes a completion event from the saved message.

Allowed **only** when the link's `access_level` is `live` (`403` otherwise); an unknown or unauthorized link returns `404`.

The response is an [SSE](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) stream (`Content-Type: text/event-stream`).

## Authentication

Requires **user** authentication. Authenticate with a Bearer token or `x-api-key` header. Native `EventSource` clients that cannot set an `Authorization` header may pass the token via the `token` query param.

## Path Parameters

**`slug`** string required

The share-link slug, taken from the share URL.

## Query Parameters

**`last_event_id`** integer optional

Resume after this SSE event id — events with a higher id are replayed before live-tailing.

**`token`** string optional

Access token for clients that cannot set an `Authorization` header (native `EventSource`). Ignored when a header credential is present.

## Returns

A `text/event-stream` response. Replayed backlog frames are tagged `"source": "replay"`; subsequent live frames are untagged. If no buffer exists but the thread has a completed response, a single synthesized `response.completed` event is emitted.

## Code Examples

### cURL


```bash
curl -N "https://api.aitronos.com/v1/shared-threads/abc123slug/stream?last_event_id=42" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### Python SDK


```python
from aitronos import Aitronos

client = Aitronos(api_key="", token="YOUR_TOKEN")
with client.threads.shared.reconnect(slug="abc123slug", last_event_id=42) as stream:
    for event in stream:
        print(event.type, event.data)
```

### Python (requests)


```python
import json
import requests

with requests.get(
    "https://api.aitronos.com/v1/shared-threads/abc123slug/stream",
    headers={"Authorization": "Bearer YOUR_TOKEN"},
    params={"last_event_id": 42},
    stream=True,
) as response:
    for line in response.iter_lines():
        if line and line.startswith(b"data: "):
            print(json.loads(line[len(b"data: ") :]))
```

### JavaScript


```javascript
// Native EventSource cannot set headers, so pass the token via the query param.
const source = new EventSource(
  "https://api.aitronos.com/v1/shared-threads/abc123slug/stream?token=YOUR_TOKEN&last_event_id=42",
);

source.onmessage = (event) => {
  console.log(JSON.parse(event.data));
};
```

## Response Examples

### Success (200) — SSE stream


```text
data: {"event": "response.content_delta", "delta": "Added a rollback", "source": "replay"}

data: {"event": "response.content_delta", "delta": " step before the deploy."}

data: {"event": "response.completed", "status": "completed", "thread_id": "thread_5f8c2a1b9d4e4c3f8a7b6c5d4e3f2a1b"}

data: [DONE]
```

### Error — Link does not grant live access (403)


```json
{
  "success": false,
  "error": {
    "code": "INSUFFICIENT_PERMISSIONS",
    "message": "This share link does not grant live co-working access",
    "system_message": "Insufficient permissions",
    "type": "authorization_error",
    "status": 403,
    "details": {
      "link_id": "slink_2b1c3d4e5f6a7b8c9d0e1f2a3b4c5d6e",
      "access_level": "view"
    },
    "trace_id": "...",
    "timestamp": "..."
  }
}
```

### No run to attach to (200)

Having nothing to resume is an **ordinary state**, not a failure — a shared thread whose newest message is an unanswered user turn reaches it every time it is opened. The endpoint answers `200 OK` with `application/json` instead of the event stream:


```json
{
  "active": false,
  "thread_id": "thread_abc123",
  "reason": "expired_or_never_produced",
  "retryable": false
}
```

`active` is always `false` on this shape and is the discriminator: branch on it, and treat any `text/event-stream` response as a stream to read. The body carries `Cache-Control: no-store`, so a "no run here" answer can never be replayed over a live run.

`retryable` is the field that decides what to do next. When a turn is outstanding but has not written its first frame yet, the same `200` comes back with `"reason": "run_in_flight_no_frames"`, `"retryable": true` and a `retry_after_ms` to pace the next attempt — retry then, and only then. A third value, `"run_settled_without_notice"`, means the run outlived the 30-minute orphan ceiling and was settled as failed without its error notice landing; it is not retryable. When `retryable` is `false` the `retry_after_ms` field is **absent** rather than null.

Because this shape is not an SSE stream, read it with `fetch` rather than a native `EventSource`: an `EventSource` requires `text/event-stream` and will treat this `application/json` answer as a connection failure and reconnect on its own schedule.

> **Migrating from the old shape.** Before 2026-08-27 this case was `404 STREAM_NOT_FOUND`, carrying the same `reason` / `retryable` / `retry_after_ms` under `error.details`. Every field survived the move; only the status and the nesting changed.


### Error — Thread not found (404)

`404` on this endpoint now means one thing only: the share link is unknown or unauthorized, or the thread behind it does not exist for this caller. It is never used for "no active stream".

## Related Resources

- [Send to Shared Thread](/api-reference/shared-threads/send-shared-thread) — Post a message to the shared thread
- [Cancel Shared Thread Response](/api-reference/shared-threads/cancel-shared-thread-response) — Cancel your in-flight response
- [Live Shared Thread](/api-reference/shared-threads/live-shared-thread) — Subscribe to the co-working event stream