Skip to main content
Routines are the programmable way to run Clay logic. Through the Public API, you can run Clay-managed functions and custom functions from backend services, queue workers, internal tools, and custom apps. Use Clay-managed functions for common enrichment and research jobs. Use custom functions for team-specific Clay logic built in the Clay UI.

Run a function routine

Custom function routine ids use the format function:t_.... To start a run, call POST /routines/{routine_id}/run.
ROUTINE_RUN_ID=$(curl --request POST \
  --url "https://api.clay.com/public/v0/routines/function:t_abc123/run" \
  --header "Content-Type: application/json" \
  --header "clay-api-key: $CLAY_API_KEY" \
  --data '{
    "items": [
      {
        "id": "row-1",
        "inputs": {
          "domain": "clay.com"
        }
      }
    ]
  }' | jq -r '.routine_run_id')

curl --request GET \
  --url "https://api.clay.com/public/v0/routines/run/$ROUTINE_RUN_ID/results" \
  --header "clay-api-key: $CLAY_API_KEY"

Webhook notifications

The run and run-batch/start requests accept an optional webhook_id. Clay notifies that webhook when the run finishes, so your system can react without polling. See clay webhooks for webhook creation, testing, delivery payloads, and signature verification.

Batch run a function routine

For large input sets, create an upload URL, upload JSONL input, then start a batch run.

Batch runs

Learn how batch runs fit into Routines.

When to use Workflows

Workflows are also routines, but they are in Alpha and are built differently. Use Workflows when you want to build, edit, validate, run, inspect, or batch-run Clay logic from the plugin or CLI instead of building the logic in the Clay UI.

Workflows (Alpha)

Compare Workflows with functions.