Skip to main content

Workforce Agents API

Drive a single agent over HTTP. Every request is authenticated with that agent's API key, sent as a bearer token:

text

All endpoints are scoped to one agent through the {agentId} path segment - find the agent ID in the agent's page URL in the dashboard. A key only works for the agent it was created for.

Start a thread

Dispatch a message to the agent. This starts a new thread and returns immediately.

text

Request Body

json
FieldTypeRequiredDescription
messagestringYesThe task or message for the agent
filesFileReference[]NoHosted file attachments

Response

Returns 201.

json

Poll the Get a thread endpoint until the status is terminal.

Example

bash

Get a thread

Read a thread's status and messages. Poll this until the run finishes.

text

Response

json
FieldTypeDescription
threadIdstringThe thread identifier
statusstringidle, queued, pending, running, completed, failed, or cancelled
failureReasonstring | nullWhy the run failed, when status is failed
messagesUIMessage[]The conversation - see UIMessage parts

Keep polling while the status is pending, queued, or running. Stop when it is completed, failed, or cancelled.

Example

bash

Follow up in a thread

Send another message into an existing thread. If the agent is still working the message runs after the current turn finishes; otherwise it starts immediately.

text

Request Body

json
FieldTypeRequiredDescription
messagestringYesThe follow-up message
filesFileReference[]NoHosted file attachments

Response

Returns 202.

json

Poll Get a thread for the new run's result.

Example

bash

Errors

Errors return { "error": string, "code": string } with an HTTP status:

StatusMeaning
401Missing or invalid API key
402The agent is blocked by a usage or spending limit
403The key is not authorized for this agent
404The thread does not exist for this agent