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, andstatusfields. See Errors.
Endpoints
Sandboxes
| POST | /v1/sandboxes | Create Sandbox |
| GET | /v1/sandboxes/:id | Get Sandbox |
| DELETE | /v1/sandboxes/:id | Delete Sandbox |
Sandbox Operations
| POST | /v1/sandboxes/:id/exec | Execute Command |
| POST | /v1/sandboxes/:id/files | Write Files |
| GET | /v1/sandboxes/:id/files | Read File |
| POST | /v1/sandboxes/:id/git/clone | Clone Repository |
Threads
| GET | /v1/sandboxes/:id/threads | List Threads |
| POST | /v1/sandboxes/:id/threads | Create Thread |
| GET | /v1/sandboxes/:id/threads/:threadId | Get Thread |
| DELETE | /v1/sandboxes/:id/threads/:threadId | Delete Thread |
Chat
| POST | /v1/chat/:slug | Send Message |
| GET | /v1/chat/:slug/:sandboxId/stream | Resume Stream |
| DELETE | /v1/chat/:slug/:sandboxId/stream | Cancel 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.