Skip to main content
Batch runs let you apply the same routine to many records. Both functions and Workflows can be run programmatically in batches. The difference is how the routine is built:
  • Functions are built and managed in the Clay UI, then run or batch-run programmatically.
  • Workflows are in Alpha and can be built, edited, run, inspected, and batch-run from the plugin or CLI.

Function batch runs

Use function batch runs when you have a Clay-managed function or custom function and want to apply it to a list of inputs. CLI function batch runs use JSONL input:
clay routines runs start function:t_abc123 --bulk rows.jsonl
Each JSONL line is one item:
{ "id": "row-1", "inputs": { "domain": "clay.com" } }
The CLI wraps the same Public API flow:
curl --request POST "https://api.clay.com/public/v0/routines/function:t_abc123/run-batch/upload-url" \
  --header "clay-api-key: $CLAY_API_KEY"
Upload the JSONL file to the returned upload_url:
curl --request PUT "$UPLOAD_URL" \
  --header "Content-Type: application/x-ndjson" \
  --data-binary @rows.jsonl
Start the batch run with the returned file_id:
curl --request POST "https://api.clay.com/public/v0/routines/function:t_abc123/run-batch/start" \
  --header "clay-api-key: $CLAY_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{ "file_id": "file_abc123" }'
Then fetch progress and the result URL:
curl --request GET "https://api.clay.com/public/v0/routines/run-batch/run_xyz789/results" \
  --header "clay-api-key: $CLAY_API_KEY"

Workflow batch runs

Use Workflow batch runs when you want the Workflow itself to be built and managed from the plugin or CLI. Workflows are in Alpha. They are useful when you need agent-first building, run inspection, snapshots, code inside the flow, or runs that avoid the 50,000 row limit.

Workflows (Alpha)

Learn when to use Workflows.