Context

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

Endpoints

GET
POST
GET
GET
POST
GET
GET
GET
POST

Retrieve context layer channel pages

The organization's context wiki: a git repo of Markdown pages hosted by PostHog.

Required API key scopes

organization:read

Path parameters

  • channel_id
    string

Response


Example request

GET /api/organizations/:organization_id/context_layer/channel-pages/:channel_id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/organizations/:organization_id/context_layer/channel-pages/:channel_id/

Example response

Status 200
RESPONSE
{
"path": "string",
"exists": true
}
Status 404 This channel has no page in the context wiki.

Retrieve context layer channel pages

The organization's context wiki: a git repo of Markdown pages hosted by PostHog.

Required API key scopes

organization:read

Path parameters

  • channel_id
    string

Response


Example request

GET /api/organizations/:organization_id/context_layer/channel-pages/:channel_id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/organizations/:organization_id/context_layer/channel-pages/:channel_id/

Example response

Status 200
RESPONSE
{
"path": "string",
"exists": true
}
Status 404 This channel has no page in the context wiki.

Create context layer commits

The organization's context wiki: a git repo of Markdown pages hosted by PostHog.

Required API key scopes

organization:write


Response


Example request

Example response

Status 200
RESPONSE
{
"head_sha": "string"
}
Status 400
RESPONSE
{
"detail": "string",
"errors": [
"string"
]
}
Status 409 The posted commits conflict with the current head; re-pull and retry.

Create context layer commits

The organization's context wiki: a git repo of Markdown pages hosted by PostHog.

Required API key scopes

organization:write


Response


Example request

Example response

Status 200
RESPONSE
{
"head_sha": "string"
}
Status 400
RESPONSE
{
"detail": "string",
"errors": [
"string"
]
}
Status 409 The posted commits conflict with the current head; re-pull and retry.

List all context layer dreams

The active dreaming task, when present, plus every landed run newest first. A landed run is one merge commit dream: <date> whose body is the summary; its changes are on the detail read.

Required API key scopes

organization:read

Response


Example request

GET /api/organizations/:organization_id/context_layer/dreams
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/organizations/:organization_id/context_layer/dreams/

Example response

Status 200
RESPONSE
{
"head_sha": "string",
"active_run": {
"run_status": "not_started",
"started_at": "2019-08-24T14:15:22Z"
},
"unpublished_run": {
"task_url": "http://example.com",
"run_status": "string",
"started_at": "2019-08-24T14:15:22Z"
},
"dreams": [
{
"sha": "string",
"date": "string",
"committed_at": "2019-08-24T14:15:22Z",
"summary": "string",
"pages_added": 0,
"pages_modified": 0,
"pages_deleted": 0
}
]
}
Status 404 The context layer is not enabled.

List all context layer dreams

The active dreaming task, when present, plus every landed run newest first. A landed run is one merge commit dream: <date> whose body is the summary; its changes are on the detail read.

Required API key scopes

organization:read

Response


Example request

GET /api/organizations/:organization_id/context_layer/dreams
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/organizations/:organization_id/context_layer/dreams/

Example response

Status 200
RESPONSE
{
"head_sha": "string",
"active_run": {
"run_status": "not_started",
"started_at": "2019-08-24T14:15:22Z"
},
"unpublished_run": {
"task_url": "http://example.com",
"run_status": "string",
"started_at": "2019-08-24T14:15:22Z"
},
"dreams": [
{
"sha": "string",
"date": "string",
"committed_at": "2019-08-24T14:15:22Z",
"summary": "string",
"pages_added": 0,
"pages_modified": 0,
"pages_deleted": 0
}
]
}
Status 404 The context layer is not enabled.

Retrieve context layer dreams

One dreaming run with the per-file unified patches it landed.

Required API key scopes

organization:read

Path parameters

  • sha
    string

Response


Example request

GET /api/organizations/:organization_id/context_layer/dreams/:sha
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/organizations/:organization_id/context_layer/dreams/:sha/

Example response

Status 200
RESPONSE
{
"run": {
"sha": "string",
"date": "string",
"committed_at": "2019-08-24T14:15:22Z",
"summary": "string",
"pages_added": 0,
"pages_modified": 0,
"pages_deleted": 0
},
"files": [
{
"path": "string",
"status": "added",
"patch": "string",
"truncated": true
}
]
}
Status 404 No dream run at this sha, or the context layer is not enabled.

Retrieve context layer dreams

One dreaming run with the per-file unified patches it landed.

Required API key scopes

organization:read

Path parameters

  • sha
    string

Response


Example request

GET /api/organizations/:organization_id/context_layer/dreams/:sha
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/organizations/:organization_id/context_layer/dreams/:sha/

Example response

Status 200
RESPONSE
{
"run": {
"sha": "string",
"date": "string",
"committed_at": "2019-08-24T14:15:22Z",
"summary": "string",
"pages_added": 0,
"pages_modified": 0,
"pages_deleted": 0
},
"files": [
{
"path": "string",
"status": "added",
"patch": "string",
"truncated": true
}
]
}
Status 404 No dream run at this sha, or the context layer is not enabled.

Create context layer enable

