Tybrite uses a dual-key architecture to ensure maximum security without sacrificing developer experience. Depending on where your code runs, you will use different keys and authentication patterns.Documentation Index
Fetch the complete documentation index at: https://docs.tybritelabs.com/llms.txt
Use this file to discover all available pages before exploring further.
API Key Types
We support two distinct key types for every store. You can manage these in your Dashboard under Settings > API Keys.Publishable Keys (tybrite_pk_...)
Publishable keys are intended for use in frontend applications, such as React websites, mobile apps, or headless storefronts.
- Scope: Read-only access to non-sensitive data (Products, Categories, Search).
- 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:
Authorization Header
For direct REST API calls, provide your key in theAuthorization header using the Bearer scheme:
Advanced Security: HMAC Signing
Sensitive operations, such as order creation or payment initialization, require an additional layer of security to prevent request tampering and replay attacks. For these requests, you must provide verified headers.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.POST /v1/payments/initializePOST /v1/ordersPATCH /v1/orders/:id
🔄 Idempotency Protection
To prevent duplicate charges and orders—especially during network retries—all state-changing financial operations require a mandatoryIdempotency-Key header.
- Mechanism: The server tracks these keys. If a request is retried with the same key, the server returns the original response with an
idempotent: trueflag. - Best Practice: Generate a unique UUID or a hash of the transaction details (e.g.,
payment-order_123-ts_456).
POST /v1/payments/initializePOST /v1/ordersPATCH /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).
Why both? A leaked publishable key alone gives an attacker no way to read or modify any specific customer’s data — they would also need that customer’s JWT, which only the AuthenticationService can issue, and only after a successful login / OTP verification / magic link redemption.
Affected endpoints
| Endpoint | xAuthToken requirement |
|---|---|
GET / PATCH /v1/customers/{id} | Required. Token’s subject must match path id. |
GET / POST / PATCH / DELETE /v1/cart/* | Required when customer_id is supplied (anonymous session carts omit it). |
GET / POST / DELETE /v1/wishlist/* | Required — wishlist always requires customer_id. |
GET /v1/gift-cards?customer_id=... | Required when customer_id is supplied. |
GET / POST / PATCH /v1/messaging/* | Required, gated by thread or message ownership. |
Example flow
Session Management
When building authenticated customer experiences (like “My Account” or “Quick Checkout”), the Tybrite SDK handles session persistence viaxAuthToken.
- Login: Call
client.auth.login()to receive a session and user object. - Persistence: Store the
session.access_tokensecurely (httpOnly cookies preferred). - Requests: Provide the token via the
xAuthTokenSDK parameter (orx-auth-tokenheader for raw REST) on protected endpoints. - Refresh: Call
client.auth.refreshToken()~60s beforeexpires_atto rotate to a fresh session.

