API Keys
Logfire provides public APIs that allow you to programmatically manage your organizations, projects, and other resources. To access these APIs, you'll need to create an API key.
Public APIs
API keys are for accessing the Logfire platform APIs, not for sending telemetry data (traces, logs, metrics). To send data to Logfire, use write tokens.
What you can do
Available to all plans:
- Projects: List, create, update, and delete projects
- Write tokens: Create, list, rotate, expire, and revoke write tokens
- Read tokens: Create, list, rotate, expire, and revoke read tokens
- Alerts: Create, list, update, and delete alerts with SQL-based conditions and notification channels
- Dashboards: Create, list, update, and delete dashboards
- Notification channels: Create, list, update, and delete notification destinations (Slack, webhooks, etc.)
- Variables: Create, read, and update project variables
Enterprise / Self-hosted only:
- Audit logs: List and retrieve audit log entries for your organization
- Billing usage: View billing usage data for current and previous periods
- SCIM provisioning: Manage users and groups via the SCIM protocol for identity provider integration
- Organization management (self-hosted only): Create, list, update, and delete organizations
API Documentation¶
Complete API reference (Swagger docs):
- US Region: https://api-us.pydantic.dev/api/docs
- EU Region: https://api-eu.pydantic.dev/api/docs
Choose the endpoint that matches your account's data region.
Creating API Keys¶
Organization API Key¶
Navigate to your organization, then Settings → API Keys → New API Key.
Organization API keys can be scoped to all projects or a specific project. See API Key Scopes for available permissions.
Project API Key¶
Navigate to your project, then Settings → API Keys → New API Key.
Project API keys are limited to the project where they were created.
Warning
Copy your API key when it's displayed—it won't be shown again.
API Key Scopes¶
When creating an API key, set the scope to define which actions the key can perform. Available scopes depend on whether you're creating an organization or project API key:
| Scope | Organization API Key | Project API Key |
|---|---|---|
| Organization management | ✓ | — |
| Notification channels | ✓ | — |
| Audit logs | ✓ | — |
| SCIM provisioning | ✓ | — |
| Billing usage | ✓ | — |
| Project settings | ✓ | ✓ |
| Write tokens management | ✓ | ✓ |
| Read tokens management | ✓ | ✓ |
| Alerts management | ✓ | ✓ |
| Dashboards management | ✓ | ✓ |
| Variables management | ✓ | ✓ |
Info
Select only the scopes your application needs to follow the principle of least privilege.
Using API Keys¶
Once you have an API key, you can use it to authenticate requests to the Logfire public APIs.
Include the API key in the Authorization header as a Bearer token.
Example: List Projects¶
Here's an example using curl to list all projects in your organization:
curl -X GET "https://api-us.pydantic.dev/api/v1/projects/" \
-H "Authorization: Bearer YOUR_API_KEY"
curl -X GET "https://api-eu.pydantic.dev/api/v1/projects/" \
-H "Authorization: Bearer YOUR_API_KEY"
Replace YOUR_API_KEY with your actual API key.
Example Response¶
A successful request will return a JSON response with your projects:
[
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"project_name": "my-project",
"created_at": "2024-05-24T11:18:22.704455Z",
"description": null,
"organization_name": "my-organization",
"visibility": "public"
}
]