Run a Flow with the API
Choose a Flow by its ID, authorize it with a scoped Flow Key, and run the active published revision.
LakeShark automatically generates a stable Flow ID when you create a Flow. You never choose or create that ID. The API panel inserts it into the ready-to-copy URL. Use a Flow Key issued for that same Flow to authorize the request. LakeShark rejects a Flow Key for a different Flow.
An AnswerSet Question Key calls an AnswerSet. A Flow Key calls only the Flow to which it was issued, even when that Flow uses multiple AnswerSets, ExecutionSets, GovernanceSets, conditionals, and AI providers.
What identifies what
| Item | What it does | Where to find it |
|---|---|---|
| Flow ID | Automatically generated by LakeShark and identifies the Flow to run | Open Flows, choose a Flow, then select API |
| Flow Key | Authorizes that selected Flow only | The same API panel; issue a key and save it securely |
| Active published revision | Selects the executable version | Flow > Publish / activate; also shown in API |
inputs |
Data provided to the Flow | Use the API example generated from its active published revision |
| Idempotency-Key (optional) | Makes retries replay the same logical run without repeating actions | Provide a stable unique value for requests your application might retry; not needed for basic calls |
The Flow ID is not a credential. Never put a Flow Key in a URL or client-side application.
Get the right Flow ID and key
- In the LakeShark console, open Flows, then select the Flow you want.
- Save its draft, choose Flow > Publish / activate, publish the intended revision, and activate it.
- Click API in the Flow editor header. Confirm the Flow name, Flow ID, and ACTIVE published revision.
- Issue a Flow Key from the API panel. Copy its secret once to your server-side secret manager.
- Use the generated request in that panel. It already contains the correct Flow ID and suggested
inputsfrom the active published revision.
Draft edits are not what the API executes. Editing or saving a draft does not activate it. Run requests use the active published revision.
Execute the selected Flow
Use this canonical endpoint:
POST https://lakeshark.dev/api/flows/v1/flows/{flow_id}/runs
X-LakeShark-Flow-Key: <flow-specific credential>
Content-Type: application/json
{"inputs":{"question":"Example question"}}
Example of the JSON POST command automatically generated by the Flow API panel. Its URL already contains your Flow’s ID. You do not generate or type an ID yourself.
# Set LAKESHARK_FLOW_KEY securely from the key issued for this Flow.
curl --fail-with-body --request POST \
'https://lakeshark.dev/api/flows/v1/flows/123e4567-e89b-42d3-a456-426614174000/runs' \
-H "X-LakeShark-Flow-Key: $LAKESHARK_FLOW_KEY" \
--json '{"inputs":{"question":"retriever golden"}}'
The sample URL above uses an illustrative Flow ID; the Copy request button inserts the real, server-generated ID for your selected Flow. --json sends an application/json POST request without a heredoc or --data-binary. It requires curl 7.82 or newer. LakeShark generates an internal signed execution identity if you omit Idempotency-Key. Input field names depend on the active published revision; never send a Flow ID, organization ID, or workspace ID inside inputs. Keep the Flow Key server-side in a secret manager, not embedded in source code or a frontend application.
For controlled retries, you can optionally add -H "Idempotency-Key: your-stable-request-id" to the curl request. Use the same value when retrying the same logical operation. A keyless retry is a new execution, so do not use automatic retries for side-effecting Flows without specifying a stable key.
A successful HTTP response contains a run object with run_id, flow_id, status, replayed, output, and error_code. Check both HTTP status and run.status; a request can be accepted but finish with a node-level failure.
Security and retries
- A key for Flow A cannot execute Flow B. Mismatched, revoked, expired, or unknown keys receive a generic
401. The server does not reveal whether a requested foreign Flow exists. - Keep keys in a secret manager, rotate by issuing a new key, migrate callers, then revoke the old key.
- The
Idempotency-Keyheader is optional. Without it, each HTTP request starts a distinct run, including a retry after a lost response. LakeShark still generates an internal signed identity so execution, budgeting, and audits use the same protected run ledger. - For side-effecting Flows or clients that automatically retry HTTP requests, provide a stable unique
Idempotency-Key(8 to 128 supported characters). Reuse that same key with identical inputs when retrying. Do not reuse one key for different inputs. - An inactive Flow or missing publication cannot execute until you publish and activate it.
- The server rechecks authorization, immutable publication, provider and Set revisions, budgets, and governance before dispatching actions. Do not interpret client-side UI validation as authorization.
Existing integrations
The earlier POST /api/flows/v1/runs route still works for existing integrations. It implicitly selected the Flow using the key. New integrations should use the explicit per-Flow URL above, which is easier to understand, audit, and troubleshoot. The older route should not be used when building a new client.
Troubleshooting
| Result | Meaning |
|---|---|
401 |
Flow Key invalid, revoked, expired, or not issued for the requested Flow |
422 |
Invalid inputs, malformed explicit idempotency key, or invalid Flow ID |
429 |
Request rate limit or Flow execution budget exceeded |
503 |
Service-side execution dependency unavailable; inspect run evidence or contact support |
HTTP 200 with run.status = "failed" |
Flow was admitted, but one of its steps failed; inspect safe step events and the error code |
The Flow API remains beta. Confirm successful execution, idempotency replay, and revocation against your published Flow before relying on it in a production application.
See Flow Studio, Inputs and mappings, and Validation and testing.