skip to content
superbot.gg

Read a turn

Part of Gateway, 7 operations. The overview covers keys, scopes and errors.

GET /v1/turns/{session}

Where a turn of one of your conversations stands: running with the text so far, done with the reply (and assets, the files it made, for a caller key that draws no cards), error, cancelled. ?request= names one turn (the request_id of an async call’s 202, from either form: x-superbot-callback-url or Prefer: respond-async); without it the conversation’s newest turn. A turn the gateway admitted reads running (empty text) from the moment of its 202, before the agent has produced a frame, so a poll that starts at once never sees a gap; one an earlier process lost after admitting it reads error with reason interrupted. Turns are stored for 24 hours. Needs the turns:read scope; the read bills nothing. A missing or unknown bearer is 401, a key without the scope 403 insufficient_scope, a request id this account never admitted 404 no_turn and a deleted conversation 410 chat_deleted.

A caller key holding turns:read (Authorization: Bearer sbc_… or x-api-key: sbc_…), or a signed-in session.

Operation id getTurn in Gateway.

Path parameters

  • session string required

    The conversation id (what x-superbot-session named, or the session of an async call’s 202).

Query parameters

  • request string optional

    A turn’s request id.

Response 200

The turn.

application/json: TurnRecord.

  • state string required

    Where the turn stands. One of running, done, error, cancelled, parked.

  • request_id string required
  • text string

    The reply so far (running) or the whole reply (done).

  • assets array of TurnAsset

    Only on a done turn, only when it made files, and only when the read is by a caller key that draws no cards (an automation step, a script): the files the reply names, one entry per file, in order. text is unchanged beside it.

    4 fields
    • name string required

      A file name with its extension where one is known, ready to hand to a Gmail attachment or a Drive upload.

    • mime string required

      The file’s media type.

    • size integer required

      The size in bytes.

    • url string required

      Where to fetch the bytes. A generated picture, sound or clip is at /gen/; an artifact is published at an unguessable, immutable public link (/shared/ or /gen/) for a zapier/ or n8n/ caller, and answered by its signed artifact link (valid 24 hours) for any other.

Errors

StatusCodeWhat to change
401unauthorized

Send a live caller key or session as Authorization: Bearer … or x-api-key. No key yet: create one at /account/api, or sign a user in at /auth.md.

403insufficient_scope

The key lacks the scope in required_scopes; mint a key that holds it.

404not_found

No such resource on this account; check the id.

view .mdopenapi
Request

curl

curl -sS -X GET "https://superbot.gg/v1/turns/$SESSION" \
  -H "Authorization: Bearer $SUPERBOT_API_KEY"

JavaScript

const session = 'SESSION';
const res = await fetch(`https://superbot.gg/v1/turns/${session}`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.SUPERBOT_API_KEY}`,
  },
});
console.log(res.status, await res.json());

Python

import os
import requests

session = "SESSION"
res = requests.request(
    "GET",
    f"https://superbot.gg/v1/turns/{session}",
    headers={
        "Authorization": f"Bearer {os.environ['SUPERBOT_API_KEY']}",
    },
)
print(res.status_code, res.json())
Response

200 The turn.

{
  "state": "running",
  "request_id": "your-request-id",
  "text": "your-text",
  "assets": [
    {
      "name": "Q3-report.pdf",
      "mime": "application/pdf",
      "size": 0,
      "url": "https://example.com"
    }
  ]
}

401 The bearer is missing, malformed or unknown.

{
  "error": "unauthorized",
  "message": "Send a live caller key or session as Authorization: Bearer … or x-api-key. No key yet: create one at /account/api, or sign a user in at /auth.md.",
  "doc_url": "https://superbot.gg/developers#errors-unauthorized",
  "request_id": "req_5f1c0a9e2b7d4c3a1e0f9b8d"
}

403 The key lacks a scope (insufficient_scope), is revoked, or may not call this route.

{
  "error": "insufficient_scope",
  "message": "The key lacks the scope in required_scopes; mint a key that holds it.",
  "doc_url": "https://superbot.gg/developers#errors-insufficient_scope",
  "request_id": "req_5f1c0a9e2b7d4c3a1e0f9b8d"
}

404 No such resource on this account.

{
  "error": "not_found",
  "message": "No such resource on this account; check the id.",
  "doc_url": "https://superbot.gg/developers#errors-not_found",
  "request_id": "req_5f1c0a9e2b7d4c3a1e0f9b8d"
}