Business

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

Endpoints

GET
GET
GET
POST
POST
POST
POST
GET
POST
GET
DELETE
POST
POST
POST
GET
GET
POST
GET
POST
GET

List all business knowledge documents window

Read-only access to parsed knowledge documents. Exposes hybrid search (search) and a drill-down window (window) so an agent (PHAI or MCP) can find and explore business knowledge chunks.

Required API key scopes

business_knowledge:read

Path parameters

  • id
    string

Query parameters

  • around_ordinal
    integer
  • radius
    integer

Example request

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

Example response

Status 200
RESPONSE
{
"chunk_id": "55e808e1-8ddc-49f1-92c9-6bbdcdff1c83",
"ordinal": 0,
"content": "string",
"heading_path": "string",
"source_name": "string",
"document_title": "string",
"url": "string"
}


List all business knowledge gap suggestions

Surfaces topics the support AI couldn't answer from the knowledge base.

Two list shapes controlled by the ticket_id query param:

  • per-ticket (?ticket_id=<uuid>): individual gap rows for that ticket.
  • aggregated (no ticket_id): gaps grouped by normalized topic with counts, for the Business knowledge suggestions panel.

Required API key scopes

business_knowledge:read

Query parameters

  • limit
    integer
  • offset
    integer
  • ticket_id
    string

Response


Example request

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

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",
"ticket_id": "595be628-f6f2-4262-9c10-6389c6c4a5b8",
"topic": "string",
"normalized_topic": "string",
"ticket_type": "string",
"outcome": "string",
"status": "string",
"resolved_source_id": "48f0e0e2-5e7b-4285-aa9b-9ab9142e12db",
"created_at": "2019-08-24T14:15:22Z"
}
]
}

Create business knowledge gap suggestions accept

Surfaces topics the support AI couldn't answer from the knowledge base.

Two list shapes controlled by the ticket_id query param:

  • per-ticket (?ticket_id=<uuid>): individual gap rows for that ticket.
  • aggregated (no ticket_id): gaps grouped by normalized topic with counts, for the Business knowledge suggestions panel.

Required API key scopes

business_knowledge:writeticket:read

Path parameters

  • id
    string

Request parameters

  • resolved_source_id
    string | null

Response


Example request

POST /api/projects/:project_id/business_knowledge/gap_suggestions/:id/accept
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/business_knowledge/gap_suggestions/:id/accept/\
-d resolved_source_id="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"ticket_id": "595be628-f6f2-4262-9c10-6389c6c4a5b8",
"topic": "string",
"normalized_topic": "string",
"ticket_type": "string",
"outcome": "string",
"status": "string",
"resolved_source_id": "48f0e0e2-5e7b-4285-aa9b-9ab9142e12db",
"created_at": "2019-08-24T14:15:22Z"
}

Create business knowledge gap suggestions dismiss

Surfaces topics the support AI couldn't answer from the knowledge base.

Two list shapes controlled by the ticket_id query param:

  • per-ticket (?ticket_id=<uuid>): individual gap rows for that ticket.
  • aggregated (no ticket_id): gaps grouped by normalized topic with counts, for the Business knowledge suggestions panel.

Required API key scopes

business_knowledge:writeticket:read

Path parameters

  • id
    string

Response


Example request

POST /api/projects/:project_id/business_knowledge/gap_suggestions/:id/dismiss
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/business_knowledge/gap_suggestions/:id/dismiss/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"ticket_id": "595be628-f6f2-4262-9c10-6389c6c4a5b8",
"topic": "string",
"normalized_topic": "string",
"ticket_type": "string",
"outcome": "string",
"status": "string",
"resolved_source_id": "48f0e0e2-5e7b-4285-aa9b-9ab9142e12db",
"created_at": "2019-08-24T14:15:22Z"
}

Create business knowledge gap suggestions accept topic

Accept all pending suggestions for a normalized topic cluster.

Request parameters

  • normalized_topic
    string
  • resolved_source_id
    string | null

Response


Example request

