Two error formats
#OAuth endpoints (/oauth/token, /oauth/revoke, /oauth/introspect) answer with RFC 6749 JSON: {"error": "invalid_grant", "error_description": "..."}. The storage API answers with an error object holding a stable code, a readable message and a requestId to quote when contacting support. Token problems also carry a WWW-Authenticate header (RFC 6750).
{
"error": {
"code": "INSUFFICIENT_SCOPE",
"message": "This access token lacks the storage:app:write permission",
"requestId": "8a6f0c1e-4b2d-4f39-9a51-2f0e3c7d1b44"
}
}
WWW-Authenticate: Bearer realm="OzVault", error="insufficient_scope", error_description="The access token lacks a required scope", scope="storage:app:write"Token endpoint errors
#Do not retry invalid_grant or invalid_client automatically; they need user or configuration action.
| error | HTTP | What to do |
|---|---|---|
| invalid_request | 400 | Fix the request: a missing, repeated or malformed parameter |
| invalid_client | 401 | Wrong, expired or revoked secret; secret sent from a browser; unknown or disabled client |
| invalid_grant | 400 | Code expired, reused or for another redirect_uri; PKCE mismatch; refresh token revoked or replayed: ask the user to connect again |
| invalid_scope | 400 | Refresh tried to widen scope |
| unsupported_grant_type | 400 | Use authorization_code or refresh_token |
| temporarily_unavailable | 429/503 | Wait for Retry-After, then retry |
Storage API errors
#| code | HTTP | Meaning |
|---|---|---|
| INVALID_TOKEN | 401 | Missing, expired or revoked access token: refresh once, then reconnect |
| INSUFFICIENT_SCOPE | 403 | Ask the user to authorize the missing scope (prompt=consent) |
| NOT_FOUND | 404 | No such file in your app's storage area |
| NAME_EXISTS | 409 | Choose another name, or replace=true with storage:app:delete |
| QUOTA_EXCEEDED | 413 | The user's account is full |
| FILE_TOO_LARGE / PAYLOAD_TOO_LARGE | 413 | Use resumable uploads, within maxFileBytes |
| CHECKSUM_MISMATCH | 422 | Bytes did not match the sha256 you supplied |
| VALIDATION_ERROR / INVALID_BODY | 400 | Invalid name, parameter or empty body |
| UPLOAD_EXPIRED / OFFSET_MISMATCH | 410/409 | Start again, or resume at the committed offset |
| RATE_LIMITED / UPLOAD_CONCURRENCY | 429 | Respect Retry-After; at most five uploads open per user |
| MAINTENANCE | 503 | Writes are briefly paused; retry later |
Rate limits and retries
#Each user connection may make 300 API requests per minute and each application 6,000. Token requests are limited per IP and per client. Retry 429 and 503 responses after Retry-After seconds with backoff; do not retry 4xx errors otherwise.
async function ozvault(path, init, tokens) {
let r = await fetch("https://api.ozvault.lol" + path, { ...init, headers: { ...init?.headers, Authorization: "Bearer " + tokens.access() } });
if (r.status === 401) { // expired or revoked access token
await tokens.refresh(); // invalid_grant here means the user disconnected
r = await fetch("https://api.ozvault.lol" + path, { ...init, headers: { ...init?.headers, Authorization: "Bearer " + tokens.access() } });
}
if (r.status === 429) {
const wait = Number(r.headers.get("Retry-After") || 1);
await new Promise((resolve) => setTimeout(resolve, wait * 1000));
return ozvault(path, init, tokens);
}
const body = r.headers.get("Content-Type")?.includes("json") ? await r.json() : r;
if (!r.ok) throw Object.assign(new Error(body.error.message), { code: body.error.code, requestId: body.error.requestId });
return body;
}Clear documentation is part of the product.