Agents SDK

API Reference

REST API for the 21st Agents runtime. Manage sandboxes, threads, files, and stream chat responses.

Base URL

https://relay.an.dev

All API requests use HTTPS. Request and response bodies are JSON-encoded.

Authentication

All endpoints require a bearer token passed via the Authorization header. Create an API key in the Dashboard.

Authorization: Bearer <your_api_key>

Conventions

  • Property names use camelCase.
  • Timestamps are ISO 8601 strings (e.g. 2026-02-26T12:00:00Z).
  • IDs are prefixed strings (e.g. sb_ for sandboxes, th_ for threads).
  • The chat endpoint returns Server-Sent Events (SSE) for streaming responses.
  • Errors return a structured JSON body with code, message, and status fields. See Errors.

Endpoints

Sandboxes

POST/v1/sandboxesCreate Sandbox
GET/v1/sandboxes/:idGet Sandbox
DELETE/v1/sandboxes/:idDelete Sandbox

Sandbox Operations

POST/v1/sandboxes/:id/execExecute Command
POST/v1/sandboxes/:id/filesWrite Files
GET/v1/sandboxes/:id/filesRead File
POST/v1/sandboxes/:id/git/cloneClone Repository

Threads

GET/v1/sandboxes/:id/threadsList Threads
POST/v1/sandboxes/:id/threadsCreate Thread
GET/v1/sandboxes/:id/threads/:threadIdGet Thread
DELETE/v1/sandboxes/:id/threads/:threadIdDelete Thread

Chat

POST/v1/chat/:slugSend Message
GET/v1/chat/:slug/:sandboxId/streamResume Stream
DELETE/v1/chat/:slug/:sandboxId/streamCancel Stream

SDKs

Next.js SDK - For the recommended approach using @21st-sdk/nextjs with server-side token exchange, see the Get Started guide.

Server SDK - For server-side sandbox and thread management, see the Server SDK page.

API Reference - 21st Agents SDK Docs