Data Deletion

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

Endpoints

GET
POST
GET
POST

List all data deletion requests

List self-service event deletion requests for this project.

Required API key scopes

data_deletion:read

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

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

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "draft",
"query": "string",
"variables": {
"property1": {
"code_name": "string",
"isNull": null,
"value": null,
"variableId": "string"
},
"property2": {
"code_name": "string",
"isNull": null,
"value": null,
"variableId": "string"
}
},
"submission_id": "945dfedc-ad7f-4af7-b20c-06082ffa3cb3",
"count": 0,
"created_by_id": 0,
"created_by_staff": true,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"approved_at": "2019-08-24T14:15:22Z",
"stats_calculated_at": "2019-08-24T14:15:22Z"
}
]
}

Create data deletion requests

Submit a one-column HogQL query for event deletion.

Required API key scopes

data_deletion:write

Request parameters

  • query
    string
  • variables
    object
  • submission_id
    string

Response


Example request

POST /api/projects/:project_id/data_deletion_requests
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/data_deletion_requests/\
-d query="string",\
-d submission_id="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "draft",
"query": "string",
"variables": {
"property1": {
"code_name": "string",
"isNull": null,
"value": null,
"variableId": "string"
},
"property2": {
"code_name": "string",
"isNull": null,
"value": null,
"variableId": "string"
}
},
"submission_id": "945dfedc-ad7f-4af7-b20c-06082ffa3cb3",
"count": 0,
"created_by_id": 0,
"created_by_staff": true,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"approved_at": "2019-08-24T14:15:22Z",
"stats_calculated_at": "2019-08-24T14:15:22Z"
}
Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "draft",
"query": "string",
"variables": {
"property1": {
"code_name": "string",
"isNull": null,
"value": null,
"variableId": "string"
},
"property2": {
"code_name": "string",
"isNull": null,
"value": null,
"variableId": "string"
}
},
"submission_id": "945dfedc-ad7f-4af7-b20c-06082ffa3cb3",
"count": 0,
"created_by_id": 0,
"created_by_staff": true,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"approved_at": "2019-08-24T14:15:22Z",
"stats_calculated_at": "2019-08-24T14:15:22Z"
}
Status 409
RESPONSE
{
"detail": "string"
}

Retrieve data deletion requests

Get one self-service event deletion request for this project.

Required API key scopes

data_deletion:read

Path parameters

  • id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "draft",
"query": "string",
"variables": {
"property1": {
"code_name": "string",
"isNull": null,
"value": null,
"variableId": "string"
},
"property2": {
"code_name": "string",
"isNull": null,
"value": null,
"variableId": "string"
}
},
"submission_id": "945dfedc-ad7f-4af7-b20c-06082ffa3cb3",
"count": 0,
"created_by_id": 0,
"created_by_staff": true,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"approved_at": "2019-08-24T14:15:22Z",
"stats_calculated_at": "2019-08-24T14:15:22Z"
}

Create data deletion requests preview

Validate a one-column HogQL query and count the selected event UUIDs.

Required API key scopes

data_deletion:write

Request parameters

  • query
    string
  • variables
    object

Response


Example request

POST /api/projects/:project_id/data_deletion_requests/preview
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/data_deletion_requests/preview/\
-d query="string"

Example response

Status 200
RESPONSE
{
"count": 0
}