> ## Documentation Index
> Fetch the complete documentation index at: https://developers.clay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Routines API

> Run Clay-managed functions and custom functions through the Public API.

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](/routines/clay-managed-functions) for common enrichment and research jobs. Use [custom functions](/routines/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`.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
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`](/cli/reference/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.

<Card title="Batch runs" href="/routines/batch-runs">
  Learn how batch runs fit into Routines.
</Card>

## 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.

<Card title="Workflows (Alpha)" href="/routines/workflows-alpha">
  Compare Workflows with functions.
</Card>
