05API basics
Keys and authentication
Every API request carries a key. Here is how to create one, how to pass it, how the API responds if something is wrong with it, and how to store it.
What a key looks like
A working key consists of the prefix rg_live_ followed by 40 more characters. It is shown in full only once, when you create it. We store only its fingerprint, so a lost key cannot be recovered—create a new one.
rg_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The portal login and password do not work for the API: they serve a different purpose, and the API does not accept them.
How to pass a key
Either of two headers will do, one per request: Authorization: Bearer <key> or X-API-Key: <key>. If both are sent, the non-empty Bearer applies; if the Bearer is invalid, the other header is not checked.
To check a key, use a balance request: it charges nothing.
# Option 1: the Authorization header curl --fail-with-body --max-time 20 \ https://api.rendergrid.io/ api/ public/ v1/ balance \ -H "Authorization: Bearer $RENDERGRID_API_KEY" # Option 2: the X-API-Key header curl --fail-with-body --max-time 20 \ https:// api.rendergrid.io/ api/ public/ v1/ balance \ -H "X-API-Key: $RENDERGRID_API_KEY"
import os import requests key = os.environ["RENDERGRID_API_KEY"] response = requests.get( "https://api.rendergrid.io/ api/ public/ v1/ balance", headers={"Authorization": f"Bearer {key}"}, timeout=(5, 20), ) response.raise_for_status() print(response.json())
// Node.js 22+, .mjs file const url = "https://api.rendergrid.io/ api/ public/ v1/ balance"; const key = process.env.RENDERGRID_API_KEY; const response = await fetch(url, { headers: { Authorization: `Bearer ${key}` }, signal: AbortSignal.timeout(20_000), }); if (!response.ok) { const body = await response.text(); throw new Error(`HTTP ${response.status}: ${body}`); } console.log(await response.json());
{
"currency": "USD",
"balance": "42.5000",
"overdraft_limit": "0.0000",
"available": "42.5000"
}Create, replace, revoke
Create a key
In the portal, in the “API keys” section, click “Create key”. Name it after the integration: “website,” “bot,” “warehouse.” That makes it easier to tell whose key it is.
Copy it right away
After you close the window, the key cannot be shown again. Put it in an environment variable or in a secret store.
Replace it without downtime
Create a new key, put it in your integration, check one request, and only then revoke the old key. A revoked key stops working immediately.
The balance and limits of an account are shared by all of its keys. Separate keys exist so that you can change and revoke access for each integration independently.
An account can have up to 50 active keys. Keys that Playground issues for the length of your session do not count toward this limit. A replaced key still counts until it expires.
You can set each key its own monthly spending limit. It is a hard cap for that key: when it is used up, requests with that key get 402 (learn more).
What the API responds
Read the reason for a refusal from error.code and error.details.reason, not from the message text.
| What happened | API response | What to do |
|---|---|---|
| The key is not sent | 401 ERR_API_KEY_INVALID, api_key_missing | Check that the header reaches the API |
| The key is wrong, revoked, or expired | 401 ERR_API_KEY_INVALID, api_key_invalid | Create a new key. The response is the same in all these cases |
| The monthly limit of the key or account is used up (if one is set) | 402 ERR_INSUFFICIENT_BALANCE, monthly_budget_exceeded | Raise the limit in the portal or wait for the new month in UTC |
| The account is disabled | 403 ERR_ACCOUNT_DISABLED, account_disabled | Stop sending requests and contact support |
| API access was paused by a manager | 403 ERR_API_SUSPENDED, api_suspended | Contact your manager. The portal remains available |
HTTP/1.1 401 Unauthorized { "error": { "code": "ERR_API_KEY_INVALID", "message": "no API key on the request", "details": { "reason": "api_key_missing" } } }
The other refusals work the same way. Their message texts and details.reason values are collected in the “Access errors” section.
Do not repeat requests in a loop on 401 and 403. More than 30 refusals per minute from one IP address, and the API stops answering requests from it for 120 seconds (burst_block). For more, see the “Limits” page.
How to store a key
- Keep the key in your server’s environment variables or in a secret manager.
- Do not put the key in website code, mobile app code, a public repository, or logs. Send API requests from your server only.
- Give each integration its own key.
- If a key may have leaked, revoke it immediately and then create a new one.
Working with an AI assistant? Do not paste the key into the chat—for more, see the “What not to give an assistant” section.