Survey

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

Endpoints

GET
GET
GET

Retrieve surveys question

Return a slim list of question labels for the team's surveys. Used by the frontend to resolve $survey_response_<question_id> property keys into human-readable question text without loading the full survey payload.

Required API key scopes

survey:read

Response


Example request

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

Example response

Status 200
RESPONSE
{
"labels": [
{
"question_id": "string",
"question_text": "string",
"question_index": 0,
"survey_id": "string",
"survey_name": "string"
}
]
}

Retrieve surveys responses count

Get response counts for all surveys.

Args: exclude_archived: Optional boolean to exclude archived responses (default: false, includes archived) survey_ids: Optional comma-separated list of survey IDs to filter by

Returns: Dictionary mapping survey IDs to response counts

Required API key scopes

survey:read

Example request

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

Example response

Status 200 No response body

Retrieve surveys global stats

Get aggregated response statistics across all surveys.

Args: date_from: Optional ISO timestamp (e.g. 2024-01-01T00:00:00Z) or relative date (e.g. -7d) for start date date_to: Optional ISO timestamp (e.g. 2024-01-31T23:59:59Z) or relative date for end date

Returns: Aggregated statistics across all surveys including total counts and rates

Required API key scopes

survey:read

Query parameters

  • date_from
    string
  • date_to
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"stats": {},
"rates": {}
}