Warehouse Saved

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

Endpoints

GET
POST
GET
PATCH
DELETE
GET
POST
POST
GET
POST
POST
POST
POST
GET
POST

List all warehouse saved queries list

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:read

Path parameters

  • project_id
    string

Query parameters

  • page
    integer
  • search
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?page=4",
"previous": "http://api.example.org/accounts/?page=2",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": "string",
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"latest_error": "string",
"is_materialized": true,
"origin": "data_warehouse"
}
]
}

Create warehouse saved queries create

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:write

Path parameters

  • project_id
    string

Request parameters

  • deleted
    boolean
  • name
    string
  • query
  • edited_history_id
    string
  • soft_update
    boolean

Response


Example request

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

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": null,
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": "string",
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "string",
"soft_update": true,
"is_materialized": true,
"origin": "data_warehouse"
}

Retrieve warehouse saved queries retrieve

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:read

Path parameters

  • id
    string
  • project_id
    string

Response


Example request

GET /api/projects/:project_id/warehouse_saved_queries/: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/warehouse_saved_queries/:id/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": null,
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": "string",
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "string",
"soft_update": true,
"is_materialized": true,
"origin": "data_warehouse"
}

Update warehouse saved queries update

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:write

Path parameters

  • id
    string
  • project_id
    string

Request parameters

  • deleted
    boolean
  • name
    string
  • query
  • edited_history_id
    string
  • soft_update
    boolean

Response


Example request

PATCH /api/projects/:project_id/warehouse_saved_queries/:id
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/warehouse_saved_queries/:id/\
-d deleted="boolean"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": null,
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": "string",
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "string",
"soft_update": true,
"is_materialized": true,
"origin": "data_warehouse"
}

Delete warehouse saved queries destroy

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:write

Path parameters

  • id
    string
  • project_id
    string

Example request

DELETE /api/projects/:project_id/warehouse_saved_queries/: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/warehouse_saved_queries/:id/

Example response

Status 204 No response body

Retrieve warehouse saved queries activity retrieve

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

activity_log:read

Path parameters

  • id
    string
  • project_id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": null,
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": "string",
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "string",
"soft_update": true,
"is_materialized": true,
"origin": "data_warehouse"
}

Create warehouse saved queries ancestors create

Return the ancestors of this saved query.

By default, we return the immediate parents. The level parameter can be used to look further back into the ancestor tree. If level overshoots (i.e. points to only ancestors beyond the root), we return an empty list.

Path parameters

  • id
    string
  • project_id
    string

Request parameters

  • deleted
    boolean
  • name
    string
  • query
  • edited_history_id
    string
  • soft_update
    boolean

Response


Example request

POST /api/projects/:project_id/warehouse_saved_queries/:id/ancestors
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/warehouse_saved_queries/:id/ancestors/\
-d name="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": null,
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": "string",
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "string",
"soft_update": true,
"is_materialized": true,
"origin": "data_warehouse"
}

Create warehouse saved queries cancel create

Cancel a running saved query workflow.

Path parameters

  • id
    string
  • project_id
    string

Request parameters

  • deleted
    boolean
  • name
    string
  • query
  • edited_history_id
    string
  • soft_update
    boolean

Response


Example request

POST /api/projects/:project_id/warehouse_saved_queries/:id/cancel
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/warehouse_saved_queries/:id/cancel/\
-d name="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": null,
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": "string",
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "string",
"soft_update": true,
"is_materialized": true,
"origin": "data_warehouse"
}

Retrieve warehouse saved queries dependencies retrieve

Return the count of immediate upstream and downstream dependencies for this saved query.

Path parameters

  • id
    string
  • project_id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": null,
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": "string",
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "string",
"soft_update": true,
"is_materialized": true,
"origin": "data_warehouse"
}

Create warehouse saved queries descendants create

Return the descendants of this saved query.

By default, we return the immediate children. The level parameter can be used to look further ahead into the descendants tree. If level overshoots (i.e. points to only descendants further than a leaf), we return an empty list.

Path parameters

  • id
    string
  • project_id
    string

Request parameters

  • deleted
    boolean
  • name
    string
  • query
  • edited_history_id
    string
  • soft_update
    boolean

Response


Example request

POST /api/projects/:project_id/warehouse_saved_queries/:id/descendants
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/warehouse_saved_queries/:id/descendants/\
-d name="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": null,
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": "string",
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "string",
"soft_update": true,
"is_materialized": true,
"origin": "data_warehouse"
}

Create warehouse saved queries materialize create

Enable materialization for this saved query with a 24-hour sync frequency.

Path parameters

  • id
    string
  • project_id
    string

Request parameters

  • deleted
    boolean
  • name
    string
  • query
  • edited_history_id
    string
  • soft_update
    boolean

Response


Example request

POST /api/projects/:project_id/warehouse_saved_queries/:id/materialize
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/warehouse_saved_queries/:id/materialize/\
-d name="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": null,
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": "string",
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "string",
"soft_update": true,
"is_materialized": true,
"origin": "data_warehouse"
}

Create warehouse saved queries revert materialization create

Undo materialization, revert back to the original view. (i.e. delete the materialized table and the schedule)

Path parameters

  • id
    string
  • project_id
    string

Request parameters

  • deleted
    boolean
  • name
    string
  • query
  • edited_history_id
    string
  • soft_update
    boolean

Response


Example request

POST /api/projects/:project_id/warehouse_saved_queries/:id/revert_materialization
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/warehouse_saved_queries/:id/revert_materialization/\
-d name="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": null,
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": "string",
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "string",
"soft_update": true,
"is_materialized": true,
"origin": "data_warehouse"
}

Create warehouse saved queries run create

Run this saved query.

Path parameters

  • id
    string
  • project_id
    string

Request parameters

  • deleted
    boolean
  • name
    string
  • query
  • edited_history_id
    string
  • soft_update
    boolean

Response


Example request

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

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": null,
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": "string",
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "string",
"soft_update": true,
"is_materialized": true,
"origin": "data_warehouse"
}

Retrieve warehouse saved queries run history retrieve

Return the recent run history (up to 5 most recent) for this materialized view.

Path parameters

  • id
    string
  • project_id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": null,
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": "string",
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "string",
"soft_update": true,
"is_materialized": true,
"origin": "data_warehouse"
}

Create warehouse saved queries resume schedules create

Resume paused materialization schedules for multiple matviews.

Accepts a list of view IDs in the request body: {"view_ids": ["id1", "id2", ...]} This endpoint is idempotent - calling it on already running or non-existent schedules is safe.

Path parameters

  • project_id
    string

Request parameters

  • deleted
    boolean
  • name
    string
  • query
  • edited_history_id
    string
  • soft_update
    boolean

Response


Example request

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

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": null,
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {
"property1": null,
"property2": null
},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": "string",
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "string",
"soft_update": true,
"is_materialized": true,
"origin": "data_warehouse"
}

Community questions

Questions about this page? or post a community question.