# Turn switches off for a session

**POST** `/api/embed/v1/sessions/current/turn-off`

Turns more switches off for the frame’s session. Nothing turns one back on.

Needs the frame’s session: `Authorization: Bearer gri_…`. The SDK calls it; you rarely do.

Embed · Self-hosted with an Embed license

## Parameters

### Body

- `turnOff` · Optional · array of strings: Switch IDs to turn off. Unknown ones are listed in `ignored`.

## Responses

- 200 OK

  The session’s switches now.

- 400 `VALIDATION_ERROR`

  The body isn’t JSON.

- 401 `UNAUTHORIZED`

  No session token.

- 401 `EMBED_SESSION_ENDED`

  The session ended. `details.reason` says why, such as `access_removed`, `role_changed` or `workspace_deleted`.

- 403 `EMBED_NOT_AVAILABLE`

  Embed isn’t licensed here, or sign-in is off (`details.reason`: `not_licensed` or `sign_in_off`).

- 500 `INTERNAL_ERROR`

  Something failed on the installation’s side. Try again.

Any call can also answer: [`413 PAYLOAD_TOO_LARGE`](https://docs.gorunner.io/errors#PAYLOAD_TOO_LARGE) · [`415 INVALID_CONTENT_TYPE`](https://docs.gorunner.io/errors#INVALID_CONTENT_TYPE) · [`429 RATE_LIMITED`](https://docs.gorunner.io/errors#RATE_LIMITED) · [`503 BUSY`](https://docs.gorunner.io/errors#BUSY). See [Errors](https://docs.gorunner.io/embed/api#errors).

Request

**curl**

```bash
GORUNNER="https://automations.example.com"
GORUNNER_SESSION="gri_…"  # the frame’s session

URL="$GORUNNER/api/embed/v1/sessions/current/"
URL="${URL}turn-off"
curl -X POST "$URL" \
  -H "Authorization: Bearer $GORUNNER_SESSION" \
  -H "Content-Type: application/json" \
  -d '{
    "turnOff": [
      "deleteRuns",
      "importExport"
    ]
  }'
```

**JavaScript**

```js
const GORUNNER = "https://automations.example.com";
const SESSION = process.env.GORUNNER_SESSION; // gri_…

const res = await fetch(
  `${GORUNNER}/api/embed/v1/sessions/current/` +
    `turn-off`,
  {
    method: "POST",
    headers: {
        Authorization: `Bearer ${SESSION}`,
        "Content-Type": "application/json",
      },
    body: JSON.stringify({
        turnOff: ["deleteRuns", "importExport"],
      }),
  },
);
const { data } = await res.json();
```

**Python**

```python
import os, requests

GORUNNER = "https://automations.example.com"
SESSION = os.environ["GORUNNER_SESSION"]  # gri_…

res = requests.post(
    f"{GORUNNER}/api/embed/v1/sessions/current/"
    f"turn-off",
    headers={"Authorization": f"Bearer {SESSION}"},
    json={
      "turnOff": ["deleteRuns", "importExport"],
    },
)
data = res.json()["data"]
```

Response · 200 OK, shortened

```json
{
  "data": {
    "switches": {
      "deleteRuns": false,
      "importExport": false,
      "…": true
    },
    "ignored": []
  }
}
```

**Every field**

### Body

- `turnOff` · Optional · array of strings

### Response · 200 OK

- `data` · object
  - `switches` · object: Every switch id with its effective value; a missing id is off.
    - `{key}` · boolean: Each key’s value.
  - `ignored` · array of strings

Related: [Switches](https://docs.gorunner.io/embed/switches) · [SDK](https://docs.gorunner.io/embed/sdk)

Source: https://docs.gorunner.io/embed/api/sign-in/narrow-session
