Documentation contents

VCP 1 Documentation›API Reference

Error Handling

One error envelope, a fixed vocabulary of codes, and unambiguous consumer behavior for each — implement error handling once and it works for every endpoint.

The envelope

Every non-2xx response carries the same JSON shape:

{ "error": { "code": "rate_limited", "message": "Too many requests." } }

code is machine-readable and drives consumer behavior; messageis for logs and debugging (clients render provider text as plain text, never markup).

Error codes

HTTPerror.codeMeaning / consumer behavior
400invalid_requestMalformed request.
400authorization_pendingPairing not yet approved — keep polling.
400slow_downIncrease the poll interval by 5 seconds.
400pairing_expiredRestart the pairing flow.
401invalid_service_tokenService token missing/invalid — the gateway alerts platform ops; users see the server as temporarily unavailable.
401expired_tokenRefresh the access token, retry once.
401unauthorizedSession token invalid or revoked — re-authenticate.
401invalid_user_tokenUser token invalid/expired — keep the library, prompt for a new token. Never a silent downgrade — see user tokens.
403forbiddenAuthenticated but not allowed: missing scope, or an object owned by another user.
404not_foundObject deleted — remove it locally.
409conflictWrite conflicts with current state (e.g. duplicate create) — refetch, then reapply or drop.
410goneProvider discontinued VCP — the client removes the server. Also used for expired delta cursors.
412precondition_failedIf-Match version mismatch — refetch the object and reapply the change. See optimistic concurrency.
429rate_limitedBack off per Retry-After, exponential + jitter.
5xxserver_errorRetry with backoff, max 3 attempts.

Two additional client-facing codes never come from your server: the gateway reportsunregistered_publisher (origin not in the registry) andunsupported_version (no shared protocol version) to the app itself.

A retry-aware request helper

The retryable cases — 429 with Retry-After, and transient5xx — are worth wrapping once so every call site gets the behavior for free:

# -i shows the status line and headers; the envelope is in the body
curl -i "https://api.example.com/vcp/v1/collections" \
  -H "VCP-Service-Token: vcps_wrong..."

HTTP/1.1 401 Unauthorized
Content-Type: application/json

{ "error": { "code": "invalid_service_token", "message": "Invalid service token." } }

Coming soon!

We're putting the finishing touches on VClarity. It'll be on the App Store and Google Play very soon.