Platform API | OAuth, Key Management & Account Settings
API reference for OAuth, Trading & Consumption API Key management, and Account Settings, most commonly used by agents.
The Platform API is the account control plane: OAuth 2.0 login, consumption API keys, trading signing keys, and account settings. It is separate from the Consumption API (inference) and the Trading API (markets, orders, balances).
Most automation flows obtain a short-lived OAuth access token here, create credentials, then call Consumption and Trading with those credentials. See Programmatic onboarding for the full happy path.
Base URL: https://platform.api.thegrid.ai/v1
The host also serves these endpoints under /api/v1, so https://platform.api.thegrid.ai/api/v1/... and https://platform.api.thegrid.ai/v1/... are equivalent. The examples in these docs use the shorter /v1 form.
Authentication uses OAuth bearer tokens from the device flow, or the browser session cookie when called from the dashboard. See Authentication for token types and how to get one. Each endpoint below lists the OAuth scope it requires; discover what a given client_id may request with the scopes endpoint.
How the Platform API fits with the other APIs
Inference does not accept OAuth access tokens: create a consumption API key here, then call the Consumption API with that key as Bearer.
OAuth
Device flow login (RFC 8628), token refresh, revocation (RFC 7009), scope discovery, and grant management. Public clients such as the Grid CLI use the grid-cli-public application; see Programmatic onboarding for how to pick a client_id.
Lists all platform scopes. Pass client_id to see only the scopes a registered OAuth application may request. No authentication required.
grid-cli-publicScope catalog
Unknown client_id
GET /v1/oauth/scopes HTTP/1.1
Host: platform.api.thegrid.ai
Accept: */*
{
"data": [
{
"name": "keys:manage",
"description": "text"
}
]
}Starts the device authorization flow. The user approves the listed scopes at verification_uri.
grid-cli-publicaccount:read account:write keys:manageDevice authorization created
https://app.thegrid.ai/activateSeconds until the device code expires
Minimum seconds between token polls
POST /v1/oauth/device/code HTTP/1.1
Host: platform.api.thegrid.ai
Content-Type: application/json
Accept: */*
Content-Length: 80
{
"client_id": "grid-cli-public",
"scope": "account:read account:write keys:manage"
}Device authorization created
{
"device_code": "text",
"user_code": "text",
"verification_uri": "https://app.thegrid.ai/activate",
"expires_in": 1,
"interval": 1
}Poll with grant_type urn:ietf:params:oauth:grant-type:device_code until the user approves, or refresh an expired access token with grant_type refresh_token.
While polling, a 400 response carries an OAuthError body. Handle each error code distinctly: authorization_pending (keep polling at interval), slow_down (increase the interval by 5 seconds, then keep polling), access_denied (user declined; stop), and expired_token (device code expired; restart the device flow). Any other error (e.g. invalid_grant) is terminal.
Refresh tokens may rotate: persist whatever refresh_token comes back in the response and discard the previous one. Refresh about 60 seconds before expires_in elapses to absorb clock skew, and on a 401/403 invalid_token from a resource endpoint, refresh once and retry.
Required for the device_code grant
Required for the refresh_token grant
Token pair issued
Bearer token, prefixed grid_at_
Refresh token, prefixed grid_rt_
BearerAccess token lifetime in seconds (3600)
account:read keys:managePolling or refresh error. The error field is one of authorization_pending, slow_down, access_denied, expired_token, or invalid_grant.
POST /v1/oauth/token HTTP/1.1
Host: platform.api.thegrid.ai
Content-Type: application/json
Accept: */*
Content-Length: 124
{
"grant_type": "urn:ietf:params:oauth:grant-type:device_code",
"client_id": "text",
"device_code": "text",
"refresh_token": "text"
}{
"access_token": "text",
"refresh_token": "text",
"token_type": "Bearer",
"expires_in": 1,
"scope": "account:read keys:manage"
}Revokes an access or refresh token. Send a JSON body with the token to revoke. token_type_hint is optional and client_id is not required. Always returns 200 with an empty body, even for unknown or already-revoked tokens, so a 200 is not proof the token existed.
An access token (grid_at_) or refresh token (grid_rt_)
Optional RFC 7009 hint. Accepted but not required.
Revoked (or unknown token, per RFC 7009). Body is empty ({}).
No content
POST /v1/oauth/revoke HTTP/1.1
Host: platform.api.thegrid.ai
Content-Type: application/json
Accept: */*
Content-Length: 49
{
"token": "text",
"token_type_hint": "access_token"
}Revoked (or unknown token, per RFC 7009). Body is empty ({}).
No content
Revocation (RFC 7009) takes a JSON body with a single required field, token, which may be either an access token (grid_at_*) or a refresh token (grid_rt_*):
The optional token_type_hint (access_token or refresh_token) from RFC 7009 is accepted but not required; client_id is not required. Per the spec, the endpoint always returns 200 with an empty body {}, including for unknown or already-revoked tokens, so do not treat a 200 as proof the token existed.
OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
Grants for the authenticated user
Authentication required
GET /v1/oauth/grants HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
"data": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"application_name": "text",
"scopes": [
"text"
],
"inserted_at": "2026-01-01T00:00:00.000Z"
}
]
}Revokes the grant and invalidates its tokens.
OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
Grant revoked
No content
Grant not found
DELETE /v1/oauth/grants/{id} HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
No content
Consumption API keys
Manage the keys used for inference on the Consumption API. All key endpoints, including list and show, require the keys:manage scope; there is no read-only key scope. The raw secret appears once in the create response, then list and show return key: null with only key_prefix.
Raw secrets are never returned on list. Requires the keys:manage scope.
OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
Keys with key set to null and key_prefix populated
GET /v1/api-keys HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
Keys with key set to null and key_prefix populated
{
"data": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "text",
"key": "text",
"key_prefix": "text",
"inserted_at": "2026-01-01T00:00:00.000Z"
}
]
}The raw secret is returned once in data.key. Store it immediately. Requires the keys:manage scope.
OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
Key created, raw secret in data.key
POST /v1/api-keys HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 31
{
"api_key": {
"name": "my-agent"
}
}Key created, raw secret in data.key
{
"data": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "text",
"key": "text",
"key_prefix": "text",
"inserted_at": "2026-01-01T00:00:00.000Z"
}
}OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
Key metadata, raw secret not included
No content
GET /v1/api-keys/{id} HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
Key metadata, raw secret not included
No content
OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
Updated
No content
PATCH /v1/api-keys/{id} HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 27
{
"api_key": {
"name": "text"
}
}Updated
No content
OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
Revoked
No content
DELETE /v1/api-keys/{id} HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
Revoked
No content
Trading signing keys
Register Ed25519 public keys for Trading API request signing. Generate the keypair locally; the private key never leaves your machine. Keypair generation and the signing scheme: Authentication. Requires the keys:manage scope.
OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
Registered Ed25519 public keys
GET /v1/signing-keys HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
Registered Ed25519 public keys
{
"data": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"label": "text",
"fingerprint": "text",
"inserted_at": "2026-01-01T00:00:00.000Z"
}
]
}Generate the keypair locally; only the public key is registered. The private key never leaves your machine. Requires the keys:manage scope.
OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
Registered. Response includes the fingerprint used as x-thegrid-fingerprint.
No content
Invalid public key
POST /v1/signing-keys HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 54
{
"signing_key": {
"label": "my-bot",
"public_key": "text"
}
}No content
OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
Revoked
No content
DELETE /v1/signing-keys/{id} HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
Revoked
No content
Account settings
Read account mode and funding automation settings, and switch between Auto Mode and Advanced Mode. Reads require the account:read scope; mutations require account:write plus a verified user, accepted legal terms, and an active account.
Some settings are owned by the account mode. The GET response lists them in mode_managed_fields (currently auto_buy_enabled and auto_transfer_enabled): Auto Mode forces them on, Advanced Mode follows the platform defaults, and writes that diverge from the dictated value return 403 mode_managed_setting. Treat those fields as read-only results of the account mode. To change behavior, switch the account mode instead.
Returns account mode and funding automation settings. Fields listed in mode_managed_fields are dictated by the account mode and are read-only through this API. Requires the account:read scope.
OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
Current settings
GET /v1/self/system-settings HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
Current settings
{
"data": {
"account_mode": "easy",
"auto_transfer_enabled": true,
"auto_buy_enabled": true,
"auto_buy_quantity": 1,
"auto_buy_trigger_threshold": 1,
"auto_reload_enabled": true,
"auto_reload_threshold_usd": "text",
"auto_reload_amount_usd": "text",
"auto_reload_monthly_limit_usd": "text",
"mode_managed_fields": [
"auto_buy_enabled",
"auto_transfer_enabled"
]
}
}Switches between auto (easy) and advanced mode. Switching back to easy fails with 409 while open orders exist. Requires the account:write scope, a verified user, accepted legal terms, and an active account.
OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
Mode switched
No content
Already in the requested mode, or open orders block the switch
Missing or invalid mode
POST /v1/self/system-settings/account-mode HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 15
{
"mode": "easy"
}No content
Idempotent. auto_buy_enabled is mode-managed: the account mode dictates its value, so only the dictated value is accepted; anything else returns 403 mode_managed_setting. Requires the account:write scope.
OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
Current settings, same shape as GET
No content
Value diverges from the mode-dictated value (mode_managed_setting)
PATCH /v1/self/system-settings/auto-buy HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 25
{
"auto_buy_enabled": true
}No content
Updates only auto_reload_* fields. Enabling auto-reload requires both USD fields, in the request or already stored. Requires the account:write scope.
OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
10100500Current settings, same shape as GET
No content
Validation error (missing USD fields, invalid ranges, limit below amount)
PATCH /v1/self/system-settings/auto_reload HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 130
{
"auto_reload_enabled": true,
"auto_reload_threshold_usd": "10",
"auto_reload_amount_usd": "100",
"auto_reload_monthly_limit_usd": "500"
}No content
auto_transfer_enabled is mode-managed: only the value dictated by the account mode is accepted (403 mode_managed_setting otherwise). Send auto_transfer_override null to clear a stored override and follow the platform default. Requires the account:write scope.
OAuth access token issued by the device or authorization-code flow. Tokens are prefixed grid_at_. Each endpoint lists the scope it requires.
Current settings, same shape as GET
No content
Value diverges from the mode-dictated value (mode_managed_setting)
PATCH /v1/self/system-settings/auto-transfer HTTP/1.1
Host: platform.api.thegrid.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 60
{
"auto_transfer_enabled": true,
"auto_transfer_override": true
}No content
Where next
Programmatic onboarding: end-to-end walkthrough from login to first inference call
Authentication: credential types and the Trading signing scheme
Consumption API: inference endpoints
Trading API: markets, orders, accounts
Auto Mode and Advanced Mode: what the account mode controls
Last updated
Was this helpful?