Skip to main content
Use this pattern when Clay should run behind a backend job, queue, webhook, internal tool, or custom UI.
NeedUse
Common enrichment or researchClay-managed function
Existing team-specific Clay logicCustom function
Logic you want to build and edit from an agent or CLIWorkflows (Alpha)

Call from the API

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"

Call from the plugin or CLI

echo '{"items":[{"id":"row-1","inputs":{"domain":"clay.com"}}]}' \
  | clay routines runs start function:t_abc123 --input -

Batch the same function

Batch runs

Learn how function and Workflow batch runs fit together.