Skip to main content

Backend API

Privacy Boost serves a small HTTP API for your own backend. Use it to read the private balances of users who signed in through your app, and to check whether a shield or unshield they submitted has settled. It authenticates with your app’s client credentials. There is no SDK for it; call it with any HTTP client.
These routes run over plain HTTPS. They don’t use the encrypted transport the SDKs use, and the client secret goes out with every request. Call them only from servers you control, and never ship the client secret in a browser bundle, a mobile app, or anything else that runs on a user’s device.

Base URL

Each network has its own server. Send requests to the serverUrl of the network you want from Supported Networks, for example https://optimism.privacyboost.io for OP Mainnet. Balances belong to that server’s chain, and balance responses include its chainId.

Authentication

The API takes the client ID and client secret of an app set up for the api_secret auth method. The Privacy Boost team issues them when it configures your app; see App Setup and API Secret. Send the pair with HTTP Basic authentication: the client ID is the username and the client secret is the password. The server doesn’t accept credentials in the URL or the request body.
The credential decides which app the request acts for, and a request can’t name a different one. A missing or wrong credential gets 401 UNAUTHORIZED with a WWW-Authenticate: Basic header. So does a revoked or expired credential, a suspended app, or an app whose api_secret method is turned off. A revoked credential can keep working for up to a minute after revocation. Every response carries Cache-Control: no-store.

Get One User’s Balances

POST /api/v1/server/balances returns the available balances of one user of your app. The body is a single JSON object with one field, and any other field is rejected.
The request field is snake_case and the response fields are camelCase. The balance is what the user can spend now: confirmed plus preconfirmed notes. If the wallet isn’t a user of your app, or has no privacy account registered on this chain, the server answers 404 NOT_FOUND. Both cases get the same response, so the endpoint never shows whether a wallet uses some other app. Only wallets that signed in through your app are visible.

List Your Users’ Balances

GET /api/v1/server/balances pages through every user of your app, in the order they first signed in, with each user’s balances. Any other query parameter, or either of these given twice or empty, returns 400 INVALID_PARAMETER.
Keep passing nextCursor back as cursor until a response has none. The cursor is opaque and works only with your app’s credentials on the same network. It expires 24 hours after the first page of the run, so a full listing has to finish within that window. An expired or altered cursor returns 400 INVALID_PARAMETER; start again without one. The set of users is fixed when the first page is read. Users who sign in after that show up in your next run. Balances are read as each page is served, so a full listing isn’t a snapshot of a single moment.

Track a Shield or Unshield

GET /api/v1/server/requests/{requestId} returns the status of a shield or unshield that one of your users submitted. Your client gets the ID from the SDK and passes it to your backend.
Poll until the status is no longer pending. Every other status is final unless an L2 reorg drops the block that settled it. The response carries no error text for a failed request. An unknown shield ID returns 404 SHIELD_NOT_FOUND and an unknown unshield ID returns 404 TRANSFER_NOT_FOUND. Private transfers and other request types share the ID space with unshields, and their IDs get the same 404 TRANSFER_NOT_FOUND. An ID that is neither a number nor a UUID returns 400 INVALID_PARAMETER.

Errors

Errors come back in this JSON shape:
Branch on code. details.request_id matches the X-Request-ID response header; include it when you report a problem to the Privacy Boost team. retryable is true for 429 and 503. Retry those after a delay, and fix the request before retrying a 4xx.

Rate Limits

Every route counts against the server’s per-IP read limit. The limit is checked before the credential, so failed authentication attempts use it up too. Status lookups also count against a second limit, shared by every request made with your app’s credentials. A request over either limit gets 429 RATE_LIMITED with a Retry-After header and details.retry_after_ms. Wait at least that long before you retry.

Next Steps