> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opengame.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Sign-in

> Sign in to the OpenGame API by device login. Start a login, redeem it for a creator token, and read the account behind that token.

A creator token lets the CLI, a CI job or your own script act for your account. `opengame login` gets one by device login: the CLI shows a code, you approve it in your browser, and the CLI trades the approved code for a token. These routes are that exchange, plus revoking a token and reading the account behind one.

[Authentication](https://docs.opengame.io/api-reference/authentication.md) covers each credential, and [errors](https://docs.opengame.io/api-reference/errors.md) covers the JSON error body.

## Start a device login

`POST https://opengame.io/api/v1/auth/device`

**Authentication:** None.

RFC 8628 device authorization. Returns a code the person types into the approval page at `/cli`. The request lives 10 minutes; poll `/api/v1/auth/token` no faster than `interval`. Limited to 300 requests per address each 10 minutes.

### Body

Sent as `application/json`.

**device\_name** `string` *required*

Shown on the approval page and used as the token's name, for example the machine's hostname. Trimmed. No control or bidirectional formatting characters, and nothing shaped like a credential. 1 to 60 characters. Example: `studio-macbook`.

### Request

```bash cURL theme={"system"}
curl --request POST \
  --url 'https://opengame.io/api/v1/auth/device' \
  --header 'Content-Type: application/json' \
  --data '{
  "device_name": "studio-macbook"
}'
```

### Response 200

A pending device request.

```json theme={"system"}
{
  "device_code": "JjpNvkFIj7hyFLADIznbufDI2hTBbfzxMIS_PCVS7KU",
  "user_code": "KQ7M-X4TB",
  "verification_uri": "https://opengame.io/cli",
  "verification_uri_complete": "https://opengame.io/cli?code=KQ7M-X4TB",
  "expires_in": 600,
  "interval": 5
}
```

### Errors

| Status | Meaning |
| - | - |
| 400 | `invalid_request`: the body is not JSON, or `device_name` is missing or not allowed. Send a short device name. |
| 404 | `not_found`: this server does not serve the creator API. The body includes no `message`. |
| 413 | `body_too_large`: the body is over `platform.device.bodyBytesMax` (1024) bytes. |
| 415 | `content_type`: send `Content-Type: application/json`. |
| 429 | `slow_down`: a lot of sign-ins have started from this network. Wait a few minutes, then run `opengame login` again. |
| 500 | `internal_error`: a failure retrying cannot fix. Quote `requestId` when you report it. |
| 503 | `platform_unconfigured`: a fault on OpenGame's side. `temporarily_unavailable`: OpenGame could not check the rate limit or save the request. Wait, then try again. |

## Exchange an approved device code for a token

`POST https://opengame.io/api/v1/auth/token`

**Authentication:** None.

Poll until the person approves. Approval and redemption are single use. The token is returned once and is never shown again; store it in the OS keychain or a file only you can read.

### Body

Sent as `application/json`.

**device\_code** `string` *required*

Matches `^[A-Za-z0-9_-]{43}$`. Example: `JjpNvkFIj7hyFLADIznbufDI2hTBbfzxMIS_PCVS7KU`.

**grant\_type** `string` *required*

Always `urn:ietf:params:oauth:grant-type:device_code`.

### Request

```bash cURL theme={"system"}
curl --request POST \
  --url 'https://opengame.io/api/v1/auth/token' \
  --header 'Content-Type: application/json' \
  --data '{
  "device_code": "JjpNvkFIj7hyFLADIznbufDI2hTBbfzxMIS_PCVS7KU",
  "grant_type": "urn:ietf:params:oauth:grant-type:device_code"
}'
```

```bash CLI theme={"system"}
opengame login --continue --json
```

### Response 200

Approved.

```json theme={"system"}
{
  "access_token": "ogt_3f9c2a71d4e8b605_Qm7xT2vLk9NcR4wZpE8sYb1HdJ6uFa3GiO5tVnXyKq0",
  "token_type": "Bearer",
  "scope": "read deploy submit"
}
```

| Field | Required | Type | What it is |
| - | - | - | - |
| `access_token` | yes | string | An `ogt_` creator token. It is rejected as `token_invalid` once it goes 90 days without a request; then run `opengame login` again. |
| `token_type` | yes | `"Bearer"` | |
| `scope` | yes | `"read deploy submit"` | |

### Errors

| Status | Meaning |
| - | - |
| 400 | `authorization_pending`: keep polling. `slow_down`: you polled early, so wait the new `interval` seconds. `access_denied`: the person denied the code, or `reason` names the approving account lost access. `expired_token`: the code expired or was already used, so run login again. These four include no `message`. `invalid_request`: the body is not a device code grant. |
| 404 | `not_found`: this server does not serve the creator API. The body includes no `message`. |
| 413 | `body_too_large`: the body is over `platform.device.bodyBytesMax` (1024) bytes. |
| 415 | `content_type`: send `Content-Type: application/json`. |
| 429 | `slow_down`: more than 12000 exchange attempts from this address in 10 minutes. Wait a few minutes before polling again. |
| 500 | `internal_error`: a failure retrying cannot fix. Quote `requestId` when you report it. |
| 503 | `temporarily_unavailable`: OpenGame could not check the rate limit or read the approval. Poll again after `interval`. |

## Revoke the calling token

`POST https://opengame.io/api/v1/auth/logout`

**Authentication:** A creator token.

A token can revoke itself and nothing else. It works even when the account has lost platform access, and the call is not counted against the token's allowance. Token administration happens in the browser.

### Request

```bash cURL theme={"system"}
curl --request POST \
  --url 'https://opengame.io/api/v1/auth/logout' \
  --header "Authorization: Bearer $OPENGAME_TOKEN"
```

```bash CLI theme={"system"}
opengame logout
```

### Response 200

Whether a live token was revoked by this call. False only when another request revoked it first.

```json theme={"system"}
{
  "revoked": true
}
```

### Errors

| Status | Meaning |
| - | - |
| 401 | `unauthorized`, with no `message`: no `ogt_` bearer token, or the token is invalid or already revoked. A browser session cannot use this operation; revoke tokens in settings instead. |
| 404 | `not_found`: this server does not serve the creator API. The body includes no `message`. |
| 500 | `internal_error`: a failure retrying cannot fix. Quote `requestId` when you report it. |
| 503 | `temporarily_unavailable`: OpenGame could not revoke the token just now. Try again. |

## Rename your handle

`POST https://opengame.io/api/v1/account/handle`

**Authentication:** A creator token or a signed-in browser session.

Rename the signed-in account's handle, as Settings does, through the same function: the same rate limits, the same moderation and the same uniqueness check. The old handle becomes free for anyone to claim at once, the account's games keep their /g links, and the profile address changes. Only a browser session or the token `opengame login` makes can do this; a token made in settings cannot, whatever the permissions, and neither can one pinned to a game. What `opengame handle` sends.

### Body

Sent as `application/json`.

**handle** `string` *required*

The new handle, without the @. Example: `stormcaller`.

### Request

```bash cURL theme={"system"}
curl --request POST \
  --url 'https://opengame.io/api/v1/account/handle' \
  --header "Authorization: Bearer $OPENGAME_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{
  "handle": "stormcaller"
}'
```

```bash CLI theme={"system"}
opengame handle <name> --yes --json
```

### Response 200

Renamed.

```json theme={"system"}
{
  "apiVersion": "1",
  "handle": "stormcaller",
  "previous": "rainmaker",
  "url": "https://opengame.io/@stormcaller"
}
```

### Errors

| Status | Meaning |
| - | - |
| 400 | `invalid_request`: the body is not `{ "handle": "..." }`. `invalid_handle`: the name breaks the handle rules, which the message names. |
| 401 | `sign_in_required`, `token_invalid` or `token_revoked`. Sign in again, or use a token that has not been revoked. |
| 403 | `forbidden`: the credential is not a browser session or the `opengame login` token, or a browser request came from another site. `not_member`: this account does not have access to the creator API. `account_inactive`: the account is suspended or deleted. `account_banned`: OpenGame's moderators have banned the account, so it can read and roll back to a version that was live, but cannot ship anything new, and `retry` is `never`. `not_launched`: the creator API is closed to this caller. It is open to each signed-in account, so sign in and try again. |
| 404 | `not_found`: this server does not serve the creator API. |
| 409 | `handle_unchanged`: that is already your handle. `handle_unavailable`: the handle is taken or not available. Nothing changed. |
| 413 | `body_too_large`: the body is over 1,024 bytes. |
| 415 | `content_type`: send `Content-Type: application/json`. |
| 429 | `rate_limited`: too many handle checks in a minute, or too many renames in a day, or this token made too many requests. Wait `retryAfterSeconds`. |
| 500 | `internal_error`: a failure retrying cannot fix. Quote `requestId` when you report it. |
| 503 | `temporarily_unavailable`: OpenGame could not check the handle, count the attempt or finish the rename, so nothing changed. Wait, then try again. `platform_unconfigured`: a fault on OpenGame's side. |

## Read who this credential is for

`GET https://opengame.io/api/v1/auth/me`

**Authentication:** A creator token or a signed-in browser session.

Returns the account behind the credential and, for a token, the scopes and game pin.

### Request

```bash cURL theme={"system"}
curl --request GET \
  --url 'https://opengame.io/api/v1/auth/me' \
  --header "Authorization: Bearer $OPENGAME_TOKEN"
```

```bash CLI theme={"system"}
opengame whoami --json
```

### Response 200

The account and the credential's scopes.

```json theme={"system"}
{
  "apiVersion": "1",
  "handle": "marlowe",
  "ogNumber": 1207,
  "avatar": {
    "seed": 48213,
    "palette": "tide"
  },
  "credential": {
    "id": "3f9c2a71d4e8b605",
    "scopes": [
      "read",
      "deploy",
      "submit"
    ],
    "gameId": null,
    "origin": "device"
  }
}
```

### Errors

| Status | Meaning |
| - | - |
| 401 | `sign_in_required`, `token_invalid` or `token_revoked`. Sign in again, or use a token that has not been revoked. |
| 403 | `not_member`: this account does not have access to the creator API. `account_inactive`: the account is suspended or deleted. `account_banned`: OpenGame's moderators have banned the account, so it can read and roll back to a version that was live, but cannot ship anything new, and `retry` is `never`. `not_launched`: the creator API is closed to this caller. It is open to each signed-in account, so sign in and try again. |
| 404 | `not_found`: this server does not serve the creator API. |
| 409 | `handle_required`: the account has no handle yet. Claim one at `url`, then run the command again. |
| 429 | `rate_limited`: this token made too many requests. Wait `retryAfterSeconds`. A browser session is not counted. |
| 500 | `internal_error`: a failure retrying cannot fix. Quote `requestId` when you report it. |
| 503 | `temporarily_unavailable`: wait `retryAfterSeconds` when given, then retry. `platform_unconfigured`: the account has no handle, and a fault on OpenGame's side left no address to claim one at. Try again later. |

## Check whether OpenGame is open to creators

`GET https://opengame.io/api/v1/status`

**Authentication:** Optional: a creator token or a signed-in browser session.

Returns whether OpenGame is open to creators, whether the account behind the credential may use it, and when deploys stop. Any signed-in account may use it, so `access` is `true` for one. Deploys stop at `entriesCloseAt`. Works with no credential. `deploysFrozen` is true once entries have closed, after which each deploy is rejected with `entries_closed`. The CLI calls this before each command except `version`, `help`, `login`, `logout` and `whoami`, stops with exit code 7 when neither `launched` nor `access` is `true`, and stops `deploy` when `deploysFrozen` is true.

### Request

```bash cURL theme={"system"}
curl --request GET \
  --url 'https://opengame.io/api/v1/status' \
  --header "Authorization: Bearer $OPENGAME_TOKEN"
```

### Response 200

Whether OpenGame is open, and this caller's access.

```json theme={"system"}
{
  "launched": true,
  "access": true,
  "opensAt": "2026-11-18T05:00:00.000Z",
  "creatorsOpenAt": "2026-11-18T05:00:00.000Z",
  "entriesCloseAt": "2026-12-19T08:00:00.000Z",
  "deploysFrozen": false
}
```

### Errors

| Status | Meaning |
| - | - |
| 500 | `internal_error`: a failure retrying cannot fix. Quote `requestId` when you report it. |
| 503 | `temporarily_unavailable`: OpenGame could not read whether it is open, or could not check the credential. Wait, then ask again. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.