Unified API: Requirements & Usage
REST Endpoints: Body & Headers
Basic Requirements
Content-Type: application/json
header when sending JSON bodies.- Include your
api_key
orauth_token
in the request body according to the endpoint requirements.
Example Body with Auth Token
JSON{ "auth_token": "USERID:TIMESTAMP:RANDOM", "action": "get_credits" }
Example Body with API Key
JSON{ "operation": "message", "params": { "message": "Hello!" }, "api_key": "YOUR_API_KEY", "agent_id": "YOUR_AGENT_ID" }
WebSocket Usage
The API provides two types of WebSocket connections for each request:
- Session-specific WebSocket URL: Receives responses only for a specific request
ws://broker-url/ws/user?session_id=SESSION_ID&api_key=BROKER_API_KEY
- Persistent WebSocket URL: Receives all events for an agent
ws://broker-url/ws/agent_stream?agent_id=AGENT_ID&broker_key=BROKER_API_KEY&agent_key=YOUR_API_KEY
Both URLs are returned in the API response for /operation
and /upload_file
endpoints. For HTTPS, use wss://
instead of ws://
.
Authentication Notes
Different endpoints require different authentication methods:
- Auth Token Required:
/info
,/createapikey
,/delete_agent
,/agent_history
- API Key Required:
/operation
,/upload_file
, WebSocket connections
Incorrect authentication will result in a 401 Unauthorized response. API keys must be valid and associated with sufficient credits.
Agent Status Requirements
Operations have specific agent status requirements:
- Message Operations: Require agent status to be "running". Cannot send messages to agents with status "thinking" or any other status.
- Other Operations: Allow both "running" and "thinking" statuses.
Attempting an operation on an agent with the wrong status will result in a 409 Conflict response.