Skip to main content
Tybrite issues two key types per store, so a credential that ships to a browser and a credential that stays on a server are different objects with different powers. Which one a call takes depends on where your code runs and whose data it touches.

API Key Types

We support two distinct key types for every store. You can manage these in your Dashboard under Integrations → API keys.
Keys issued by a store that runs on a white-label platform carry that platform’s own vendor prefix in place of tybrite_ — acmecommerce_sk_live_…. Only the vendor name changes; the sk/pk and live/test segments are identical everywhere, so parse those rather than matching the full prefix.

Publishable Keys (tybrite_pk_...)

Publishable keys are intended for use in frontend applications, such as React websites, mobile apps, or headless storefronts.
  • Scope: Catalogue reads (products, categories, search) and the actions a shopper takes for themselves: cart and wishlist, reviews, storefront events, and the Agent API’s quotes, cart drafts and checkout intents. Everything else needs a secret key.
  • Security: Safe to include in client-side bundles or public repositories.
  • Usage:

Secret Keys (tybrite_sk_...)

Secret keys are for server-side environments and provide full administrative access to your commerce data.
  • Scope: Full Read/Write access (Orders, Customers, Payments, Settings).
  • Security: Must never be exposed to the client. Keep them in environment variables (TYBRITE_SECRET_KEY).
  • Usage:

Environments & Sandbox

The key prefix determines which environment your requests target — there is no separate sandbox base URL. What sandbox isolation means in practice:
  • Orders, customers, cart items, wishlist entries, product reviews, and messaging conversations created with a test key are stored in the sandbox partition and are never returned to live key requests.
  • Payment providers switch to test mode automatically when a test key is used — Stripe test mode, PayPal sandbox, Paystack test keys, M-Pesa sandbox — regardless of what your store’s payment settings show.
  • Every authenticated response, including error responses, includes a Tybrite-Environment: production | sandbox header so you can confirm which partition resolved. A live key always reports production; no other value stands for live data.
Build and test your entire integration with tybrite_sk_test_* keys. When you’re ready for production, swap to tybrite_sk_live_* and the right environment follows automatically — no code changes needed.

Authorization Header

For direct REST API calls, provide your key in the Authorization header using the Bearer scheme:

Advanced Security: HMAC Signing

Sensitive operations — order creation, payment initialization — carry a request signature in addition to the key, so a tampered body or a replayed request is rejected rather than acted on.

Generating the signature

The signature is a SHA-256 HMAC hash of the payload, where the payload is the current Unix timestamp concatenated with the JSON request body.
The timestamp may be sent in seconds or milliseconds — both are accepted — and a signature is valid for five minutes either side of it. A request that fails verification returns 401 with a code naming the cause: signature_missing, timestamp_missing, timestamp_malformed, timestamp_out_of_window or signature_invalid. A store with no signing secret configured returns 500 config_error. Sign the exact bytes you send: re-serializing the body after signing it produces a different string and the signature will not match. Endpoints requiring HMAC signing: Most integrations sign with the store’s own signing secret, shown above as TYBRITE_HMAC_SECRET. An application that connected through GC Connect instead receives its own per-merchant signing_secret at the code exchange and signs with that. Responses to secret-key calls that read orders, payment status and returns carry a signature made with the same secret. See Verify a response.

Idempotency Protection

State-changing financial operations require an Idempotency-Key header, so a retry after a network failure resolves to the original charge or order rather than a second one.
  • Mechanism: The server tracks these keys. If a request is retried with the same key, the server returns the original response with an idempotent: true flag.
  • Choosing a key: A unique UUID, or a hash of the transaction details (e.g., payment-order_123-ts_456).
A retry with the same key and the same body returns the original result. The same key with a different body returns 409 with the code idempotency_key_reused; payment initialisation, catalog ingestion and marketplace checkout also return 409 idempotency_in_progress while the first request with the key is still being processed, and the same request can be sent again shortly. Endpoints requiring an Idempotency Key:
  • POST /v1/payments/initialize
  • POST /v1/orders
  • PATCH /v1/orders/:id

Customer Session Tokens (xAuthToken)

