> ## 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.

# End Sessions

> End every live and queued session of a project while keeping it on.

End every live and queued session of a project without switching it off. Viewers receive disconnect code `4000`; new viewers can join straight away. Use it to clear stuck viewers, or right before switching the active build so everyone lands on the new one.

<Info>
  Scope: `control`. Team members need the Editor role or above. Limited to 30 control calls per minute per account.
</Info>

## Path parameters

<ParamField path="projectId" type="string" required>
  The project whose sessions to end.
</ParamField>

## Headers

<ParamField header="x-api-key" type="string" required>
  An API key issued with the `control` scope.
</ParamField>

## Response

<ResponseField name="enabled" type="boolean">The project's on/off state, unchanged by this call.</ResponseField>
<ResponseField name="sessionsSignalled" type="number">Live and queued sessions told to end. `0` when there were none.</ResponseField>
<ResponseField name="regionAnswered" type="boolean">`false` when the region's session store could not be read; nothing was ended. Retry.</ResponseField>

<RequestExample>
  ```bash cURL theme={"dark"}
  curl -X POST https://platform.streampixel.io/api/v1/projects/664f1a2b3c4d5e6f7a8b9c0d/sessions/end \
    -H "x-api-key: $STREAMPIXEL_API_KEY"
  ```

  ```javascript Node.js theme={"dark"}
  const res = await fetch(
    'https://platform.streampixel.io/api/v1/projects/664f1a2b3c4d5e6f7a8b9c0d/sessions/end',
    { method: 'POST', headers: { 'x-api-key': process.env.STREAMPIXEL_API_KEY } }
  );
  console.log(await res.json());
  ```

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

  r = requests.post(
      "https://platform.streampixel.io/api/v1/projects/664f1a2b3c4d5e6f7a8b9c0d/sessions/end",
      headers={"x-api-key": os.environ["STREAMPIXEL_API_KEY"]},
  )
  print(r.json())
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={"dark"}
  {
    "projectId": "664f1a2b3c4d5e6f7a8b9c0d",
    "name": "Showroom",
    "region": "Europe",
    "enabled": true,
    "sessionsSignalled": 2,
    "regionAnswered": true
  }
  ```
</ResponseExample>

## Errors

| Status | `code`          | Cause                                                                          |
| ------ | --------------- | ------------------------------------------------------------------------------ |
| `403`  | `API_KEY_SCOPE` | The key was issued without `control`.                                          |
| `403`  | —               | The project belongs to another account, or the team role cannot edit projects. |
| `404`  | `NOT_FOUND`     | No project with that id.                                                       |
| `429`  | `RATE_LIMITED`  | More than 30 control calls in a minute. `Retry-After` is set.                  |
