Notebooks

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

Endpoints

POST
POST
GET
POST
POST
GET
POST
GET
POST
GET
POST
POST
GET
GET
GET
GET
GET
GET

Create notebooks kernel restart

The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.

Path parameters

  • short_id
    string

Request parameters

  • title
    stringnull
  • content
  • text_content
    stringnull
  • version
    integer
  • deleted
    boolean
  • variables
    Click to open
    array
  • _create_in_folder
    string

Example request

POST /api/projects/:project_id/notebooks/:short_id/kernel/restart
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/notebooks/:short_id/kernel/restart/\
-d title=["string","null"]

Example response

Status 200 No response body

Create notebooks kernel start

The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.

Path parameters

  • short_id
    string

Request parameters

  • title
    stringnull
  • content
  • text_content
    stringnull
  • version
    integer
  • deleted
    boolean
  • variables
    Click to open
    array
  • _create_in_folder
    string

Example request

POST /api/projects/:project_id/notebooks/:short_id/kernel/start
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/notebooks/:short_id/kernel/start/\
-d title=["string","null"]

Example response

Status 200 No response body

Retrieve notebooks kernel status

Live-checked kernel runtime state for this notebook, its compute configuration, and the catalog of dataframes/tables a cell can currently reference (with column schemas).

Required API key scopes

notebook:read

Path parameters

  • short_id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"backend": "string",
"status": "string",
"last_used_at": "2019-08-24T14:15:22Z",
"last_error": "string",
"runtime_id": "cb6c5dda-251e-4b64-ab75-e6c8247ffa87",
"kernel_id": "string",
"kernel_pid": 0,
"sandbox_id": "string",
"frames": [
{
"name": "string",
"kind": "string",
"columns": [
[
"string"
]
],
"row_count": 0,
"row_count_is_estimate": false
}
],
"cpu_cores": 0.1,
"memory_gb": 0.1,
"disk_size_gb": 0,
"idle_timeout_seconds": 0,
"hourly_price": 0.1,
"preset_key": "string"
}

Create notebooks kernel stop

The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.

Path parameters

  • short_id
    string

Request parameters

  • title
    stringnull
  • content
  • text_content
    stringnull
  • version
    integer
  • deleted
    boolean
  • variables
    Click to open
    array
  • _create_in_folder
    string

Example request

POST /api/projects/:project_id/notebooks/:short_id/kernel/stop
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/notebooks/:short_id/kernel/stop/\
-d title=["string","null"]

Example response

Status 200 No response body

Create notebooks sql v2 run

Dispatch an asynchronous run of a notebook SQL or Python cell. Returns a run_id immediately; poll the run result endpoint until the status is terminal. One run at a time per notebook. Flag-gated (revamped-py-notebooks).

Required API key scopes

notebook:writequery:read

Path parameters

  • short_id
    string

Request parameters

  • node_id
    string
  • node_type
    Default: hogql
  • code
    string
  • output_name
    string
    Default:
  • refs
    object
  • variables
    Click to open
    array
  • connection_id
    stringnull
  • send_raw_query
    boolean
    Default: false

Response


Example request

POST /api/projects/:project_id/notebooks/:short_id/sql_v2/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/notebooks/:short_id/sql_v2/run/\
-d node_id="string",\
-d code="string"

Example response

Status 200
RESPONSE
{
"run_id": "dded282c-8ebd-44cf-8ba5-9a234973d1ec",
"starts_sandbox": true,
"sandbox_hourly_price": 0
}
Status 409 The notebook already has a cell running. Wait for it to finish, then run this one. A conflict with the notebook's state rather than a rate, so it is not worth retrying on a timer.
Status 429 The project has as many notebook cells in flight as it may. Unlike the 409, retrying shortly is the right response.

Retrieve notebooks sql v2 runs

Read a run's durable state: its status, and — once done or interrupted — the result envelope (columns, first rows, stdout/stderr, media, error). Poll until terminal. Flag-gated (revamped-py-notebooks).

