Developers / API
Talk to your agent from your systems
In the API an agent is a playbook. It has versions, and one of them is active: the one in production. Your channel sends it each message and does what the response says.
Chat with the active version
One endpoint: POST /playbooks/{base_id}/active/chat. The base_id stays the same across versions, so publishing a new version never changes your integration. If the agent has no active version, the endpoint answers 404.
Use one conversation_id per conversation and send it on every turn. The agent keeps the state of the conversation on its side.
curl -X POST https://api.studiochat.io/playbooks/$AGENT_ID/active/chat \
-H "X-API-Key: $FOXFORD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"conversation_id": "order-4821",
"user_message": "Where is my order?",
"user": "customer-1093"
}'Request
| Field | What it is |
|---|---|
conversation_id | Required. Your id for this conversation. |
user_message | Required. The latest message from the person. |
user | Your id for the person. Set once: the first id wins and a different one later is refused. |
organization | Your id for the company the person writes for, in B2B channels. Set once, like user. |
context | Any object that helps the agent: customer data, the page, the plan. It can also feed the parameters of its tools. |
attachments | Files sent with the message, such as images the agent should look at. |
include_citations | Keep the knowledge base citations in the reply. Off by default. |
tags | Tags from your channel. They add up across messages. |
Response
| Field | What it is |
|---|---|
events | What the agent decided to do this turn, in order. |
explanation | Where the conversation stands, in a sentence. |
tool_calls | The calls the agent made to your systems. |
collected_data | The fields collected when a form inside the conversation is complete. |
citations | The knowledge base sources behind the reply, when asked for. |
first_seen | True on the first message of a conversation. |
user_id | The person the conversation is bound to. |
elapsed_time_ms | How long the reply took. |
The shape of a response, trimmed
{
"events": [
{ "event_type": "message",
"data": { "content": "It left the warehouse today. Here is the tracking link: ..." } }
],
"explanation": "Order found, shipping status shared.",
"tool_calls": [ ... ],
"first_seen": true,
"user_id": "customer-1093",
"elapsed_time_ms": 2140
}Events
| event_type | What it is |
|---|---|
message | A message for the person. Show it. |
label | A label for the conversation. |
priority | A priority for the conversation. |
note | A private note for your team. Never show it to the person. |
handoff_agent | Hand the conversation to a specific person on your team. |
handoff_team | Hand the conversation to a team. |
Keys
Every request carries a project key in the X-API-Key header. Keys belong to one project, can be rotated, and are shown once, when they are created. Your Foxford team issues them.
A sandbox key starts with sbs_. With it, a request that would change something returns 202 and an approval_id instead of running: a person approves it first.
A request without a key gets a 401. Errors come back as JSON with a detail field.
Read conversations
Every conversation that runs through an agent can be read back with the same key: the messages, the tools it called, the sources it cited and how it was scored.
| GET | /projects/{project_id}/conversationsA page of conversations. Filter by dates, version, handoff, sentiment or your user id. Up to 100 per page. |
| GET | /projects/{project_id}/conversations/{conversation_id}One conversation: every message, tool call and citation. |
| POST | /projects/{project_id}/conversations/batchFull detail for up to 50 conversations in one request. |
| GET | /projects/{project_id}/conversations/{conversation_id}/metricsThe quality scores of one conversation, once it has been scored. |
| GET | /projects/{project_id}/conversations/analyticsTotals for a period: volume, what was resolved without a person, by version and by tag. |
# the last 100 conversations that were handed to a person
curl "https://api.studiochat.io/projects/$PROJECT_ID/conversations?has_handoff=true&limit=100" \
-H "X-API-Key: $FOXFORD_API_KEY"
# full detail for up to 50 at once
curl -X POST "https://api.studiochat.io/projects/$PROJECT_ID/conversations/batch" \
-H "X-API-Key: $FOXFORD_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "conversation_ids": ["order-4821", "order-4822"] }'The full reference
Every endpoint, with its schemas, is in the OpenAPI document generated from the code. Your key reaches the endpoints of its own project.
Job done
Tell us which task comes off the list first. We start by mapping it with you.