Environments-2

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

Retry a batch export run.

We use the same underlying mechanism as when backfilling a batch export, as retrying a run is the same as backfilling one run.

Create environments batch exports runs retry

Required API key scopes

batch_export:write

Path parameters

  • batch_export_id
    string

    The BatchExport this run belongs to.

  • id
    string

    A UUID string identifying this batch export run.

  • 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

  • status

    The status of this run.

    • Cancelled - Cancelled
    • Completed - Completed
    • ContinuedAsNew - Continued As New
    • Failed - Failed
    • FailedRetryable - Failed Retryable
    • Terminated - Terminated
    • TimedOut - Timedout
    • Running - Running
    • Starting - Starting
  • records_completed
    integer

    The number of records that have been exported.

  • latest_error
    string

    The latest error that occurred during this run.

  • data_interval_start
    string

    The start of the data interval.

  • data_interval_end
    string

    The end of the data interval.

  • cursor
    string

    An opaque cursor that may be used to resume.

  • finished_at
    string

    The timestamp at which this BatchExportRun finished, successfully or not.

  • records_total_count
    integer

    The total count of records that should be exported in this BatchExportRun.

Request

POST /api/environments/:project_id/batch_exports/:batch_export_id/runs/:id/retry
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/environments/:project_id/batch_exports/:batch_export_id/runs/:id/retry/\
-d status=undefined,\
-d data_interval_end="string"

Response

Status 200 No response body

Create environments batch exports runs retry

Required API key scopes

batch_export:write

Path parameters

  • batch_export_id
    string

    The BatchExport this run belongs to.

  • id
    string

    A UUID string identifying this batch export run.

  • 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

  • status

    The status of this run.

    • Cancelled - Cancelled
    • Completed - Completed
    • ContinuedAsNew - Continued As New
    • Failed - Failed
    • FailedRetryable - Failed Retryable
    • Terminated - Terminated
    • TimedOut - Timedout
    • Running - Running
    • Starting - Starting
  • records_completed
    integer

    The number of records that have been exported.

  • latest_error
    string

    The latest error that occurred during this run.

  • data_interval_start
    string

    The start of the data interval.

  • data_interval_end
    string

    The end of the data interval.

  • cursor
    string

    An opaque cursor that may be used to resume.

  • finished_at
    string

    The timestamp at which this BatchExportRun finished, successfully or not.

  • records_total_count
    integer

    The total count of records that should be exported in this BatchExportRun.

Request

POST /api/environments/:project_id/batch_exports/:batch_export_id/runs/:id/retry
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/environments/:project_id/batch_exports/:batch_export_id/runs/:id/retry/\
-d status=undefined,\
-d data_interval_end="string"

Response

Status 200 No response body

Retrieve environments batch exports

Required API key scopes

batch_export:read

Path parameters

  • id
    string

    A UUID string identifying this batch export.

  • 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/.

Response


Request

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

Response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"team_id": 0,
"name": "string",
"model": "events",
"destination": {
"type": "S3",
"config": null
},
"interval": "hour",
"paused": true,
"created_at": "2019-08-24T14:15:22Z",
"last_updated_at": "2019-08-24T14:15:22Z",
"last_paused_at": "2019-08-24T14:15:22Z",
"start_at": "2019-08-24T14:15:22Z",
"end_at": "2019-08-24T14:15:22Z",
"latest_runs": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "Cancelled",
"records_completed": -2147483648,
"latest_error": "string",
"data_interval_start": "2019-08-24T14:15:22Z",
"data_interval_end": "2019-08-24T14:15:22Z",
"cursor": "string",
"created_at": "2019-08-24T14:15:22Z",
"finished_at": "2019-08-24T14:15:22Z",
"last_updated_at": "2019-08-24T14:15:22Z",
"records_total_count": -2147483648,
"batch_export": "0fa0a8a1-f280-4977-8bb4-bc7801a6902f"
}
],
"hogql_query": "string",
"schema": null
}

Retrieve environments batch exports

Required API key scopes

batch_export:read

Path parameters

  • id
    string

    A UUID string identifying this batch export.

  • 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/.

Response


Request

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

