> ## Documentation Index
> Fetch the complete documentation index at: https://docs.streampixel.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Disconnect Codes

> Every session ending in a window, with the close code that explains it.

Return the disconnect-code entries recorded for a project in a window: one per session ending, with the code, the session it belongs to and when. Group by code to see *why* sessions end; the meaning of each code is in [Disconnect codes](/resources/quick-start-guide/disconnect-codes).

<Info>
  Scope: `read`. Default `limit` is 1000, newest first.
</Info>

## Path parameters

<ParamField path="projectId" type="string" required>
  The project.
</ParamField>

## Query parameters

<ParamField query="startDate" type="string">ISO 8601 start of the window.</ParamField>
<ParamField query="endDate" type="string">ISO 8601 end of the window.</ParamField>
<ParamField query="limit" type="integer" default="1000">Entries to return.</ParamField>
<ParamField query="skip" type="integer" default="0">Offset.</ParamField>

## Headers

<ParamField header="x-api-key" type="string" required>
  Your Streampixel API key.
</ParamField>

## Response

<ResponseField name="totalDisconnectEntries" type="number">Entries in the window.</ResponseField>
<ResponseField name="count" type="number">Entries returned.</ResponseField>

<ResponseField name="disconnectCodes" type="array">
  <Expandable title="Entry fields">
    <ResponseField name="disconnectCode" type="number">The close code, e.g. `1000`, `1006`, `4004`, `4006`.</ResponseField>
    <ResponseField name="sessionId" type="string">The session.</ResponseField>
    <ResponseField name="streamingId" type="string | null">The streamer instance.</ResponseField>
    <ResponseField name="timestamp" type="string">ISO 8601.</ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={"dark"}
  curl "https://platform.streampixel.io/api/v1/analytics/projects/664f1a2b3c4d5e6f7a8b9c0d/disconnect-codes?startDate=2026-09-25T00:00:00Z&endDate=2026-09-26T00:00:00Z" \
    -H "x-api-key: $STREAMPIXEL_API_KEY"
  ```

  ```javascript Node.js theme={"dark"}
  const u = new URL('https://platform.streampixel.io/api/v1/analytics/projects/664f1a2b3c4d5e6f7a8b9c0d/disconnect-codes');
  u.search = new URLSearchParams({ startDate: '2026-09-25T00:00:00Z', endDate: '2026-09-26T00:00:00Z' });
  const { disconnectCodes } = await (await fetch(u, { headers: { 'x-api-key': process.env.STREAMPIXEL_API_KEY } })).json();
  const histogram = {};
  for (const e of disconnectCodes) histogram[e.disconnectCode] = (histogram[e.disconnectCode] ?? 0) + 1;
  console.log(histogram); // e.g. { 1000: 118, 1006: 12, 4004: 9, 4006: 2 }
  ```

  ```python Python theme={"dark"}
  import os, collections, requests

  r = requests.get(
      "https://platform.streampixel.io/api/v1/analytics/projects/664f1a2b3c4d5e6f7a8b9c0d/disconnect-codes",
      params={"startDate": "2026-09-25T00:00:00Z", "endDate": "2026-09-26T00:00:00Z"},
      headers={"x-api-key": os.environ["STREAMPIXEL_API_KEY"]},
  )
  print(collections.Counter(e["disconnectCode"] for e in r.json()["disconnectCodes"]))
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={"dark"}
  {
    "success": true,
    "projectId": "664f1a2b3c4d5e6f7a8b9c0d",
    "totalDisconnectEntries": 141,
    "count": 141,
    "limit": 1000,
    "skip": 0,
    "disconnectCodes": [
      { "disconnectCode": 1000, "sessionId": "session_1790294409382_3035", "streamingId": "st_7f3a", "timestamp": "2026-09-25T14:31:40.000Z", "logType": "Webrtc" },
      { "disconnectCode": 4006, "sessionId": "session_1790293988120_2210", "streamingId": "st_6c11", "timestamp": "2026-09-25T13:58:02.000Z", "logType": "Webrtc" }
    ]
  }
  ```
</ResponseExample>

## Grouping codes

| Group         | Codes                          | Meaning                                                                                      |
| ------------- | ------------------------------ | -------------------------------------------------------------------------------------------- |
| Normal        | `1000`, `1001`                 | The viewer left.                                                                             |
| Transient     | `1005`, `1006`                 | Network or a suspended tab; the SDK reconnects.                                              |
| Your build    | `4002`, `4003`, `4006`         | Missing, would not start, or crashed. Read the [log](/resources/api-reference/download-log). |
| Your settings | `4000`, `4004`                 | Project off, or the runtime limit was reached.                                               |
| Capacity      | `4001`                         | No free streaming server.                                                                    |
| Platform      | `4005`, `4007`, `4008`, `4009` | Setup or reconnection failed. Contact support if it repeats.                                 |

## Errors

| Status | Cause                                                            |
| ------ | ---------------------------------------------------------------- |
| `403`  | The key lacks `read`, or the project belongs to another account. |