Create the organization's wiki with the default structure and import existing channel CONTEXT.md documents once. Idempotent.

Required API key scopes

organization:write

Response


Example request

POST /api/organizations/:organization_id/context_layer/enable
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/organizations/:organization_id/context_layer/enable/

Example response

Status 201
RESPONSE
{
"head_sha": "string"
}

Create context layer enable

Create the organization's wiki with the default structure and import existing channel CONTEXT.md documents once. Idempotent.

Required API key scopes

organization:write

Response


Example request

POST /api/organizations/:organization_id/context_layer/enable
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/organizations/:organization_id/context_layer/enable/

Example response

Status 201
RESPONSE
{
"head_sha": "string"
}

Retrieve context layer export

A short-lived download URL for the wiki's current bundle: the whole repo and its history, one file, standard git.

Required API key scopes

organization:read

Response


Example request

GET /api/organizations/:organization_id/context_layer/export
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/organizations/:organization_id/context_layer/export/

Example response

Status 200
RESPONSE
{
"url": "string",
"head_sha": "string"
}

Retrieve context layer export

A short-lived download URL for the wiki's current bundle: the whole repo and its history, one file, standard git.

Required API key scopes

organization:read

Response


Example request

GET /api/organizations/:organization_id/context_layer/export
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/organizations/:organization_id/context_layer/export/

Example response

Status 200
RESPONSE
{
"url": "string",
"head_sha": "string"
}

Retrieve context layer pages

The organization's context wiki: a git repo of Markdown pages hosted by PostHog.

Required API key scopes

organization:read

Query parameters

  • head_sha
    string
  • limit
    integer
  • offset
    integer
    Default: 0
  • path
    string

Response


Example request

GET /api/organizations/:organization_id/context_layer/pages
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/organizations/:organization_id/context_layer/pages/

Example response

Status 200
RESPONSE
{
"path": "string",
"content": "string",
"head_sha": "string",
"updated_at": "2019-08-24T14:15:22Z",
"offset": 0,
"total_length": 0,
"next_offset": 0,
"complete": true
}
Status 400 Invalid query, or the offset exceeds the page length.
Status 404 No page at this path.
Status 409 The wiki changed. Restart from offset zero.

Retrieve context layer pages

The organization's context wiki: a git repo of Markdown pages hosted by PostHog.

Required API key scopes

organization:read

Query parameters

  • head_sha
    string
  • limit
    integer
  • offset
    integer
    Default: 0
  • path
    string

Response


Example request

GET /api/organizations/:organization_id/context_layer/pages
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/organizations/:organization_id/context_layer/pages/

Example response

Status 200
RESPONSE
{
"path": "string",
"content": "string",
"head_sha": "string",
"updated_at": "2019-08-24T14:15:22Z",
"offset": 0,
"total_length": 0,
"next_offset": 0,
"complete": true
}
Status 400 Invalid query, or the offset exceeds the page length.
Status 404 No page at this path.
Status 409 The wiki changed. Restart from offset zero.

List all context layer proposals

The organization's context wiki: a git repo of Markdown pages hosted by PostHog.

Required API key scopes

organization:read

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

GET /api/organizations/:organization_id/context_layer/proposals
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/organizations/:organization_id/context_layer/proposals/

Example 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": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"task_id": "736fde4d-9029-4915-8189-01353d6982cb",
"path": "string",
"original_content": "string",
"content": "string",
"base_head": "string",
"created_at": "2019-08-24T14:15:22Z"
}
]
}

List all context layer proposals

The organization's context wiki: a git repo of Markdown pages hosted by PostHog.

Required API key scopes

organization:read

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

GET /api/organizations/:organization_id/context_layer/proposals
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/organizations/:organization_id/context_layer/proposals/

Example 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": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"task_id": "736fde4d-9029-4915-8189-01353d6982cb",
"path": "string",
"original_content": "string",
"content": "string",
"base_head": "string",
"created_at": "2019-08-24T14:15:22Z"
}
]
}

Create context layer proposals apply

The organization's context wiki: a git repo of Markdown pages hosted by PostHog.

Required API key scopes

organization:write

Path parameters

  • proposal_id
    string

Response


Example request

POST /api/organizations/:organization_id/context_layer/proposals/:proposal_id/apply
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/organizations/:organization_id/context_layer/proposals/:proposal_id/apply/

Example response

Status 200
RESPONSE
{
"head_sha": "string"
}
Status 400
RESPONSE
{
"detail": "string",
"errors": [
"string"
]
}
Status 409
RESPONSE
{
"detail": "string",
"current_head": "string"
}

Create context layer proposals apply

The organization's context wiki: a git repo of Markdown pages hosted by PostHog.

Required API key scopes

organization:write

Path parameters

  • proposal_id
    string

Response


Example request

POST /api/organizations/:organization_id/context_layer/proposals/:proposal_id/apply
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/organizations/:organization_id/context_layer/proposals/:proposal_id/apply/

Example response

Status 200
RESPONSE
{
"head_sha": "string"
}
Status 400
RESPONSE
{
"detail": "string",
"errors": [
"string"
]
}
Status 409
RESPONSE
{
"detail": "string",
"current_head": "string"
}