Response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"team_id": 0,
"name": "string",
"model": "events",
"destination": {
"type": "S3",
"config": null
},
"interval": "hour",
"paused": true,
"created_at": "2019-08-24T14:15:22Z",
"last_updated_at": "2019-08-24T14:15:22Z",
"last_paused_at": "2019-08-24T14:15:22Z",
"start_at": "2019-08-24T14:15:22Z",
"end_at": "2019-08-24T14:15:22Z",
"latest_runs": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "Cancelled",
"records_completed": -2147483648,
"latest_error": "string",
"data_interval_start": "2019-08-24T14:15:22Z",
"data_interval_end": "2019-08-24T14:15:22Z",
"cursor": "string",
"created_at": "2019-08-24T14:15:22Z",
"finished_at": "2019-08-24T14:15:22Z",
"last_updated_at": "2019-08-24T14:15:22Z",
"records_total_count": -2147483648,
"batch_export": "0fa0a8a1-f280-4977-8bb4-bc7801a6902f"
}
],
"hogql_query": "string",
"schema": null
}

Update environments batch exports

Required API key scopes

batch_export:write

Path parameters

  • id
    string

    A UUID string identifying this batch export.

  • 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

  • name
    string

    A human-readable name for this BatchExport.

  • model

    Which model this BatchExport is exporting.

    • events - Events
    • persons - Persons
  • destination
  • interval
  • paused
    boolean

    Whether this BatchExport is paused or not.

  • last_paused_at
    string

    The timestamp at which this BatchExport was last paused.

  • start_at
    string

    Time before which any Batch Export runs won't be triggered.

  • end_at
    string

    Time after which any Batch Export runs won't be triggered.

  • hogql_query
    string

Response


Request

PATCH /api/environments/:project_id/batch_exports/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:project_id/batch_exports/:id/\
-d team_id="integer"

Response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"team_id": 0,
"name": "string",
"model": "events",
"destination": {
"type": "S3",
"config": null
},
"interval": "hour",
"paused": true,
"created_at": "2019-08-24T14:15:22Z",
"last_updated_at": "2019-08-24T14:15:22Z",
"last_paused_at": "2019-08-24T14:15:22Z",
"start_at": "2019-08-24T14:15:22Z",
"end_at": "2019-08-24T14:15:22Z",
"latest_runs": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "Cancelled",
"records_completed": -2147483648,
"latest_error": "string",
"data_interval_start": "2019-08-24T14:15:22Z",
"data_interval_end": "2019-08-24T14:15:22Z",
"cursor": "string",
"created_at": "2019-08-24T14:15:22Z",
"finished_at": "2019-08-24T14:15:22Z",
"last_updated_at": "2019-08-24T14:15:22Z",
"records_total_count": -2147483648,
"batch_export": "0fa0a8a1-f280-4977-8bb4-bc7801a6902f"
}
],
"hogql_query": "string",
"schema": null
}

Update environments batch exports

Required API key scopes

batch_export:write

Path parameters

  • id
    string

    A UUID string identifying this batch export.

  • 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

  • name
    string

    A human-readable name for this BatchExport.

  • model

    Which model this BatchExport is exporting.

    • events - Events
    • persons - Persons
  • destination
  • interval
  • paused
    boolean

    Whether this BatchExport is paused or not.

  • last_paused_at
    string

    The timestamp at which this BatchExport was last paused.

  • start_at
    string

    Time before which any Batch Export runs won't be triggered.

  • end_at
    string

    Time after which any Batch Export runs won't be triggered.

  • hogql_query
    string

Response


Request

PATCH /api/environments/:project_id/batch_exports/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:project_id/batch_exports/:id/\
-d team_id="integer"

Response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"team_id": 0,
"name": "string",
"model": "events",
"destination": {
"type": "S3",
"config": null
},
"interval": "hour",
"paused": true,
"created_at": "2019-08-24T14:15:22Z",
"last_updated_at": "2019-08-24T14:15:22Z",
"last_paused_at": "2019-08-24T14:15:22Z",
"start_at": "2019-08-24T14:15:22Z",
"end_at": "2019-08-24T14:15:22Z",
"latest_runs": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "Cancelled",
"records_completed": -2147483648,
"latest_error": "string",
"data_interval_start": "2019-08-24T14:15:22Z",
"data_interval_end": "2019-08-24T14:15:22Z",
"cursor": "string",
"created_at": "2019-08-24T14:15:22Z",
"finished_at": "2019-08-24T14:15:22Z",
"last_updated_at": "2019-08-24T14:15:22Z",
"records_total_count": -2147483648,
"batch_export": "0fa0a8a1-f280-4977-8bb4-bc7801a6902f"
}
],
"hogql_query": "string",
"schema": null
}

