This documentation is available to agents as Markdown at https://docs.synthesized.io/tdk/latest/user_guide/020_guides/advanced_workflows/external_api_reference.md. For the complete documentation index, see llms.txt.

REST API

Run and stop workflows, poll run status and fetch logs over HTTP, from CI/CD pipelines and other systems.

The API is served by your own Governor deployment at [scheme]://[host]:[port]/external/api/v1, where the scheme, host, and port are the ones that expose your API deployment. The API address may differ from the address you use for the Governor UI. There is no hosted endpoint: every request goes to the instance you run, authenticated with an access key generated on that instance.

Authentication

Send an access key in the X-Access-Key header of every request:

curl https://governor.example.com/external/api/v1/healthy \
  -H "X-Access-Key: $ACCESS_KEY"

Requests run with the permissions of the user who generated the key. An invalid or expired key gets an HTTP 401 response. To create a key, see Generating a New Access Key.

Endpoints

Paths are relative to /external/api/v1. Workflow IDs and run IDs are integers.

Method Path What it does

GET

/healthy

Checks that the API is reachable. Returns OK.

POST

/workflow/{workflow_id}/run

Starts a run of the workflow and returns as soon as the run is accepted, with its workflow_run_id.

POST

/workflow/{workflow_id}/runsync

Starts a run and waits for it to finish before it returns.

POST

/workflow/{workflow_id}/stop

Stops the workflow’s current run. Returns 404 if the workflow has no run to stop.

GET

/workflow/{workflow_id}/runs

Lists the workflow’s runs.

GET

/workflow-run/{workflow_run_id}

Gets a run’s status, start and end times, and error message.

GET

/workflow-run/{workflow_run_id}/logs

Gets a run’s log as plain text. skip skips that many lines from the start, and limit caps the number of lines returned.

GET

/workers

Lists the connected workers, with their groups and last heartbeat. Needs the key of a user with the Administrator role; other keys get 403.

The spec also lists /agents, the deprecated name of /workers, and two /spire endpoints that workers use to get their credentials. You don’t call those yourself.

The run endpoints and /workflow-run/{workflow_run_id} return a run:

{
  "workflow_run_id": 1,
  "workflow_run_status": "COMPLETED",
  "start_date": "2024-04-25T22:24:52.844341Z",
  "end_date": "2024-04-25T22:25:04.863765Z",
  "user_id": 1,
  "error_message": null
}

error_message explains why a run failed.

Run statuses

Status Meaning Final

QUEUED

The run is accepted and waiting to start.

No

RUNNING

The run is in progress.

No

STOPPING

A stop was requested, and the run is stopping.

No

COMPLETED

The run finished successfully.

Yes

FAILED

The run ended with an error. Check error_message and the log.

Yes

STOPPED

The run was stopped before it finished.

Yes

Errors

Status Cause

401

The access key is invalid or expired.

403

The key’s user doesn’t have the permission. For example, /workers needs the Administrator role.

404

stop was called for a workflow with no run to stop.

500

stop couldn’t stop the run.

Run a workflow from a pipeline

A pipeline usually starts a run, polls its status until the status is final, and fetches the log if the run didn’t complete. This script uses curl and jq:

set -euo pipefail
BASE="https://governor.example.com/external/api/v1"
WORKFLOW_ID=42

RUN_ID=$(curl -sf -X POST "$BASE/workflow/$WORKFLOW_ID/run" \
  -H "X-Access-Key: $ACCESS_KEY" | jq -r '.workflow_run_id')

while true; do
  STATUS=$(curl -sf "$BASE/workflow-run/$RUN_ID" \
    -H "X-Access-Key: $ACCESS_KEY" | jq -r '.workflow_run_status')
  case "$STATUS" in
    COMPLETED) echo "Run $RUN_ID completed"; exit 0 ;;
    FAILED|STOPPED)
      echo "Run $RUN_ID ended with status $STATUS"
      curl -sf "$BASE/workflow-run/$RUN_ID/logs" -H "X-Access-Key: $ACCESS_KEY" | tail -n 50
      exit 1 ;;
    *) sleep 15 ;;
  esac
done

runsync gives the same result in one call, but holds the HTTP request open for the whole run. Polling works for runs of any length.

For complete pipelines, see CI/CD integrations.

Examples

The examples use https://your-domain.com. Replace it with the scheme, host and port that expose your API. For Docker Compose, this may differ from the address and port of the Governor UI.

Check API availability

curl -X GET \
  https://your-domain.com/external/api/v1/healthy \
  -H 'X-Access-Key: {your_access_key}'

The expected response is OK.

Run a workflow

curl -X POST \
  https://your-domain.com/external/api/v1/workflow/{workflow_id}/run \
  -H 'X-Access-Key: {your_access_key}'

The response looks like this:

{
  "workflow_run_id": 1,
  "workflow_run_status": "RUNNING",
  "start_date": "2024-04-25T22:24:52.84434075Z",
  "end_date": null,
  "user_id": 1,
  "error_message": null
}

The run is dispatched to a connected worker whose groups include both the input and the output data source’s Worker group. The run call returns as soon as the run has been accepted; use runsync instead to block until the run finishes.

