# List Cohorts — Amplitude

> List all behavioral cohorts in the Amplitude project. Returns a cohorts array; each entry defaults to id, name, size, lastMod, appId. Pass fields to get more, e.g. description, published, archived, or the large definition (the cohort's…

- Key: `amplitude-list-cohorts`
- Type: Action (Read-only)
- Version: 0.0.2
- App: Amplitude (`amplitude`) — https://pipedream.com/apps/amplitude.md
- This page (HTML): https://pipedream.com/apps/amplitude/actions/list-cohorts
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/amplitude/actions/list-cohorts/list-cohorts.mjs

## Description

List all behavioral cohorts in the Amplitude project. Returns a `cohorts` array; each entry defaults to id, name, size, lastMod, appId. Pass `fields` to get more, e.g. `description`, `published`, `archived`, or the large `definition` (the cohort's filter logic) / `owners`/`viewers` (email arrays). Use this to discover valid cohort IDs for **Request Cohort Download** (step 1 of 3, followed by **Get Cohort Download Status** and **Download Cohort File**, to fetch a cohort's member list). Example: call with no parameters -> returns `{cohorts: [{id: "abc123", name: "Power Users Q3", size: 4200, lastMod: 1722873600000, appId: 849238}, ...]}`. [See the documentation](https://amplitude.com/docs/apis/analytics/behavioral-cohorts#get-all-cohorts).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `includeSyncInfo` | `boolean` | No | When true, include cohort sync metadata in the response (the includeSyncInfo param) — each cohort's syncMetadata field is then always kept regardless of fields. |
| `fields` | `string[]` | No | Field names to return for each cohort (id is always included). Defaults to: id, name, size, lastMod, appId. Also available: description, published, archived, createdAt, lastComputed, definition, owners, viewers, syncMetadata (auto-included when Include Sync Info is true). Pass only what you need to keep responses small. |

## 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": "amplitude",
      },
    },
  },
)

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: "amplitude-list-cohorts",
  arguments: {
    includeSyncInfo: true,
    fields: ["Fields"],
  },
})
```

**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: "amplitude-list-cohorts",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    amplitude: { authProvisionId: "apn_xxxxxxx" },
    includeSyncInfo: true,
    fields: ["Fields"],
  },
})

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": "amplitude-list-cohorts",
    "configured_props": {
      "amplitude": { "authProvisionId": "apn_xxxxxxx" },
      "includeSyncInfo": true,
      "fields": ["Fields"]
    }
  }'
```

---

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