Required API key scopes

notebook:readquery:read

Path parameters

  • run_id
    string
  • short_id
    string

Response


Example request

GET /api/projects/:project_id/notebooks/:short_id/sql_v2/runs/:run_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/notebooks/:short_id/sql_v2/runs/:run_id/

Example response

Status 200
RESPONSE
{
"status": "string",
"result": {
"status": "string",
"frames": [
{
"name": "string",
"kind": "string",
"columns": [
[
"string"
]
],
"row_count": 0,
"row_count_is_estimate": false
}
],
"stdout": "",
"stderr": "",
"media": [
{
"mime_type": "string",
"data": "string"
}
],
"columns": [
"string"
],
"types": [
[
"string"
]
],
"row_count": 0,
"has_more": false,
"first_page": [
[
null
]
],
"result_id": "cd1ea384-5045-47f3-9678-d1fc6f8c8581",
"error": "string",
"timings": {
"property1": 0.1,
"property2": 0.1
}
},
"error": "string",
"rows": [
[
null
]
]
}

Create notebooks sql v2 runs interrupt

Stop a running cell. Idempotent: interrupting an already-finished run returns its outcome unchanged. Flag-gated (revamped-py-notebooks).

Required API key scopes

notebook:write

Path parameters

  • run_id
    string
  • short_id
    string

Response


Example request

POST /api/projects/:project_id/notebooks/:short_id/sql_v2/runs/:run_id/interrupt
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/notebooks/:short_id/sql_v2/runs/:run_id/interrupt/

Example response

Status 200
RESPONSE
{
"status": "string",
"detail": "string"
}
Status 202
RESPONSE
{
"status": "string",
"detail": "string"
}

Retrieve notebooks sql v2 state

The full notebook view for agents: title, document source (markdown, or raw content for legacy rich-text notebooks), every cell with its dependency edges and derived run status (including staleness), and the kernel's runtime state and compute config. Flag-gated (revamped-py-notebooks).

Required API key scopes

notebook:readquery:read

Path parameters

  • short_id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"notebook_id": "string",
"title": "string",
"version": 0,
"markdown": "string",
"content": null,
"kernel": {
"status": "string",
"cpu_cores": 0,
"memory_gb": 0,
"idle_timeout_seconds": 0
},
"cells": [
{
"node_id": "string",
"cell_type": "string",
"dataframe_name": "string",
"code": "string",
"status": "string",
"depends_on": [
"string"
],
"dependents": [
"string"
],
"last_run": {
"run_id": "dded282c-8ebd-44cf-8ba5-9a234973d1ec",
"status": "string",
"finished_at": "2019-08-24T14:15:22Z",
"row_count": 0,
"columns": [
"string"
],
"error": "string"
}
}
]
}

Create notebooks widget

The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.

Required API key scopes

notebook:write

Path parameters

  • node_id
    string
  • short_id
    string

Request parameters

  • generation_id
    string

Example request

POST /api/projects/:project_id/notebooks/:short_id/widgets/:node_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/notebooks/:short_id/widgets/:node_id/cancel/\
-d generation_id="string"

Example response

Status 204 No response body
Status 400
RESPONSE
{
"code": "string",
"detail": "string"
}
Status 404
RESPONSE
{
"code": "string",
"detail": "string"
}

Retrieve notebooks widget

The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.

Required API key scopes

notebook:readquery:read

Path parameters

  • frame_name
    string
  • node_id
    string
  • short_id
    string

Query parameters

  • limit
    integer
  • offset
    integer
  • run_id
    string
  • version_id
    string

Response


Example request

GET /api/projects/:project_id/notebooks/:short_id/widgets/:node_id/frames/:frame_name
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/notebooks/:short_id/widgets/:node_id/frames/:frame_name/

Example response

