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
POST
GET
POST
POST

List all warehouse saved queries

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:read

Query parameters

  • include_columns
    boolean
    Default: true
  • 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": {},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"description": "string",
"sync_frequency": "string",
"columns": [
{}
],
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"folder_id": "7695bac3-9397-4ec2-9335-45a2a16f1901",
"folder_name": "string",
"latest_error": "string",
"suspended": {
"property1": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
},
"property2": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
}
},
"is_materialized": true,
"is_incremental": true,
"origin": "data_warehouse",
"is_test": true,
"expires_at": "2019-08-24T14:15:22Z",
"user_access_level": "string",
"engine": {
"target": "clickhouse",
"dialect": "hogql",
"connection_id": "string",
"capabilities": {
"materialize": {
"available": true,
"reason": "string"
},
"lineage": {
"available": true,
"reason": "string"
},
"referenceable_from_clickhouse": {
"available": true,
"reason": "string"
},
"column_source": "clickhouse_probe"
}
}
}
]
}

Create warehouse saved queries

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:write

Request parameters

  • name
    string
  • query
    object
  • incremental
  • description
    string | null
  • sync_frequency
  • folder_id
    string | null
  • edited_history_id
    string | null
  • soft_update
    boolean | null
  • acknowledge_breaking_changes
    boolean
    Default: false
  • is_test
    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",\
-d query="object"

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": {
"kind": "HogQLQuery",
"query": "string"
},
"incremental": {
"enabled": false,
"incremental_key": "string",
"unique_key": [
"string"
],
"lookback_seconds": 0
},
"incremental_state": {
"watermark": "string",
"definition_fingerprint": "string",
"last_full_refresh_at": "string",
"last_run_mode": "incremental"
},
"has_incremental_history": true,
"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": {},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"description": "string",
"sync_frequency": "never",
"sync_frequency_bounds": {
"frequency_mode": "tiered",
"options": [
{
"cadence": "15min",
"allowed": true,
"blocked_by": "source",
"blocker": {
"id": "string",
"name": "string"
},
"speeds_up": [
{
"id": "string",
"name": "string"
}
],
"speeds_up_withheld": true
}
],
"floor": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"plan_floor": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"ceiling": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"best_effort_sources": [
{
"id": "string",
"name": "string"
}
],
"best_effort_sources_withheld": true
},
"plan_clamp": {
"previous_target_seconds": 0,
"plan_floor_seconds": 0,
"at": "2019-08-24T14:15:22Z"
},
"columns": [
{}
],
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"folder_id": "7695bac3-9397-4ec2-9335-45a2a16f1901",
"folder_name": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "feb47346-b7f7-4e35-8606-69eec98e0287",
"soft_update": true,
"acknowledge_breaking_changes": false,
"is_materialized": true,
"origin": "data_warehouse",
"is_test": true,
"expires_at": "2019-08-24T14:15:22Z",
"user_access_level": "string",
"suspended": {
"property1": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
},
"property2": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
}
},
"engine": {
"target": "clickhouse",
"dialect": "hogql",
"connection_id": "string",
"capabilities": {
"materialize": {
"available": true,
"reason": "string"
},
"lineage": {
"available": true,
"reason": "string"
},
"referenceable_from_clickhouse": {
"available": true,
"reason": "string"
},
"column_source": "clickhouse_probe"
}
}
}

Retrieve warehouse saved queries

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:read

Path parameters

  • 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": {
