octo api: call any endpoint
Send any request to the Askocto REST API from the terminal with octo api, using your saved key, JSON bodies and automatic pagination.
Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.
octo api sends a raw request to the REST API with your saved key attached. Use it for endpoints that have no dedicated command, to try a request before you write code, or to reproduce an error and read its request id.
Syntax
octo api METHOD PATH [flags]
METHOD is GET, POST, PUT, PATCH or DELETE. PATH starts with /v2 for the current API or /v1 for the legacy chatbots API. The CLI adds the base URL, the Authorization: Bearer header and Content-Type: application/json, and prints the response body.
Flags
| Flag | Description |
|---|---|
-d, --data |
The JSON request body, or @file.json to read it from a file. |
-q, --query |
A query parameter as key=value. Repeat for several. |
-H, --header |
An extra header as Name: value. |
--paginate |
Follow nextCursor and combine every page into one list. |
--include |
Print the status line and response headers first. |
--raw |
Print the body exactly as received, with no formatting. |
Examples
Read the first page of agents.
octo api GET /v2/agents --query limit=50
Send a chat message.
octo api POST /v2/agents/agt_123/chat \
--data '{"messages":[{"role":"user","content":"Where is my order?"}],"stream":false}'
Update a ticket from a file.
octo api PATCH /v2/helpdesk/tickets/tkt_5d1 --data @update.json
Read every page of conversations.
octo api GET /v2/agents/agt_123/conversations --paginate --query limit=100
You should see the JSON of each response. With --paginate, the output is one array that contains the data items of all pages. See Pagination for how cursors work.
Errors
A response with a status of 400 or higher is printed in full and the command exits with code 1. The body follows the error format:
{
"error": {
"code": "not_found",
"message": "Agent not found.",
"requestId": "req_9c2e41"
}
}
Keep the requestId when you contact support. For a rate_limited error, wait for the time in the Retry-After header before you run the command again.
Warning:
octo apiruns exactly what you type. ADELETErequest removes data at once, and there is no confirmation prompt.
Related pages
- API overview lists every endpoint.
- API integration shows the same calls in code.
- octo health checks that your key works before you start.