skip to content
superbot.gg

Read an agent computer job

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

GET /v1/devices/{device_id}/jobs/{job_id}

The job and, once it is done or failed, its result. wait (seconds, at most 25) parks the read until the job settles. A job lost to a Superbot restart answers 410 job_lost_in_restart (retryable: true, kind): it may have run on the agent computer, so check before repeating anything that changes state, then send it again. An id nobody minted, another account's, or older than the 600 s job lifetime is 404 job_not_found.

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

Operation id getAgentJob in Devices.

Path parameters

  • device_id string required

    An agent computer (agt_…) on your account.

  • job_id string required

    The job id the enqueue answered.

Query parameters

  • wait string optional

    Seconds to wait for the job to settle, 0-25.

Response 200

The job.

application/json: AgentJobView.

  • job_id string required
  • device_id string 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.

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

  • created_at string required
  • expires_at string required
  • result AgentJobResult

    Present once the state is done or failed.

    3 fields
    • ok boolean required
    • content any
    • error object
      2 fields
      • code string required
      • message string required

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.

410job_lost_in_restart

Superbot restarted after the job was queued and its outcome was not kept (job_lost_in_restart, retryable: true, kind). Send the job again once a repeat is safe.

view .mdopenapi
Request

curl

curl -sS -X GET "https://superbot.gg/v1/devices/$DEVICE_ID/jobs/$JOB_ID" \
  -H "Authorization: Bearer $SUPERBOT_API_KEY"

JavaScript

const deviceId = 'DEVICE_ID';
const jobId = 'JOB_ID';
const res = await fetch(`https://superbot.gg/v1/devices/${deviceId}/jobs/${jobId}`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.SUPERBOT_API_KEY}`,
  },
});
console.log(res.status, await res.json());

Python

import os
import requests

device_id = "DEVICE_ID"
job_id = "JOB_ID"
res = requests.request(
    "GET",
    f"https://superbot.gg/v1/devices/{device_id}/jobs/{job_id}",
    headers={
        "Authorization": f"Bearer {os.environ['SUPERBOT_API_KEY']}",
    },
)
print(res.status_code, res.json())
Response

200 The job.

{
  "job_id": "your-job-id",
  "device_id": "your-device-id",
  "kind": "bash",
  "state": "queued",
  "created_at": "your-created-at",
  "expires_at": "your-expires-at",
  "result": {
    "ok": true,
    "content": "your-content",
    "error": {
      "code": "your-code",
      "message": "your-message"
    }
  }
}

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

410 Superbot restarted after the job was queued and its outcome was not kept (`job_lost_in_restart`, `retryable: true`, `kind`). Send the job again once a repeat is safe.

{
  "error": "job_lost_in_restart",
  "message": "your-message",
  "doc_url": "https://superbot.gg/developers#errors",
  "request_id": "req_5f1c0a9e2b7d4c3a1e0f9b8d"
}