# Search Records — Airtable

> Find records in a table using an Airtable formula, or a Search Field + Search Value pair. Search Formula takes precedence when provided; otherwise Search Field and Search Value must both be set. Use List Tables first to look up the table's…

- Key: `airtable_oauth-search-records`
- Type: Action (Read-only)
- Version: 1.0.0
- App: Airtable (`airtable_oauth`) — https://pipedream.com/apps/airtable-oauth.md
- This page (HTML): https://pipedream.com/apps/airtable-oauth/actions/search-records
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/airtable_oauth/actions/search-records/search-records.mjs

## Description

Find records in a table using an Airtable formula, or a `Search Field` + `Search Value` pair. `Search Formula` takes precedence when provided; otherwise `Search Field` and `Search Value` must both be set. Use **List Tables** first to look up the table's field names. [See the documentation](https://airtable.com/developers/web/api/list-records)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `baseId` | `string` | Yes | The ID of the base to use, e.g. appXXXXXXXXXXXXXX. Use List Bases to look one up. |
| `tableId` | `string` | Yes | The ID of the table to use, e.g. tblXXXXXXXXXXXXXX. Use List Tables to look one up. |
| `searchFormula` | `string` | No | An Airtable formula to filter records by, e.g. FIND('test-1', {Tags}) to find records where Tags includes test-1, or {Status} = "Won" for an exact match. Takes precedence over Search Field + Search Value when set. |
| `fieldName` | `string` | No | The field to match against Search Value, e.g. Status. Use together with Search Value as a simpler alternative to Search Formula. Use the List Tables action to look up the table's field names. |
| `value` | `string` | No | The value to match against Search Field, e.g. Won. For a checkbox field, use true or false; for a number field, a numeric value. |
| `returnFieldsByFieldId` | `boolean` | No | If set to true, the returned field objects will have the field ID as the key, instead of the field name. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "airtable_oauth",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "airtable_oauth-search-records",
  arguments: {
    baseId: "Base",
    tableId: "Table",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "airtable_oauth-search-records",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    airtable_oauth: { authProvisionId: "apn_xxxxxxx" },
    baseId: "Base",
    tableId: "Table",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "airtable_oauth-search-records",
    "configured_props": {
      "airtable_oauth": { "authProvisionId": "apn_xxxxxxx" },
      "baseId": "Base",
      "tableId": "Table"
    }
  }'
```

---

- App: https://pipedream.com/apps/airtable-oauth.md · All apps: https://pipedream.com/apps