Status 200
RESPONSE
{
"name": "string",
"runId": "78c33d18-170c-44d3-a227-b3194f134f73",
"columns": [
{
"name": "string",
"type": "string"
}
],
"rows": [
[
null
]
],
"totalRowCount": 0,
"includedRowCount": 0,
"offset": 0,
"nextOffset": 0,
"truncated": true
}
Status 403
RESPONSE
{
"code": "string",
"detail": "string"
}
Status 404
RESPONSE
{
"code": "string",
"detail": "string"
}
Status 409
RESPONSE
{
"code": "string",
"detail": "string"
}
Status 429
RESPONSE
{
"code": "string",
"detail": "string"
}

Create notebooks widget

The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.

Required API key scopes

notebook:writequery:read

Path parameters

  • node_id
    string
  • short_id
    string

Request parameters

  • prompt
    string
  • generation_id
    string
  • model
    Default: claude-sonnet-4-6
  • generation_operation
    Default: regenerate
  • expected_current_version_id
    string

Response


Example request

POST /api/projects/:project_id/notebooks/:short_id/widgets/:node_id/generate
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/notebooks/:short_id/widgets/:node_id/generate/\
-d prompt="string",\
-d generation_id="string"

Example response

Status 202
RESPONSE
{
"lifecycle_status": "awaiting_generation",
"error_detail": "string",
"error_code": "string",
"failure_phase": "generating_source",
"artifact_url": "http://example.com",
"frame_names": [
"string"
],
"current_version_id": "158beffb-f9de-457f-bbee-873740e72504",
"widget_id": "917f3fdb-2905-481f-8ff6-04c0fb7d466c",
"instance_id": "06587974-2dbe-4e10-8bf9-38cce0f5a366",
"has_versions": true,
"active_job": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "queued",
"phase": "string",
"model": "string",
"created_at": "2019-08-24T14:15:22Z",
"started_at": "2019-08-24T14:15:22Z"
},
"security_review": {
"severity": "none",
"summary": "string",
"findings": [
{
"severity": "low",
"title": "string",
"details": "string"
}
],
"model": "string",
"review_version": "string",
"reviewed_at": "2019-08-24T14:15:22Z"
},
"build_hash": "string"
}
Status 400
RESPONSE
{
"code": "string",
"detail": "string"
}
Status 403
RESPONSE
{
"code": "string",
"detail": "string"
}
Status 404
RESPONSE
{
"code": "string",
"detail": "string"
}
Status 409
RESPONSE
{
"code": "string",
"detail": "string"
}
Status 429
RESPONSE
{
"code": "string",
"detail": "string"
}

Create notebooks widget

The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.

Required API key scopes

notebook:write

Path parameters

  • node_id
    string
  • short_id
    string

Request parameters

  • version_id
    string
  • expected_current_version_id
    string

Response


Example request

POST /api/projects/:project_id/notebooks/:short_id/widgets/:node_id/revert
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/notebooks/:short_id/widgets/:node_id/revert/\
-d version_id="string",\
-d expected_current_version_id="string"

Example response

Status 200
RESPONSE
{
"lifecycle_status": "awaiting_generation",
"error_detail": "string",
"error_code": "string",
"failure_phase": "generating_source",
"artifact_url": "http://example.com",
"frame_names": [
"string"
],
"current_version_id": "158beffb-f9de-457f-bbee-873740e72504",
"widget_id": "917f3fdb-2905-481f-8ff6-04c0fb7d466c",
"instance_id": "06587974-2dbe-4e10-8bf9-38cce0f5a366",
"has_versions": true,
"active_job": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "queued",
"phase": "string",
"model": "string",
"created_at": "2019-08-24T14:15:22Z",
"started_at": "2019-08-24T14:15:22Z"
},
"security_review": {
"severity": "none",
"summary": "string",
"findings": [
{
"severity": "low",
"title": "string",
"details": "string"
}
],
"model": "string",
"review_version": "string",
"reviewed_at": "2019-08-24T14:15:22Z"
},
"build_hash": "string"
}
Status 400
RESPONSE
{
"code": "string",
"detail": "string"
}
Status 404
RESPONSE
{
"code": "string",
"detail": "string"
}
Status 409
RESPONSE
{
"code": "string",
"detail": "string"
}
Status 429
RESPONSE
{
"code": "string",
"detail": "string"
}

