# Sign-in

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

## Start a browser sign-in for the CLI or desktop app (device authorization, RFC 8628)[#]

POST`/v1/auth/device`public

JSON body

`client`required"cli" | "desktop"

—

`name`requiredstring

This computer's hostname Max length 64.

`source`"cli_hint" | "cli_cloud"

Optional: what started the sign-in (the kosa8 CLI sets it); recorded as a new org's sign-up source

Responses

200400429

```
curl -s -X POST https://api.kosa8.com/v1/auth/device \
  -H 'Content-Type: application/json' -d @body.json
```

## The kosa8 CLI reports a Cloud hint shown or a --cloud handoff (anonymous; a key, if sent, adds the org). Allowed names and values only, body at most 512 bytes, rate-limited per network[#]

POST`/v1/cli-events`public

JSON body

`name`required"cloud_hint_shown" | "cloud_handoff" | "cloud_handoff_login"

—

`reason`"gpu" | "too_big" | "parallel" | "no_local" | "share"

cloud_hint_shown: required; cloud_handoff: the hint that preceded it, if any

`cmd`"run" | "sandbox_create"

cloud_handoff and cloud_handoff_login

`stage`"started" | "completed" | "failed"

cloud_handoff_login

`signed_in`boolean

cloud_handoff: whether the CLI was already signed in

`os`requiredstring

—

`arch`requiredstring

—

`version`requiredstring

—

`install_id`requiredstring

A random per-install id; stored only as a keyed hash

Responses

202400413429

```
curl -s -X POST https://api.kosa8.com/v1/cli-events \
  -H 'Content-Type: application/json' -d @body.json
```

## Poll for the sign-in's API key: 428 authorization_pending, 429 slow_down, 403 access_denied, 410 expired_token; 200 once, then 410[#]

POST`/v1/auth/device/token`public

JSON body

`device_code`requiredstring

—

Responses

200400403410428429

```
curl -s -X POST https://api.kosa8.com/v1/auth/device/token \
  -H 'Content-Type: application/json' -d @body.json
```

## The sign-in a code belongs to (the /device page). Needs a person signed in to the dashboard, not an API key[#]

GET`/v1/auth/device/pending`any key

Parameters

`user_code`query · string

ABCD-EFGH; any case, dash optional

Responses

200400401403404410

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

## Approve: makes an API key named after the device for the approver. Dashboard session only[#]

POST`/v1/auth/device/approve`scope keys:manage

JSON body

`user_code`requiredstring

—

Responses

200400401403404409410

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

## Deny: the device's next poll gets 403 access_denied. Dashboard session only[#]

POST`/v1/auth/device/deny`any key

JSON body

`user_code`requiredstring

—

Responses

200400401403404409410

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

## What the consent page shows for an OAuth authorization request (the query of /oauth/authorize). Dashboard session only[#]

GET`/v1/oauth/authorize`any key

Parameters

`client_id`query · string

As sent to /oauth/authorize

`redirect_uri`query · string

As sent to /oauth/authorize

`response_type`query · string

As sent to /oauth/authorize

`state`query · string

As sent to /oauth/authorize

`code_challenge`query · string

As sent to /oauth/authorize

`code_challenge_method`query · string

As sent to /oauth/authorize

`scope`query · string

As sent to /oauth/authorize

`resource`query · string

As sent to /oauth/authorize

Responses

200400401403

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

## Approve: returns redirect_to, the client's redirect_uri with a 60-second, single-use code and the state. Dashboard session only[#]

POST`/v1/oauth/authorize/approve`any key

JSON body

`client_id`requiredstring

—

`redirect_uri`requiredstring

—

`response_type`required"code"

—

`state`requiredstring

—

`code_challenge`requiredstring

—

`code_challenge_method`required"S256"

—

`scope`string

—

`resource`string

—

`scopes`array of string

The ones the person kept, of those asked for; at most what their role holds

Responses

200400401403

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

## Deny: returns redirect_to with error=access_denied. Dashboard session only[#]

POST`/v1/oauth/authorize/deny`any key

Responses

200400401403

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

## Dynamic client registration (RFC 7591) for MCP clients. redirect_uris: https, http on localhost/127.0.0.1/[::1], or an app's own scheme; no fragments. Rate-limited per network[#]

POST`/oauth/register`public

JSON body

`redirect_uris`requiredarray of string

—

`client_name`string

Max length 100.

`client_uri`string

—

`token_endpoint_auth_method`"none" | "client_secret_post" | "client_secret_basic"

Default client_secret_basic (RFC 7591); MCP clients usually send none

`grant_types`array of "authorization_code" | "refresh_token"

—

`response_types`array of "code"

—

Responses

201400429

```
curl -s -X POST https://api.kosa8.com/oauth/register \
  -H 'Content-Type: application/json' -d @body.json
```

## OAuth 2.1 token endpoint (application/x-www-form-urlencoded): authorization_code with PKCE (code_verifier) and resource, or refresh_token. Access tokens last 1 h and work only at /mcp; refresh tokens last 30 days and rotate on every use (a reused one revokes the grant)[#]

POST`/oauth/token`public

Responses

200400401

```
curl -s -X POST https://api.kosa8.com/oauth/token
```

## Token revocation (RFC 7009): a refresh token ends its grant, an access token only itself. 200 whether or not the token was known[#]

POST`/oauth/revoke`public

Responses

200400401

```
curl -s -X POST https://api.kosa8.com/oauth/revoke
```

---
Source: https://docs.kosa8.com/api/sign-in/
