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
PATCH
DELETE
GET
POST
GET
DELETE
POST
POST
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 libraries

Libraries in this project. The default library is first.

Required API key scopes

business_knowledge:read

Example request

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

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"is_default": true,
"source_count": 0,
"repos": [
"string"
]
}

Create business knowledge libraries

Required API key scopes

business_knowledge:write

Request parameters

  • name
    string

Response


Example request

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

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"is_default": true,
"source_count": 0,
"repos": [
"string"
]
}

Retrieve business knowledge libraries

Required API key scopes

business_knowledge:read

Path parameters

  • id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"is_default": true,
"source_count": 0,
"repos": [
"string"
]
}

Update business knowledge libraries

Send only the fields you want to change. source_ids replaces every source in the library. repos replaces this environment's repositories and leaves repositories that only another environment allows.

Required API key scopes

business_knowledge:write

Path parameters

  • id
    string

Request parameters

  • name
    string
  • source_ids
    array
  • repos
    array

Response


Example request

PATCH /api/projects/:project_id/business_knowledge/libraries/: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/business_knowledge/libraries/:id/\
-d name="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"is_default": true,
"source_count": 0,
"repos": [
"string"
]
}

Delete business knowledge libraries

Removes the library and its links. Sources, documents, and selected repositories stay.

Required API key scopes

business_knowledge:write

Path parameters

  • id
    string

Example request

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

Example response

Status 204 No response body

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

  • library_id
    string
  • 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
}