---
title: API reference
section: API
order: 8
---

<!-- GENERATED from apps/api/src/api/v1-spec.ts by `pnpm --filter @gridtac/api openapi`. Do not edit by hand. -->

# API reference

Every call, generated from the server code. Base URL: `https://api.gridtac.com`. The same thing as an
OpenAPI 3 document, for generating a client: [openapi.json](https://api.gridtac.com/api/v1/openapi.json).
Keys and how to make them: [Authentication](authentication.md). What each error code means: [Errors](errors.md).

## Keys

Make and manage API keys.

### Create an API key

```http
POST /api/v1/keys
```

Needs a signed-in session from the last 15 minutes, on an account with two-factor on or one that signs in only with Google or Apple. The answer is the only time the full key is shown.

**Auth:** a session signed in within the last 15 minutes, with two-factor on or Google/Apple sign-in only.

**Body:**

| Field | Type | Notes |
|---|---|---|
| `kind` | `play` / `team` / `dash` / `prop` / `link` / `gw` | prop and gw keys come from pairing a device, and link keys from the game page (a spectator link); none of them can be made here. |
| `label` | string |  |
| `gameId` | string (uuid) |  |
| `teamId` (optional) | string (uuid) | Required for a team key. |

**201:** The new key, with its secret (once).

| Field | Type | Notes |
|---|---|---|
| `id` | string (uuid) |  |
| `kind` | `play` / `team` / `dash` / `prop` / `link` / `gw` |  |
| `label` | string |  |
| `prefix` | string | The public part of the key, e.g. gt_team_ab12cd34. Safe to show. |
| `gameId` | string (uuid) or null |  |
| `teamId` | string (uuid) or null |  |
| `status` | `active` / `paused` / `blocked` / `revoked` / `expired` |  |
| `createdAt` | string (date-time) | ISO 8601 time |
| `lastUsedAt` | string (date-time) or null | ISO 8601 time |
| `expiresAt` | string (date-time) or null | ISO 8601 time |
| `pausedUntil` (optional) | string (date-time) | Only while the key is paused. |
| `pausedReason` (optional) | string or null | Only while the key is paused. |
| `key` | string | The full key. Shown ONCE: store it now, it cannot be read again. |

**Errors:** [`forbidden`](errors.md#forbidden), [`game_ended`](errors.md#game_ended), [`game_key_limit`](errors.md#game_key_limit), [`game_not_found`](errors.md#game_not_found), [`invalid_body`](errors.md#invalid_body), [`kind_not_creatable`](errors.md#kind_not_creatable), [`mfa_required`](errors.md#mfa_required), [`not_in_game`](errors.md#not_in_game), [`reauth_required`](errors.md#reauth_required), [`team_not_found`](errors.md#team_not_found), [`team_required`](errors.md#team_required), [`too_many_keys`](errors.md#too_many_keys), [`unauthorized`](errors.md#unauthorized).

### Your API keys

```http
GET /api/v1/keys
```

Newest first. Never the secrets.

**Auth:** a signed-in session (cookie).

**200:** Your keys.

| Field | Type | Notes |
|---|---|---|
| `keys` | array of ApiKey |  |

**Errors:** [`unauthorized`](errors.md#unauthorized).

### Rotate a key

```http
POST /api/v1/keys/{id}/rotate
```

A new secret for the same key. The old secret stops at once.

**Auth:** a session signed in within the last 15 minutes, with two-factor on or Google/Apple sign-in only.

**Path:** `id` (string (uuid)).

**200:** The key, with its new secret (once).

| Field | Type | Notes |
|---|---|---|
| `id` | string (uuid) |  |
| `kind` | `play` / `team` / `dash` / `prop` / `link` / `gw` |  |
| `label` | string |  |
| `prefix` | string | The public part of the key, e.g. gt_team_ab12cd34. Safe to show. |
| `gameId` | string (uuid) or null |  |
| `teamId` | string (uuid) or null |  |
| `status` | `active` / `paused` / `blocked` / `revoked` / `expired` |  |
| `createdAt` | string (date-time) | ISO 8601 time |
| `lastUsedAt` | string (date-time) or null | ISO 8601 time |
| `expiresAt` | string (date-time) or null | ISO 8601 time |
| `pausedUntil` (optional) | string (date-time) | Only while the key is paused. |
| `pausedReason` (optional) | string or null | Only while the key is paused. |
| `key` | string | The full key. Shown ONCE: store it now, it cannot be read again. |

**Errors:** [`key_blocked`](errors.md#key_blocked), [`key_not_found`](errors.md#key_not_found), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`reauth_required`](errors.md#reauth_required), [`unauthorized`](errors.md#unauthorized).

### Revoke a key

```http
DELETE /api/v1/keys/{id}
```

Your own key, or any key bound to a game you run as game master. Revoking twice is fine.

**Auth:** a signed-in session (cookie).

**Path:** `id` (string (uuid)).

**204:** Revoked.

**Errors:** [`key_not_found`](errors.md#key_not_found), [`unauthorized`](errors.md#unauthorized).

### What this key is

```http
GET /api/v1/whoami
```

**Auth:** any key; counts against the `read` budget.

**200:** The key behind the call.

| Field | Type | Notes |
|---|---|---|
| `keyId` | string (uuid) |  |
| `kind` | `play` / `team` / `dash` / `prop` / `link` / `gw` |  |
| `label` | string |  |
| `gameId` | string (uuid) or null |  |
| `teamId` | string (uuid) or null |  |

**Errors:** [`forbidden`](errors.md#forbidden), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`rate_limited`](errors.md#rate_limited).

## Player

Act as yourself in a game: a player key.

### What you see in the app

```http
GET /api/v1/play
```

Your own unit and status, and what your side sees: units, markers, drawings, orders, zones, the score as far as the game master shows it, and the events meant for your side. Never the game master view.

**Auth:** a play key (`gt_play_`); counts against the `read` budget.

**200:** Your view.

| Field | Type | Notes |
|---|---|---|
| `me` | object |  |
| `me.playerId` | string (uuid) |  |
| `me.callsign` | string |  |
| `me.role` | string or null |  |
| `me.platoon` | string or null |  |
| `me.squad` | string or null |  |
| `me.unit` | Entity or null | Your own live unit, or null when you are not reporting. |
| `game` | object |  |
| `game.id` | string (uuid) |  |
| `game.name` | string |  |
| `game.phase` | `draft` / `live` / `ended` |  |
| `game.paused` | boolean |  |
| `game.startedAt` | string (date-time) or null | ISO 8601 time |
| `game.endsAt` | string (date-time) or null | ISO 8601 time |
| `team` | object or null |  |
| `team.id` | string (uuid) |  |
| `team.name` | string |  |
| `team.color` | string | Hex colour, #rrggbb |
| `serverTime` | string (date-time) | ISO 8601 time |
| `scoreVisibility` | `full` / `own` / `none` | The game master's score setting. |
| `score` | array of object | Only the teams the score setting shows. |
| `score[].id` | string (uuid) |  |
| `score[].name` | string |  |
| `score[].color` | string | Hex colour, #rrggbb |
| `score[].points` | number |  |
| `zones` | array of object | Active zones this side can see. |
| `zones[].id` | string (uuid) |  |
| `zones[].name` | string |  |
| `zones[].ownerTeamId` | string (uuid) or null |  |
| `zones[].geometry` | object or null | GeoJSON geometry (Polygon, or Point with a radius); null for an indoor zone set by hand. |
| `zones[].geometry.type` | string |  |
| `zones[].geometry.coordinates` (optional) | any |  |
| `units` | array of Entity | Live units this side can see. |
| `lastKnown` | array of Entity | Units that went dark, as they were at their last fix. |
| `markers` | array of Marker |  |
| `graphics` | array of Graphic |  |
| `orders` | array of Order |  |
| `orderAcks` | array of object |  |
| `orderAcks[].orderUid` | string |  |
| `orderAcks[].by` | string |  |
| `orderAcks[].time` | integer |  |
| `events` | array of object | The latest 50 events meant for this side (never chat). |
| `events[].type` | string |  |
| `events[].at` | string (date-time) | ISO 8601 time |
| `events[].actor` | string or null |  |
| `events[].summary` | string or null |  |

**Errors:** [`device_key_scope`](errors.md#device_key_scope), [`forbidden`](errors.md#forbidden), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`no_side`](errors.md#no_side), [`not_in_game`](errors.md#not_in_game), [`rate_limited`](errors.md#rate_limited), [`wrong_key_kind`](errors.md#wrong_key_kind).

### Report your position

```http
POST /api/v1/play/position
```

**Auth:** a play key (`gt_play_`); counts against the `position` budget.

**Body:**

| Field | Type | Notes |
|---|---|---|
| `point` | GeoPoint |  |
| `speed` (optional) | number |  |
| `course` (optional) | number |  |
| `battery` (optional) | number |  |
| `intervalSec` (optional) | number |  |
| `mock` (optional) | boolean |  |
| `time` (optional) | integer | Ignored: the server stamps its own time. |

**202:** Accepted: published on your own live topic, through the same checks as your phone.

| Field | Type | Notes |
|---|---|---|
| `accepted` | `true` |  |

**Errors:** [`forbidden`](errors.md#forbidden), [`game_ended`](errors.md#game_ended), [`game_not_found`](errors.md#game_not_found), [`invalid_body`](errors.md#invalid_body), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`not_in_game`](errors.md#not_in_game), [`player_devices_off`](errors.md#player_devices_off), [`rate_limited`](errors.md#rate_limited), [`unavailable`](errors.md#unavailable), [`wrong_key_kind`](errors.md#wrong_key_kind).

### Report your status

```http
POST /api/v1/play/status
```

**Auth:** a play key (`gt_play_`); counts against the `status` budget.

**Body:**

| Field | Type | Notes |
|---|---|---|
| `status` | `alive` / `hit` / `down` / `medic` / `out` / `respawn` |  |

**202:** Accepted: published on your own live topic, through the same checks as your phone.

| Field | Type | Notes |
|---|---|---|
| `accepted` | `true` |  |

**Errors:** [`forbidden`](errors.md#forbidden), [`game_ended`](errors.md#game_ended), [`game_not_found`](errors.md#game_not_found), [`invalid_body`](errors.md#invalid_body), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`not_in_game`](errors.md#not_in_game), [`player_devices_off`](errors.md#player_devices_off), [`rate_limited`](errors.md#rate_limited), [`unavailable`](errors.md#unavailable), [`wrong_key_kind`](errors.md#wrong_key_kind).

### Raise an SOS

```http
POST /api/v1/play/sos
```

The same SOS as the app: one active per player, seen by everyone in the game, pushed to every phone.

**Auth:** a play key (`gt_play_`); counts against the `sos` budget.

**Body:**

| Field | Type | Notes |
|---|---|---|
| `point` | object |  |
| `point.lat` | number |  |
| `point.lon` | number |  |
| `approx` (optional) | boolean | true when the point is a guess; a fresh fix from the phone wins. |

**201:** The SOS is up.

| Field | Type | Notes |
|---|---|---|
| `uid` | string |  |
| `point` | GeoPoint |  |
| `time` | integer |  |

**Errors:** [`forbidden`](errors.md#forbidden), [`game_ended`](errors.md#game_ended), [`game_not_found`](errors.md#game_not_found), [`invalid_body`](errors.md#invalid_body), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`not_in_game`](errors.md#not_in_game), [`player_devices_off`](errors.md#player_devices_off), [`rate_limited`](errors.md#rate_limited), [`wrong_key_kind`](errors.md#wrong_key_kind).

### Clear your own SOS

```http
DELETE /api/v1/play/sos
```

**Auth:** a play key (`gt_play_`); counts against the `sos` budget.

**200:** How many of your SOS marks were cleared (0 is fine).

| Field | Type | Notes |
|---|---|---|
| `cleared` | integer |  |

**Errors:** [`forbidden`](errors.md#forbidden), [`game_ended`](errors.md#game_ended), [`game_not_found`](errors.md#game_not_found), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`not_in_game`](errors.md#not_in_game), [`player_devices_off`](errors.md#player_devices_off), [`rate_limited`](errors.md#rate_limited), [`wrong_key_kind`](errors.md#wrong_key_kind).

### WILCO an order

```http
POST /api/v1/play/orders/{uid}/ack
```

Only an order sent to you.

**Auth:** a play key (`gt_play_`); counts against the `wilco` budget.

**Path:** `uid` (string).

**204:** Acknowledged.

**Errors:** [`device_key_scope`](errors.md#device_key_scope), [`forbidden`](errors.md#forbidden), [`game_ended`](errors.md#game_ended), [`game_not_found`](errors.md#game_not_found), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`not_in_game`](errors.md#not_in_game), [`order_not_found`](errors.md#order_not_found), [`player_devices_off`](errors.md#player_devices_off), [`rate_limited`](errors.md#rate_limited), [`wrong_key_kind`](errors.md#wrong_key_kind).

### Place or update a mark

```http
POST /api/v1/play/marks
```

The game's marker rule decides who may; the mark belongs to your side.

**Auth:** a play key (`gt_play_`); counts against the `mark` budget.

**Body:**

| Field | Type | Notes |
|---|---|---|
| `uid` (optional) | string | Your own id, to update the same mark later. Made for you when left out. |
| `marker` | `enemy` / `friendly` / `objective` / `hazard` / `bomb` / `spot` / `rally` / `vehicle` / `building` / `box` / `fob` / `hq` / `medevac` / `waypoint` | An SOS has its own call. |
| `point` | object |  |
| `point.lat` | number |  |
| `point.lon` | number |  |
| `label` (optional) | string |  |
| `note` (optional) | string |  |
| `color` (optional) | string |  |
| `deadline` (optional) | integer | Epoch ms |

**201:** The mark as stored.

| Field | Type | Notes |
|---|---|---|
| `kind` | `marker` |  |
| `uid` | string |  |
| `marker` | `enemy` / `friendly` / `objective` / `hazard` / `bomb` / `spot` / `rally` / `vehicle` / `building` / `box` / `fob` / `hq` / `medevac` / `waypoint` / `sos` |  |
| `point` | GeoPoint |  |
| `sender` | string |  |
| `channel` | string |  |
| `teamId` (optional) | string or null |  |
| `label` (optional) | string |  |
| `note` (optional) | string |  |
| `color` (optional) | string |  |
| `sidc` (optional) | string |  |
| `time` | integer |  |
| `stale` | integer |  |
| `deadline` (optional) | integer |  |

**Errors:** [`device_key_scope`](errors.md#device_key_scope), [`forbidden`](errors.md#forbidden), [`game_ended`](errors.md#game_ended), [`game_not_found`](errors.md#game_not_found), [`invalid_body`](errors.md#invalid_body), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`marks_not_allowed`](errors.md#marks_not_allowed), [`mfa_required`](errors.md#mfa_required), [`no_side`](errors.md#no_side), [`not_in_game`](errors.md#not_in_game), [`not_your_mark`](errors.md#not_your_mark), [`player_devices_off`](errors.md#player_devices_off), [`rate_limited`](errors.md#rate_limited), [`wrong_key_kind`](errors.md#wrong_key_kind).

### Remove your own mark

```http
DELETE /api/v1/play/marks/{uid}
```

**Auth:** a play key (`gt_play_`); counts against the `mark` budget.

**Path:** `uid` (string).

**204:** Removed (or it was already gone).

**Errors:** [`device_key_scope`](errors.md#device_key_scope), [`forbidden`](errors.md#forbidden), [`game_ended`](errors.md#game_ended), [`game_not_found`](errors.md#game_not_found), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`marks_not_allowed`](errors.md#marks_not_allowed), [`mfa_required`](errors.md#mfa_required), [`no_side`](errors.md#no_side), [`not_in_game`](errors.md#not_in_game), [`not_your_mark`](errors.md#not_your_mark), [`player_devices_off`](errors.md#player_devices_off), [`rate_limited`](errors.md#rate_limited), [`wrong_key_kind`](errors.md#wrong_key_kind).

## Team

One team's commander view: a team key.

### One team's commander view

```http
GET /api/v1/team
```

Read-only, own team only. Carries live positions: not cached.

**Auth:** a team key (`gt_team_`); counts against the `read` budget.

**200:** The team view.

| Field | Type | Notes |
|---|---|---|
| `game` | object |  |
| `game.id` | string (uuid) |  |
| `game.name` | string |  |
| `game.phase` | `draft` / `live` / `ended` |  |
| `game.paused` | boolean |  |
| `game.startedAt` | string (date-time) or null | ISO 8601 time |
| `game.endsAt` | string (date-time) or null | ISO 8601 time |
| `team` | object or null |  |
| `team.id` | string (uuid) |  |
| `team.name` | string |  |
| `team.color` | string | Hex colour, #rrggbb |
| `serverTime` | string (date-time) | ISO 8601 time |
| `scoreVisibility` | `full` / `own` / `none` | The game master's score setting. |
| `score` | array of object | Only the teams the score setting shows. |
| `score[].id` | string (uuid) |  |
| `score[].name` | string |  |
| `score[].color` | string | Hex colour, #rrggbb |
| `score[].points` | number |  |
| `zones` | array of object | Active zones this side can see. |
| `zones[].id` | string (uuid) |  |
| `zones[].name` | string |  |
| `zones[].ownerTeamId` | string (uuid) or null |  |
| `zones[].geometry` | object or null | GeoJSON geometry (Polygon, or Point with a radius); null for an indoor zone set by hand. |
| `zones[].geometry.type` | string |  |
| `zones[].geometry.coordinates` (optional) | any |  |
| `units` | array of Entity | Live units this side can see. |
| `lastKnown` | array of Entity | Units that went dark, as they were at their last fix. |
| `markers` | array of Marker |  |
| `graphics` | array of Graphic |  |
| `orders` | array of Order |  |
| `orderAcks` | array of object |  |
| `orderAcks[].orderUid` | string |  |
| `orderAcks[].by` | string |  |
| `orderAcks[].time` | integer |  |
| `events` | array of object | The latest 50 events meant for this side (never chat). |
| `events[].type` | string |  |
| `events[].at` | string (date-time) | ISO 8601 time |
| `events[].actor` | string or null |  |
| `events[].summary` | string or null |  |

**Errors:** [`forbidden`](errors.md#forbidden), [`game_not_found`](errors.md#game_not_found), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`rate_limited`](errors.md#rate_limited), [`wrong_key_kind`](errors.md#wrong_key_kind).

## Dashboard

The spectator view: a dashboard key.

### The spectator dashboard

```http
GET /api/v1/dashboard
```

One shared snapshot per game, rebuilt at most every 5 seconds. A spectator link (gt_link_, made by the game master on the game page) reads the same.

**Auth:** a dashboard key (`gt_dash_`) or a spectator link key (`gt_link_`); counts against the `read` budget.

**200:** The dashboard.

| Field | Type | Notes |
|---|---|---|
| `game` | object |  |
| `game.id` | string (uuid) |  |
| `game.name` | string |  |
| `game.paused` | boolean |  |
| `game.startedAt` | string (date-time) or null | ISO 8601 time |
| `game.endsAt` | string (date-time) or null | ISO 8601 time |
| `game.phase` | `draft` / `live` / `ended` |  |
| `game.startsAt` | string (date-time) or null | ISO 8601 time |
| `serverTime` | string (date-time) | ISO 8601 time |
| `delayMin` | integer or null | null = live; else everything below is this many minutes old (the dashboard delay the game master set). |
| `asOf` | string (date-time) | The moment the picture shows: serverTime, or serverTime minus the delay. |
| `waitingUntil` | string (date-time) or null | Delayed, and no picture old enough yet: when there will be one. Score, zones and events are empty until then. |
| `scoreVisible` | boolean |  |
| `teams` | array of object |  |
| `teams[].id` | string (uuid) |  |
| `teams[].name` | string |  |
| `teams[].color` | string | Hex colour, #rrggbb |
| `teams[].points` | number or null | null while the score is hidden |
| `zones` | array of object |  |
| `zones[].id` | string (uuid) |  |
| `zones[].name` | string |  |
| `zones[].ownerTeamId` | string (uuid) or null |  |
| `effects` | array of object | Running UAVs and EMPs. |
| `effects[].kind` | `uav` / `emp` |  |
| `effects[].teamId` | string (uuid) | The side that fired it. |
| `effects[].targetTeamIds` | array of string (uuid) |  |
| `effects[].radiusM` | number or null | null = the whole side. Where the circle is never shows. |
| `effects[].leftSec` | integer | Seconds left at asOf; frozen while the game is paused. |
| `events` | array of object |  |
| `events[].type` | string |  |
| `events[].at` | string (date-time) | ISO 8601 time |
| `events[].summary` | string or null |  |
| `area` | array of any or null | [west, south, east, north] of the play area every side may see, to frame a map; null when the game has none. |
| `positions` | object or null | null unless the game master shows positions, and then only as they were delayMin minutes ago. |
| `positions.delayMin` | integer |  |
| `positions.asOf` | string (date-time) | ISO 8601 time |
| `positions.units` | array of object |  |
| `positions.units[].callsign` | string |  |
| `positions.units[].teamId` | string (uuid) or null |  |
| `positions.units[].point` | object |  |
| `positions.units[].at` | string (date-time) | ISO 8601 time |

**Errors:** [`forbidden`](errors.md#forbidden), [`game_not_found`](errors.md#game_not_found), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`rate_limited`](errors.md#rate_limited), [`wrong_key_kind`](errors.md#wrong_key_kind).

## Webhooks

Live events pushed to your server, signed: a team or dashboard key.

### Register a webhook

```http
POST /api/v1/webhooks
```

Every event this key may see is POSTed to the URL, signed with the secret in this answer (shown once). A team key hears its team's events, a dashboard key the dashboard's. At most 5 per key.

**Auth:** a team key (`gt_team_`) or a dashboard key (`gt_dash_`); counts against the `manage` budget.

**Body:**

| Field | Type | Notes |
|---|---|---|
| `url` | string | https:// on the public internet. Private and reserved addresses are refused. |
| `events` (optional) | array of string | Only these event types. Left out: every type the key may see. |

**201:** The webhook, with its secret (once).

| Field | Type | Notes |
|---|---|---|
| `id` | string (uuid) |  |
| `url` | string |  |
| `events` | array of string or null | The event types it asked for; null = every type the key may see. |
| `status` | `active` / `disabled` |  |
| `disabledReason` | string or null |  |
| `createdAt` | string (date-time) | ISO 8601 time |
| `secret` | string | whsec_…: signs every delivery. Shown only in this answer. |

**Errors:** [`forbidden`](errors.md#forbidden), [`invalid_body`](errors.md#invalid_body), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`rate_limited`](errors.md#rate_limited), [`url_not_allowed`](errors.md#url_not_allowed), [`webhook_limit`](errors.md#webhook_limit), [`wrong_key_kind`](errors.md#wrong_key_kind).

### This key's webhooks

```http
GET /api/v1/webhooks
```

**Auth:** a team key (`gt_team_`) or a dashboard key (`gt_dash_`); counts against the `manage` budget.

**200:** The webhooks, newest first. Never the secrets.

| Field | Type | Notes |
|---|---|---|
| `webhooks` | array of object |  |
| `webhooks[].id` | string (uuid) |  |
| `webhooks[].url` | string |  |
| `webhooks[].events` | array of string or null | The event types it asked for; null = every type the key may see. |
| `webhooks[].status` | `active` / `disabled` |  |
| `webhooks[].disabledReason` | string or null |  |
| `webhooks[].createdAt` | string (date-time) | ISO 8601 time |

**Errors:** [`forbidden`](errors.md#forbidden), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`rate_limited`](errors.md#rate_limited), [`wrong_key_kind`](errors.md#wrong_key_kind).

### Remove a webhook

```http
DELETE /api/v1/webhooks/{id}
```

Nothing more is sent to it, including retries. Removing twice is fine.

**Auth:** a team key (`gt_team_`) or a dashboard key (`gt_dash_`); counts against the `manage` budget.

**Path:** `id` (string (uuid)).

**204:** Removed.

**Errors:** [`forbidden`](errors.md#forbidden), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`rate_limited`](errors.md#rate_limited), [`webhook_not_found`](errors.md#webhook_not_found), [`wrong_key_kind`](errors.md#wrong_key_kind).

### The delivery log

```http
GET /api/v1/webhooks/{id}/deliveries
```

The latest 50 deliveries, newest first, with each attempt's outcome. Kept for 14 days.

**Auth:** a team key (`gt_team_`) or a dashboard key (`gt_dash_`); counts against the `manage` budget.

**Path:** `id` (string (uuid)).

**200:** The deliveries.

| Field | Type | Notes |
|---|---|---|
| `deliveries` | array of object |  |
| `deliveries[].id` | string (uuid) |  |
| `deliveries[].eventType` | string |  |
| `deliveries[].status` | `pending` / `delivered` / `failed` |  |
| `deliveries[].attempts` | integer |  |
| `deliveries[].lastStatus` | integer or null | Your server's HTTP status on the last attempt; null when it could not be reached. |
| `deliveries[].lastError` | string or null |  |
| `deliveries[].createdAt` | string (date-time) | ISO 8601 time |
| `deliveries[].deliveredAt` | string (date-time) or null | ISO 8601 time |
| `deliveries[].nextAttemptAt` | string (date-time) or null | When a pending delivery is tried again. |

**Errors:** [`forbidden`](errors.md#forbidden), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`rate_limited`](errors.md#rate_limited), [`webhook_not_found`](errors.md#webhook_not_found), [`wrong_key_kind`](errors.md#wrong_key_kind).

### Send a test delivery

```http
POST /api/v1/webhooks/{id}/ping
```

A `ping` event, signed like any other, to check your receiver.

**Auth:** a team key (`gt_team_`) or a dashboard key (`gt_dash_`); counts against the `manage` budget.

**Path:** `id` (string (uuid)).

**202:** Queued; it shows in the delivery log.

| Field | Type | Notes |
|---|---|---|
| `deliveryId` | string (uuid) |  |

**Errors:** [`forbidden`](errors.md#forbidden), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`rate_limited`](errors.md#rate_limited), [`webhook_not_found`](errors.md#webhook_not_found), [`wrong_key_kind`](errors.md#wrong_key_kind).

## Devices

Pair beacons and props, lend club devices, take them back.

### Start pairing from the device

```http
POST /api/v1/devices/announce
```

For a device with internet and a display (RFC 8628 device authorization). Show userCode on the device; keep deviceCode secret and poll POST /api/v1/devices/token every `interval` seconds until the owner has typed the code in GridTac.

**Auth:** none.

**Body:**

| Field | Type | Notes |
|---|---|---|
| `kind` | `beacon` / `prop` / `gateway` | A gateway is a LoRa radio that forwards beacons and props to GridTac (from 1.8, BETA). |
| `model` | string | vendor.model, as in its GT-Link manifest. |
| `fw` | string |  |

**201:** The codes.

| Field | Type | Notes |
|---|---|---|
| `userCode` | string | ABCD-EFGH, for the display. |
| `deviceCode` | string | Secret: only for polling. |
| `expiresIn` | integer |  |
| `interval` | integer |  |

**Errors:** [`invalid_body`](errors.md#invalid_body), [`rate_limited`](errors.md#rate_limited).

### Poll for the device key

```http
POST /api/v1/devices/token
```

From the device, with its deviceCode. 202 while the owner has not typed the code yet; 200 once, with the device id and its key; after that the pairing is gone.

**Auth:** none.

**Body:**

| Field | Type | Notes |
|---|---|---|
| `deviceCode` | string |  |

**200:** Paired: the device id and its own key (once).

| Field | Type | Notes |
|---|---|---|
| `deviceId` | string |  |
| `key` | string |  |

**202:** Not yet: poll again after `interval` seconds.

| Field | Type | Notes |
|---|---|---|
| `status` | `pending` |  |
| `interval` | integer |  |

**Errors:** [`invalid_body`](errors.md#invalid_body), [`pairing_expired`](errors.md#pairing_expired), [`pairing_not_found`](errors.md#pairing_not_found), [`rate_limited`](errors.md#rate_limited).

### Type in the code a device shows

```http
POST /api/v1/devices/approve
```

Signed in. Makes the device yours, or your club's when you manage it. No two-factor needed: a device never does more than the account that paired it.

**Auth:** a signed-in session (cookie).

**Body:**

| Field | Type | Notes |
|---|---|---|
| `userCode` | string | The code the device shows, with or without the dash. |
| `label` | string |  |
| `clubId` (optional) | string (uuid) | Register it as this club's (you must manage the club); left out, it is yours. |

**201:** The device; it receives its key on its next poll.

| Field | Type | Notes |
|---|---|---|
| `id` | string | dev_…: the opaque id the device uses in its topics. |
| `kind` | `beacon` / `prop` / `gateway` | A gateway is a LoRa radio that forwards beacons and props to GridTac (from 1.8, BETA). |
| `label` | string |  |
| `model` | string or null |  |
| `fw` | string or null |  |
| `owner` | object |  |
| `owner.kind` | `player` / `club` |  |
| `owner.clubId` | string (uuid) or null |  |
| `owner.clubName` | string or null |  |
| `assignment` | object or null | Who uses it in which game right now; null when it is with its owner. |
| `assignment.gameId` | string (uuid) |  |
| `assignment.gameName` | string |  |
| `assignment.playerId` | string (uuid) or null |  |
| `assignment.callsign` | string or null |  |
| `assignment.since` | string (date-time) | ISO 8601 time |
| `assignment.accepted` | boolean | False while a loan waits for the player to accept it; the device's key does nothing until then. |
| `radioAddr` | string or null | A LoRa device: its 4-byte radio address as 8 hex digits, the addr in its frame headers. Write it into the device with its key. Null for a device without a radio key. |
| `status` | `active` / `revoked` |  |
| `online` | boolean | A prop or gateway connected over MQTT right now (its last will says when it drops). Always false for a beacon, which only posts. |
| `battery` | number or null | Battery percent from the latest telemetry, or null. |
| `lastSeenAt` | string (date-time) or null | ISO 8601 time |
| `createdAt` | string (date-time) | ISO 8601 time |

**Errors:** [`device_limit`](errors.md#device_limit), [`forbidden`](errors.md#forbidden), [`invalid_body`](errors.md#invalid_body), [`pairing_expired`](errors.md#pairing_expired), [`pairing_not_found`](errors.md#pairing_not_found), [`rate_limited`](errors.md#rate_limited), [`too_many_devices`](errors.md#too_many_devices), [`unauthorized`](errors.md#unauthorized).

### Register a device through the phone (BLE)

```http
POST /api/v1/devices
```

For a LoRa-only or display-less device the app has proved it stands next to (a code on its display, or a held button and a matching blink pattern). The app writes the returned id and key back over BLE.

**Auth:** a signed-in session (cookie).

**Body:**

| Field | Type | Notes |
|---|---|---|
| `kind` | `beacon` / `prop` / `gateway` | A gateway is a LoRa radio that forwards beacons and props to GridTac (from 1.8, BETA). |
| `model` | string |  |
| `fw` | string |  |
| `label` | string |  |
| `clubId` (optional) | string (uuid) |  |
| `radioKey` (optional) | string | A LoRa prop's or beacon's own 16-byte AEAD key, base64, read from the device over BLE or USB. Stored encrypted; never given out again. The answer's radioAddr is the address the device then uses. |

**201:** The device with its key (once).

| Field | Type | Notes |
|---|---|---|
| `id` | string | dev_…: the opaque id the device uses in its topics. |
| `kind` | `beacon` / `prop` / `gateway` | A gateway is a LoRa radio that forwards beacons and props to GridTac (from 1.8, BETA). |
| `label` | string |  |
| `model` | string or null |  |
| `fw` | string or null |  |
| `owner` | object |  |
| `owner.kind` | `player` / `club` |  |
| `owner.clubId` | string (uuid) or null |  |
| `owner.clubName` | string or null |  |
| `assignment` | object or null | Who uses it in which game right now; null when it is with its owner. |
| `assignment.gameId` | string (uuid) |  |
| `assignment.gameName` | string |  |
| `assignment.playerId` | string (uuid) or null |  |
| `assignment.callsign` | string or null |  |
| `assignment.since` | string (date-time) | ISO 8601 time |
| `assignment.accepted` | boolean | False while a loan waits for the player to accept it; the device's key does nothing until then. |
| `radioAddr` | string or null | A LoRa device: its 4-byte radio address as 8 hex digits, the addr in its frame headers. Write it into the device with its key. Null for a device without a radio key. |
| `status` | `active` / `revoked` |  |
| `online` | boolean | A prop or gateway connected over MQTT right now (its last will says when it drops). Always false for a beacon, which only posts. |
| `battery` | number or null | Battery percent from the latest telemetry, or null. |
| `lastSeenAt` | string (date-time) or null | ISO 8601 time |
| `createdAt` | string (date-time) | ISO 8601 time |
| `key` | string or null | Its own key (gt_play_ for a beacon, gt_prop_ for a prop, gt_gw_ for a gateway). Shown only in this answer; write it into the device and nowhere else. |

**Errors:** [`device_limit`](errors.md#device_limit), [`forbidden`](errors.md#forbidden), [`invalid_body`](errors.md#invalid_body), [`too_many_devices`](errors.md#too_many_devices), [`unauthorized`](errors.md#unauthorized).

### Your devices and your clubs'

```http
GET /api/v1/devices
```

Yours, and those of every club you manage. Never their keys. A loan whose game has ended is shown as back with its owner. `loans` are beacons someone else lends to you; one with `accepted: false` waits for your answer.

**Auth:** a signed-in session (cookie).

**200:** The devices.

| Field | Type | Notes |
|---|---|---|
| `devices` | array of object |  |
| `devices[].id` | string | dev_…: the opaque id the device uses in its topics. |
| `devices[].kind` | `beacon` / `prop` / `gateway` | A gateway is a LoRa radio that forwards beacons and props to GridTac (from 1.8, BETA). |
| `devices[].label` | string |  |
| `devices[].model` | string or null |  |
| `devices[].fw` | string or null |  |
| `devices[].owner` | object |  |
| `devices[].owner.kind` | `player` / `club` |  |
| `devices[].owner.clubId` | string (uuid) or null |  |
| `devices[].owner.clubName` | string or null |  |
| `devices[].assignment` | object or null | Who uses it in which game right now; null when it is with its owner. |
| `devices[].assignment.gameId` | string (uuid) |  |
| `devices[].assignment.gameName` | string |  |
| `devices[].assignment.playerId` | string (uuid) or null |  |
| `devices[].assignment.callsign` | string or null |  |
| `devices[].assignment.since` | string (date-time) | ISO 8601 time |
| `devices[].assignment.accepted` | boolean | False while a loan waits for the player to accept it; the device's key does nothing until then. |
| `devices[].radioAddr` | string or null | A LoRa device: its 4-byte radio address as 8 hex digits, the addr in its frame headers. Write it into the device with its key. Null for a device without a radio key. |
| `devices[].status` | `active` / `revoked` |  |
| `devices[].online` | boolean | A prop or gateway connected over MQTT right now (its last will says when it drops). Always false for a beacon, which only posts. |
| `devices[].battery` | number or null | Battery percent from the latest telemetry, or null. |
| `devices[].lastSeenAt` | string (date-time) or null | ISO 8601 time |
| `devices[].createdAt` | string (date-time) | ISO 8601 time |
| `loans` | array of object |  |
| `loans[].id` | string | dev_…: the opaque id the device uses in its topics. |
| `loans[].kind` | `beacon` / `prop` / `gateway` | A gateway is a LoRa radio that forwards beacons and props to GridTac (from 1.8, BETA). |
| `loans[].label` | string |  |
| `loans[].model` | string or null |  |
| `loans[].fw` | string or null |  |
| `loans[].owner` | object |  |
| `loans[].owner.kind` | `player` / `club` |  |
| `loans[].owner.clubId` | string (uuid) or null |  |
| `loans[].owner.clubName` | string or null |  |
| `loans[].assignment` | object or null | Who uses it in which game right now; null when it is with its owner. |
| `loans[].assignment.gameId` | string (uuid) |  |
| `loans[].assignment.gameName` | string |  |
| `loans[].assignment.playerId` | string (uuid) or null |  |
| `loans[].assignment.callsign` | string or null |  |
| `loans[].assignment.since` | string (date-time) | ISO 8601 time |
| `loans[].assignment.accepted` | boolean | False while a loan waits for the player to accept it; the device's key does nothing until then. |
| `loans[].radioAddr` | string or null | A LoRa device: its 4-byte radio address as 8 hex digits, the addr in its frame headers. Write it into the device with its key. Null for a device without a radio key. |
| `loans[].status` | `active` / `revoked` |  |
| `loans[].online` | boolean | A prop or gateway connected over MQTT right now (its last will says when it drops). Always false for a beacon, which only posts. |
| `loans[].battery` | number or null | Battery percent from the latest telemetry, or null. |
| `loans[].lastSeenAt` | string (date-time) or null | ISO 8601 time |
| `loans[].createdAt` | string (date-time) | ISO 8601 time |

**Errors:** [`unauthorized`](errors.md#unauthorized).

### Use a device in a game

```http
POST /api/v1/devices/{id}/assign
```

A beacon: yours for yourself, or your club's lent to a member who plays in that game. A loan to someone other than you waits for them to accept it in their own app (`assignment.accepted: false`); until then the beacon's key does nothing. A prop: into a game you run as game master. Ends any earlier assignment; a loan returns to the club when the game ends.

**Auth:** a signed-in session (cookie).

**Path:** `id` (string).

**Body:**

| Field | Type | Notes |
|---|---|---|
| `gameId` | string (uuid) |  |
| `playerId` (optional) | string (uuid) | Beacons: who carries it. Left out for your own beacon: you. |

**200:** The device, assigned.

| Field | Type | Notes |
|---|---|---|
| `id` | string | dev_…: the opaque id the device uses in its topics. |
| `kind` | `beacon` / `prop` / `gateway` | A gateway is a LoRa radio that forwards beacons and props to GridTac (from 1.8, BETA). |
| `label` | string |  |
| `model` | string or null |  |
| `fw` | string or null |  |
| `owner` | object |  |
| `owner.kind` | `player` / `club` |  |
| `owner.clubId` | string (uuid) or null |  |
| `owner.clubName` | string or null |  |
| `assignment` | object or null | Who uses it in which game right now; null when it is with its owner. |
| `assignment.gameId` | string (uuid) |  |
| `assignment.gameName` | string |  |
| `assignment.playerId` | string (uuid) or null |  |
| `assignment.callsign` | string or null |  |
| `assignment.since` | string (date-time) | ISO 8601 time |
| `assignment.accepted` | boolean | False while a loan waits for the player to accept it; the device's key does nothing until then. |
| `radioAddr` | string or null | A LoRa device: its 4-byte radio address as 8 hex digits, the addr in its frame headers. Write it into the device with its key. Null for a device without a radio key. |
| `status` | `active` / `revoked` |  |
| `online` | boolean | A prop or gateway connected over MQTT right now (its last will says when it drops). Always false for a beacon, which only posts. |
| `battery` | number or null | Battery percent from the latest telemetry, or null. |
| `lastSeenAt` | string (date-time) or null | ISO 8601 time |
| `createdAt` | string (date-time) | ISO 8601 time |

**Errors:** [`beacon_limit`](errors.md#beacon_limit), [`device_not_found`](errors.md#device_not_found), [`forbidden`](errors.md#forbidden), [`game_device_limit`](errors.md#game_device_limit), [`game_ended`](errors.md#game_ended), [`game_not_found`](errors.md#game_not_found), [`invalid_body`](errors.md#invalid_body), [`not_in_game`](errors.md#not_in_game), [`not_your_player`](errors.md#not_your_player), [`unauthorized`](errors.md#unauthorized).

### Accept a beacon lent to you

```http
POST /api/v1/devices/{id}/accept
```

Only the player it is lent to, on their own session. From then on the beacon reports for you in that game.

**Auth:** a signed-in session (cookie).

**Path:** `id` (string).

**200:** The device, now in use by you.

| Field | Type | Notes |
|---|---|---|
| `id` | string | dev_…: the opaque id the device uses in its topics. |
| `kind` | `beacon` / `prop` / `gateway` | A gateway is a LoRa radio that forwards beacons and props to GridTac (from 1.8, BETA). |
| `label` | string |  |
| `model` | string or null |  |
| `fw` | string or null |  |
| `owner` | object |  |
| `owner.kind` | `player` / `club` |  |
| `owner.clubId` | string (uuid) or null |  |
| `owner.clubName` | string or null |  |
| `assignment` | object or null | Who uses it in which game right now; null when it is with its owner. |
| `assignment.gameId` | string (uuid) |  |
| `assignment.gameName` | string |  |
| `assignment.playerId` | string (uuid) or null |  |
| `assignment.callsign` | string or null |  |
| `assignment.since` | string (date-time) | ISO 8601 time |
| `assignment.accepted` | boolean | False while a loan waits for the player to accept it; the device's key does nothing until then. |
| `radioAddr` | string or null | A LoRa device: its 4-byte radio address as 8 hex digits, the addr in its frame headers. Write it into the device with its key. Null for a device without a radio key. |
| `status` | `active` / `revoked` |  |
| `online` | boolean | A prop or gateway connected over MQTT right now (its last will says when it drops). Always false for a beacon, which only posts. |
| `battery` | number or null | Battery percent from the latest telemetry, or null. |
| `lastSeenAt` | string (date-time) or null | ISO 8601 time |
| `createdAt` | string (date-time) | ISO 8601 time |

**Errors:** [`device_not_found`](errors.md#device_not_found), [`unauthorized`](errors.md#unauthorized).

### Decline a beacon lent to you

```http
POST /api/v1/devices/{id}/decline
```

Only the player it is lent to. The loan ends and the beacon goes back to its owner.

**Auth:** a signed-in session (cookie).

**Path:** `id` (string).

**200:** The device, back with its owner.

| Field | Type | Notes |
|---|---|---|
| `id` | string | dev_…: the opaque id the device uses in its topics. |
| `kind` | `beacon` / `prop` / `gateway` | A gateway is a LoRa radio that forwards beacons and props to GridTac (from 1.8, BETA). |
| `label` | string |  |
| `model` | string or null |  |
| `fw` | string or null |  |
| `owner` | object |  |
| `owner.kind` | `player` / `club` |  |
| `owner.clubId` | string (uuid) or null |  |
| `owner.clubName` | string or null |  |
| `assignment` | object or null | Who uses it in which game right now; null when it is with its owner. |
| `assignment.gameId` | string (uuid) |  |
| `assignment.gameName` | string |  |
| `assignment.playerId` | string (uuid) or null |  |
| `assignment.callsign` | string or null |  |
| `assignment.since` | string (date-time) | ISO 8601 time |
| `assignment.accepted` | boolean | False while a loan waits for the player to accept it; the device's key does nothing until then. |
| `radioAddr` | string or null | A LoRa device: its 4-byte radio address as 8 hex digits, the addr in its frame headers. Write it into the device with its key. Null for a device without a radio key. |
| `status` | `active` / `revoked` |  |
| `online` | boolean | A prop or gateway connected over MQTT right now (its last will says when it drops). Always false for a beacon, which only posts. |
| `battery` | number or null | Battery percent from the latest telemetry, or null. |
| `lastSeenAt` | string (date-time) or null | ISO 8601 time |
| `createdAt` | string (date-time) | ISO 8601 time |

**Errors:** [`device_not_found`](errors.md#device_not_found), [`unauthorized`](errors.md#unauthorized).

### Take a device back

```http
POST /api/v1/devices/{id}/return
```

By its owner, a manager of the owning club, the player who has it (that is how you withdraw a loan you accepted), or for a prop the game master of the game it plays in. Its key stops acting in the game at once.

**Auth:** a signed-in session (cookie).

**Path:** `id` (string).

**200:** The device, back with its owner.

| Field | Type | Notes |
|---|---|---|
| `id` | string | dev_…: the opaque id the device uses in its topics. |
| `kind` | `beacon` / `prop` / `gateway` | A gateway is a LoRa radio that forwards beacons and props to GridTac (from 1.8, BETA). |
| `label` | string |  |
| `model` | string or null |  |
| `fw` | string or null |  |
| `owner` | object |  |
| `owner.kind` | `player` / `club` |  |
| `owner.clubId` | string (uuid) or null |  |
| `owner.clubName` | string or null |  |
| `assignment` | object or null | Who uses it in which game right now; null when it is with its owner. |
| `assignment.gameId` | string (uuid) |  |
| `assignment.gameName` | string |  |
| `assignment.playerId` | string (uuid) or null |  |
| `assignment.callsign` | string or null |  |
| `assignment.since` | string (date-time) | ISO 8601 time |
| `assignment.accepted` | boolean | False while a loan waits for the player to accept it; the device's key does nothing until then. |
| `radioAddr` | string or null | A LoRa device: its 4-byte radio address as 8 hex digits, the addr in its frame headers. Write it into the device with its key. Null for a device without a radio key. |
| `status` | `active` / `revoked` |  |
| `online` | boolean | A prop or gateway connected over MQTT right now (its last will says when it drops). Always false for a beacon, which only posts. |
| `battery` | number or null | Battery percent from the latest telemetry, or null. |
| `lastSeenAt` | string (date-time) or null | ISO 8601 time |
| `createdAt` | string (date-time) | ISO 8601 time |

**Errors:** [`device_not_found`](errors.md#device_not_found), [`unauthorized`](errors.md#unauthorized).

### Unpair a device

```http
DELETE /api/v1/devices/{id}
```

Its key stops at once and it leaves any game. Pair it again to use it. Revoking twice is fine.

**Auth:** a signed-in session (cookie).

**Path:** `id` (string).

**204:** Unpaired.

**Errors:** [`device_not_found`](errors.md#device_not_found), [`unauthorized`](errors.md#unauthorized).

### A prop's MQTT credentials

```http
POST /api/v1/prop/mqtt-credentials
```

With its own prop key. A JWT for the broker that lets the prop publish only under gridtac/dev/<its id>/ (hello, evt, state, tele, ack, lwt) and subscribe only to its cmd and game topics. Fetch a new one before expiresAt.

**Auth:** a prop key (`gt_prop_`); counts against the `read` budget.

**200:** The credentials.

| Field | Type | Notes |
|---|---|---|
| `deviceId` | string |  |
| `username` | string |  |
| `token` | string | The MQTT password. |
| `expiresAt` | integer |  |
| `topics` | object |  |
| `topics.publish` | object |  |
| `topics.subscribe` | object |  |

**Errors:** [`device_not_found`](errors.md#device_not_found), [`forbidden`](errors.md#forbidden), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`rate_limited`](errors.md#rate_limited), [`wrong_key_kind`](errors.md#wrong_key_kind).

### A gateway's MQTT credentials

```http
POST /api/v1/gw/mqtt-credentials
```

BETA, from 1.8. With its own gateway key (gt_gw_). A JWT for the broker that lets the gateway publish only gridtac/gw/<its id>/up, tele and lwt, and subscribe only to its down topic. A gateway carries the encrypted frames of other devices and holds none of their keys. Fetch a new one before expiresAt.

**Auth:** a gateway key (`gt_gw_`); counts against the `read` budget.

**200:** The credentials.

| Field | Type | Notes |
|---|---|---|
| `deviceId` | string | dev_…: the gateway id in its topics. |
| `username` | string |  |
| `token` | string | The MQTT password. |
| `expiresAt` | integer |  |
| `topics` | object |  |
| `topics.publish` | object |  |
| `topics.subscribe` | object |  |

**Errors:** [`device_not_found`](errors.md#device_not_found), [`forbidden`](errors.md#forbidden), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`rate_limited`](errors.md#rate_limited), [`wrong_key_kind`](errors.md#wrong_key_kind).

### A prop's events over HTTPS

```http
POST /api/v1/prop/events
```

The fallback for a sleepy or simple prop: input events (deduplicated on boot and seq, so a retry is safe), with its state or telemetry so the server can date queued events. The answer carries the commands waiting for it and the game clock.

**Auth:** a prop key (`gt_prop_`); counts against the `event` budget.

**Body:**

| Field | Type | Notes |
|---|---|---|
| `evts` | array of object |  |
| `evts[].b` | integer | Boot counter, stored in flash and incremented on every start. |
| `evts[].s` | integer | Sequence number within this boot, from 0. |
| `evts[].ms` | integer | Milliseconds since boot: the device has no trusted clock (ADR 0007 section 5). |
| `evts[].c` | string | Capability id. |
| `evts[].e` | string | Event: press, hold, release, set, code, tag, tripped, cleared, moved, still, hit, value. |
| `evts[].x` (optional) | number or string | Value: hold ms, switch position, code, tag uid, hit strength, analog value. |
| `evts[].z` (optional) | string | Zone of a hit. |
| `state` (optional) | object |  |
| `state.b` | integer | Boot counter, stored in flash and incremented on every start. |
| `state.s` | integer | Sequence number within this boot, from 0. |
| `state.ms` | integer | Milliseconds since boot: the device has no trusted clock (ADR 0007 section 5). |
| `state.st` | object |  |
| `state.st.own` (optional) | integer or null | Owner: team slot 0-3, null = neutral. |
| `state.st.pr` (optional) | number | Progress 0-1 (a capture in progress). |
| `state.st.mo` (optional) | string | Mode it runs. |
| `tele` (optional) | object |  |
| `tele.b` | integer | Boot counter, stored in flash and incremented on every start. |
| `tele.s` | integer | Sequence number within this boot, from 0. |
| `tele.ms` | integer | Milliseconds since boot: the device has no trusted clock (ADR 0007 section 5). |
| `tele.bat` (optional) | object |  |
| `tele.bat.v` (optional) | number |  |
| `tele.bat.pct` (optional) | number |  |
| `tele.rssi` (optional) | number |  |
| `tele.snr` (optional) | number |  |
| `tele.gps` (optional) | object |  |
| `tele.gps.la` | number |  |
| `tele.gps.lo` | number |  |
| `tele.gps.acc` (optional) | number |  |
| `tele.up` (optional) | integer |  |

**200:** Taken.

| Field | Type | Notes |
|---|---|---|
| `accepted` | integer |  |
| `cmds` | array of object or object or object or object or object or object |  |
| `cmds[].id` | string | Command id; the device echoes it in its ack. |
| `cmds[].k` | `config` |  |
| `cmds[].mo` (optional) | string |  |
| `cmds[].set` (optional) | object | Mode settings: teams per colour, hold time, volume. |
| `game` | object |  |
| `game.v` | `1` |  |
| `game.g` | string or null | Game id; null when not assigned (the device shows "not in a game"). |
| `game.ph` | `draft` / `scheduled` / `live` / `paused` / `ended` | Phase. |
| `game.srv` | integer | Server time, epoch ms. |
| `game.sa` (optional) | integer or null | Scheduled kickoff. |
| `game.ea` (optional) | integer or null | Scheduled or set ENDEX. |
| `game.tm` (optional) | array of object |  |
| `game.tm[].id` | string |  |
| `game.tm[].l` | string |  |
| `game.tm[].ea` | integer |  |
| `game.tm[].phy` (optional) | boolean |  |
| `game.pa` (optional) | integer or null | Paused at, or null. |

**Errors:** [`device_not_found`](errors.md#device_not_found), [`forbidden`](errors.md#forbidden), [`invalid_body`](errors.md#invalid_body), [`invalid_key`](errors.md#invalid_key), [`key_blocked`](errors.md#key_blocked), [`key_expired`](errors.md#key_expired), [`key_owner_lost`](errors.md#key_owner_lost), [`key_paused`](errors.md#key_paused), [`key_required`](errors.md#key_required), [`key_revoked`](errors.md#key_revoked), [`mfa_required`](errors.md#mfa_required), [`rate_limited`](errors.md#rate_limited), [`wrong_key_kind`](errors.md#wrong_key_kind).

## Shared types

### ApiKey

An API key as its owner sees it. Never the secret, except once in the create and rotate answers.

| Field | Type | Notes |
|---|---|---|
| `id` | string (uuid) |  |
| `kind` | `play` / `team` / `dash` / `prop` / `link` / `gw` |  |
| `label` | string |  |
| `prefix` | string | The public part of the key, e.g. gt_team_ab12cd34. Safe to show. |
| `gameId` | string (uuid) or null |  |
| `teamId` | string (uuid) or null |  |
| `status` | `active` / `paused` / `blocked` / `revoked` / `expired` |  |
| `createdAt` | string (date-time) | ISO 8601 time |
| `lastUsedAt` | string (date-time) or null | ISO 8601 time |
| `expiresAt` | string (date-time) or null | ISO 8601 time |
| `pausedUntil` (optional) | string (date-time) | Only while the key is paused. |
| `pausedReason` (optional) | string or null | Only while the key is paused. |

### Entity

| Field | Type | Notes |
|---|---|---|
| `uid` | string |  |
| `affiliation` | `friend` / `hostile` / `neutral` / `unknown` |  |
| `callsign` | string |  |
| `team` (optional) | string |  |
| `squad` (optional) | string |  |
| `point` | GeoPoint |  |
| `status` (optional) | `alive` / `hit` / `down` / `medic` / `out` / `respawn` |  |
| `battery` (optional) | number |  |
| `speed` (optional) | number |  |
| `course` (optional) | number |  |
| `src` (optional) | `beacon` |  |
| `time` | integer |  |
| `stale` | integer |  |

### GeoPoint

| Field | Type | Notes |
|---|---|---|
| `lat` | number |  |
| `lon` | number |  |
| `hae` (optional) | number |  |
| `ce` (optional) | number |  |
| `le` (optional) | number |  |

### Graphic

| Field | Type | Notes |
|---|---|---|
| `kind` | `graphic` |  |
| `uid` | string |  |
| `shape` | `line` / `area` / `arrow` / `circle` |  |
| `points` | array of GeoPoint |  |
| `radius` (optional) | number |  |
| `sender` | string |  |
| `channel` | string |  |
| `teamId` (optional) | string or null |  |
| `label` (optional) | string |  |
| `color` (optional) | string |  |
| `time` | integer |  |
| `stale` | integer |  |

### Marker

| Field | Type | Notes |
|---|---|---|
| `kind` | `marker` |  |
| `uid` | string |  |
| `marker` | `enemy` / `friendly` / `objective` / `hazard` / `bomb` / `spot` / `rally` / `vehicle` / `building` / `box` / `fob` / `hq` / `medevac` / `waypoint` / `sos` |  |
| `point` | GeoPoint |  |
| `sender` | string |  |
| `channel` | string |  |
| `teamId` (optional) | string or null |  |
| `label` (optional) | string |  |
| `note` (optional) | string |  |
| `color` (optional) | string |  |
| `sidc` (optional) | string |  |
| `svg` (optional) | string |  |
| `time` | integer |  |
| `stale` | integer |  |
| `deadline` (optional) | integer |  |

### Order

| Field | Type | Notes |
|---|---|---|
| `kind` | `order` |  |
| `uid` | string |  |
| `sender` | string |  |
| `channel` | string |  |
| `orderType` | `move` / `waypoint` / `hold` / `rally` / `attack` / `recon` / `support` |  |
| `point` (optional) | GeoPoint |  |
| `waypoints` (optional) | array of GeoPoint |  |
| `text` (optional) | string |  |
| `time` | integer |  |
| `stale` | integer |  |
| `deadline` (optional) | integer |  |

### Problem

RFC 9457 problem details, sent as application/problem+json.

| Field | Type | Notes |
|---|---|---|
| `type` | string (uri) | A link to this code on the errors page. |
| `title` | string | For people; may be reworded. |
| `status` | integer |  |
| `detail` (optional) | string | For people; may be reworded. |
| `code` | string | Stable machine code: branch on this. |
| `retryAfterSec` (optional) | integer or null | Seconds until a retry can work (rate limits, pauses). |
| `issues` (optional) | array of object | invalid_body only: each problem with the request body. |
| `issues[].path` | string |  |
| `issues[].message` | string |  |
