# Server routes

> The routes the server adds under /auth/ for agents, tokens, claims, OAuth, and devices.

From `server/openapi.json` in tensile-tools/tensile-auth at commit `e66760d` (v0.4.1-7-ge66760d). The HTML page is https://auth.tensile.tools/docs/reference/api/server.

The server adds these routes under `/auth/`: agents and tokens for the signed-in person, agent claims, OAuth consent, device approval, and secret-scanning alerts.

## /auth/admin

### POST /auth/admin/invites/accept

Spend an admin invitation from tensile-auth-server admin invite, and become an administrator. Needs a second factor within 15 minutes.

Auth: The `__Host-session` cookie.

Body: `object` as `application/json`.

| Field | Type | Description |
|---|---|---|
| `code` (required) | `string` |  |

| Status | Meaning | Body |
|---|---|---|
| 204 | Done |  |
| default | A refusal, as an RFC 9457 problem | `Problem` |

## /auth/agents

### POST /auth/agents

Create an agent.

Auth: The `__Host-session` cookie.

Body: `object` as `application/json`.

| Status | Meaning | Body |
|---|---|---|
| 201 | Done | `object` |
| default | A refusal, as an RFC 9457 problem | `Problem` |

### GET /auth/agents/tree

The signed-in person's live sessions, as a tree of delegations.

Auth: The `__Host-session` cookie.

| Status | Meaning | Body |
|---|---|---|
| 200 | Done | `object` |
| default | A refusal, as an RFC 9457 problem | `Problem` |

### POST /auth/agents/{id}/delegate

Give one of the person's agents a token, shown once.

Auth: The `__Host-session` cookie.

| Parameter | In | Type | Description |
|---|---|---|---|
| `id` (required) | path | `string` |  |

Body: `object` as `application/json`.

| Status | Meaning | Body |
|---|---|---|
| 201 | Done | `object` |
| default | A refusal, as an RFC 9457 problem | `Problem` |

### POST /auth/agents/{id}/revoke

Revoke one of the person's agents and every session it holds.

Auth: The `__Host-session` cookie.

| Parameter | In | Type | Description |
|---|---|---|---|
| `id` (required) | path | `string` |  |

| Status | Meaning | Body |
|---|---|---|
| 204 | Done |  |
| default | A refusal, as an RFC 9457 problem | `Problem` |

## /auth/claims

### POST /auth/claims/claim

Claim an agent that signed up by itself.

Auth: The `__Host-session` cookie.

Body: `object` as `application/json`.

| Status | Meaning | Body |
|---|---|---|
| 200 | Done | `object` |
| default | A refusal, as an RFC 9457 problem | `Problem` |

### POST /auth/claims/peek

Show an unclaimed agent and its pairing words before claiming it.

Auth: The `__Host-session` cookie.

Body: `object` as `application/json`.

| Status | Meaning | Body |
|---|---|---|
| 200 | Done | `object` |
| default | A refusal, as an RFC 9457 problem | `Problem` |

## /auth/device

### GET /auth/device/{code}

The pending device request for a user code, for the app's device page.

Auth: The `__Host-session` cookie.

| Parameter | In | Type | Description |
|---|---|---|---|
| `code` (required) | path | `string` |  |

| Status | Meaning | Body |
|---|---|---|
| 200 | Done | `object` |
| default | A refusal, as an RFC 9457 problem | `Problem` |

### POST /auth/device/{code}/approve

Approve the device request for a user code.

Auth: The `__Host-session` cookie.

| Parameter | In | Type | Description |
|---|---|---|---|
| `code` (required) | path | `string` |  |

| Status | Meaning | Body |
|---|---|---|
| 204 | Done |  |
| default | A refusal, as an RFC 9457 problem | `Problem` |

### POST /auth/device/{code}/deny

Deny the device request for a user code.

Auth: The `__Host-session` cookie.

| Parameter | In | Type | Description |
|---|---|---|---|
| `code` (required) | path | `string` |  |

| Status | Meaning | Body |
|---|---|---|
| 204 | Done |  |
| default | A refusal, as an RFC 9457 problem | `Problem` |

## /auth/leakscan

### POST /auth/leakscan

Receive a secret-scanning alert in the format of GitHub's partner program, and revoke each leaked session or app key.

Auth: None.

Body: `array of object` as `application/json`.

| Status | Meaning | Body |
|---|---|---|
| 200 | A label for each reported token | `array of object` |
| default | A refusal, with the status text only |  |

## /auth/oauth

### GET /auth/oauth/requests/{id}

A pending OAuth authorization request, for the app's consent page.

Auth: The `__Host-session` cookie.

| Parameter | In | Type | Description |
|---|---|---|---|
| `id` (required) | path | `string` |  |

| Status | Meaning | Body |
|---|---|---|
| 200 | Done | `object` |
| default | A refusal, as an RFC 9457 problem | `Problem` |

### POST /auth/oauth/requests/{id}/approve

Approve an OAuth authorization request, and answer where to send the browser.

Auth: The `__Host-session` cookie.

| Parameter | In | Type | Description |
|---|---|---|---|
| `id` (required) | path | `string` |  |

| Status | Meaning | Body |
|---|---|---|
| 200 | Done | `object` |
| default | A refusal, as an RFC 9457 problem | `Problem` |

### POST /auth/oauth/requests/{id}/deny

Deny an OAuth authorization request, and answer where to send the browser.

Auth: The `__Host-session` cookie.

| Parameter | In | Type | Description |
|---|---|---|---|
| `id` (required) | path | `string` |  |

| Status | Meaning | Body |
|---|---|---|
| 200 | Done | `object` |
| default | A refusal, as an RFC 9457 problem | `Problem` |

## /auth/tokens

### POST /auth/tokens

Create a personal access token, shown once.

Auth: The `__Host-session` cookie.

Body: `object` as `application/json`.

| Status | Meaning | Body |
|---|---|---|
| 201 | Done | `object` |
| default | A refusal, as an RFC 9457 problem | `Problem` |