Delete environments batch exports

Required API key scopes

batch_export:write

Path parameters

  • id
    string

    A UUID string identifying this batch export.

  • 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

DELETE /api/environments/:project_id/batch_exports/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X DELETE \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:project_id/batch_exports/:id/

Response

Status 204 No response body

Delete environments batch exports

Required API key scopes

batch_export:write

Path parameters

  • id
    string

    A UUID string identifying this batch export.

  • 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

DELETE /api/environments/:project_id/batch_exports/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X DELETE \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:project_id/batch_exports/:id/

Response

Status 204 No response body

Create environments batch exports backfill

Trigger a backfill for a BatchExport.

Required API key scopes

batch_export:write

Path parameters

  • id
    string

    A UUID string identifying this batch export.

  • 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

  • name
    string

    A human-readable name for this BatchExport.

  • model

    Which model this BatchExport is exporting.

    • events - Events
    • persons - Persons
  • destination
  • interval
  • paused
    boolean

    Whether this BatchExport is paused or not.

  • last_paused_at
    string

    The timestamp at which this BatchExport was last paused.

  • start_at
    string

    Time before which any Batch Export runs won't be triggered.

  • end_at
    string

    Time after which any Batch Export runs won't be triggered.

  • hogql_query
    string

Request

POST /api/environments/:project_id/batch_exports/:id/backfill
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/environments/:project_id/batch_exports/:id/backfill/\
-d name="string",\
-d destination=undefined,\
-d interval=undefined

Response

Status 200 No response body

Create environments batch exports backfill

Trigger a backfill for a BatchExport.

Required API key scopes

batch_export:write

Path parameters

  • id
    string

    A UUID string identifying this batch export.

  • 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

  • name
    string

    A human-readable name for this BatchExport.

  • model

    Which model this BatchExport is exporting.

    • events - Events
    • persons - Persons
  • destination
  • interval
  • paused
    boolean

    Whether this BatchExport is paused or not.

  • last_paused_at
    string

    The timestamp at which this BatchExport was last paused.

  • start_at
    string

    Time before which any Batch Export runs won't be triggered.

  • end_at
    string

    Time after which any Batch Export runs won't be triggered.

  • hogql_query
    string

Request

POST /api/environments/:project_id/batch_exports/:id/backfill
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/environments/:project_id/batch_exports/:id/backfill/\
-d name="string",\
-d destination=undefined,\
-d interval=undefined

Response

Status 200 No response body

Retrieve environments batch exports logs

Path parameters

  • id
    string

    A UUID string identifying this batch export.

  • 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

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

Response

Status 200 No response body

Retrieve environments batch exports logs

Path parameters

  • id
    string

    A UUID string identifying this batch export.

  • 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

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

Response

Status 200 No response body

Create environments batch exports pause

Pause a BatchExport.

Required API key scopes

batch_export:write

Path parameters

  • id
    string

    A UUID string identifying this batch export.

  • 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

  • name
    string

    A human-readable name for this BatchExport.

  • model

    Which model this BatchExport is exporting.

    • events - Events
    • persons - Persons
  • destination
  • interval
  • paused
    boolean

    Whether this BatchExport is paused or not.

  • last_paused_at
    string

    The timestamp at which this BatchExport was last paused.

  • start_at
    string

    Time before which any Batch Export runs won't be triggered.

  • end_at
    string

    Time after which any Batch Export runs won't be triggered.

  • hogql_query
    string

Request

POST /api/environments/:project_id/batch_exports/:id/pause
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/environments/:project_id/batch_exports/:id/pause/\
-d name="string",\
-d destination=undefined,\
-d interval=undefined

Response

Status 200 No response body

Create environments batch exports pause

Pause a BatchExport.

Required API key scopes

batch_export:write

