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

# Encode Clay functions into business systems

> Call Clay functions from backend jobs, internal tools, queues, and product workflows.

Use this pattern when Clay should run behind a backend job, queue, webhook, internal tool, or custom UI.

## Recommended path

| Need                                                  | Use                   |
| ----------------------------------------------------- | --------------------- |
| Common enrichment or research                         | Clay-managed function |
| Existing team-specific Clay logic                     | Custom function       |
| Logic you want to build and edit from an agent or CLI | Workflows (Alpha)     |

## Call from the API

```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"
```

## Call from the plugin or CLI

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
echo '{"items":[{"id":"row-1","inputs":{"domain":"clay.com"}}]}' \
  | clay routines runs start function:t_abc123 --input -
```

## Batch the same function

<Card title="Batch runs" href="/routines/batch-runs">
  Learn how function and Workflow batch runs fit together.
</Card>
