Trigger agent runs, pass variables, and track runs to completion from your application over the REST API.
Once you’ve built an agent in the dashboard, you integrate it into your application over the REST API: trigger runs, pass per-run values, track each run to completion, and read the result.Runs are asynchronous. You create a run, then track it to a terminal state by polling.
To scaffold the integration quickly, open an agent’s run view in the dashboard and use Build API in to open the agent’s API prompt in a coding tool like Cursor.
Use variables to pass per-run dynamic values without writing them into the prompt. Each variable pairs a value the placeholder resolves to with an optional description that tells the agent when to use it. Reference a variable in the task or system prompt as %variableName%.
{ "agentId": "a1b2c3d4-5678-90ab-cdef-1234567890ab", "task": "Check in to my flight using confirmation %confirmation%", "variables": { "confirmation": { "value": "XYZ123", "description": "The flight confirmation code to enter at check-in" } }}
Variables suit values like account numbers, dates of birth, and confirmation codes. The agent fills the placeholder without the value appearing inline in the task.
To follow what the agent is doing while it runs, poll List run messages. Save the response’s nextSince and pass it back as since to fetch only newer messages:
Both list endpoints use cursor pagination. Pass the nextCursor from a response back as cursor to fetch the next page.List runs filters by agentId, status, and a startAt/endAt time range: