Process a document in 60 seconds
Run this single script to authenticate, create a flow, and process your first invoice:What just happened?
What just happened?
- Authenticated with your SuperAI account.
- Created a 4-task invoice processing flow: Receive File → Convert to Text → Extract Invoice Data → Validate.
- Started processing a sample invoice PDF.
- Got back a flow ID and execution ID to track progress.
What are SuperAI Flows?
SuperAI Flows automate multi-step document processing pipelines. A typical flow:- Classifies documents (invoice, receipt, contract)
- Extracts structured data based on document type
- Validates extracted values
- Delivers results via webhook or API
Flow definition example
Flows are defined in declarative YAML that’s both human-readable and type-safe. Here’s a complete document processing workflow:- Task chaining —
extract_datareferences output fromclassify_documentusing{{classify_document.splits[0].document_url}} - Type safety — Each field specifies a
data_type(string, float, etc.) - Built-in executors — Use pre-built task executors like
document_classifierandtext_to_structured - Validation — Chain validation tasks to ensure data quality
Prerequisites
- A SuperAI account (sign up free)
- Your login email and password
curlandjqinstalled (for testing examples)
Authentication
SuperAI uses JWT-based authentication. All API requests require a valid access token.1
Get the anonymous key
This is a public endpoint — no auth required.
2
Exchange credentials for JWT tokens
3
Use the access token in every request
Token management
When your access token expires, use the refresh token to get a new one without re-authenticating:
Run your first flow
Start a flow by creating a flow execution with your input data.id— The flow execution ID (use this to check status and retrieve results)status— Current execution state (running,completed,failed)flow_version— Version of the flow used (remains constant even if the flow is updated)
filename, mime_type, and document_url. Other flows may have different input schemas — check the flow’s input_schema.
Check execution status
Retrieve results
Get task execution results for your flow:flow_execution_id— Filter by flow execution (required for most queries)task_name— Filter by specific task nametask_execution_idx— Filter by execution attempt (0 = first attempt, 1 = first retry)
Webhooks (recommended)
Instead of polling for results, configure webhooks to receive real-time notifications when flows complete. The Webhook Notification task sends POST requests to your specified URL. Add a Webhook Notification task to your flow with these parameters:- Url (required) — Your webhook endpoint URL
- Authorization Header Value (optional) — Auth token or API key for securing your webhook
- Payload (required) — The data to send (can reference task outputs using
{{task_name.field}}syntax)
x-webhook-token header), process the payload, and return a 2xx status code to acknowledge receipt.
Troubleshooting
Authentication failed / Invalid credentials
Authentication failed / Invalid credentials
- Verify your credentials work in the web UI first at flows.super.ai.
- Check for special characters in your password; wrap it in single quotes to preserve them:
export PASSWORD='your-password'. - Verify the anonymous key is valid — it should be a long JWT string.
Flow not found (404)
Flow not found (404)
- Verify the flow was created successfully (check the flow creation response).
- List all flows you have access to:
curl https://flows.super.ai/api/flows -H "Authorization: Bearer $TOKEN". - Confirm you’re using the correct UUID and are logged into the correct organization — flows are organization-specific.
Bad Request (400) when creating an execution
Bad Request (400) when creating an execution
- Validate your JSON is well-formed (pipe it through
jq). - For custom flows, check the required input schema:
curl "https://flows.super.ai/api/flows/$FLOW_ID" -H "Authorization: Bearer $TOKEN" | jq .input_schema.
Execution stuck in 'running'
Execution stuck in 'running'
Some flows take minutes for complex documents. Use webhooks instead of polling, and inspect task executions to see which task is blocking:
curl "https://flows.super.ai/api/task-executions?flow_execution_id=$EXEC_ID" -H "Authorization: Bearer $TOKEN" | jq '.task_executions[] | {task_name, status}'.Rate limiting (429)
Rate limiting (429)
The API implements fair-use rate limiting. If you receive 429 (Too Many Requests), wait before retrying and implement exponential backoff.
request_id from any error responses.
Error handling
The API uses standard HTTP status codes:
Errors follow a consistent format. See the full Error Codes reference.
Next steps
Downloading files
Retrieve
gs:// files returned in your flow outputs.API Reference
Full endpoint documentation with schemas.