> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Use the Logs API The Logs API is the surface for anything you want to script or wire into your own tooling: pulling log records into a dashboard you already run, provisioning alerts alongside the rest of your infrastructure, or keeping sampling rules in version control. It's a project-scoped REST API and uses the same [authentication](/docs/api.md) as the rest of PostHog. Note that this is for reading and managing logs – to *send* logs to PostHog you use an [OpenTelemetry client](/docs/logs/installation.md), not this API. ## Before you start 1. **Set up Logs** – [send them to PostHog with an OpenTelemetry client](/docs/logs/installation.md) so there's something to read. 2. **Get API access** – [create a personal API key](/docs/api/personal-api-keys.md) with the scopes you need. ## What you can do here | Endpoint | What it's for | | --- | --- | | `/api/projects/:project_id/logs/` | Query log records with filters | | `/api/projects/:project_id/logs/alerts/` | Manage [log alerts](/docs/logs/alerts.md) | | `/api/projects/:project_id/logs/views/` | Manage saved views | | `/api/projects/:project_id/logs/sampling_rules/` | Manage sampling and drop rules | | `/api/projects/:project_id/logs/metric_rules/` | Manage [log-based metrics](/docs/logs/metrics.md) | Each collection supports the usual list, retrieve, create, update, and delete operations. See the [API reference](/docs/api.md) for request and response shapes. ## When to use the API instead of MCP Both let you work with logs outside the web app, but they're for different jobs. Use the API when something needs to run repeatably and unattended – a nightly export, an alert defined in Terraform, a status page. Use [MCP](/docs/logs/surfaces/mcp.md) when you're the one investigating and want an agent to do the querying for you. ## Related - Explore the same data in the [web app](/docs/logs/surfaces/web-app.md). - Query it conversationally over [MCP](/docs/logs/surfaces/mcp.md). - See the full [PostHog API reference](/docs/api.md). - Send logs in with an [OpenTelemetry client](/docs/logs/installation.md). ### Still have questions? Ask PostHog AI ### Was this page useful? HelpfulCould be better