Skip to main content
Twin exposes a REST API that lets you create agents, trigger runs, inspect events, and manage API keys programmatically.

Base URL

OpenAPI Specification

A machine-readable OpenAPI 3.1 schema is available at:
You can use this spec to generate client libraries, import into tools like Postman or Insomnia, or explore the API interactively in the docs playground above.

Authentication

Use the following header on every request:
Generate an API key from your Twin account or via the API itself (see below).

Error Handling

Error responses follow RFC 9457 Problem Details and return Content-Type: application/problem+json.
  • type is a URI identifying the problem type (about:blank means no extra semantics beyond the HTTP status).
  • status is the HTTP status code.
  • title is the standard HTTP reason phrase.
  • detail is a human-readable error message.
If you are migrating from the previous error.code / error.message format, update your error parsing logic.

API Keys

API key management endpoints currently use the /api/public/v1 path family. These endpoints use the same auth headers and Problem Detail error format as the /v1 endpoints.

List API keys

Returns all API keys for the authenticated user.Example
Response

Create an API key

Creates a new API key. The full key is only returned once, so store it securely.Request bodyExample
Response
The api_key field is only returned at creation time. Store it immediately.

Revoke an API key

Permanently revokes an API key. Requests using it stop working immediately.Path parametersExample
Response

Identity

Get current user

Returns the authenticated user ID.Example
Response

Agents

Versioned agent endpoints live under /v1/agents.

List agents

Returns agents for the authenticated user, with optional pagination and workspace filtering.Query parametersExample
Response

Create an agent

Creates a new agent and returns the full agent object.Request bodyExample
Response 201 Created

Get an agent

Returns full details for a specific agent.Path parametersExample
Response

Delete an agent

Permanently deletes an agent and its run data.Path parametersExample
Response 204 No Content — empty body on success. Returns 404 if the agent was not found.

Runs

Trigger, list, cancel, and delete runs under each agent.

List runs

Returns run history for an agent.Path parametersQuery parametersExample
Response

Start a run

Starts a run for an existing agent.Path parametersRequest bodyExample
Response 201 Created

Delete a run

Deletes a run for a specific agent.Path parametersExample
Response 204 No Content — empty body on success. Returns 404 if the run was not found.

Cancel a run

Cancels a running run. The request is idempotent — cancelling an already-finished run returns success.Path parametersRequest body (optional)The body is entirely optional — you may send an empty object {} or omit the body altogether.Example
Response
An empty error means success. A non-empty value is informational (e.g. the run was already stopped).

Events

List run events

Returns events for a specific run.Path parametersQuery parametersExample
Response

Webhooks

Register webhook URLs to receive push notifications when runs change state. Instead of polling for run completion, your backend gets an HTTP POST for each lifecycle event.

Event types

Create a webhook

Registers a webhook URL for the given agent. The signing secret is returned only once in the response — store it immediately.Path parametersRequest bodyExample
Response 201 Created
The signing_secret is only returned at creation time. Store it securely — you need it to verify incoming webhook signatures.

List webhooks

Returns all webhooks registered for the given agent.Path parametersExample
Response

Get a webhook

Returns details for a specific webhook.Path parametersExample
Response

Update a webhook

Updates a webhook’s URL, subscribed events, or status. All fields are optional — only provided fields are changed.Path parametersRequest bodyExample
Response

Delete a webhook

Permanently deletes a webhook. No further events will be delivered.Path parametersExample
Response 204 No Content

Webhook payload

When a subscribed event fires, Twin sends an HTTP POST to your webhook URL with a JSON body:

Verifying webhook signatures

Every webhook delivery includes two headers: To verify authenticity, compute HMAC-SHA256(signing_secret, raw_request_body) and compare it to the signature in the header. Example (Node.js)

Schedules

Manage cron-based schedules for agents. Each agent can have at most one schedule.

Get agent schedule

Returns the current schedule for an agent, if one exists.Path parametersExample
Response
Returns {"schedule": null} if no schedule is set.

Set agent schedule

Creates or replaces the cron schedule for an agent. The agent must be deployed.Path parametersRequest bodyExample
Response
Twin uses 7-field cron expressions: sec min hour day month day-of-week year.

Delete agent schedule

Removes the schedule from an agent.Path parametersExample
Response

Pause schedule

Pauses the agent’s schedule. The schedule is retained but will not trigger runs until resumed.Path parametersExample
Response

Resume schedule

Resumes a paused schedule.Path parametersExample
Response

List all schedules

Returns all schedules for the authenticated user across all agents.Example
Response

Instructions

Read and update the auto-generated instructions for an agent, with version history.

Get instructions

Returns the current instructions for an agent.Path parametersExample
Response

Update instructions

Replaces the agent’s instructions. Each update creates a new version in the history.Path parametersRequest bodyExample
Response

Get instructions history

Returns previous versions of the agent’s instructions.Path parametersQuery parametersExample
Response

Workspaces

Organize agents into workspaces (folders). Every user has at least one default workspace.

List workspaces

Returns all workspaces for the authenticated user.Example
Response

Create a workspace

Creates a new workspace.Request bodyExample
Response 201 Created

Update a workspace

Updates a workspace’s name or icon.Path parametersRequest bodyExample
Response

Delete a workspace

Deletes a workspace and all agents inside it.Path parametersExample
Response
This permanently deletes the workspace and all agents within it.

Reorder workspaces

Sets the display order of workspaces.Request bodyExample
Response

Move agent to workspace

Moves an agent from its current workspace to a different one.Path parametersRequest bodyExample
Response

Quick Reference

Agent, run, and event APIs are now versioned REST endpoints under /v1 with standard HTTP methods.

Get your API key

Sign in to Twin to generate your API key and start building.