251
All tools

Create a cohort

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

Updated Sep 27, 2026

create-cohort.md

Create a cohort

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

Note: 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.

{ "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.

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)

Before anything else, confirm access with the cheapest read-only call, like a list or a search. Never send or change anything to test access.

Rules

  • Ask the user before anything that sends messages, costs money, or changes data, and say how many records it touches. One approval covers a batch the user has seen.
  • Never print API keys.

Ways in

RouteSourceCallRequiredDocs
MCPOfficial · remotecohorts-createOAuthDocs
CLIOfficialposthog-cli api call cohorts-createAPI key in $POSTHOG_CLI_API_KEYDocs
APIOfficialPOST /api/projects/{project_id}/cohorts/API key in $POSTHOG_PERSONAL_API_KEYDocs

Workflows using Create a cohort

No workflows yet
No published workflow uses Create a cohort yet.