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

# Run a search, then enrich with a function

> Use Searches to find records, then run Clay-managed functions on the results.

This is the simplest high-value Clay developer flow:

1. Use Searches to find companies, people, or jobs.
2. Pass the results into a routine.
3. Use Clay-managed functions to enrich the records.

For example, you might search for heads of sales at B2B SaaS companies, then run a Clay-managed function to find work emails.

## 1. Run a search

Create a search, then fetch the first page of results.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
SEARCH_ID=$(curl --request POST \
  --url https://api.clay.com/public/v0/searches \
  --header "Content-Type: application/json" \
  --header "clay-api-key: $CLAY_API_KEY" \
  --data '{
    "source_type": "people",
    "query": "Heads of sales at B2B SaaS companies in New York"
  }' | jq -r '.search_id')

curl --request POST \
  --url "https://api.clay.com/public/v0/searches/$SEARCH_ID/next" \
  --header "Content-Type: application/json" \
  --header "clay-api-key: $CLAY_API_KEY" \
  --data '{ "limit": 10 }'
```

## 2. Choose a function

Use a Clay-managed function when Clay already provides the enrichment you need, such as finding emails, phone numbers, company data, technology data, funding, or job openings.

<Card title="Clay-managed functions" href="/routines/clay-managed-functions">
  Learn when to use Clay-provided functions.
</Card>

## 3. Run the function

Run the function routine on the records you want to enrich.

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

Then fetch the result:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
clay routines runs get run_abc123
```

## Next steps

<Card title="Searches" href="/searches">
  Learn the search flow in more detail.
</Card>

<Card title="Batch runs" href="/routines/batch-runs">
  Run the same routine across many records.
</Card>
