---
title: Authentication and API keys
section: API
order: 1
---

# Authentication and API keys

The GridTac API (`https://api.gridtac.com/api/v1`) is for scripts, dashboards, bots and devices
that work with a game. Every call carries an **API key**:

```http
GET /api/v1/whoami
Authorization: Bearer gt_dash_k7q2m9x4h3pd_Zx81…
```

## Who can create keys

Keys are made on [gridtac.com](https://gridtac.com) under **API & hardware → API keys** in the account menu, top right (or with
`POST /api/v1/keys`, below). Spectator links are the exception: the game master makes those in the
game's settings.

You create keys while signed in to GridTac, on an account that has **two-factor authentication
turned on, or that signs in only with Google or Apple**. An account with a password and no
two-factor cannot create keys, and if two-factor is later turned off, that account's keys stop
working until it is turned back on. Creating or rotating a key also needs a sign-in from the last
15 minutes.

## Kinds of key

A key belongs to one game and does one job. The kind is part of the key, so you can tell what a
leaked key could do just by reading it.

| Kind | Prefix | What it is for | Who creates it | Sees |
|---|---|---|---|---|
| Player | `gt_play_` | Your own device or script in a game you play in | You, in that game | What you see in the app |
| Team | `gt_team_` | A team's own board or bot | The game master (any team) or that team's commander (own team) | What that team's commander sees |
| Dashboard | `gt_dash_` | A spectator screen | The game master | Score, zones, phase and clock; no positions unless the GM allows them with a delay |
| Prop | `gt_prop_` | A device in the game (a domination box, a beacon) | Issued when the device is paired, not created by hand | Only its own commands |
| Spectator link | `gt_link_` | A screen with no account: gridtac.com/watch#gt_link_… | The game master, in the game's settings (Map permissions) | Exactly what a dashboard key sees ([Spectator link](dashboard.md#spectator-link)) |

There is no key that sees everything. A key never sees more than the person it stands for.

Team and dashboard keys and spectator links stop working 24 hours after their game ends. Player keys work until you
revoke them.

## Managing keys

These calls use your normal signed-in session, not an API key.

| Call | What it does |
|---|---|
| `POST /api/v1/keys` `{ kind, label, gameId, teamId? }` | Creates a key. **The response is the only time you see the full key**; store it somewhere safe. |
| `GET /api/v1/keys` | Your keys, shown by prefix and status (`active`, `paused`, `revoked`, `blocked`, `expired`), never their secret. |
| `POST /api/v1/keys/{id}/rotate` | A new secret for the same key. The old secret stops working at once. |
| `DELETE /api/v1/keys/{id}` | Revokes the key. A game master can also revoke keys bound to their game, spectator links included: the game's settings list every key bound to it (who made it, for which side, when it was last used). |

**A key follows its maker's place in the game.** It is checked again on every call, and in every
webhook delivery: a team key works while its maker is the game master or that team's commander, a
dashboard key while its maker is a game master, a player key while its player is the maker. Moved to
another side, no longer commander, kicked, or an account suspended: the key answers
`key_owner_lost` until that is true again (within a few seconds of the change).

Spectator links are made and listed on the game's page, not with these calls: `POST /api/v1/keys` refuses `kind: "link"` with `kind_not_creatable`, and `GET /api/v1/keys` does not list them.

At most 10 new keys an hour per account, and at most 10 team and dashboard keys per game.

## Rate limits

Limits are per key, per minute, per kind of call. Every response carries `RateLimit-Limit`,
`RateLimit-Remaining` and `RateLimit-Reset` (seconds to the next window).

| Key | Budget per minute |
|---|---|
| Player | reads 60, position 30 (one every 2 s), status 10, SOS 6, marks 20, order acknowledgements 60 |
| Team | reads 60, webhooks 30 |
| Dashboard | reads 120, webhooks 30 |
| Spectator link | reads 120 (shared by every screen on the link) |
| Prop | reads 60, events 60 (an HTTPS batch is one call), MQTT input events 120 (each message) |

Over the budget you get `429 rate_limited` with `Retry-After`. A key that keeps going past its
budget (20 refused calls within 10 minutes) is **paused for 15 minutes**, and the game master is
told. Three pauses in a day **block** the key until GridTac support lifts it. Limits act only on
the key: they never change anything in the game.

## Checking a key

```http
GET /api/v1/whoami
Authorization: Bearer gt_…
```

```json
{ "keyId": "…", "kind": "dash", "label": "Scoreboard", "gameId": "…", "teamId": null }
```

## Keeping keys safe

- Treat a key like a password. Do not put it in a public repository, a screenshot or a URL.
- The `gt_` prefix is easy to find for secret scanners; if one turns up somewhere it should not be,
  rotate or revoke it.
- GridTac stores only a keyed hash of each key. Nobody at GridTac can show you a lost key: rotate
  it to get a new one.

Errors are described in [Errors](errors.md).
