---
ref: tool:posthog/create-cohort
name: Create a cohort
company: company:posthog
workflows: []
access: [mcp, cli, api]
tags: [capability:build-audience, category:product-analytics, has:api, has:cli, has:mcp]
docs: https://posthog.com/docs/api/cohorts
updated: 2026-09-27
---

# Create a cohort

Creates a cohort of persons from property or behavioral filters, or a static cohort from a list of person IDs.

Needs a personal API key with the `cohort:write` scope.

## Set up

Use the first option your agent supports.

### MCP (official, remote)

Add this server to your agent's MCP settings, then sign in when asked.

```json
{ "mcpServers": { "posthog": { "url": "https://mcp.posthog.com/mcp" } } }
```

Call the MCP tool `cohorts-create`.

Server URL: https://mcp.posthog.com/mcp

### CLI (official)

Install the command, then confirm it runs.

```sh
npm install -g @posthog/cli@latest
posthog-cli --version
```

Run `posthog-cli api call cohorts-create`.

Set `$POSTHOG_CLI_API_KEY` in your environment first (get a key: https://app.posthog.com/settings/user-api-keys?preset=mcp_server).

### API (official)

- Base URL: https://us.posthog.com
- Endpoint: `POST /api/projects/:project_id/cohorts/`
- Auth: send the header `Authorization: Bearer $POSTHOG_PERSONAL_API_KEY`
- Get a key: https://us.posthog.com/settings/user-api-keys
- Docs: https://posthog.com/docs/api

Before doing anything else, make one read-only call to confirm access.

## Rules

- Ask the user before anything that sends messages, costs money, or changes data.
- Never print API keys.
