Endpoints-2

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

Endpoints

PATCH
DELETE
GET
POST
GET
GET
POST

Update endpoints

Path parameters

  • name
    string

    URL-safe name for the endpoint

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.


Example request

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

Example response

Status 200 No response body

Delete endpoints

Delete an endpoint and clean up materialized query.

Required API key scopes

endpoint:write

Path parameters

  • name
    string

    URL-safe name for the endpoint

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.


Example request

DELETE /api/projects/:project_id/endpoints/:name
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/endpoints/:name/

Example response

Status 204 No response body

Delete endpoints

Delete an endpoint and clean up materialized query.

Required API key scopes

endpoint:write

Path parameters

  • name
    string

    URL-safe name for the endpoint

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.


Example request

DELETE /api/projects/:project_id/endpoints/:name
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/endpoints/:name/

Example response

Status 204 No response body

Retrieve endpoints run

Execute endpoint with optional materialization. Supports version parameter, runs latest version if not set.

Required API key scopes

endpoint:read

Path parameters

  • name
    string

    URL-safe name for the endpoint

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.


Example request

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

Example response

Status 200 No response body

Retrieve endpoints run

Execute endpoint with optional materialization. Supports version parameter, runs latest version if not set.

Required API key scopes

endpoint:read

Path parameters

  • name
    string

    URL-safe name for the endpoint

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.


Example request

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

Example response

Status 200 No response body

Create endpoints run

Execute endpoint with optional materialization. Supports version parameter, runs latest version if not set.

Required API key scopes

endpoint:read

Path parameters

  • name
    string

    URL-safe name for the endpoint

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.


Request parameters

  • client_query_id
    string

    Client provided query ID. Can be used to retrieve the status or cancel the query.

  • filters_override

    A map for overriding insight query filters.

    Tip: Use to get data for a specific customer or user.

  • query_override
    object

    Map of Insight query keys to be overridden at execution time. For example: Assuming query = {"kind": "TrendsQuery", "series": [{"kind": "EventsNode","name": "$pageview","event": "$pageview","math": "total"}]} If query_override = {"series": [{"kind": "EventsNode","name": "$identify","event": "$identify","math": "total"}]} The query executed will return the count of $identify events, instead of $pageview's

  • refresh
    Default: blocking

    Whether results should be calculated sync or async, and how much to rely on the cache:

    • 'blocking' - calculate synchronously (returning only when the query is done), UNLESS there are very fresh results in the cache
    • 'force_blocking' - calculate synchronously, even if fresh results are already cached
  • variables
    object

    A map for overriding HogQL query variables, where the key is the variable name and the value is the variable value. Variable must be set on the endpoint's query between curly braces (i.e. {variable.from_date}) For example: {"from_date": "1970-01-01"}


Example request

POST /api/projects/:project_id/endpoints/:name/run
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/endpoints/:name/run/\
-d client_query_id="string"

Example response

Status 200 No response body

Create endpoints run

Execute endpoint with optional materialization. Supports version parameter, runs latest version if not set.

Required API key scopes

endpoint:read

Path parameters

  • name
    string

    URL-safe name for the endpoint

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.


Request parameters

  • client_query_id
    string

    Client provided query ID. Can be used to retrieve the status or cancel the query.

  • filters_override

    A map for overriding insight query filters.

    Tip: Use to get data for a specific customer or user.

  • query_override
    object

    Map of Insight query keys to be overridden at execution time. For example: Assuming query = {"kind": "TrendsQuery", "series": [{"kind": "EventsNode","name": "$pageview","event": "$pageview","math": "total"}]} If query_override = {"series": [{"kind": "EventsNode","name": "$identify","event": "$identify","math": "total"}]} The query executed will return the count of $identify events, instead of $pageview's

  • refresh
    Default: blocking

    Whether results should be calculated sync or async, and how much to rely on the cache:

    • 'blocking' - calculate synchronously (returning only when the query is done), UNLESS there are very fresh results in the cache
    • 'force_blocking' - calculate synchronously, even if fresh results are already cached
  • variables
    object

    A map for overriding HogQL query variables, where the key is the variable name and the value is the variable value. Variable must be set on the endpoint's query between curly braces (i.e. {variable.from_date}) For example: {"from_date": "1970-01-01"}


Example request

POST /api/projects/:project_id/endpoints/:name/run
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/endpoints/:name/run/\
-d client_query_id="string"

Example response

Status 200 No response body

Retrieve endpoints versions

List all versions for an endpoint.

Required API key scopes

endpoint:read

Path parameters

  • name
    string

    URL-safe name for the endpoint

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.


Example request

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

Example response

Status 200 No response body

Retrieve endpoints versions

List all versions for an endpoint.

Required API key scopes

endpoint:read

Path parameters

  • name
    string

    URL-safe name for the endpoint

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.


Example request

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

Example response

Status 200 No response body

Retrieve endpoints versions retrieve

Get details of a specific endpoint version.

Required API key scopes

endpoint:read

Path parameters

  • name
    string

    URL-safe name for the endpoint

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

  • version_number
    string

Example request

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

Example response

Status 200 No response body

Retrieve endpoints versions retrieve

Get details of a specific endpoint version.

Required API key scopes

endpoint:read

Path parameters

  • name
    string

    URL-safe name for the endpoint

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

  • version_number
    string

Example request

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

Example response

Status 200 No response body

Create endpoints last execution times

Get the last execution times in the past 6 months for multiple endpoints.

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.


Request parameters

  • names
    array

Response


Example request

POST /api/projects/:project_id/endpoints/last_execution_times
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/endpoints/last_execution_times/\
-d names="array"

Example response

Status 200
RESPONSE
{
"query_status": {
"complete": false,
"dashboard_id": null,
"end_time": null,
"error": false,
"error_message": null,
"expiration_time": null,
"id": "string",
"insight_id": null,
"labels": null,
"pickup_time": null,
"query_async": true,
"query_progress": {
"active_cpu_time": 0,
"bytes_read": 0,
"estimated_rows_total": 0,
"rows_read": 0,
"time_elapsed": 0
},
"results": null,
"start_time": null,
"task_id": null,
"team_id": 0
}
}

Create endpoints last execution times

Get the last execution times in the past 6 months for multiple endpoints.

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.


Request parameters

  • names
    array

Response


Example request

POST /api/projects/:project_id/endpoints/last_execution_times
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/endpoints/last_execution_times/\
-d names="array"

Example response

Status 200
RESPONSE
{
"query_status": {
"complete": false,
"dashboard_id": null,
"end_time": null,
"error": false,
"error_message": null,
"expiration_time": null,
"id": "string",
"insight_id": null,
"labels": null,
"pickup_time": null,
"query_async": true,
"query_progress": {
"active_cpu_time": 0,
"bytes_read": 0,
"estimated_rows_total": 0,
"rows_read": 0,
"time_elapsed": 0
},
"results": null,
"start_time": null,
"task_id": null,
"team_id": 0
}
}

Community questions

Questions about this page? or post a community question.