For the complete documentation index, see llms.txt. This page is also available as Markdown.

Quickstart

Run a saved workflow from your backend and read its result. This walkthrough uses the same saved project version for the input schema and execution, so a newer unpublished edit cannot change the input contract halfway through.

1. Prepare a key and a saved project version

Create a personal API key in StackAI → Settings → API Keys, in the organization containing your project. Give it projects.read, projects.run, and analytics.read. The key owner must also have access to the project. Store the key in your backend's secret manager.

Publish the project and enable run logging. Copy the project ID from its URL. In the project's version history, select the saved version you intend to run and note its version number. Use that number throughout this walkthrough. Saved versions and API versions are separate: /v2 selects the API contract; PROJECT_VERSION selects workflow content.

export STACKAI_BASE_URL='https://api.stack-ai.com'
export PROJECT_ID='YOUR_PROJECT_ID'
export PROJECT_VERSION='1' # Replace with your selected saved version number.
# Set STACKAI_API_KEY through your secret manager or secure local environment.

For a private installation, replace the base URL with its configured API origin.

2. Read that version's inputs

curl --fail-with-body -sS --get \
  "$STACKAI_BASE_URL/v2/projects/$PROJECT_ID/io-schema" \
  -H "Authorization: Bearer $STACKAI_API_KEY" \
  --data-urlencode "version=$PROJECT_VERSION"

For a workflow with one text input and one output, a response can look like this:

{"data":{"input_kind":"legacy_input_nodes","inputs":[{"id":"in-0","name":"Question"}],"outputs":[{"id":"out-0","name":"Answer"}]}}

Use the returned id values as object keys, not the display names. Replace in-0 and out-0 below if your project returns different identifiers. latest is useful for discovery, but it can select a different saved version from the published version; this walkthrough pins a number instead.

3. Start one run

Create run.json. Replace the project ID and version with the values you selected above:

A 201 Created response includes a Location header and a run object. Save data.run_id before you do anything else. The status might already have advanced by the time you receive the response. This excerpt shows a run still waiting to execute:

The excerpt omits timestamps, usage, and other run fields. The endpoint reference contains complete response examples. A 201 confirms creation, not successful execution. If the POST times out, do not automatically repeat it: the first run may already exist.

4. Read the result

Poll with a bounded delay. queued and running mean work is in progress. succeeded, failed, and cancelled are terminal. A paused run needs a human response; waiting alone cannot resume it.

A successful response excerpt:

This text illustrates the response shape; your workflow supplies its own answer. Display the value under the output ID returned in step 2. A failed run can still return HTTP 200 from the status endpoint:

Check the run's status before displaying its output. Keep its ID so you can inspect the same execution after a process restart. See Run workflows end to end for a bounded polling client and human-input handling.

Last updated

Was this helpful?