Before you start
You need:- A HockeyStack workspace on a plan with API access.
- A Revenue Agents API token. Generate one in workspace settings — it looks
like
hsr_live_<hex>. Treat it like a password. - A deal ID from your CRM. Any open or recently-closed deal works.
curl. The base URL is
https://app.hockeystack.com/api/revenue-agents/v1.
Export the basics so the snippets stay short:
1. Verify the token
Call/me to confirm the token works and to see which workspace it belongs
to:
200 with your workspace metadata means you are good to go. A 401 means
the token is missing, malformed, or revoked.
2. Initialize the deal agent
Each deal needs an agent provisioned once. This is asynchronous — thePUT
returns immediately and the worker takes about 3–8 minutes.
202 with status: "initializing". Poll the same path until
status flips to active:
active— ready for messages.provisioning_failed— retry thePUT.
PUT returns 409. That is
fine — skip to the next step.
3. Open a conversation
A conversation groups a sequence of messages with the same agent. Create one:conversation_id. Save it:
4. Send a message
POST to the conversation. This returns 202 immediately with a job handle —
the agent runs in the background.
5. Poll for the result
Poll the job endpoint on a 1–5 second interval untilstatus lands in a
terminal state:
completed— read the assistant reply fromresult.messages.failed— readerror.code,error.category, anderror.message.
404. Read the result before that window closes.
What to try next
- Streaming instead of polling — send the same
POSTwithAccept: text/event-stream(or{ "stream": true }in the body) to receivetext_delta,tool_use, anddoneevents in real time. - Company agents — every endpoint above has a
/companies/{companyId}/…counterpart with the same shape. - Tasks —
GET /taskslists the agent-generated next actions. Mark themcompletedordismissedto feed the learning loop. - Credits —
GET /credits/balancereports usage against your monthly bundle. Watch this to avoid503once the cap is reached.