"kind": "HogQLQuery",
"query": "string"
},
"incremental": {
"enabled": false,
"incremental_key": "string",
"unique_key": [
"string"
],
"lookback_seconds": 0
},
"incremental_state": {
"watermark": "string",
"definition_fingerprint": "string",
"last_full_refresh_at": "string",
"last_run_mode": "incremental"
},
"has_incremental_history": true,
"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": {},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"description": "string",
"sync_frequency": "never",
"sync_frequency_bounds": {
"frequency_mode": "tiered",
"options": [
{
"cadence": "15min",
"allowed": true,
"blocked_by": "source",
"blocker": {
"id": "string",
"name": "string"
},
"speeds_up": [
{
"id": "string",
"name": "string"
}
],
"speeds_up_withheld": true
}
],
"floor": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"plan_floor": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"ceiling": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"best_effort_sources": [
{
"id": "string",
"name": "string"
}
],
"best_effort_sources_withheld": true
},
"plan_clamp": {
"previous_target_seconds": 0,
"plan_floor_seconds": 0,
"at": "2019-08-24T14:15:22Z"
},
"columns": [
{}
],
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"folder_id": "7695bac3-9397-4ec2-9335-45a2a16f1901",
"folder_name": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "feb47346-b7f7-4e35-8606-69eec98e0287",
"soft_update": true,
"acknowledge_breaking_changes": false,
"is_materialized": true,
"origin": "data_warehouse",
"is_test": true,
"expires_at": "2019-08-24T14:15:22Z",
"user_access_level": "string",
"suspended": {
"property1": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
},
"property2": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
}
},
"engine": {
"target": "clickhouse",
"dialect": "hogql",
"connection_id": "string",
"capabilities": {
"materialize": {
"available": true,
"reason": "string"
},
"lineage": {
"available": true,
"reason": "string"
},
"referenceable_from_clickhouse": {
"available": true,
"reason": "string"
},
"column_source": "clickhouse_probe"
}
}
}

Update warehouse saved queries

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:write

Path parameters

  • id
    string

Request parameters

  • name
    string
  • query
    object
  • incremental
  • description
    string | null
  • sync_frequency
  • folder_id
    string | null
  • edited_history_id
    string | null
  • soft_update
    boolean | null
  • acknowledge_breaking_changes
    boolean
    Default: false
  • is_test
    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": {
"kind": "HogQLQuery",
"query": "string"
},
"incremental": {
"enabled": false,
"incremental_key": "string",
"unique_key": [
"string"
],
"lookback_seconds": 0
},
"incremental_state": {
"watermark": "string",
"definition_fingerprint": "string",
"last_full_refresh_at": "string",
"last_run_mode": "incremental"
},
"has_incremental_history": true,
"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": {},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"description": "string",
"sync_frequency": "never",
"sync_frequency_bounds": {
"frequency_mode": "tiered",
"options": [
{
"cadence": "15min",
"allowed": true,
"blocked_by": "source",
"blocker": {
"id": "string",
"name": "string"
},
"speeds_up": [
{
"id": "string",
"name": "string"
}
],
"speeds_up_withheld": true
}
],
"floor": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"plan_floor": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"ceiling": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"best_effort_sources": [
{
"id": "string",
"name": "string"
}
],
"best_effort_sources_withheld": true
},
"plan_clamp": {
"previous_target_seconds": 0,
"plan_floor_seconds": 0,
"at": "2019-08-24T14:15:22Z"
},
"columns": [
{}
],
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"folder_id": "7695bac3-9397-4ec2-9335-45a2a16f1901",
"folder_name": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "feb47346-b7f7-4e35-8606-69eec98e0287",
"soft_update": true,
"acknowledge_breaking_changes": false,
"is_materialized": true,
"origin": "data_warehouse",
"is_test": true,
"expires_at": "2019-08-24T14:15:22Z",
"user_access_level": "string",
"suspended": {
"property1": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
},
"property2": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
}
},
"engine": {
"target": "clickhouse",
"dialect": "hogql",
"connection_id": "string",
"capabilities": {
"materialize": {
"available": true,
"reason": "string"
},
"lineage": {
"available": true,
"reason": "string"
},
"referenceable_from_clickhouse": {
"available": true,
"reason": "string"
},
"column_source": "clickhouse_probe"
}
}
}

Delete warehouse saved queries

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:write

Path parameters

  • 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

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

activity_log:read

Path parameters

  • 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": {
