ozvault home

OZVAULT CONNECT · ERRORS

Handle OAuth and API errors

Stable error codes for the OzVault Connect token endpoint and storage API, with retry guidance, rate limits and request IDs.

Reviewed Published by OzVault

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).

TypeScript
{
  "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.

OAuth error codes
errorHTTPWhat to do
invalid_request400Fix the request: a missing, repeated or malformed parameter
invalid_client401Wrong, expired or revoked secret; secret sent from a browser; unknown or disabled client
invalid_grant400Code expired, reused or for another redirect_uri; PKCE mismatch; refresh token revoked or replayed: ask the user to connect again
invalid_scope400Refresh tried to widen scope
unsupported_grant_type400Use authorization_code or refresh_token
temporarily_unavailable429/503Wait for Retry-After, then retry

Storage API errors

#
API error codes
codeHTTPMeaning
INVALID_TOKEN401Missing, expired or revoked access token: refresh once, then reconnect
INSUFFICIENT_SCOPE403Ask the user to authorize the missing scope (prompt=consent)
NOT_FOUND404No such file in your app's storage area
NAME_EXISTS409Choose another name, or replace=true with storage:app:delete
QUOTA_EXCEEDED413The user's account is full
FILE_TOO_LARGE / PAYLOAD_TOO_LARGE413Use resumable uploads, within maxFileBytes
CHECKSUM_MISMATCH422Bytes did not match the sha256 you supplied
VALIDATION_ERROR / INVALID_BODY400Invalid name, parameter or empty body
UPLOAD_EXPIRED / OFFSET_MISMATCH410/409Start again, or resume at the committed offset
RATE_LIMITED / UPLOAD_CONCURRENCY429Respect Retry-After; at most five uploads open per user
MAINTENANCE503Writes 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.

TypeScript
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.