Stop a workflow

curl -X POST \
  https://your-domain.com/external/api/v1/workflow/{workflow_id}/stop \
  -H 'X-Access-Key: {your_access_key}'

The response looks like this:

{
  "workflow_run_id": 1,
  "workflow_run_status": "STOPPING",
  "start_date": "2024-04-25T22:24:52.84434075Z",
  "end_date": "2024-04-25T22:25:52.84434075Z",
  "user_id": 1,
  "error_message": null
}

Get a run’s status

curl -X GET \
  https://your-domain.com/external/api/v1/workflow-run/{workflow_run_id} \
  -H 'X-Access-Key: {your_access_key}'

List a workflow’s runs

curl -X GET \
  https://your-domain.com/external/api/v1/workflow/{workflow_id}/runs \
  -H 'X-Access-Key: {your_access_key}'

The response is a list of runs, in the same format as a single run.

Get a run’s log

Get the whole log:

curl -X GET \
  https://your-domain.com/external/api/v1/workflow-run/{workflow_run_id}/logs \
  -H 'X-Access-Key: {your_access_key}'

Get 50 lines, after skipping the first 100:

curl -X GET \
  "https://your-domain.com/external/api/v1/workflow-run/{workflow_run_id}/logs?skip=100&limit=50" \
  -H "X-Access-Key: {your_access_key}"

The response looks like this:

25-04-2025 13:22:36.768 INFO  i.s.g.f.w.service.WorkflowRunner [][][] - Workflow runner version: Synthesized TDK 1.95
25-04-2025 13:22:36.769 DEBUG i.s.g.f.w.service.WorkflowRunner [][][] - Workflow run 3494 started
25-04-2025 13:22:36.808 DEBUG i.s.tdk.executor.SynthesizedExecutor [][][] - Changing state: INIT -> SCHEMA_COPY
25-04-2025 13:22:36.836 DEBUG i.s.t.d.c.DetailsDatasourceContainer [][][] - Waiting 20000 ms for #12_jdbc_postgresql_cloud-main-spawn_postgres_database_azure_com_5432 to acquire 20 connections
25-04-2025 13:22:36.836 INFO  com.zaxxer.hikari.HikariDataSource [][][] - #12_jdbc_postgresql_cloud-main-spawn_postgres_database_azure_com_5432 - Starting...
...

List connected workers

This needs the key of a user with the Administrator role.

curl -X GET \
  https://your-domain.com/external/api/v1/workers \
  -H 'X-Access-Key: {your_access_key}'

The response looks like this:

[
    {
      "id": "00000000-00000000-00000000-00000000",
      "status": "ALIVE",
      "tags": "postgresql,production,eu-west",
      "data_source_tags": "postgresql,api-gateway",
      "latest_heartbeat": "2023-11-15T14:30:45Z"
    }
]

Full endpoint reference

The reference below is rendered from the OpenAPI specification that ships with each release, so it always matches the version this page is published for. Open an endpoint to see its parameters and response schema.

OpenAPI specification (YAML)
openapi: 3.1.0
info:
  title: "Governor External API"
  description: |
    This API provides external access to the Governor services
  version: "1.0.0"

x-package: io.synthesized.governor.external.api

