Web Analytics Bot

For instructions on how to authenticate to use this endpoint, see API overview.

Endpoints

GET
POST
DELETE

List all web analytics bot rules

The project's own bot rules, in the order they are checked at query time.

Required API key scopes

web_analytics:read

Example request

GET /api/projects/:project_id/web_analytics_bot_rules
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/web_analytics_bot_rules/

Example response

Status 200
RESPONSE
{
"id": "string",
"name": "string",
"category": "string",
"combiner": "AND",
"items": [
{
"id": "string",
"key": "string",
"matcher": "string",
"pattern": "string"
}
]
}

Create web analytics bot rules

Add one bot rule to the project. A rule combines one or more single-property conditions with AND or OR. A pattern is rejected if it cannot run, because a broken rule would break every query that classifies traffic for the project.

Required API key scopes

web_analytics:write

Request parameters

  • name
    string
  • category
    string
  • combiner
    string
    Default: AND
  • items
    Click to open
    array

Response


Example request

POST /api/projects/:project_id/web_analytics_bot_rules
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/web_analytics_bot_rules/\
-d name="string",\
-d items="array"

Example response

Status 201
RESPONSE
{
"id": "string",
"name": "string",
"category": "string",
"combiner": "AND",
"items": [
{
"id": "string",
"key": "string",
"matcher": "string",
"pattern": "string"
}
]
}

Delete web analytics bot rules

Remove one bot rule by its id. The built-in bot list is unaffected.

Required API key scopes

web_analytics:write

Path parameters

  • id
    string

Example request

DELETE /api/projects/:project_id/web_analytics_bot_rules/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X DELETE \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/web_analytics_bot_rules/:id/

Example response

Status 204 No response body