skip to content
superbot.gg

Run a job on an agent computer

Part of Devices, 10 operations. The overview covers keys, scopes and errors.

POST /v1/devices/{device_id}/jobs

Queue one device-shell job on a linked agent computer, by its id. First-party only: a session or a device token of your own Superbot app; agent computer tokens, MCP connectors, caller keys and the account API key are refused (403). An asleep agent computer answers queued_asleep; the job waits for its next poll up to 600 s.

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

Operation id createAgentJob in Devices.

Path parameters

  • device_id string required

    An agent computer (agt_…) on your account.

Request body

application/json, required.

  • kind AgentJobKind required

    The device-shell job kinds a first-party device may run on an agent computer. One of bash, bash_write, bash_output, bash_kill, bash_resize, read, write, glob, grep.

  • args object required

    The relay tool's own args, camelCase, per kind: bash {command, cwd?, timeoutMs?, runInBackground?, interactive?} (interactive: a real tty, answered with bash_write; open a terminal pane with {command: <login shell>, runInBackground: true, interactive: true}, whose result carries {type: 'terminal', terminalId}); bash_write {terminalId, input, newline?}; bash_output {terminalId, since?, wait?}; bash_kill {terminalId}; bash_resize {terminalId, cols, rows} (a terminal pane's resize of an interactive terminal's tty: integers, cols 20..500, rows 5..200; a non-interactive terminal answers not_a_tty); read {path, line?, limit?}; write {path, content, overwrite?}; glob {pattern, cwd?}; grep {pattern, path?, cwd?}. Unknown keys are refused.

Response 201

Queued.

application/json: AgentJobEnqueueResponse.

  • job_id string required
  • state AgentJobState required

    queued_asleep: the agent computer has no open poll; the job waits for its next poll inside the 600 s TTL. expired: the TTL ran out before a result. One of queued, queued_asleep, claimed, done, failed, expired.

  • expires_at string required

    ISO 8601, 600 s after the enqueue.

Errors

StatusCodeWhat to change
400invalid_request

A parameter or body field is invalid; param names it and issues lists every problem.

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.

429rate_limited

Over the per-key request bucket; retry after x-ratelimit-reset.

view .mdopenapi
Request

curl

curl -sS -X POST "https://superbot.gg/v1/devices/$DEVICE_ID/jobs" \
  -H "Authorization: Bearer $SUPERBOT_API_KEY" \
  -H "content-type: application/json" \
  -d '{"kind":"bash","args":{}}'

JavaScript

const deviceId = 'DEVICE_ID';
const res = await fetch(`https://superbot.gg/v1/devices/${deviceId}/jobs`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.SUPERBOT_API_KEY}`,
    'content-type': 'application/json',
  },
  body: JSON.stringify({"kind":"bash","args":{}}),
});
console.log(res.status, await res.json());

Python

import os
import requests

device_id = "DEVICE_ID"
res = requests.request(
    "POST",
    f"https://superbot.gg/v1/devices/{device_id}/jobs",
    headers={
        "Authorization": f"Bearer {os.environ['SUPERBOT_API_KEY']}",
        "content-type": "application/json",
    },
    json={"kind":"bash","args":{}},
)
print(res.status_code, res.json())
Response

201 Queued.

{
  "job_id": "your-job-id",
  "state": "queued",
  "expires_at": "your-expires-at"
}

400 The request is malformed or a parameter is invalid; `param` names the field.

{
  "error": "invalid_request",
  "message": "A parameter or body field is invalid; param names it and issues lists every problem.",
  "doc_url": "https://superbot.gg/developers#errors-invalid_request",
  "request_id": "req_5f1c0a9e2b7d4c3a1e0f9b8d"
}

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"
}

429 Over the per-key request bucket; retry after x-ratelimit-reset.

{
  "error": "rate_limited",
  "message": "Over the per-key request bucket; retry after x-ratelimit-reset.",
  "doc_url": "https://superbot.gg/developers#errors-rate_limited",
  "request_id": "req_5f1c0a9e2b7d4c3a1e0f9b8d"
}