"kind": "HogQLQuery",
"query": "string"
},
"incremental": {
"enabled": false,
"incremental_key": "string",
"unique_key": [
"string"
],
"lookback_seconds": 0
},
"incremental_state": {
"watermark": "string",
"definition_fingerprint": "string",
"last_full_refresh_at": "string",
"last_run_mode": "incremental"
},
"has_incremental_history": true,
"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": {},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"description": "string",
"sync_frequency": "never",
"sync_frequency_bounds": {
"frequency_mode": "tiered",
"options": [
{
"cadence": "15min",
"allowed": true,
"blocked_by": "source",
"blocker": {
"id": "string",
"name": "string"
},
"speeds_up": [
{
"id": "string",
"name": "string"
}
],
"speeds_up_withheld": true
}
],
"floor": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"plan_floor": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"ceiling": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"best_effort_sources": [
{
"id": "string",
"name": "string"
}
],
"best_effort_sources_withheld": true
},
"plan_clamp": {
"previous_target_seconds": 0,
"plan_floor_seconds": 0,
"at": "2019-08-24T14:15:22Z"
},
"columns": [
{}
],
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"folder_id": "7695bac3-9397-4ec2-9335-45a2a16f1901",
"folder_name": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "feb47346-b7f7-4e35-8606-69eec98e0287",
"soft_update": true,
"acknowledge_breaking_changes": false,
"is_materialized": true,
"origin": "data_warehouse",
"is_test": true,
"expires_at": "2019-08-24T14:15:22Z",
"user_access_level": "string",
"suspended": {
"property1": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
},
"property2": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
}
},
"engine": {
"target": "clickhouse",
"dialect": "hogql",
"connection_id": "string",
"capabilities": {
"materialize": {
"available": true,
"reason": "string"
},
"lineage": {
"available": true,
"reason": "string"
},
"referenceable_from_clickhouse": {
"available": true,
"reason": "string"
},
"column_source": "clickhouse_probe"
}
}
}

Create warehouse saved queries ancestors

Return the ancestors of this saved query.

By default, we return every ancestor. The level parameter bounds how many hops back to walk, so 1 gives the immediate parents.

Path parameters

  • id
    string

Request parameters

  • level
    integer | null

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 level="integer"

Example response

Status 200
RESPONSE
{
"ancestors": [
"string"
]
}

Create warehouse saved queries cancel

Cancel a running saved query workflow.

Path parameters

  • id
    string

Request parameters

  • name
    string
  • query
    object
  • incremental
  • description
    string | null
  • sync_frequency
  • folder_id
    string | null
  • edited_history_id
    string | null
  • soft_update
    boolean | null
  • acknowledge_breaking_changes
    boolean
    Default: false
  • is_test
    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",\
-d query="object"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": {
"kind": "HogQLQuery",
"query": "string"
},
"incremental": {
"enabled": false,
"incremental_key": "string",
"unique_key": [
"string"
],
"lookback_seconds": 0
},
"incremental_state": {
"watermark": "string",
"definition_fingerprint": "string",
"last_full_refresh_at": "string",
"last_run_mode": "incremental"
},
"has_incremental_history": true,
"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": {},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"description": "string",
"sync_frequency": "never",
"sync_frequency_bounds": {
"frequency_mode": "tiered",
"options": [
{
"cadence": "15min",
"allowed": true,
"blocked_by": "source",
"blocker": {
"id": "string",
"name": "string"
},
"speeds_up": [
{
"id": "string",
"name": "string"
}
],
"speeds_up_withheld": true
}
],
"floor": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"plan_floor": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"ceiling": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"best_effort_sources": [
{
"id": "string",
"name": "string"
}
],
"best_effort_sources_withheld": true
},
"plan_clamp": {
"previous_target_seconds": 0,
"plan_floor_seconds": 0,
"at": "2019-08-24T14:15:22Z"
},
"columns": [
{}
],
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"folder_id": "7695bac3-9397-4ec2-9335-45a2a16f1901",
"folder_name": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "feb47346-b7f7-4e35-8606-69eec98e0287",
"soft_update": true,
"acknowledge_breaking_changes": false,
"is_materialized": true,
"origin": "data_warehouse",
"is_test": true,
"expires_at": "2019-08-24T14:15:22Z",
"user_access_level": "string",
"suspended": {
"property1": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
},
"property2": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
}
},
"engine": {
"target": "clickhouse",
"dialect": "hogql",
"connection_id": "string",
"capabilities": {
"materialize": {
"available": true,
"reason": "string"
},
"lineage": {
"available": true,
"reason": "string"
},
"referenceable_from_clickhouse": {
"available": true,
"reason": "string"
},
"column_source": "clickhouse_probe"
}
}
}