paths:
  /external/api/v1/healthy:
    get:
      operationId: getExternalHealth
      description: Health check
      tags:
        - external_health
      responses:
        "200":
          description: Healthcheck API
          content:
            application/json:
              schema:
                type: string

  /external/api/v1/agents:
    get:
      operationId: agents
      tags:
        - external_agents
      deprecated: true
      description: Requires an API key of a user with the Administrator role.
      responses:
        "200":
          description: get list of agents
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/ApiAgentResponse"
        "403":
          description: The API key's user is not allowed to manage organization settings

  /external/api/v1/workers:
    get:
      operationId: workers
      tags:
        - external_workers
      description: Requires an API key of a user with the Administrator role.
      responses:
        "200":
          description: get list of workers
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/ApiAgentResponse"
        "403":
          description: The API key's user is not allowed to manage organization settings

  /external/api/v1/workflow/{workflow_id}/runsync:
    description: Run specified workflow synchronously (and wait for its completion)
    post:
      operationId: runWorkflowSync
      tags:
        - external_workflow_run
      parameters:
        - name: workflow_id
          in: path
          required: true
          schema:
            type: integer
            format: int64
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiWorkflowRunResponse"

  /external/api/v1/workflow/{workflow_id}/run:
    description: Run specified workflow
    post:
      operationId: runWorkflow
      tags:
        - external_workflow_run
      parameters:
        - name: workflow_id
          in: path
          required: true
          schema:
            type: integer
            format: int64
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiWorkflowRunResponse"

  /external/api/v1/workflow/{id}/stop:
    description: stop workflow
    post:
      operationId: stopWorkflow
      tags:
        - external_workflow_run
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
            format: int64
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiWorkflowRunResponse"
        "404":
          description: Workflow has no workflow run to stop
        "500":
          description: Workflow failed to stop

  /external/api/v1/workflow-run/{id}:
    description: Get workflow run
    get:
      operationId: getWorkflowRun
      tags:
        - external_workflow_run
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
            format: int64
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiWorkflowRunResponse"

  /external/api/v1/workflow/{workflow_id}/runs:
    description: Get workflow runs
    get:
      operationId: listWorkflowRuns
      tags:
        - external_workflow_run
      parameters:
        - name: workflow_id
          in: path
          required: true
          schema:
            type: integer
            format: int64
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/ApiWorkflowRunResponse"

  /external/api/v1/workflow-run/{id}/logs:
    description: get workflow run log file.
    get:
      operationId: getWorkflowRunLogs
      tags:
        - external_workflow_run
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
            format: int64
        - in: query
          name: skip
          required: false
          description: >
            The skip lines number is an optional parameter.
          schema:
            type: integer
            format: int32
            default: 0
        - in: query
          name: limit
          required: false
          description: >
            The fetch size is an optional parameter. When this parameter is not provided,
            it loads all lines from the skip position.
          schema:
            type: integer
            format: int32
            default: 2147483647
      responses:
        "200":
          description: OK
          content:
            application/octet-stream:
              schema:
                type: string
  /external/api/v1/spire/refresh-token/bootstrap:
    description: >
      Exchange a just-consumed SPIRE join token for the first refresh token. Governor verifies
      the join token was actually consumed by a real SPIRE attestation before issuing one.
    post:
      operationId: bootstrapRefreshToken
      tags:
        - external_spire_refresh_token
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ApiBootstrapRefreshTokenRequest"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiRefreshTokenResponse"

  /external/api/v1/spire/refresh-token:
    description: >
      Rotate a refresh token: mints a fresh SPIRE join token and a new refresh token,
      superseding the presented one. Presenting an already-superseded token revokes the
      whole rotation chain.
    post:
      operationId: refreshWorkerToken
      tags:
        - external_spire_refresh_token
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ApiRefreshTokenRequest"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiRefreshTokenResponse"

components:
  schemas:
    ApiBootstrapRefreshTokenRequest:
      type: object
      required:
        - join_token
      properties:
        join_token:
          type: string
        idempotency_key:
          type: ["string", "null"]
          minLength: 32
          maxLength: 128
          description: >
            Optional, client-generated, retained across retries of one logical bootstrap attempt.
            Lets Governor return the credentials the first attempt issued when its HTTP response was
            lost, instead of refusing the retry because the workload already holds a token it never
            received. Without a matching key, a second exchange of an already-used join token is
            refused.
            Must be unguessable - at least 128 bits from a CSPRNG, e.g. a random UUID. Presenting
            a matching key returns credentials, so a predictable one (a hostname, a counter) is a
            second credential an attacker can guess.

    ApiRefreshTokenRequest:
      type: object
      required:
        - refresh_token
      properties:
        refresh_token:
          type: string
        idempotency_key:
          type: ["string", "null"]
          minLength: 32
          maxLength: 128
          description: >
            Optional, client-generated, retained across retries of one logical rotation attempt.
            Lets Governor durably recognize a retry after a lost HTTP response (including across a
            restart or a different replica) and return the credentials the first attempt issued,
            rather than minting a second set. A retry Governor can no longer answer that way is
            rejected with 409. Without a matching key, replaying an already-superseded token is
            treated as reuse and revokes the whole rotation chain.
            Must be unguessable - at least 128 bits from a CSPRNG, e.g. a random UUID. Presenting
            a matching key returns credentials, so a predictable one (a hostname, a counter) is a
            second credential an attacker can guess.

    ApiRefreshTokenResponse:
      type: object
      required:
        - refresh_token
        - expires_at
      properties:
        join_token:
          type: string
          description: >
            Only present on the ongoing-refresh response. The bootstrap response omits it: the
            worker already has a valid SVID at bootstrap time, so no new join token is needed yet.
        refresh_token:
          type: string
        expires_at:
          type: string
          format: date-time

    ApiWorkflowRunResponse:
      type: object
      title: RunWorkflowResponse
      required:
        - workflow_run_id
      properties:
        workflow_run_id:
          type: integer
          format: int64
        workflow_run_status:
          $ref: '#/components/schemas/ApiWorkflowRunStatus'
        start_date:
          type: string
          format: date-time
          example: "2021-01-30T08:30:00Z"
        end_date:
          type: string
          format: date-time
          example: "2021-01-30T08:30:00Z"
        user_id:
          type: integer
          format: int64
        error_message:
          type: string

    ApiAgentResponse:
      type: object
      required:
        - id
        - status
        - tags
        - data_source_tags
      properties:
        id:
          type: string
        status:
          $ref: "#/components/schemas/ApiAgentStatus"
        tags:
          type: string
        data_source_tags:
          type: string
        latest_heartbeat:
          type: string
          format: date-time

    ApiAgentStatus:
      enum:
        - ALIVE

    ApiWorkflowRunStatus:
      enum:
        - QUEUED
        - RUNNING
        - COMPLETED
        - FAILED
        - STOPPING
        - STOPPED