POST /api/projects/:project_id/business_knowledge/gap_suggestions/accept_topic
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/business_knowledge/gap_suggestions/accept_topic/\
-d normalized_topic="string"

Example response

Status 200
RESPONSE
{
"normalized_topic": "string",
"updated": 0
}

Create business knowledge gap suggestions dismiss topic

Dismiss all pending suggestions for a normalized topic cluster.

Request parameters

  • normalized_topic
    string
  • resolved_source_id
    string | null

Response


Example request

POST /api/projects/:project_id/business_knowledge/gap_suggestions/dismiss_topic
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/business_knowledge/gap_suggestions/dismiss_topic/\
-d normalized_topic="string"

Example response

Status 200
RESPONSE
{
"normalized_topic": "string",
"updated": 0
}

List all business knowledge playground chats

Chats started by the current user in this project.

Required API key scopes

business_knowledge:read

Example request

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

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"title": "string",
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"has_open_turn": true
}

Create business knowledge playground chats

Create an empty chat. The first question sets the title.

Required API key scopes

business_knowledge:write

Response


Example request

POST /api/projects/:project_id/business_knowledge/playground/chats
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/business_knowledge/playground/chats/

Example response

Status 201 Empty playground chat.
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"title": "string",
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"has_open_turn": true,
"turns": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"question": "string",
"task_id": "736fde4d-9029-4915-8189-01353d6982cb",
"position": 0,
"run": {
"task_id": "736fde4d-9029-4915-8189-01353d6982cb",
"run_id": "dded282c-8ebd-44cf-8ba5-9a234973d1ec",
"status": "running",
"reply": "string",
"sources": [
{
"ref": "string",
"excerpt": "string"
}
],
"searches": [
{
"tool": "business-knowledge-documents-search",
"input": "string"
}
],
"error": "string",
"docs_search_called": true
},
"error": "string"
}
]
}

Retrieve business knowledge playground chats

Reload a chat and its turns. Each turn's answer comes from its sandbox run. A chat started before AI data processing was turned off can still be read.

Required API key scopes

business_knowledge:read

Path parameters

  • id
    string

Response


Example request

GET /api/projects/:project_id/business_knowledge/playground/chats/: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/business_knowledge/playground/chats/:id/

Example response

Status 200 Playground chat with turns.
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"title": "string",
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"has_open_turn": true,
"turns": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"question": "string",
"task_id": "736fde4d-9029-4915-8189-01353d6982cb",
"position": 0,
"run": {
"task_id": "736fde4d-9029-4915-8189-01353d6982cb",
"run_id": "dded282c-8ebd-44cf-8ba5-9a234973d1ec",
"status": "running",
"reply": "string",
"sources": [
{
"ref": "string",
"excerpt": "string"
}
],
"searches": [
{
"tool": "business-knowledge-documents-search",
"input": "string"
}
],
"error": "string",
"docs_search_called": true
},
"error": "string"
}
]
}
Status 404 No playground chat with this id for the current user.

Delete business knowledge playground chats

Deletes the chat and its turns. Does not cancel a running sandbox agent.

Required API key scopes

business_knowledge:write

Path parameters

  • id
    string

Example request

DELETE /api/projects/:project_id/business_knowledge/playground/chats/: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/business_knowledge/playground/chats/:id/

Example response

Status 204 Chat deleted.

Create business knowledge playground chats ask

Append a turn and start a sandbox run. A second question in the same chat while its answer is still open returns 409. Other chats can run at the same time, up to 3 open answers per person.

Required API key scopes

business_knowledge:write

Path parameters

  • id
    string

Request parameters

  • question
    string

Response


Example request

POST /api/projects/:project_id/business_knowledge/playground/chats/:id/ask
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/business_knowledge/playground/chats/:id/ask/\
-d question="string"

Example response