Retrieve warehouse saved queries dependencies

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

Path parameters

  • 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
{
"upstream_count": 0,
"downstream_count": 0
}

Create warehouse saved queries descendants

Return the descendants of this saved query.

By default, we return every descendant. The level parameter bounds how many hops forward to walk, so 1 gives the immediate children.

Path parameters

  • id
    string

Request parameters

  • level
    integer | null

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 level="integer"

Example response

Status 200
RESPONSE
{
"descendants": [
"string"
]
}

Create warehouse saved queries materialize

Enable materialization for this saved query, at the requested sync frequency or daily.

Required API key scopes

warehouse_view:write

Path parameters

  • id
    string

Request parameters

  • sync_frequency
    Default: 24hour

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 sync_frequency=undefined

Example response

Status 200 No response body

Create warehouse saved queries resume

Resume materialization suspended after repeated failures.

Scheduled runs skip a suspended model and everything downstream of it, so it cannot succeed its way back on its own.

Required API key scopes

warehouse_view:write

Path parameters

  • id
    string

Request parameters

  • engine

Response


Example request

POST /api/projects/:project_id/warehouse_saved_queries/:id/resume
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/resume/\
-d engine=undefined

Example response

Status 200
RESPONSE
{
"resumed": true
}

Create warehouse saved queries revert materialization

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

Required API key scopes

warehouse_view:write

Path parameters

  • id
    string

Request parameters

  • name
    string
  • query
    object
  • incremental
  • description
    string | null
  • sync_frequency
  • folder_id
    string | null
  • edited_history_id
    string | null
  • soft_update
    boolean | null
  • acknowledge_breaking_changes
    boolean
    Default: false
  • is_test
    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",\
-d query="object"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": {
"kind": "HogQLQuery",
"query": "string"
},
"incremental": {
"enabled": false,
"incremental_key": "string",
"unique_key": [
"string"
],
"lookback_seconds": 0
},
"incremental_state": {
"watermark": "string",
"definition_fingerprint": "string",
"last_full_refresh_at": "string",
"last_run_mode": "incremental"
},
"has_incremental_history": true,
"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": {},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"description": "string",
"sync_frequency": "never",
"sync_frequency_bounds": {
"frequency_mode": "tiered",
"options": [
{
"cadence": "15min",
"allowed": true,
"blocked_by": "source",
"blocker": {
"id": "string",
"name": "string"
},
"speeds_up": [
{
"id": "string",
"name": "string"
}
],
"speeds_up_withheld": true
}
],
"floor": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"plan_floor": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"ceiling": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"best_effort_sources": [
{
"id": "string",
"name": "string"
}
],
"best_effort_sources_withheld": true
},
"plan_clamp": {
"previous_target_seconds": 0,
"plan_floor_seconds": 0,
"at": "2019-08-24T14:15:22Z"
},
"columns": [
{}
],
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"folder_id": "7695bac3-9397-4ec2-9335-45a2a16f1901",
"folder_name": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "feb47346-b7f7-4e35-8606-69eec98e0287",
"soft_update": true,
"acknowledge_breaking_changes": false,
"is_materialized": true,
"origin": "data_warehouse",
"is_test": true,
"expires_at": "2019-08-24T14:15:22Z",
"user_access_level": "string",
"suspended": {
"property1": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
},
"property2": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
}
},
"engine": {
"target": "clickhouse",
"dialect": "hogql",
"connection_id": "string",
"capabilities": {
"materialize": {
"available": true,
"reason": "string"
},
"lineage": {
"available": true,
"reason": "string"
},
"referenceable_from_clickhouse": {
"available": true,
"reason": "string"
},
"column_source": "clickhouse_probe"
}
}
}

Create warehouse saved queries run

Run this saved query.

Required API key scopes

warehouse_view:write

Path parameters

  • id
    string

Request parameters

  • full_refresh
    boolean
    Default: false
  • direction
  • engine
    Default: clickhouse

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 full_refresh="boolean"

Example response

