REST API overview
Call Runbear agents and manage your organization from your own code over the REST API, starting with a three-request quickstart.
On this page
The Runbear REST API lets your own software talk to your agents: start a conversation, send messages, stream replies, attach files, and manage agents, keys and usage. Use it to put an agent behind your own product, run it from a backend job, or pull its traces and credit usage into your own systems.
These pages explain how the API behaves: authentication, chat, streaming, files, errors and limits. Every request and response field is listed in the OpenAPI reference.
Base URL and reference#
- Base URL:
https://api.runbear.io/v1 - Interactive reference:
https://api.runbear.io/v1/docs - Raw OpenAPI 3.1 document:
https://api.runbear.io/v1/openapi.json
The API publishes 57 operations. Generate a client from the raw document if your language has an OpenAPI generator, and regenerate it when you pick up new fields.
What you need#
- An API key for your organization. See Authentication and API keys.
- The id of the agent you want to call. It is the id in the agent's
dashboard URL, and
GET /v1/assistantslists every agent your key can see.
Quickstart#
Create a thread for the agent, run a turn on it, then read the thread back.
export RUNBEAR_API_KEY="<your key>"
export AGENT_ID="<agent id>"
# 1. Create a thread
curl -s https://api.runbear.io/v1/threads \
-H "Authorization: Bearer $RUNBEAR_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"assistant_id\": \"$AGENT_ID\"}"
# => {"thread":{"id":"<thread id>"}}
# 2. Run a turn and wait for the reply
curl -s https://api.runbear.io/v1/threads/<thread id>/runs \
-H "Authorization: Bearer $RUNBEAR_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"assistant_id\": \"$AGENT_ID\", \"messages\": [{\"role\": \"user\", \"content\": \"What can you help me with?\"}]}"
# => {"message":{"id":"...","content":"..."}}
# 3. Read the conversation
curl -s https://api.runbear.io/v1/threads/<thread id>/messages \
-H "Authorization: Bearer $RUNBEAR_API_KEY"To show the reply as it is written, call /runs/stream instead of /runs
and read the stream. For a single request that creates the
thread for you, use POST /v1/chat/completions; Chat compares the
two.
Naming: agents and assistants#
The API is older than the word "agent" in the dashboard, so both names appear.
An assistant is an agent: request bodies and query strings name it
assistant_id, and responses name it assistantId.
/v1/assistantsis the original agent resource.GET /v1/assistantsis the only endpoint that lists every agent, and takes an optionalnamefilter (case-insensitive, partial match)./v1/agentsis the full management resource.GET /v1/agentsdoes not list everything: it requiresids, a comma-separated list of 1 to 100 agent ids, and answers400without it.PATCH /v1/assistants/{id}writes itsdescriptionfield into the agent's system prompt, not into a short description.
Resource map#
| Resource | Operations | What it does |
|---|---|---|
| Threads and runs | GET, POST /v1/threads; POST /v1/threads/{threadId}/runs and /runs/stream; GET /v1/threads/{threadId}/messages | Conversations with an agent. See Chat |
| Chat | POST /v1/chat/completions, POST /v1/chat/suggestions | One-call chat, and follow-up suggestions. See Chat |
| Files | POST /v1/files/upload | Attachments for a message. See Files |
| Sessions | POST /v1/sessions, POST /v1/sessions/refresh | Browser session passes for the Web SDK |
| Assistants | GET /v1/assistants, GET and PATCH /v1/assistants/{id} | List agents, and edit name and system prompt |
| Agents | GET, POST /v1/agents; GET, PATCH, DELETE /v1/agents/{id} | Create and configure agents. See Managing agents via API |
| Agent knowledge | /v1/agents/{id}/knowledge-bases/... (6 operations) | Website, Google Drive and uploaded-file knowledge |
| Agent feedback | GET /v1/agents/{id}/analytics/feedback | Response feedback counts |
| Tool integrations | /v1/agents/{id}/tool-integrations/... (6 operations), GET /v1/tool-integrations/managed-mcps | Attach tools to an agent. See Tool integrations API |
| Hooks | GET, PUT, DELETE /v1/agents/{id}/hooks and /session-start-hook | Call your code during a conversation. See Hooks API |
| Traces | GET /v1/agents/{id}/traces, /traces/export, /traces/{traceId}, /messages/{messageId}/trace | What each turn did. See Traces API |
| Credits | GET /v1/credits/usage, /usage/periods, /usage/entries | Credit usage. See Credits API |
| API keys | GET, POST /v1/api-keys; PATCH, DELETE /v1/api-keys/{id} | Manage keys. See Authentication and API keys |
| AI Gateway | GET, PUT, DELETE /v1/ai-gateway | Route the organization's model traffic through a Cloudflare AI Gateway |
| Google Drive service accounts | GET, POST /v1/integrations/google-drive/service-accounts, DELETE .../{id} | Service accounts for Drive knowledge |
| Integration suggestions | GET, PUT /v1/integration-suggestions | Whether agents suggest connecting apps they don't have yet |
Conventions#
- Requests and responses are JSON, except file upload (multipart) and the two streaming routes (NDJSON).
- Ids are UUIDs. Timestamps are ISO 8601.
- Most successful calls answer
200; the exceptions are listed in Errors and limits. - Paginated lists use opaque cursors. Pass back the
nextCursoryou received and stop when it isnull.
Related#
- Authentication and API keys
- Chat and Streaming
- Files
- Errors and limits
- Web SDK — embed an agent in a web page
- MCP server — manage agents from an AI client