Business

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

Endpoints

GET
POST
GET
POST
GET
GET
PATCH
GET
POST
GET
PATCH
DELETE
GET
POST
GET

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.

Retrieve business knowledge settings

Fetch whether this project learns from resolved support tickets, and whether Support is on in this environment.

Required API key scopes

business_knowledge:read

Response


Example request

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

Example response

Status 200 The team's Business knowledge learning settings.
RESPONSE
{
"learn_from_support_enabled": true,
"support_enabled": true
}

Update business knowledge settings

Partially update Business knowledge learning settings. Enabling learn-from-support requires Support to be on in this environment.

Required API key scopes

business_knowledge:write

Request parameters

  • learn_from_support_enabled
    boolean

Response


Example request

PATCH /api/projects/:project_id/business_knowledge/settings
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/settings/\
-d learn_from_support_enabled="boolean"

Example response

Status 200 The updated Business knowledge learning settings.
RESPONSE
{
"learn_from_support_enabled": true,
"support_enabled": true
}
Status 400 Learn from support cannot be enabled while Support is off.

List all business knowledge sources

Required API key scopes

business_knowledge:read

Query parameters

  • added_by
    string
    One of: "human""learned"
  • library_id
    string
  • limit
    integer
  • offset
    integer
  • search
    string
  • source_type
    string
    One of: "file""text""url"
  • unfiled
    boolean

Response


Example request

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

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",
"team_id": 0,
"name": "string",
"source_type": "text",
"is_generated": true,
"status": "pending",
"error_message": "string",
"document_count": 0,
"chunk_count": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"source_url": "http://example.com",
"last_refresh_at": "2019-08-24T14:15:22Z",
"last_refresh_status": "success",
"last_refresh_error": "string",
"refresh_interval": "manual",
"next_refresh_at": "string",
"has_unsafe_documents": true,
"embedding_status": "pending",
"learned_from_ticket_number": 0,
"learned_from_ticket_url": "http://example.com",
"crawl_mode": "single",
"crawl_config": null,
"original_filename": "string",
"file_content_type": "string",
"file_size_bytes": 0,
"always_include": true,
"library_ids": [
"497f6eca-6276-4993-bfeb-53cbbbba6f08"
]
}
]
}

Create business knowledge sources

Required API key scopes

business_knowledge:write

Request parameters

  • name
    string
  • text
    string
  • always_include
    boolean
    Default: false

Response


Example request

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

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"team_id": 0,
"name": "string",
"source_type": "text",
"is_generated": true,
"status": "pending",
"error_message": "string",
"document_count": 0,
"chunk_count": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"source_url": "http://example.com",
"last_refresh_at": "2019-08-24T14:15:22Z",
"last_refresh_status": "success",
"last_refresh_error": "string",
"refresh_interval": "manual",
"next_refresh_at": "string",
"has_unsafe_documents": true,
"embedding_status": "pending",
"learned_from_ticket_number": 0,
"learned_from_ticket_url": "http://example.com",
"crawl_mode": "single",
"crawl_config": null,
"original_filename": "string",
"file_content_type": "string",
"file_size_bytes": 0,
"always_include": true,
"library_ids": [
"497f6eca-6276-4993-bfeb-53cbbbba6f08"
]
}

Retrieve business knowledge sources

Required API key scopes

business_knowledge:read

Path parameters

  • id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"team_id": 0,
"name": "string",
"source_type": "text",
"is_generated": true,
"status": "pending",
"error_message": "string",
"document_count": 0,
"chunk_count": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"source_url": "http://example.com",
"last_refresh_at": "2019-08-24T14:15:22Z",
"last_refresh_status": "success",
"last_refresh_error": "string",
"refresh_interval": "manual",
"next_refresh_at": "string",
"has_unsafe_documents": true,
"embedding_status": "pending",
"learned_from_ticket_number": 0,
"learned_from_ticket_url": "http://example.com",
"crawl_mode": "single",
"crawl_config": null,
"original_filename": "string",
"file_content_type": "string",
"file_size_bytes": 0,
"always_include": true,
"library_ids": [
"497f6eca-6276-4993-bfeb-53cbbbba6f08"
]
}

Update business knowledge sources

Required API key scopes

business_knowledge:write

Path parameters

  • id
    string

Request parameters

  • name
    string
  • text
    string
  • always_include
    boolean
  • library_ids
    array

Response


Example request

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

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"team_id": 0,
"name": "string",
"source_type": "text",
"is_generated": true,
"status": "pending",
"error_message": "string",
"document_count": 0,
"chunk_count": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"source_url": "http://example.com",
"last_refresh_at": "2019-08-24T14:15:22Z",
"last_refresh_status": "success",
"last_refresh_error": "string",
"refresh_interval": "manual",
"next_refresh_at": "string",
"has_unsafe_documents": true,
"embedding_status": "pending",
"learned_from_ticket_number": 0,
"learned_from_ticket_url": "http://example.com",
"crawl_mode": "single",
"crawl_config": null,
"original_filename": "string",
"file_content_type": "string",
"file_size_bytes": 0,
"always_include": true,
"library_ids": [
"497f6eca-6276-4993-bfeb-53cbbbba6f08"
]
}

Delete business knowledge sources

Required API key scopes

business_knowledge:write

Path parameters

  • id
    string

Example request

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

Example response

Status 204 No response body

List all business knowledge sources documents

Required API key scopes

business_knowledge:read

Path parameters

  • id
    string

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

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

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",
"url": "http://example.com",
"title": "string",
"safety_verdict": "unknown"
}
]
}

Create business knowledge sources refresh

Path parameters

  • id
    string

Request parameters


    Response


    Example request

    POST /api/projects/:project_id/business_knowledge/sources/:id/refresh
    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/sources/:id/refresh/\
    -d team_id="integer"

    Example response

    Status 200
    RESPONSE
    {
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "team_id": 0,
    "name": "string",
    "source_type": "text",
    "is_generated": true,
    "status": "pending",
    "error_message": "string",
    "document_count": 0,
    "chunk_count": 0,
    "created_at": "2019-08-24T14:15:22Z",
    "updated_at": "2019-08-24T14:15:22Z",
    "source_url": "http://example.com",
    "last_refresh_at": "2019-08-24T14:15:22Z",
    "last_refresh_status": "success",
    "last_refresh_error": "string",
    "refresh_interval": "manual",
    "next_refresh_at": "string",
    "has_unsafe_documents": true,
    "embedding_status": "pending",
    "learned_from_ticket_number": 0,
    "learned_from_ticket_url": "http://example.com",
    "crawl_mode": "single",
    "crawl_config": null,
    "original_filename": "string",
    "file_content_type": "string",
    "file_size_bytes": 0,
    "always_include": true,
    "library_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    ]
    }

    Retrieve business knowledge sources text

    Path parameters

    • id
      string

    Example request

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

    Example response

    Status 200