Note
Treat your API token like a password. Do not commit it to version control or expose it in client-side code.
Include your token on every request using one of the following methods. Do not use both simultaneously — this will result in a 400 error.
Method 1 — Request header (recommended):
curl -X GET "https://api.ocean.io/v2/credits/balance" \
-H "X-Api-Token: YOUR_API_TOKEN"import requests
response = requests.get(
'https://api.ocean.io/v2/credits/balance',
headers={'X-Api-Token': 'YOUR_API_TOKEN'},
)const response = await fetch('https://api.ocean.io/v2/credits/balance', {
headers: { 'X-Api-Token': 'YOUR_API_TOKEN' },
});Method 2 — Query parameter:
curl -X GET "https://api.ocean.io/v2/credits/balance?apiToken=YOUR_API_TOKEN"import requests
response = requests.get(
'https://api.ocean.io/v2/credits/balance',
params={'apiToken': 'YOUR_API_TOKEN'},
)const response = await fetch(
'https://api.ocean.io/v2/credits/balance?apiToken=YOUR_API_TOKEN',
);Headers don't appear in server logs or browser history — query parameters do.
| Scenario | Status code | Response |
|---|---|---|
| Token missing from request | 403 |
{"detail": "API token should be provided in headers or query parameters"} |
| Token is invalid or unrecognised | 403 |
{"detail": "Invalid API token"} |
| Token provided in both header and query param | 400 |
{"detail": "Conflicting API tokens provided in query parameters and headers"} |
If you suspect a token has been compromised, revoke it immediately in Account Settings and generate a new one. Update all systems using the old token before revoking to avoid downtime.