Call Sigma agents with the API
You can run a Sigma agent programmatically with the Sigma REST API and use the reply in your own application, instead of interacting with the agent through a chat element or action in a workbook.
For example, you can use the API to embed a Sigma agent in a custom chat interface in your own application or call an agent from a script or an automated pipeline.
The API runs the agent with the calling user’s permissions and row-level security, using the same instructions, data sources, and tools configured for the agent in the workbook.
User requirements
To call an agent using the API, you must have the following:
- Client credentials with the REST API scope
- The client credentials must be assigned to a user with at least Can view access to the workbook containing the agent that you want to run.
Limitations
-
You cannot interact with a warehouse agent using this API endpoint. Instead, use the API endpoints associated with your data platform.
-
Only one system message can be specified per conversation.
-
When an agent is run outside a workbook, such as from the home page, an automated action, or via the API, action tools run differently:
- Action tools that require approval run without approval.
- Some action tools cannot be run, such as action sequences that contain unavailable actions or action tools that run unavailable actions.
For a list of actions that are available when the agent is run outside a workbook, see About automated action sequences.
What you can do with the agent API
The agent API is a stateless, chat-completion-style endpoint. With it, you can do any of the following:
- Send a full conversation and get the agent’s next reply, including any text, tool calls, and tool results.
- Continue a multi-turn conversation by replaying the previous output as part of the next request’s messages.
- Retrieve the agent response as a structured JSON schema, instead of free-form text.
- Limit a run with a maximum number of tool-calling steps (
maxTurns) or a maximum number of output tokens (maxOutputTokens). - Run the agent against a tagged version of the workbook, instead of the latest published version.
- Attach caller-defined metadata to a run, which is logged to the
ai_usagetable (if configured) in your data platform for tracking and auditing. - Stream the agent’s reply as a sequence of events instead of waiting for the full turn to complete.
Decide whether to retrieve a streaming response
By default, the agent API returns a single JSON response after the agent finishes its turn. Set stream to true in the request to instead receive a sequence of events as the agent works.
Decide which response type fits your use case by reviewing the following table:
Get started calling an agent with the API
To get started calling an agent with the API:
-
Identify the agents that you have access to. You can call the List agents endpoint to retrieve the list of all agents that you can access in your Sigma organization, including the
workbookIdandagentIdof each agent. -
Decide whether to modify the default request with optional details, such as:
- Send your user prompt as a message with
"role": "user"in themessageslist. - Determine whether your use case needs a streaming or non-streaming response.
- Determine whether you want to receive a response as text or structured JSON.
- Specify arbitrary metadata to be logged to the
AI_USAGEtable. - Include previous conversation output as context in the
messageslist. See Continue a conversation.
- Send your user prompt as a message with
Run an agent
To run an agent, send a POST request to the Run a Sigma agent endpoint.
- Include the
workbookIdandagentIdfor the agent. - Specify relevant content in the request.
- If you want to add system-level context to the agent instructions, such as “never tell the user what source you are querying”, include that as a
systemmessage. - Store the returned
runIdalongside your own logs so you can correlate a run with a support request if needed.
The response includes the agent’s reply in output, along with usage details about the run, such as the number of turns and tokens consumed.
Continue a conversation
To continue a conversation with an agent, store and provide the context about the current conversation yourself when making a request to run the agent. Chat history is not currently stored for messages sent to or from an agent when run through the Sigma REST API, even if chat history is turned on for your organization. You also cannot continue a conversation programmatically that was started from the Sigma UI.
To continue a conversation, append the previous response’s output to the messages array and send the full history again on the next call:
Retrieve structured output
If you want to structure the output returned by the agent, you can specify a desired JSON output structure when you make a request:
That request returns a response like the following:

