API keys — which key goes where
Monoverse uses two credentials. One is a public identifier (safe to ship in a page or an app binary); one is a server-only secret. This page is the single map.
| Credential | Real format | Public? | Lives in | Authorizes | Get it from |
|---|---|---|---|---|---|
| Site publishable key | pk_ + 32 url-safe chars | Yes — origin- and app-id-locked | Your site's HTML / JS bundle and your app binary | Widget session minting on allow-listed origins; mobile session-token minting for the app ids added to it (Mode B); also pair-by-key to bootstrap a producer | Cabinet → Integrations; app ids under your site → Mobile apps |
| Ingest shared secret | base64 of 32 random bytes (shared_secret_b64) | No — server only | Your backend, encrypted at rest | HMAC-signing of every ingest request; Mode A mobile token minting | Returned once by pair-by-key |
One more string you will meet in the flow — not a long-lived credential you store:
- Session token — a short-lived JWT the widget and SDKs mint for themselves from a publishable key (or that your server mints in Mode A). You never copy or store it.
The real key formats
A real web key looks like pk_4T8mQzXcV1nY7wKfB2rL9pDhJ6sGaU0e — the prefix pk_ followed by 32
url-safe random characters. There is no live / test segment: if you see pk_live_…
anywhere, that is an old placeholder, not a different key type. Copy the key from the cabinet exactly
as issued. Older mobile keys start with vb_pk_ and keep working.
The docs use pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx / pk_… as placeholders — always substitute
your own key.
sk_…The cabinet references your ingest secret by a display id starting with sk_ so it can be
identified without being revealed. The actual credential your producer signs with is the base64
shared_secret_b64 value returned once at pairing — the sk_… display id is not the secret and
cannot sign anything.
Pairing a backend
A backend turns your pk_ into the shared secret once, and proves on the way that it runs on the
key's own domain. The SDKs do it for you in ensurePaired(), ensure_paired() and
php artisan monoverse:pair; the steps below are the wire contract, for a producer you write yourself.
- The backend receives the
pk_— from its configuration: the key the cabinet shows beside your site. - It holds a nonce and asks to pair — it draws 32 to 128 random URL-safe characters, keeps them
for at most 600 s, and sends them with the key to
POST /api/v1/ingest/pair-by-key, withX-Monoverse-Protocol-Version: 2and the body below. The nonce goes to no one but Monoverse. - Monoverse fetches the challenge — before it answers, it calls
GET https://<your domain>/monoverse/pair-challenge?challenge=<c>over HTTPS, on the key's domain and then on itswww.host: at most 4 fetches, no redirect followed, at most 4096 bytes read. - The backend answers with the proof —
200with{"proof": "<hex HMAC-SHA256 of c, keyed with the nonce>"}andCache-Control: no-store, or404with codeno_pairing_in_progresswhen no nonce is live. A proof that does not match refuses the pairing with403 domain_unproven. - The secret is returned once — the answer to step 2 carries
tenant_id,shared_secret_b64,ingest_url,protocol_versionandaccount. Store the decoded secret encrypted; no call shows it again.
| Field | Rule |
|---|---|
public_key | your pk_ |
pair_nonce | the nonce from step 2 |
site_url | the shop's origin; its host must be the key's domain, else 403 domain_mismatch |
provider_id | optional: the SDK's registered id, such as laravel, node, python or woocommerce; any other gets 400 unknown_provider |
plugin_version, callbacks, stack | optional: the SDK's version, the callback paths it serves, at most 6 ids of the stack it runs |
The WordPress plugin answers the same challenge at /?rest_route=/monoverse-sync/v1/pair-challenge.
Until 2027-04-30 the server also tries the challenge routes the SDKs answered before 1.0, which
Renamed packages lists. Every other refusal is listed in
Errors & retries.
Placement rules
pk_is an identifier, not a secret (like a Stripepk_). The security boundary is the origin allow-list (web) or theapp_idallowlist + connection status (mobile) — never the secrecy of the key. Details: Tenant isolation and Auth & API keys (mobile).- The ingest shared secret must never reach a browser or an app binary. All first-party producer SDKs store it encrypted at rest (AES-256-GCM) and redact it from logs. If it leaks, unpair and re-pair to rotate.
- One tenant, all surfaces. Both credentials resolve to the same tenant server-side; the
client never sends a
tenant_id. Cross-tenant access is structurally impossible from a client.
Which one do I need right now?
- Putting the widget on a site →
pk_(Frontend — add the widget) - Syncing a catalog from your backend → your
pk_, then the shared secret (Backend — get your catalog in, Pairing a backend) - Shipping a mobile app without a backend → your site's
pk_with your app ids added (Quickstart — mobile) - Shipping a mobile app with a backend → the shared secret, server-side (Mode A in Auth & API keys)