# Billing

32 endpoints at `https://api.kosa8.com`, sent with `Authorization: Bearer $KOSA8_API_KEY`. Generated from the API's own [OpenAPI description](https://api.kosa8.com/openapi.json), which a test holds to the router.

## Spend alerts recorded for this organization: 50, 75 and 100% of the spend cap or the Starter allowance[#]

GET`/v1/billing/alerts`scope sandboxes:read

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/billing/alerts \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Start checkout to add a payment method or plan; answers {url}, a checkout page a person opens and pays[#]

POST`/v1/billing/checkout`scope admin · owner

Owner only: an owner member or the organization's own admin key; an admin member gets 403. A plan checkout ({plan}, no pack) is also open to an API key bound to an owner with sandboxes:write, such as an AI agent's key from POST /v1/auth/device {client: agent}: it answers {url, plan, agent_message}, a link to give the person, who pays on that page. The key itself cannot pay, change or cancel the plan, open the portal or change the spend cap.

JSON body

`plan`"solo" | "pro" | "team" | "scale"

—

`yearly`boolean

—

`seats`integer

—

`pack`string

—

Responses

200401403

```
curl -s -X POST https://api.kosa8.com/v1/billing/checkout \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## Open the billing portal (invoices, payment method)[#]

POST`/v1/billing/portal`scope admin · owner

Owner only: an owner member or the organization's own admin key; an admin member gets 403.

Responses

200401403

```
curl -s -X POST https://api.kosa8.com/v1/billing/portal \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Re-check the payment provider for this org's subscription[#]

POST`/v1/billing/sync`scope admin · owner

Owner only: an owner member or the organization's own admin key; an admin member gets 403.

Responses

200401403

```
curl -s -X POST https://api.kosa8.com/v1/billing/sync \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Change plan (Solo, Pro, Team, Scale; seats for Team and Scale, yearly or monthly); the prorated difference is charged now[#]

POST`/v1/billing/plan`scope admin · owner

Owner only: an owner member or the organization's own admin key; an admin member gets 403.

Responses

200401403

```
curl -s -X POST https://api.kosa8.com/v1/billing/plan \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Whether the plan is paused (snapshots and data kept until kept_until), and the reasons a cancel may give[#]

GET`/v1/billing/cancel`scope admin · owner

Owner only: an owner member or the organization's own admin key; an admin member gets 403.

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/billing/cancel \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Cancel, pause (1 to 3 months, snapshots kept) or resume the plan in one call. The plan runs to the end of the period paid; nothing renews after it. reason is optional[#]

POST`/v1/billing/cancel`scope admin · owner

Owner only: an owner member or the organization's own admin key; an admin member gets 403.

JSON body

`mode`required"cancel" | "pause" | "resume"

—

`months`integer

Min 1. Max 3.

`reason`"too_expensive" | "not_using" | "missing_feature" | "switching" | "bugs" | "project_ended" | "other"

—

`note`string

Max length 500.

Responses

200401403

```
curl -s -X POST https://api.kosa8.com/v1/billing/cancel \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## Add-on packs: each pack, its price, the limit it adds to and how many are in force. available is false when none is sold here[#]

GET`/v1/billing/addons`scope sandboxes:read

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/billing/addons \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Buy add-on packs ({addon: hours_100 | running_10, quantity}): monthly, stackable on any plan. Answers {url} for a checkout (the first of a kind) or {quantity} when added to the pack subscription. Needs a plan (402 plan_required)[#]

POST`/v1/billing/addons`scope admin · owner

Owner only: an owner member or the organization's own admin key; an admin member gets 403.

JSON body

`addon`required"hours_100" | "running_10"

—

`quantity`integer

Min 1. Max 100.

Responses

200401403

```
curl -s -X POST https://api.kosa8.com/v1/billing/addons \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## Remove add-on packs (?quantity, default 1); the last one stops at the end of the month paid for (ends_at)[#]

DELETE`/v1/billing/addons/{addon}`scope admin · owner

Owner only: an owner member or the organization's own admin key; an admin member gets 403.

Parameters

`addon`requiredpath · string

hours_100 or running_10

`quantity`query · integer

how many packs to remove (default 1)

Responses

200401403404

```
curl -s -X DELETE https://api.kosa8.com/v1/billing/addons/$ADDON \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Burst Passes: the pass (null when none is sold here; available false), the passes held, those running and when each ends[#]

GET`/v1/billing/burst`scope sandboxes:read

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/billing/burst \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Activate Burst Passes ({quantity}, default 1): each raises the running limit for its hours from now, stacking up to max_active. Holding fewer than asked, answers {url}, a checkout for the rest, activated once paid. 404 not_available when none is sold here; 409 burst_cap past max_active; needs a plan (402 plan_required)[#]

POST`/v1/billing/burst`scope admin · owner

Owner only: an owner member or the organization's own admin key; an admin member gets 403.

JSON body

`quantity`integer

Min 1.

Responses

200401403404409

```
curl -s -X POST https://api.kosa8.com/v1/billing/burst \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## Pay what is owed now (after a declined charge, once the card is fixed)[#]

POST`/v1/billing/charge-now`scope admin · owner

Owner only: an owner member or the organization's own admin key; an admin member gets 403.

Responses

200401403

```
curl -s -X POST https://api.kosa8.com/v1/billing/charge-now \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Link a kosa8 licence to the org[#]

POST`/v1/billing/licence`scope admin · owner

Owner only: an owner member or the organization's own admin key; an admin member gets 403.

Responses

200401403

```
curl -s -X POST https://api.kosa8.com/v1/billing/licence \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## The plan's licence keys, for kosa8 login to activate on a member's own machine (a person only)[#]

POST`/v1/billing/machine-licence`scope sandboxes:write

Responses

200401403404

```
curl -s -X POST https://api.kosa8.com/v1/billing/machine-licence \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## Prepaid credit balance and packs[#]

GET`/v1/billing/credits`scope sandboxes:read

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/billing/credits \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Redirect to checkout for a plan[#]

GET`/v1/checkout/plan`public

Parameters

`plan`query · string

Plan key

Responses

200

```
curl -s -X GET https://api.kosa8.com/v1/checkout/plan
```

## This month's bill so far[#]

GET`/v1/usage`scope sandboxes:read

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/usage \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Slack and PagerDuty channels for spend alerts (50/75/100%) and plan-limit events; secrets are shown only as their last four characters[#]

GET`/v1/alert-channels`scope sandboxes:read

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/alert-channels \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Set the Slack incoming-webhook URL ({url}) or the PagerDuty Events v2 routing key ({routing_key}); sealed at rest, never shown again in full[#]

PUT`/v1/alert-channels/{kind}`scope admin

Parameters

`kind`requiredpath · string

slack or pagerduty

JSON body

`url`string

slack: https://hooks.slack.com/services/…

`routing_key`string

pagerduty: 32-character integration key

`events`array of "spend_cap.alert" | "spending_cap.reached" | "plan_limit.reached" | "plan_limit.near"

—

Responses

200400401403404

```
curl -s -X PUT https://api.kosa8.com/v1/alert-channels/$KIND \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## Remove a Slack or PagerDuty alert channel[#]

DELETE`/v1/alert-channels/{kind}`scope admin

Parameters

`kind`requiredpath · string

slack or pagerduty

Responses

200401403404

```
curl -s -X DELETE https://api.kosa8.com/v1/alert-channels/$KIND \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Send one test alert to the channel now; answers the HTTP status Slack or PagerDuty gave[#]

POST`/v1/alert-channels/{kind}/test`scope admin

Parameters

`kind`requiredpath · string

slack or pagerduty

Responses

200401403404

```
curl -s -X POST https://api.kosa8.com/v1/alert-channels/$KIND/test \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## The running-sandbox limit: how many are active, the limit, and the last request for more[#]

GET`/v1/limits`scope sandboxes:read

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/limits \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Ask kosa8 for a higher running-sandbox limit; kosa8 answers the owner by email. Once a day[#]

POST`/v1/limits/request`scope admin

JSON body

`max_running`requiredinteger

Above the current limit

`reason`string

What the sandboxes are for Max length 500.

Responses

202400401403429

```
curl -s -X POST https://api.kosa8.com/v1/limits/request \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## Daily spend, top sandboxes, /v1/run runs counted apart, running now against the plan limit and the month's peak, credit left and projected month-end spend[#]

GET`/v1/usage/insights`scope sandboxes:read

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/usage/insights \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## This month's sandbox and run cost grouped by template, by the API key or person that made each, by agent (the label agent=<name>) and by label; ?format=csv gives one row per sandbox[#]

GET`/v1/usage/breakdown`scope sandboxes:read

Parameters

`format`query · "json" | "csv"

json (default) or csv

Responses

200400401403

```
curl -s -X GET https://api.kosa8.com/v1/usage/breakdown \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Up to two upgrade moments for this org, most urgent first, each grounded in the org's own usage and the real price tables[#]

GET`/v1/recommendations`scope sandboxes:read

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/recommendations \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Hide a moment for this org for 14 days[#]

POST`/v1/recommendations/{id}/dismiss`scope sandboxes:read

Parameters

`id`requiredpath · string

The moment's id, e.g. add_card

Responses

200401403404

```
curl -s -X POST https://api.kosa8.com/v1/recommendations/$SBX/dismiss \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Refer and earn link and invitations[#]

GET`/v1/referral`scope sandboxes:read

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/referral \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Affiliate program status[#]

GET`/v1/affiliate`scope sandboxes:read

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/affiliate \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Apply to the affiliate program[#]

POST`/v1/affiliate/apply`scope admin

Responses

200401403

```
curl -s -X POST https://api.kosa8.com/v1/affiliate/apply \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## Set affiliate payout details (method, email, country, legal name)[#]

POST`/v1/affiliate/payout`scope admin

Responses

200401403

```
curl -s -X POST https://api.kosa8.com/v1/affiliate/payout \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

---
Source: https://docs.kosa8.com/api/billing/
