Billing

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

Endpoints

PATCH
GET
GET
GET
GET
POST
POST
POST
POST
GET

Update billing license

Request parameters

  • plan
    string
  • billing_limit
    integer

Example request

PATCH /api/billing/license
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/billing/license/\
-d plan="string"

Example response

Status 200 No response body

Update billing license

Request parameters

  • plan
    string
  • billing_limit
    integer

Example request

PATCH /api/billing/license
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/billing/license/\
-d plan="string"

Example response

Status 200 No response body

Retrieve billing period

Required API key scopes

llm_gateway:read

Response


Example request

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

Example response

Status 200
RESPONSE
{
"current_period_start": "2019-08-24T14:15:22Z",
"current_period_end": "2019-08-24T14:15:22Z"
}

Retrieve billing period

Required API key scopes

llm_gateway:read

Response


Example request

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

Example response

Status 200
RESPONSE
{
"current_period_start": "2019-08-24T14:15:22Z",
"current_period_end": "2019-08-24T14:15:22Z"
}

Retrieve billing portal

Example request

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

Example response

Status 200 No response body

Retrieve billing portal

Example request

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

Example response

Status 200 No response body

Retrieve billing spend

Endpoint to fetch spend data (proxy to billing service).

Required API key scopes

billing:read

Query parameters

  • after
    string | null
  • breakdowns
    string | null
  • end_date
    string | null
  • interval
    string | null
  • page_size
    integer | null
  • start_date
    string | null
  • team_ids
    string | null
  • top_projects
    integer | null
  • usage_types
    string | null

Response


Example request

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

Example response

Status 200
RESPONSE
{
"status": "string",
"type": "string",
"customer_id": 0,
"results": [
{
"id": 0,
"label": "string",
"data": [
0.1
],
"dates": [
"string"
],
"breakdown_type": "type",
"breakdown_value": null
}
],
"team_id_options": [
0
],
"next": "string",
"total_count": 0
}

Retrieve billing spend

Endpoint to fetch spend data (proxy to billing service).

Required API key scopes

billing:read

Query parameters

  • after
    string | null
  • breakdowns
    string | null
  • end_date
    string | null
  • interval
    string | null
  • page_size
    integer | null
  • start_date
    string | null
  • team_ids
    string | null
  • top_projects
    integer | null
  • usage_types
    string | null

Response


Example request

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

Example response

Status 200
RESPONSE
{
"status": "string",
"type": "string",
"customer_id": 0,
"results": [
{
"id": 0,
"label": "string",
"data": [
0.1
],
"dates": [
"string"
],
"breakdown_type": "type",
"breakdown_value": null
}
],
"team_id_options": [
0
],
"next": "string",
"total_count": 0
}

Retrieve billing spend export

Download the spend breakdown as CSV, honouring the requested project cap.

Required API key scopes

billing:read

Query parameters

  • after
    string | null
  • breakdowns
    string | null
  • end_date
    string | null
  • interval
    string | null
  • page_size
    integer | null
  • start_date
    string | null
  • team_ids
    string | null
  • top_projects
    integer | null
  • usage_types
    string | null

Example request

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

Example response

Status 200 No response body

Retrieve billing spend export

Download the spend breakdown as CSV, honouring the requested project cap.

Required API key scopes

billing:read

Query parameters

  • after
    string | null
  • breakdowns
    string | null
  • end_date
    string | null
  • interval
    string | null
  • page_size
    integer | null
  • start_date
    string | null
  • team_ids
    string | null
  • top_projects
    integer | null
  • usage_types
    string | null

Example request

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

Example response

Status 200 No response body

Create billing startups apply

Request parameters

  • plan
    string
  • billing_limit
    integer

Example request

POST /api/billing/startups/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/billing/startups/apply/\
-d plan="string",\
-d billing_limit="integer"

Example response

Status 200 No response body

Create billing startups apply

Request parameters

  • plan
    string
  • billing_limit
    integer

Example request

POST /api/billing/startups/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/billing/startups/apply/\
-d plan="string",\
-d billing_limit="integer"

Example response

Status 200 No response body

Create billing subscription switch plan

Request parameters

  • plan
    string
  • billing_limit
    integer

Example request

POST /api/billing/subscription/switch-plan
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/billing/subscription/switch-plan/\
-d plan="string",\
-d billing_limit="integer"

Example response

Status 200 No response body

Create billing subscription switch plan

Request parameters

  • plan
    string
  • billing_limit
    integer

Example request

POST /api/billing/subscription/switch-plan
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/billing/subscription/switch-plan/\
-d plan="string",\
-d billing_limit="integer"

Example response

Status 200 No response body

Create billing trials activate

Request parameters

  • plan
    string
  • billing_limit
    integer

Example request

POST /api/billing/trials/activate
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/billing/trials/activate/\
-d plan="string",\
-d billing_limit="integer"

Example response

Status 200 No response body

Create billing trials activate

Request parameters

  • plan
    string
  • billing_limit
    integer

Example request

POST /api/billing/trials/activate
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/billing/trials/activate/\
-d plan="string",\
-d billing_limit="integer"

Example response

Status 200 No response body

Create billing trials cancel

Request parameters

  • plan
    string
  • billing_limit
    integer

Example request

POST /api/billing/trials/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/billing/trials/cancel/\
-d plan="string",\
-d billing_limit="integer"

Example response

Status 200 No response body

Create billing trials cancel

Request parameters

  • plan
    string
  • billing_limit
    integer

Example request

POST /api/billing/trials/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/billing/trials/cancel/\
-d plan="string",\
-d billing_limit="integer"

Example response

Status 200 No response body

Retrieve billing usage

Required API key scopes

billing:read

Query parameters

  • after
    string | null
  • breakdowns
    string | null
  • end_date
    string | null
  • interval
    string | null
  • page_size
    integer | null
  • start_date
    string | null
  • team_ids
    string | null
  • top_projects
    integer | null
  • usage_types
    string | null

Response


Example request

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

Example response

Status 200
RESPONSE
{
"status": "string",
"type": "string",
"customer_id": 0,
"results": [
{
"id": 0,
"label": "string",
"data": [
0.1
],
"dates": [
"string"
],
"breakdown_type": "type",
"breakdown_value": null
}
],
"team_id_options": [
0
],
"next": "string",
"total_count": 0
}

Retrieve billing usage

Required API key scopes

billing:read

Query parameters

  • after
    string | null
  • breakdowns
    string | null
  • end_date
    string | null
  • interval
    string | null
  • page_size
    integer | null
  • start_date
    string | null
  • team_ids
    string | null
  • top_projects
    integer | null
  • usage_types
    string | null

Response


Example request

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

Example response

Status 200
RESPONSE
{
"status": "string",
"type": "string",
"customer_id": 0,
"results": [
{
"id": 0,
"label": "string",
"data": [
0.1
],
"dates": [
"string"
],
"breakdown_type": "type",
"breakdown_value": null
}
],
"team_id_options": [
0
],
"next": "string",
"total_count": 0
}