# API keys

9 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.

## List keys (never secrets)[#]

GET`/v1/api-keys`scope keys:manage

Responses

200401403

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

## Create a key; the secret is shown once[#]

POST`/v1/api-keys`scope keys:manage

JSON body

`name`requiredstring

—

`scopes`array of string

—

`expires_in_s`integer

Min 300. Max 31536000.

Responses

201400401403

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

## Revoke a key now[#]

DELETE`/v1/api-keys/{id}`scope keys:manage

Parameters

`id`requiredpath · string

Id

Responses

200401403404

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

## New key with the same name and scopes; the old one lives grace_s more[#]

POST`/v1/api-keys/{id}/rotate`scope keys:manage

Parameters

`id`requiredpath · string

Id

JSON body

`grace_s`integer

Min 0. Max 86400.

Responses

201401403404

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

## List capability tokens (never secrets): every one in the org with keys:manage, else the ones this key or person made[#]

GET`/v1/tokens`any key

Parameters

`all`query · "1"

Also the last day's revoked and expired ones

Responses

200401403

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

## Make a short-lived capability token (at most 24 h) limited to some scopes and, optionally, some sandboxes; the secret is shown once[#]

POST`/v1/tokens`any key

A token holds only scopes its maker holds, from sandboxes:read, sandboxes:write and functions:invoke. With sandbox_ids it reaches only those sandboxes; with labels only sandboxes carrying every label, and a sandbox it creates gets them. A limited token answers 403 token_restricted on every other route. It stops when the key that made it is revoked, when its member leaves, and while the org is frozen. A token cannot make tokens.

JSON body

`scopes`requiredarray of "sandboxes:read" | "sandboxes:write" | "functions:invoke"

—

`sandbox_ids`array of string

Sandboxes (sbx_…) of this org it may reach

`labels`object

Labels every sandbox it reaches must carry; it may create sandboxes, which get them

`ttl_s`integer

Lifetime in seconds; default 3600 Min 60. Max 86400.

`name`string

Max length 64.

Responses

201400401403404429

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

## Revoke a capability token; it stops at once[#]

DELETE`/v1/tokens/{id}`any key

Parameters

`id`requiredpath · string

Id

Responses

200401403404

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

## Apps connected through OAuth (Claude, ChatGPT, Codex, …): the org's with keys:manage, else your own[#]

GET`/v1/oauth/grants`any key

Responses

200401403

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

## Disconnect an app: its access and refresh tokens stop at once[#]

DELETE`/v1/oauth/grants/{id}`any key

Parameters

`id`requiredpath · string

Id

Responses

200401403404

```
curl -s -X DELETE https://api.kosa8.com/v1/oauth/grants/$SBX \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

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