Logs
For instructions on how to authenticate to use this endpoint, see API overview.
Endpoints
GET | |
POST | |
GET | |
PATCH | |
DELETE | |
POST | |
POST | |
GET | |
POST | |
POST | |
GET | |
POST | |
POST | |
POST | |
POST | |
GET | |
POST | |
GET | |
POST |
List all environments logs alerts
Also available via the PostHog MCP server:
logs-alerts-list— List log alerts
Required API key scopes
logs:readQuery parameters
- limitinteger
- offsetinteger
Response
Example request
GET /api /environments /:environment_id /logs /alertsExample response
Status 200
Create environments logs alerts
Also available via the PostHog MCP server:
logs-alerts-create— Create log alert
Required API key scopes
logs:writeRequest parameters
- namestring
- enabledbooleanDefault:
true - filters
- threshold_countintegerDefault:
100 - threshold_operatorDefault:
above - window_minutesintegerDefault:
5 - evaluation_periodsintegerDefault:
1 - datapoints_to_alarmintegerDefault:
1 - cooldown_minutesintegerDefault:
0 - snooze_untilstringnull
Response
Example request
POST /api /environments /:environment_id /logs /alertsExample response
Status 201
Retrieve environments logs alerts
Also available via the PostHog MCP server:
logs-alerts-retrieve— Get log alert
Required API key scopes
logs:readPath parameters
- idstring
Response
Example request
GET /api /environments /:environment_id /logs /alerts /:idExample response
Status 200
Update environments logs alerts
Also available via the PostHog MCP server:
logs-alerts-partial-update— Update log alert
Required API key scopes
logs:writePath parameters
- idstring
Request parameters
- namestring
- enabledbooleanDefault:
true - filters
- threshold_countintegerDefault:
100 - threshold_operatorDefault:
above - window_minutesintegerDefault:
5 - evaluation_periodsintegerDefault:
1 - datapoints_to_alarmintegerDefault:
1 - cooldown_minutesintegerDefault:
0 - snooze_untilstringnull
Response
Example request
PATCH /api /environments /:environment_id /logs /alerts /:idExample response
Status 200
Delete environments logs alerts
Also available via the PostHog MCP server:
logs-alerts-destroy— Delete log alert
Required API key scopes
logs:writePath parameters
- idstring
Example request
DELETE /api /environments /:environment_id /logs /alerts /:idExample response
Status 204 No response body
Create environments logs alerts destinations
Also available via the PostHog MCP server:
logs-alerts-destinations-create— Attach alert destination
Create a notification destination for this alert. One HogFunction is created per alert event kind (firing, resolved, ...) atomically.
Required API key scopes
logs:writePath parameters
- idstring
Request parameters
- type
- slack_workspace_idinteger
- slack_channel_idstring
- slack_channel_namestring
- webhook_urlstring
Response
Example request
POST /api /environments /:environment_id /logs /alerts /:id /destinationsExample response
Status 201
Create environments logs alerts destinations delete
Also available via the PostHog MCP server:
logs-alerts-destinations-delete-create— Detach alert destination
Delete a notification destination by deleting its HogFunction group atomically.
Required API key scopes
logs:writePath parameters
- idstring
Request parameters
- hog_function_idsarray
Example request
POST /api /environments /:environment_id /logs /alerts /:id /destinations /deleteExample response
Status 204 No response body
List all environments logs alerts events
Also available via the PostHog MCP server:
logs-alerts-events-list— List alert events
Paginated event history for this alert, newest first. Returns state transitions, errored checks, and user-initiated control-plane rows (reset, enable/disable, snooze/unsnooze, threshold change) — quiet no-op check rows (where state didn't change and there was no error) are filtered out since only the last 10 are kept and they carry no forensic value. Optional ?kind=... narrows to a single kind.
Required API key scopes
logs:readPath parameters
- idstring
Query parameters
- limitinteger
- offsetinteger
Response
Example request
GET /api /environments /:environment_id /logs /alerts /:id /eventsExample response
Status 200
Create environments logs alerts reset
Reset a broken alert. Clears the consecutive-failure counter and schedules an immediate recheck.
Required API key scopes
logs:writePath parameters
- idstring
Response
Example request
POST /api /environments /:environment_id /logs /alerts /:id /resetExample response
Status 200
Create environments logs alerts simulate
Also available via the PostHog MCP server:
logs-alerts-simulate-create— Simulate log alert
Simulate a logs alert on historical data using the full state machine. Read-only — no alert check records are created.
Required API key scopes
logs:readRequest parameters
- filters
- threshold_countinteger
- threshold_operator
- window_minutesinteger
- check_interval_minutesintegerDefault:
5 - evaluation_periodsintegerDefault:
1 - datapoints_to_alarmintegerDefault:
1 - cooldown_minutesintegerDefault:
0 - date_fromstring
Response
Example request
POST /api /environments /:environment_id /logs /alerts /simulateExample response
Status 200
Retrieve environments logs attributes
Required API key scopes
logs:readQuery parameters
- attribute_typestringOne of:
"log""resource" - dateRange
- filterGrouparrayDefault:
- limitinteger
- offsetinteger
- searchstring
- search_valuesbooleanDefault:
false - serviceNamesarrayDefault:
Response
Example request
GET /api /environments /:environment_id /logs /attributesExample response
Status 200
Create environments logs count
Required API key scopes
logs:readRequest parameters
- query
Response
Example request
POST /api /environments /:environment_id /logs /countExample response
Status 200
Create environments logs count ranges
Required API key scopes
logs:readRequest parameters
- query
Response
Example request
POST /api /environments /:environment_id /logs /count-rangesExample response
Status 200
Create environments logs explainlogwithai
Explain a log entry using AI.
POST /api/environments/:id/logs/explainLogWithAI/
Required API key scopes
logs:writeRequest parameters
- uuidstring
- timestampstring
- force_refreshbooleanDefault:
false
Response
Example request
POST /api /environments /:environment_id /logs /explainLogWithAIExample response
Status 201
Create environments logs export
Required API key scopes
logs:readExample request
POST /api /environments /:environment_id /logs /exportExample response
Status 201
Retrieve environments logs has logs
Required API key scopes
logs:readExample request
GET /api /environments /:environment_id /logs /has_logsExample response
Status 200
Create environments logs query
Required API key scopes
logs:readRequest parameters
- query
Response
Example request
POST /api /environments /:environment_id /logs /queryExample response
Status 200
List all environments logs sampling rules
Required API key scopes
logs:readQuery parameters
- limitinteger
- offsetinteger
Response
Example request
GET /api /environments /:environment_id /logs /sampling_rulesExample response
Status 200
Create environments logs sampling rules
Required API key scopes
logs:writeRequest parameters
- namestring
- enabledbooleanDefault:
false - priorityintegernull
- rule_type
- scope_servicestringnull
- scope_path_patternstringnull
- scope_attribute_filtersarray
- config
Response
Example request
POST /api /environments /:environment_id /logs /sampling_rules