Status 201 Chat with the new turn.
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"title": "string",
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"has_open_turn": true,
"turns": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"question": "string",
"task_id": "736fde4d-9029-4915-8189-01353d6982cb",
"position": 0,
"run": {
"task_id": "736fde4d-9029-4915-8189-01353d6982cb",
"run_id": "dded282c-8ebd-44cf-8ba5-9a234973d1ec",
"status": "running",
"reply": "string",
"sources": [
{
"ref": "string",
"excerpt": "string"
}
],
"searches": [
{
"tool": "business-knowledge-documents-search",
"input": "string"
}
],
"error": "string",
"docs_search_called": true
},
"error": "string"
}
]
}
Status 403 AI data processing is not approved for this organization.
Status 409 This chat already has an answer that has not finished, or this person already has 3 answers running.

Create business knowledge repositories connect

Stores the installation for this environment. Switching installations clears the selected repositories.

Required API key scopes

business_knowledge:write

Request parameters

  • integration_id
    integer

Response


Example request

POST /api/projects/:project_id/business_knowledge/repositories/connect
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/business_knowledge/repositories/connect/\
-d integration_id="integer"

Example response

Status 200
RESPONSE
{
"connected": true,
"integration_id": 0,
"integration_name": "string",
"repos": [
"string"
]
}

Create business knowledge repositories disconnect

Clears the installation and the selected repositories for this environment.

Required API key scopes

business_knowledge:write

Response


Example request

POST /api/projects/:project_id/business_knowledge/repositories/disconnect
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/business_knowledge/repositories/disconnect/

Example response

Status 200
RESPONSE
{
"connected": true,
"integration_id": 0,
"integration_name": "string",
"repos": [
"string"
]
}

Retrieve business knowledge repositories file

Reads one file whose path is in the cached file list, at the cached commit. The path must come from the repository search.

Required API key scopes

business_knowledge:read

Query parameters

  • path
    string
  • repo
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"repo": "string",
"path": "string",
"url": "http://example.com",
"content": "string",
"truncated": true
}


Create business knowledge repositories selection

Every name must be a repository the connected installation can see. Names are stored lowercased.

Required API key scopes

business_knowledge:write

Request parameters

  • repos
    array

Response


Example request

POST /api/projects/:project_id/business_knowledge/repositories/selection
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/business_knowledge/repositories/selection/\
-d repos="array"

Example response

Status 200
RESPONSE
{
"connected": true,
"integration_id": 0,
"integration_name": "string",
"repos": [
"string"
]
}

Retrieve business knowledge repositories status

The GitHub installation and the repositories this environment allows business knowledge to read.

Required API key scopes

business_knowledge:read

Response


Example request

GET /api/projects/:project_id/business_knowledge/repositories/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/business_knowledge/repositories/status/

Example response

Status 200
RESPONSE
{
"connected": true,
"integration_id": 0,
"integration_name": "string",
"repos": [
"string"
]
}

Create business knowledge sandbox

Start a sandbox agent that can search only this project's business knowledge. Returns immediately.

Required API key scopes

business_knowledge:write

Request parameters

  • question
    string

Response


Example request

POST /api/projects/:project_id/business_knowledge/sandbox
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/business_knowledge/sandbox/\
-d question="string"

Example response

Status 201 The sandbox run has started.
RESPONSE
{
"task_id": "736fde4d-9029-4915-8189-01353d6982cb",
"run_id": "dded282c-8ebd-44cf-8ba5-9a234973d1ec"
}
Status 403 AI data processing is not approved for this organization.
Status 409 This person already has a sandbox run that has not finished.

Retrieve business knowledge sandbox

Poll a sandbox run started by the current user. A run that started before AI data processing was turned off can still be read.

Required API key scopes

business_knowledge:read

Path parameters

  • id
    string

Response


Example request

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

Example response

Status 200 Current sandbox run.
RESPONSE
{
"task_id": "736fde4d-9029-4915-8189-01353d6982cb",
"run_id": "dded282c-8ebd-44cf-8ba5-9a234973d1ec",
"status": "running",
"reply": "string",
"sources": [
{
"ref": "string",
"excerpt": "string"
}
],
"searches": [
{
"tool": "business-knowledge-documents-search",
"input": "string"
}
],
"error": "string",
"docs_search_called": true
}
Status 404 No sandbox run with this id for the current user.