Path parameters

  • id
    string

    A UUID string identifying this batch export.

  • 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

  • name
    string

    A human-readable name for this BatchExport.

  • model

    Which model this BatchExport is exporting.

    • events - Events
    • persons - Persons
  • destination
  • interval
  • paused
    boolean

    Whether this BatchExport is paused or not.

  • last_paused_at
    string

    The timestamp at which this BatchExport was last paused.

  • start_at
    string

    Time before which any Batch Export runs won't be triggered.

  • end_at
    string

    Time after which any Batch Export runs won't be triggered.

  • hogql_query
    string

Request

POST /api/environments/:project_id/batch_exports/:id/pause
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/environments/:project_id/batch_exports/:id/pause/\
-d name="string",\
-d destination=undefined,\
-d interval=undefined

Response

Status 200 No response body

Create environments batch exports unpause

Unpause a BatchExport.

Required API key scopes

batch_export:write

Path parameters

  • id
    string

    A UUID string identifying this batch export.

  • 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

  • name
    string

    A human-readable name for this BatchExport.

  • model

    Which model this BatchExport is exporting.

    • events - Events
    • persons - Persons
  • destination
  • interval
  • paused
    boolean

    Whether this BatchExport is paused or not.

  • last_paused_at
    string

    The timestamp at which this BatchExport was last paused.

  • start_at
    string

    Time before which any Batch Export runs won't be triggered.

  • end_at
    string

    Time after which any Batch Export runs won't be triggered.

  • hogql_query
    string

Request

POST /api/environments/:project_id/batch_exports/:id/unpause
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/environments/:project_id/batch_exports/:id/unpause/\
-d name="string",\
-d destination=undefined,\
-d interval=undefined

Response

Status 200 No response body

Create environments batch exports unpause

Unpause a BatchExport.

Required API key scopes

batch_export:write

Path parameters

  • id
    string

    A UUID string identifying this batch export.

  • 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

  • name
    string

    A human-readable name for this BatchExport.

  • model

    Which model this BatchExport is exporting.

    • events - Events
    • persons - Persons
  • destination
  • interval
  • paused
    boolean

    Whether this BatchExport is paused or not.

  • last_paused_at
    string

    The timestamp at which this BatchExport was last paused.

  • start_at
    string

    Time before which any Batch Export runs won't be triggered.

  • end_at
    string

    Time after which any Batch Export runs won't be triggered.

  • hogql_query
    string

Request

POST /api/environments/:project_id/batch_exports/:id/unpause
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/environments/:project_id/batch_exports/:id/unpause/\
-d name="string",\
-d destination=undefined,\
-d interval=undefined

Response

Status 200 No response body

List all environments dashboards

Adds an "access_controls" action to the viewset that handles access control for the given resource

Why a mixin? We want to easily add this to any existing resource, including providing easy helpers for adding access control info such as the current users access level to any response.

Required API key scopes

dashboard:read

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/.

Query parameters

  • limit
    integer

    Number of results to return per page.

  • offset
    integer

    The initial index from which to return the results.

Response


Request

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

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": 0,
"name": "string",
"description": "string",
"pinned": true,
"created_at": "2019-08-24T14:15:22Z",
"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
}
},
"is_shared": true,
"deleted": true,
"creation_mode": "default",
"tags": [
null
],
"restriction_level": 21,
"effective_restriction_level": 21,
"effective_privilege_level": 21,
"user_access_level": "string"
}
]
}

List all environments dashboards

Adds an "access_controls" action to the viewset that handles access control for the given resource

Why a mixin? We want to easily add this to any existing resource, including providing easy helpers for adding access control info such as the current users access level to any response.

Required API key scopes

dashboard:read

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/.

Query parameters

  • limit
    integer

    Number of results to return per page.

  • offset
    integer

    The initial index from which to return the results.

Response


Request

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

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": 0,
"name": "string",
"description": "string",
"pinned": true,
"created_at": "2019-08-24T14:15:22Z",
"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
}
},
"is_shared": true,
"deleted": true,
"creation_mode": "default",
"tags": [
null
],
"restriction_level": 21,
"effective_restriction_level": 21,
"effective_privilege_level": 21,
"user_access_level": "string"
}
]
}
Next page →

Questions?

Was this page useful?