Retrieve notebooks widget

The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.

Required API key scopes

notebook:read

Path parameters

  • node_id
    string
  • short_id
    string

Query parameters

  • version_id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"source": "string"
}
Status 400
RESPONSE
{
"code": "string",
"detail": "string"
}
Status 404
RESPONSE
{
"code": "string",
"detail": "string"
}

Retrieve notebooks widget

The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.

Required API key scopes

notebook:read

Path parameters

  • node_id
    string
  • short_id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"lifecycle_status": "awaiting_generation",
"error_detail": "string",
"error_code": "string",
"failure_phase": "generating_source",
"artifact_url": "http://example.com",
"frame_names": [
"string"
],
"current_version_id": "158beffb-f9de-457f-bbee-873740e72504",
"widget_id": "917f3fdb-2905-481f-8ff6-04c0fb7d466c",
"instance_id": "06587974-2dbe-4e10-8bf9-38cce0f5a366",
"has_versions": true,
"active_job": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "queued",
"phase": "string",
"model": "string",
"created_at": "2019-08-24T14:15:22Z",
"started_at": "2019-08-24T14:15:22Z"
},
"security_review": {
"severity": "none",
"summary": "string",
"findings": [
{
"severity": "low",
"title": "string",
"details": "string"
}
],
"model": "string",
"review_version": "string",
"reviewed_at": "2019-08-24T14:15:22Z"
},
"build_hash": "string"
}
Status 404
RESPONSE
{
"code": "string",
"detail": "string"
}

Retrieve notebooks widget

The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.

Required API key scopes

notebook:read

Path parameters

  • node_id
    string
  • short_id
    string

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

GET /api/projects/:project_id/notebooks/:short_id/widgets/:node_id/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/notebooks/:short_id/widgets/:node_id/versions/

Example response

Status 200
RESPONSE
{
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"parent_version_id": "f8d7c285-7613-4ade-8a91-ac987c2c73a9",
"version": 1,
"version_operation": "initial",
"prompt_delta": "string",
"effective_prompt": "string",
"model": "string",
"created_at": "2019-08-24T14:15:22Z",
"build_status": "queued",
"artifact_url": "http://example.com",
"frame_names": [
"string"
],
"is_current": true,
"security_review": {
"severity": "none",
"summary": "string",
"findings": [
{
"severity": "low",
"title": "string",
"details": "string"
}
],
"model": "string",
"review_version": "string",
"reviewed_at": "2019-08-24T14:15:22Z"
},
"build_hash": "string"
}
],
"count": 0,
"next_offset": 0
}
Status 404
RESPONSE
{
"code": "string",
"detail": "string"
}

Retrieve notebooks all activity

The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.

Example request

GET /api/projects/:project_id/notebooks/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/notebooks/activity/

Example response

Status 200 No response body

Retrieve notebooks kernel compute options

Compute rates, presets, and the sizes the kernel config endpoint accepts. Static per region, so a client can fetch it once and price any shape a user picks.

Required API key scopes

notebook:read

Response


Example request

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

Example response

Status 200
RESPONSE
{
"currency": "string",
"cpu_rate_per_core_hour": 0.1,
"memory_rate_per_gb_hour": 0.1,
"default_preset_key": "string",
"presets": [
{
"key": "string",
"name": "string",
"description": "string",
"cpu_cores": 0.1,
"memory_gb": 0.1,
"hourly_price": 0.1
}
],
"allowed_cpu_cores": [
0.1
],
"allowed_memory_gb": [
0.1
],
"allowed_idle_timeout_seconds": [
0
]
}

Retrieve notebooks recording comments

The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.

Example request

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

Example response

Status 200 No response body