While API keys authenticate your application to Galactic Core, customer session tokens authenticate end customers to their own data within your store. They are required on top of an API key for endpoints that access or modify a specific customer’s records (cart, wishlist, profile, gift cards, messaging). The two credentials are independent, so a leaked publishable key on its own reaches no specific customer’s data: that also requires the customer’s JWT, which only the AuthenticationService issues, and only after a successful sign-up confirmation, login, emailed-code verification, or password reset.

Affected endpoints

A customer credential for a closed customer account returns 403 with the code account_closed on every endpoint above. See Closed customer accounts.

Example flow

Recommended storage: prefer httpOnly, Secure, SameSite=Lax cookies over localStorage. Cookies are immune to XSS-based token theft and the browser handles attachment automatically. Reach for localStorage only when your storefront is a native mobile WebView or a same-origin SPA without a backing server, and pair it with a strict CSP.
Never log, persist server-side, or share customer access tokens between sessions. Each token is bound to a single customer and grants direct read/write access to their cart, wishlist, profile, and messages.

Key Usage by Endpoint

Every endpoint accepts one of the credentials above, or a combination of them. The legend:
  • pk or sk — either a publishable or a secret key works.
  • sk only — a secret key is required; a publishable key returns 403 Forbidden.
  • pk (browser) — a publishable key is enough; safe to call directly from the browser.
  • + session — also requires a customer session token: xAuthToken, or one of the bring-your-own-auth credentials (x-external-auth for a signed assertion, x-idp-token for a token from your own identity provider). Send exactly one of the three.
  • + HMAC — also requires a request signature.
  • Public — no key required.
  • Operator — a marketplace operator key. It resolves to one marketplace and reads only the merchants selling on it.

Discovery & catalog (read)

Cart & wishlist (storefront writes)

Customers & authentication

Checkout — orders & payments

Engagement

Platform & integrations

Marketplace (operator deployments)


Session Management

When building authenticated customer experiences (like “My Account” or “Quick Checkout”), the Tybrite SDK handles session persistence via xAuthToken.
  1. Sign in: Call client.authentication.login() (or verifyRegistration() after sign-up, verifyOtp() for an emailed code) to receive a session and user object.
  2. Persistence: Store the session.access_token securely (httpOnly cookies preferred).
  3. Requests: Provide the token via the xAuthToken SDK parameter (or x-auth-token header for raw REST) on protected endpoints.
  4. Refresh: Call client.authentication.refreshToken() shortly before expires_at (the access token lasts 15 minutes) and store the returned pair; each refresh token works once. A customer-scoped call that answers 401 invalid_token is refreshed once, and the shopper is signed out if the refresh fails.
Our TypeScript SDK exposes refreshToken so you can wire up a scheduled rotation. See the Authentication Service for the full method reference and lifecycle diagram.

Subscription status and key scope

A store whose subscription is not active, or that has been deactivated, answers every API-keyed request with 402 and the code subscription_expired until the subscription is renewed. The response carries the usual Tybrite-Environment header. A key issued through GC Connect carries only the scopes the merchant approved. A request outside them returns 403 with the code insufficient_scope, and a request that needs a secret key returns 403 forbidden.

Keys limited to a list of endpoints

A key issued for a single custom extension is limited to an approved list of endpoints. A request outside the list returns 403 with the code endpoint_not_allowed. Other keys are not affected.

Limited publishable keys

A publishable key can be limited to the products that carry one tag, such as gifts, so that a second storefront on the same store shows only that range while sharing the store’s stock, orders and customers. A merchant creates one in GC Admin under Settings, API keys. A limited key returns only the slice on every read: products, facets and search, store information, collections, promotions, posts, lookbooks, reviews, recommendations, prices and discovery lists, with counts computed on the slice. A product outside the slice answers 404. A write that names a product, variant, promotion or review outside the slice (cart, wishlist, stock reservation, an order line, a review, a promotion calculation, a storefront event) returns 403 with the code out_of_scope, and nothing is written or reserved. A route that has no slice behaviour returns 403 with the code endpoint_not_allowed. Responses are cached per limit, so a limited key never receives a response cached for the whole store. Shopper sign-up and sign-in stay store-wide. Secret keys and GC Connect keys cannot be limited.