AI agent
Preview an AI agent turn
Authorization
AuthorizationstringrequiredAn API token, sent as Bearer <token>.
Needs the ai:write ability
Path parameters
agentstringrequiredId of the AI agent, starting with aia_, such as aia_01jx2m8k4t. Find it with GET /ai/agents.
Body
application/jsonaction_mocksobjectWhat each action answers instead of really being called, as an object keyed by action id; each value has status (HTTP status, 100 to 599) and body (any JSON), such as {"aac_abc123": {"status": 200, "body": {"order": {"status": "shipped"}}}}. An action with no mock answers with the result of its last live test.
active_stateobjectShow child attributesHide child attributes
branchesobjectCopy it unchanged from the state the last preview turn handed back: an object of step id to the side that step took.
called_action_idsstring[] | nullCopy it unchanged from the state the last preview turn handed back: the list of ids of the actions already called, such as ["aac_01jx2m8k4t"].
completed_step_idsstring[] | nullCopy it unchanged from the state the last preview turn handed back: the list of ids of the procedure's steps already done.
pendingobject[] | nullCopy it unchanged from the state the last preview turn handed back: the list of writes still waiting to be confirmed or approved, each with action_id, tool, args, state and summary.
Show child attributesHide child attributes
action_idstringrequiredId of the action whose write is waiting, starting with aac_, such as aac_01jx2m8k4t, copied from the last turn's state. Put it in confirmed_action_ids to confirm it.
argsobjectThe arguments the waiting write would be called with, as an object, copied unchanged from the last turn's state, such as {"order_id": "1042"}.
statestringWhy the write waits, copied from the last turn's state: awaiting_confirmation (the customer must confirm) or pending_approval (a teammate must approve).
summarystringThe short text that says what the waiting write would do, copied unchanged from the last turn's state.
toolstringrequiredThe tool name of the action whose write is waiting, copied unchanged from the last turn's state.
procedure_idstringId of the procedure the conversation is in, starting with prc_, such as prc_01jx2m8k4t, copied from the state the last preview turn handed back.
statusstringWhere the procedure stands, copied from the state the last preview turn handed back: active, completed, handed_off or exited. Only active carries the procedure on.
step_outputsobjectCopy it unchanged from the state the last preview turn handed back: an object of what the procedure's steps have produced so far.
confirmed_action_idsstring[] | nullIds of the waiting writes you confirm or approve this turn, taken from action_id in the pending list of the state the last preview turn handed back (send that state as active_state). At most 10, such as ["aac_01jx2m8k4t"]. You may send these without a message.
Maximum items: 10
historyobject[] | nullThe turns so far, oldest first, at most 40, as returned by earlier calls.
Maximum items: 40
Show child attributesHide child attributes
rolestringrequiredWho wrote this earlier message: customer or agent, such as "customer".
Available options:customeragent
textstringrequiredWhat that earlier message said, at most 4000 characters, such as Hi, where is my order?
Maximum length: 4000
messagestringWhat the customer writes, up to 4000 characters.
Maximum length: 4000
personaobjectShow child attributesHide child attributes
attributesobjectThe made-up customer's custom attributes, as an object of attribute key to value. They count as trusted. Such as {"plan": "pro"}.
channelstringThe channel the made-up customer writes from: widget, email, slack, whatsapp, instagram, facebook or api. Left out or empty, it is widget. Such as "email".
Available options:widgetemailslackwhatsappinstagramfacebookapi
companyobjectThe custom attributes of the made-up customer's company, as an object of attribute key to value, such as {"plan": "enterprise"}.
emailstringThe made-up customer's email address, at most 320 characters, such as ada@example.com.
Maximum length: 320
external_idstringYour own system's id of the made-up customer, at most 200 characters, such as user_8421. Giving one makes them a known user, not a lead.
Maximum length: 200
inbox_idstringId of the inbox the made-up conversation is placed in, starting with inbox_, such as inbox_01jx2m8k4t. Find it with GET /inboxes.
Maximum length: 64
namestringThe made-up customer's name, at most 200 characters, such as Ada Lovelace.
Maximum length: 200
verifiedbooleantrue when the made-up customer is signed in, so their identity and email count as verified; false or left out for an unverified visitor.
source_conversation_idstringA real conversation (conv_...) whose messages the preview replays as the turns so far. The conversation is not changed.
stream_idstringAn id you make up, at most 64 characters, so the turn reports its progress live on your own realtime channel while it happens. Only useful to a client listening on that channel; leave it out otherwise. Such as "sim-7f3a2c".
Maximum length: 64
versionstringdraft tests the working copy, live the published one. Left out, it is draft.
Available options:draftlive
Response 200
OKdataobjectrequiredShow child attributesHide child attributes
action_callsobject[] | nullrequiredThe actions the agent called this turn, in order, each with what it was called with and what it answered. No call reached the workspace's own systems.
Show child attributesHide child attributes
action_idstringrequiredId of the workspace action the simulation called (starts with aac_).
argsobjectThe arguments the action was called with, as a JSON object. Left out when there were none.
blockedbooleanTrue when the call was stopped before it ran; a blocked call does not count as called in a test's assertions. Left out when false.
succeededbooleanrequiredTrue when the mocked call answered with success. Nothing real is run in a simulation.
toolstringrequiredThe action's tool name, the name the AI calls it by.
active_stateobjectrequiredShow child attributesHide child attributes
branchesobjectrequiredBranches of the procedure taken so far in the simulated conversation, as an object of strings. Send the whole state back with the next turn.
called_action_idsstring[] | nullrequiredIds of the actions called so far in the simulated conversation. Send the whole state back with the next turn.
completed_step_idsstring[] | nullrequiredIds of the procedure steps completed so far. Send the whole state back with the next turn.
pendingobject[] | nullrequiredWrites that wait on the customer's confirmation or a teammate's approval; empty for none.
Show child attributesHide child attributes
action_idstringrequiredId of the action whose write is waiting, such as aac_....
argsobjectrequiredThe arguments the action was called with, as an object.
statestringrequiredWhat the write waits on: awaiting_confirmation for the customer's yes, pending_approval for a teammate's approval.
summarystringrequiredOne line saying what the write would do.
toolstringrequiredName of the tool the agent called for the action.
procedure_idstringId of the procedure the simulated conversation is running, such as prc_.... Left out when it runs none.
statusstringWhere the procedure stands: active, completed, handed_off or exited. Left out when no procedure runs.
step_outputsobjectrequiredWhat the procedure's steps produced so far, as an object. Send the whole state back with the next turn.
handoffobjectrequiredShow child attributesHide child attributes
notestringNote the agent left for the team at the handover. Left out when there is none.
prioritystringPriority the handover set on the conversation. Left out when it set none.
reasonstringrequiredWhy the simulated turn handed over, such as customer_requested, unknown, frustration, safety or max_replies.
team_idstringId of the team the handover sent the conversation to, such as team_.... Left out when it chose none.
objectstringrequiredThe kind of record this is, the same for every record of its kind, such as article.
outcomestringrequiredHow the turn ended, such as answered, unknown, handoff, refused or error.
procedure_traceanyThe procedure the agent followed this turn and the steps it took, as a JSON object. Left out when it followed none.
replystringrequiredWhat the agent wrote to the customer this turn. Empty when it wrote nothing.
run_idstringrequiredId of the run that answered this turn.
transferobjectrequiredShow child attributesHide child attributes
agent_idstringrequiredId of the agent the conversation was passed to (starts with aia_).
from_namestringrequiredName of the agent that passed the conversation on.
namestringrequiredName of the agent the conversation was passed to.
summarystringrequiredWhat the first agent told the next one about the conversation so far.
Response error
ErrorcodestringrequiredStable code for programs to tell errors apart, such as validation_failed or internal_error.
errorsobjectEach rejected field mapped to its messages. Only present when the input was invalid.
messagestringrequiredWhat went wrong, in words safe to show a person.