Prerequisites
- A workflow defined and saved in the Workflows UI
- A Scale API key
- Your Scale account ID (the account that owns the workflow)
Authentication
Send requests over HTTPS to your SGP host—the same origin you use to open the Workflows UI. Every example below uses a base URL of the formhttps://<your-sgp-host>/corp-api/compass/api.
Include these headers on each request:
<your-api-key> is your Scale API key. <your-account-id> is the ID of the account that owns the workflow you want to run.
Run and wait
The usual pattern is to start a run, then block until it finishes (up to a configurable timeout).curl equivalent
API reference
All paths below are relative toBASE_URL (https://<your-sgp-host>/corp-api/compass/api).
POST /v1/workflow/run
Starts a workflow run and returns immediately with a sessionId.
Request body:
variables is optional. Values override defaults configured in the workflow and are substituted into {{variable_name}} placeholders in your cards. For typical use cases, use flat string values.
Response:
GET /v1/sessions/:sessionId
Returns the current status of a running session. Use this endpoint when you want to poll instead of blocking on the result endpoint.
Example response:
Card status values
GET /v1/sessions/:sessionId/result?timeout=<ms>
Waits until the session reaches idle or errored, or until timeout milliseconds elapse (default 600000, ten minutes), then returns the final output.
Query parameters
timeout— milliseconds to wait (default600000)
data contains the rows. schema describes the columns. start and end describe the row index range returned.
Polling instead of blocking
If you prefer short requests instead of a long-lived connection, pollGET /v1/sessions/:sessionId until the session is idle, then call GET /v1/sessions/:sessionId/result to fetch the tabular output.
The following example reuses the same BASE_URL and HEADERS as in Run and wait.
Polling returns session state (status and card metadata), not the full workflow table. After the session reaches
idle, call GET /v1/sessions/:sessionId/result to retrieve the rows.Workflow variables
Variables let you parameterize a workflow without editing its definition. They replace{{variable_name}} placeholders in card configuration (for example, filter values, prompt templates, or model parameters).
Error handling
Error bodies are JSON. Many errors look like this:error and message:
This variant parses JSON error bodies from failed responses:
runWorkflowSafe assumes BASE_URL and HEADERS are defined the same way as in Run and wait.