Status 200
RESPONSE
{
"node_ids": [
"497f6eca-6276-4993-bfeb-53cbbbba6f08"
],
"skipped": [
{
"node_id": "6e0bdcac-9717-4a6f-972e-97489dffeb0c",
"name": "string",
"reason": "string"
}
]
}
Status 400 The body is invalid, the view can't be materialized, or this view's query doesn't compile.
Status 403 You can't edit every view in the run, a view in the run reads a table you don't have access to, or engine is 'trino' and the organization has no managed warehouse.
Status 409 engine is 'trino' and a managed warehouse run is already in progress, or the run started from the PostHog app and a view it would build is still running.
Status 429 Every view this run would build ran too recently and has not changed since. Runs with engine 'trino' and runs started from the PostHog app have no such limit; the app refuses a run only while a view is still running. The Retry-After header gives the wait in seconds.

Retrieve warehouse saved queries run history

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

Required API key scopes

warehouse_view:read

Path parameters

  • 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": {
"kind": "HogQLQuery",
"query": "string"
},
"incremental": {
"enabled": false,
"incremental_key": "string",
"unique_key": [
"string"
],
"lookback_seconds": 0
},
"incremental_state": {
"watermark": "string",
"definition_fingerprint": "string",
"last_full_refresh_at": "string",
"last_run_mode": "incremental"
},
"has_incremental_history": true,
"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": {},
"role_at_organization": "engineering"
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"description": "string",
"sync_frequency": "never",
"sync_frequency_bounds": {
"frequency_mode": "tiered",
"options": [
{
"cadence": "15min",
"allowed": true,
"blocked_by": "source",
"blocker": {
"id": "string",
"name": "string"
},
"speeds_up": [
{
"id": "string",
"name": "string"
}
],
"speeds_up_withheld": true
}
],
"floor": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"plan_floor": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"ceiling": {
"label": "string",
"blocker": {
"id": "string",
"name": "string"
},
"pinned": true
},
"best_effort_sources": [
{
"id": "string",
"name": "string"
}
],
"best_effort_sources_withheld": true
},
"plan_clamp": {
"previous_target_seconds": 0,
"plan_floor_seconds": 0,
"at": "2019-08-24T14:15:22Z"
},
"columns": [
{}
],
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"folder_id": "7695bac3-9397-4ec2-9335-45a2a16f1901",
"folder_name": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": "feb47346-b7f7-4e35-8606-69eec98e0287",
"soft_update": true,
"acknowledge_breaking_changes": false,
"is_materialized": true,
"origin": "data_warehouse",
"is_test": true,
"expires_at": "2019-08-24T14:15:22Z",
"user_access_level": "string",
"suspended": {
"property1": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
},
"property2": {
"at": "2019-08-24T14:15:22Z",
"reason": "string",
"job_id": "string"
}
},
"engine": {
"target": "clickhouse",
"dialect": "hogql",
"connection_id": "string",
"capabilities": {
"materialize": {
"available": true,
"reason": "string"
},
"lineage": {
"available": true,
"reason": "string"
},
"referenceable_from_clickhouse": {
"available": true,
"reason": "string"
},
"column_source": "clickhouse_probe"
}
}
}

Create warehouse saved queries check incremental

Report whether a query can be materialized incrementally, without running it.

Parses the SQL only, so it is cheap enough to call from the editor as the user types. Lets the editor explain why the incremental option is unavailable before anything is saved.

Required API key scopes

warehouse_view:read

Request parameters

  • query
    string
  • incremental_key
    string | null
  • unique_key
    array | null
  • lookback_seconds
    integer

Response


Example request

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

Example response

Status 200
RESPONSE
{
"eligible": true,
"key_candidates": [
"string"
],
"unique_key_candidates": [
"string"
],
"key_candidate_types": {
"property1": "string",
"property2": "string"
},
"blockers": [
"string"
],
"warnings": [
"string"
]
}

Create warehouse saved queries resume schedules

Resume materialization for several models that were suspended after repeated failures.

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

Required API key scopes

warehouse_view:write

Request parameters

  • view_ids
    array

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 view_ids="array"

Example response

Status 202 No response body