Skip to content

Direct API Invocation

Direct API invocation creates a production workflow run through an external HTTP request. The requested workflow must exist in the committed main workflow snapshot and requires enabled: true. Omitting enabled is treated the same as enabled: false, so a user must explicitly enable the workflow before it is externally invokable.

POST /api/workflows/{workflow_id}/runs
Path parameterTypeRequiredDescription
workflow_idstringYesWorkflow ID to run. The server resolves the committed main workflow snapshot for this workflow and only invokes it when the snapshot has enabled: true.

The request body is required and strict. It must contain only inputs.

{
"inputs": {
"topic": "quantum computing trends"
}
}
FieldTypeRequiredDescription
inputsobjectYesWorkflow input values. May be empty when the workflow has no required inputs.

No other request body fields are accepted.

Invoke a workflow through the Direct API
curl -X POST http://localhost:8000/api/workflows/research-pipeline/runs \
-H "Content-Type: application/json" \
-H "x-request-id: req_01HTZK7V9QK4K4Z8Z9J4Z4Z4Z4" \
-d '{
"inputs": {
"topic": "quantum computing trends"
}
}'

The x-request-id header is optional. When present, Runsight records it as the run source correlation ID.

Direct API callers must not send privileged execution, provenance, delivery, simulation, or idempotency fields in the JSON body.

Examples of rejected fields:

Field
workflow_id
source
branch
commit_sha
debug
simulation
simulation_id
simulation_branch
idempotency_key
idempotency_token
trigger
trigger_id
delivery
delivery_id
provenance
source_metadata
source_correlation_id
caller

Unsupported or privileged request body fields are rejected with 422 WORKFLOW_INPUT_VALIDATION_ERROR.

A successful Direct API invocation returns 200 with a RunResponse.

200 means run creation or launch was accepted. Workflow execution continues in the background, and the run may later be pending, running, failed, or completed.

The response uses the server run response schema and includes the created run details, including server-authored values such as source: "api" and branch: "main".

Direct API always sets these run properties on the server.

PropertyValueCaller-controlled
sourceapiNo
branchmainNo
source_metadata.entry_pathdirect_apiNo
source_metadata.request_pathRequest pathNo
source_correlation_idFrom request headersHeaders only

Runsight reads correlation IDs from request headers.

HeaderDescription
x-request-idRequest correlation ID
x-correlation-idAlternate request correlation ID

source_correlation_id cannot be supplied in the request body.

Direct API always resolves the committed main workflow snapshot and requires that snapshot to be enabled.

Runtime assetResolution behavior
Workflow YAMLCommitted main snapshot with enabled: true
Nested workflow YAMLCommitted main snapshot through the resolved git ref
Snapshot-capable workflow asset discoveryReceives the resolved git ref from the execution runtime
Provider settingsLive server runtime configuration
Server settingsLive server runtime configuration
API keys and credentialsLive server environment or configuration

Dirty working tree edits to workflow YAML and nested workflow YAML are ignored by Direct API runs. Do not rely on dirty working tree edits for Direct API workflow definitions.

Environment variables use the RUNSIGHT_ prefix.

SettingDefaultDescription
RUNSIGHT_EXTERNAL_INVOCATION_ENABLEDtrueEnables external Direct API invocation.
RUNSIGHT_PUBLIC_BASE_URLunsetOptional public base URL for external invocation contexts.
RUNSIGHT_EXTERNAL_INVOCATION_BODY_LIMIT_BYTES1048576Maximum Direct API request body size in bytes.
RUNSIGHT_MAX_CONCURRENT_RUNS5Maximum concurrent workflow runs.
RUNSIGHT_MAX_PENDING_EXTERNAL_INVOCATIONS32Maximum queued pending external invocations.

The default host is 127.0.0.1.

Docker compose publishes the API on host loopback:

docker-compose.yml
ports:
- "127.0.0.1:8000:8000"

The Dockerfile command may bind to 0.0.0.0 inside the container. Host publishing examples should still bind to loopback unless you intentionally expose the service.

StatusCodeDescription
404WORKFLOW_NOT_FOUNDThe workflow ID does not resolve to a workflow, or the committed main workflow snapshot is not enabled.
413REQUEST_BODY_TOO_LARGEThe request body exceeds RUNSIGHT_EXTERNAL_INVOCATION_BODY_LIMIT_BYTES.
422WORKFLOW_INPUT_VALIDATION_ERRORThe body shape is invalid, privileged fields are present, required inputs are missing, or input types do not match.
429ADMISSION_SATURATEDRuntime admission limits are saturated.
503RUNTIME_UNAVAILABLEThe workflow runtime is unavailable or external invocation is disabled.

Direct API request and workflow input validation failures use 422, not 400.

Direct API invocation in RUN-85 does not provide idempotency support.

InputBehavior
x-idempotency-key headerNot persisted, exposed, or used for deduplication
Request body idempotency fieldsRejected with 422 WORKFLOW_INPUT_VALIDATION_ERROR

Runsight redacts sensitive workflow input values by omitting the value from stored and returned workflow_inputs payloads.

source_metadata is server-authored for Direct API runs. Unsafe metadata keys are rejected or dropped. Accepted responses, detail responses, list responses, and stored payloads must not leak authorization data, raw sensitive input values, or unsupported idempotency fields.

Webhook and schedule invocation are not part of RUN-85.

SourceAvailability
apiShipped production source
manualShipped production source
webhookNot part of RUN-85
scheduleNot part of RUN-85