Skip to main content
The CustomersService class (accessed via client.customers) exposes the customer record as a first-class API resource — meant for integrations that manage authentication outside Galactic Core.
Two integration paths. If your storefront uses Galactic Core’s built-in auth (/v1/auth/register, /v1/auth/login, etc.), prefer the AuthenticationService — it creates and links the customer record for you. Use CustomersService when you’re bringing your own identity provider (Auth0, Clerk, Cognito, Firebase, NextAuth, SSO, etc.) and want to provision the Galactic Core customer record directly from your backend. See Customers and Auth for the full decision matrix.
Sandbox isolation: Customer records created with a tybrite_sk_test_* key exist only in the sandbox environment and are never visible to production keys. Every response includes a Tybrite-Environment: sandbox | production header confirming which environment resolved.

Profile Management

A customer carries a custom_fields array — fields the merchant defined themselves, such as a VAT registration. See Custom Fields.

createCustomer

Provision a Galactic Core customer record. The customer exists immediately and can place orders, hold a cart, leave reviews, etc. — but no Galactic Core login credentials are created. Authentication remains the responsibility of your external identity provider. Pass external_id to store your upstream user identifier (Auth0 sub, Clerk user.id, etc.). It’s unique per store + environment, so subsequent reads can look up the Galactic Core customer by that identifier without keeping a side-table. Pass marketing_consent to record whether the customer opted in to marketing communications. It defaults to false (opt-in) — only set it to true when the customer affirmatively checks a marketing opt-in box on your storefront. When true, the customer becomes eligible to be subscribed to the store’s connected marketing tools.
Secret Key only. Call this from a secure server-side environment — typically a webhook or post-signup hook in your identity provider.
Response 201:
A store holds one customer per email address, compared without regard to case or surrounding spaces. When a customer with the request’s email already exists, createCustomer responds 200 with that customer instead of creating a second one. Only the existing customer’s empty phone, address and external_id are filled from the request; every other field is left unchanged, and no customer.created event is sent. A new customer responds 201. An external_id already used by a different customer responds 409.
A newly created customer starts at the bronze tier with no purchase history, so last_purchase and store_metrics are null until their first order. tier is the pricing tier the merchant assigned to the customer, and is returned by the authentication endpoints.
The customer’s marketing opt-in can be changed later via updateCustomer (e.g. when a signed-in shopper toggles email preferences in their account). Pass requestBody: { marketing_consent: false } to opt them out.
createCustomer returns { customer }. getCustomer returns the customer fields at the top level.

getCustomer

Retrieve a customer’s profile, including store metrics and purchase history. This is the endpoint your “My Account” page calls. The response includes store_credit_balance — the customer’s redeemable store-credit balance, which can be applied at checkout via apply_store_credit on createOrder. Sign an xExternalAuth assertion in your backend (see Customers and Auth for the signing helper) and pass it through:
If your storefront authenticates customers through Galactic Core (Path A), pass the customer’s session JWT as xAuthToken in place of xExternalAuth:
If you’d rather not sign an assertion, pass the raw token from your identity provider (for example a Firebase ID token) as xIdpToken. Galactic Core forwards it to your store’s configured Auth verifier, which validates it and returns the identity:
xIdpToken is fail-closed: if the verifier rejects the token or is unreachable, the request is unauthenticated (401). It requires an Auth verifier to be configured for the store.Provide exactly one of xAuthToken, xExternalAuth, or xIdpToken. More than one → 400. Mismatch with the path id → 403.
Response 200 — the customer fields are returned at the top level (not wrapped in a customer key):
address, last_purchase, and store_metrics are null until the customer has supplied an address and made a purchase. tier is the pricing tier the merchant assigned to the customer; new customers start at bronze.

updateCustomer

Partially update a customer’s profile. Only the fields you supply are modified. Typical caller: a “Save changes” button on the customer’s account page. The writable fields are name, phone, address, status (active or inactive) and marketing_consent. Any other field in requestBody — external_id, tier or a purchase total, for example — is ignored, and a body naming no writable field returns the customer unchanged. email is writable only when the call is made with a secret key, from your storefront’s server after it has verified the new address. With a publishable key, email is ignored like any other non-writable field, because guest orders are linked to a customer by email address. Changing email to an address another customer of the store already uses returns 409.
Response 200 — the updated profile, wrapped in a customer key:
You can also pass a raw identity-provider token (for example a Firebase ID token) as xIdpToken, which Galactic Core forwards to your store’s Auth verifier — fail-closed, so a rejected or unreachable verifier returns 401:
Provide exactly one of xAuthToken, xExternalAuth, or xIdpToken. More than one → 400. Mismatch with the path id → 403.
updateCustomer returns { customer }. Unwrap the customer key to get the resource.

Saved addresses

Let a signed-in shopper keep a personal address book — multiple billing and shipping addresses they can reuse at checkout instead of re-typing them every time. Pre-fill your checkout form from listAddresses, or pre-select the shopper’s default shipping/billing address. These are customer-self operations: they work with a publishable key (safe to call from the browser), but require the shopper’s session token in xAuthToken. The token must resolve to the customer in the id path parameter, otherwise the call returns 403. A credential for a closed customer account returns 403 with account_closed (see Closed customer accounts).
Single default per kind. Setting an address as the default for shipping (is_default_shipping) or billing (is_default_billing) automatically clears any previous default of the same kind, so there’s always at most one default shipping address and one default billing address.

listAddresses

Return the shopper’s saved addresses, defaults first. Use this to render their saved addresses at checkout.
Response (200)

createAddress

Save a new address to the shopper’s address book. full_name, line1, city, and country are required; everything else is optional. address_type is one of shipping, billing, or both (default both).
Response (201)

updateAddress

Partially update a saved address — only the fields you supply are changed. Pass the address id as addressId.

deleteAddress

Remove an address from the shopper’s address book.

Subscribe & Save subscriptions

A shopper subscription is one shopper’s acceptance of a Subscribe & Save offer: which items, how often, where to send them and how each delivery is paid. These are customer-self operations. They work with a publishable key and require the shopper’s session token in xAuthToken (or xExternalAuth, never both); the token must resolve to the customer in the id path parameter, otherwise the call returns 403. A subscription that belongs to another shopper reads as 404.

listShopperSubscriptions

List a shopper’s Subscribe & Save subscriptions. Return the signed-in shopper’s Subscribe & Save subscriptions at this store, newest first (at most 100). Each subscription lists its items, the interval, the date of the next delivery, the saved card that is charged (when there is one) and the terms the shopper accepted. Customer-self access. Works with a publishable key (safe from the browser). Provide the shopper’s session token in the x-auth-token header (or the store’s bring-your-own-auth assertion in x-external-auth); it must resolve to the customer in the {id} path parameter, otherwise the request returns 403. A subscription that belongs to another shopper reads as 404.
Response

GET /v1/customers/{id}/shopper-subscriptions

getShopperSubscription

Get a Subscribe & Save subscription. Return one of the signed-in shopper’s subscriptions. Customer-self access. Works with a publishable key (safe from the browser). Provide the shopper’s session token in the x-auth-token header (or the store’s bring-your-own-auth assertion in x-external-auth); it must resolve to the customer in the {id} path parameter, otherwise the request returns 403. A subscription that belongs to another shopper reads as 404.
Response

GET /v1/customers/{id}/shopper-subscriptions/{subscriptionId}

updateShopperSubscription

Change a Subscribe & Save subscription. Change one thing about the shopper’s subscription per request: the delivery interval, the items, or where the deliveries go. A change to the items applies from the next delivery; a change to the interval restarts the schedule from today. A change the offer or the store does not allow is refused with 400 or 409 and a message the shopper can read: an interval the offer does not list, an item the offer does not cover, or item changes the store has turned off. Send exactly one group of fields:
  • interval_unit with interval_count: the delivery interval, one of the offer’s intervals.
  • items: the full list of items for each delivery, 1 to 50 entries. Items left out are removed.
  • fulfillment_method with shipping_address_id (one of the shopper’s saved addresses) for delivery, or with pickup_location_id for pickup, and optionally shipping_option_id.
Customer-self access. Works with a publishable key (safe from the browser). Provide the shopper’s session token in the x-auth-token header (or the store’s bring-your-own-auth assertion in x-external-auth); it must resolve to the customer in the {id} path parameter, otherwise the request returns 403. A subscription that belongs to another shopper reads as 404.
Response

PATCH /v1/customers/{id}/shopper-subscriptions/{subscriptionId}

pauseShopperSubscription

Pause a Subscribe & Save subscription. Pause the subscription so no delivery is created while it is paused. Send until to resume automatically on that date, from tomorrow up to a year ahead; omit it to stay paused until the shopper resumes. Only an active subscription can be paused, and not while a delivery is being prepared. Customer-self access. Works with a publishable key (safe from the browser). Provide the shopper’s session token in the x-auth-token header (or the store’s bring-your-own-auth assertion in x-external-auth); it must resolve to the customer in the {id} path parameter, otherwise the request returns 403. A subscription that belongs to another shopper reads as 404.
Response

POST /v1/customers/{id}/shopper-subscriptions/{subscriptionId}/pause

resumeShopperSubscription

Resume a paused Subscribe & Save subscription. Resume a paused subscription. The next delivery date is calculated from today on the subscription’s interval. Customer-self access. Works with a publishable key (safe from the browser). Provide the shopper’s session token in the x-auth-token header (or the store’s bring-your-own-auth assertion in x-external-auth); it must resolve to the customer in the {id} path parameter, otherwise the request returns 403. A subscription that belongs to another shopper reads as 404.
Response

POST /v1/customers/{id}/shopper-subscriptions/{subscriptionId}/resume

skipNextShopperDelivery

Skip the next Subscribe & Save delivery. Skip the next scheduled delivery. The following delivery keeps the subscription’s interval. A delivery that is already being prepared cannot be skipped, and an offer may limit how many deliveries a shopper skips in a year. Customer-self access. Works with a publishable key (safe from the browser). Provide the shopper’s session token in the x-auth-token header (or the store’s bring-your-own-auth assertion in x-external-auth); it must resolve to the customer in the {id} path parameter, otherwise the request returns 403. A subscription that belongs to another shopper reads as 404.
Response

POST /v1/customers/{id}/shopper-subscriptions/{subscriptionId}/skip-next

cancelShopperSubscription

Cancel a Subscribe & Save subscription. Cancel the subscription in one step. The cancellation takes effect today unless the offer requires a minimum number of deliveries that have not yet been made, in which case it takes effect on the date of the last committed delivery and cancel_effective_on says when. Send preview: true to read that date, and how many deliveries remain, without cancelling, so the shopper is told before they confirm. Customer-self access. Works with a publishable key (safe from the browser). Provide the shopper’s session token in the x-auth-token header (or the store’s bring-your-own-auth assertion in x-external-auth); it must resolve to the customer in the {id} path parameter, otherwise the request returns 403. A subscription that belongs to another shopper reads as 404.
Response
POST /v1/customers/{id}/shopper-subscriptions/{subscriptionId}/cancel

Saved payment methods

A card the shopper agreed to keep for later deliveries is listed without its number: brand, last four digits and expiry. startShopperCardUpdate returns a hosted page on which the shopper enters a replacement card for one subscription, so card details never reach the storefront.

startShopperCardUpdate

Add a card to a Subscribe & Save subscription. Start adding a replacement card for a subscription. The response is the payment processor’s own hosted page; the shopper enters the card there. When the processor confirms the card it is saved and the subscription charges it for every later delivery, and a delivery that was waiting on a declined card is retried with it. The shopper returns to the subscription’s manage page afterwards. A store whose processor cannot save cards answers 409. At most 10 sessions can be started per shopper per hour (429). Customer-self access. Works with a publishable key (safe from the browser). Provide the shopper’s session token in the x-auth-token header (or the store’s bring-your-own-auth assertion in x-external-auth); it must resolve to the customer in the {id} path parameter, otherwise the request returns 403. A subscription that belongs to another shopper reads as 404.
Response

POST /v1/customers/{id}/shopper-subscriptions/{subscriptionId}/payment-method

listShopperPaymentMethods

List a shopper’s saved cards. Return the cards the signed-in shopper has saved for Subscribe & Save deliveries, newest first. Each card shows its brand, last four digits and expiry; the card number and the processor’s references are never returned. Removed and replaced cards are not listed. Customer-self access. Works with a publishable key (safe from the browser). Provide the shopper’s session token in the x-auth-token header (or the store’s bring-your-own-auth assertion in x-external-auth); it must resolve to the customer in the {id} path parameter, otherwise the request returns 403. A subscription that belongs to another shopper reads as 404.
Response

GET /v1/customers/{id}/payment-methods

deleteShopperPaymentMethod

Remove a saved card. Remove one of the signed-in shopper’s saved cards. The store can no longer charge it. A subscription that was charging this card switches to confirm-and-pay: the shopper is sent a link to pay each delivery until a new card is added. Customer-self access. Works with a publishable key (safe from the browser). Provide the shopper’s session token in the x-auth-token header (or the store’s bring-your-own-auth assertion in x-external-auth); it must resolve to the customer in the {id} path parameter, otherwise the request returns 403. A subscription that belongs to another shopper reads as 404.
Response
DELETE /v1/customers/{id}/payment-methods/{paymentMethodId}

Purchased items

Digital downloads, codes and licence keys, and event tickets are delivered once an order is paid. listShopperFulfilments lists the delivered items across orders, revealShopperFulfilmentCodes returns the codes of one delivery in clear, and downloadShopperFulfilmentFile answers with a redirect to a short-lived link to one file. See What a store can sell.

listShopperFulfilments

List a shopper’s delivered items. Return the downloads, codes, event tickets and services the shopper has bought, across their orders, newest first. Each purchased unit is one entry, so an order line of three event tickets lists three entries. An entry is preparing until the item is delivered, then delivered, and voided after a refund or return. A digital entry lists its files, each with a download_url. A code entry shows its codes masked and a reveal_url; read the codes themselves with POST /v1/customers/{id}/fulfilments/{fulfilment_id}/reveal. An event_ticket entry lists its tickets with the text to encode as the QR code. A service entry carries the merchant’s confirmation note. Customer-self access. Works with a publishable key (safe from the browser). Provide the shopper’s session token in the x-auth-token header (or the store’s bring-your-own-auth assertion in x-external-auth, never both); it must resolve to the customer in the {id} path parameter, otherwise the request returns 403. A Connect key needs the fulfilment:read scope.
Response

GET /v1/customers/{id}/fulfilments

revealShopperFulfilmentCodes

Reveal the codes of a delivered item. Return the codes of one code entry in clear, for example a licence key or a voucher code. Each reveal is recorded and is limited per shopper and per address; the response is never cached. An entry that is not the shopper’s reads as 404, and an entry that was refunded or whose codes are not available answers 409 or 410 with a sentence for the shopper. Customer-self access. Works with a publishable key (safe from the browser). Provide the shopper’s session token in the x-auth-token header (or the store’s bring-your-own-auth assertion in x-external-auth, never both); it must resolve to the customer in the {id} path parameter, otherwise the request returns 403. A Connect key needs the fulfilment:read scope.
Response

POST /v1/customers/{id}/fulfilments/{fulfilment_id}/reveal

downloadShopperFulfilmentFile

Download a file the shopper bought. Answer 302 with a short-lived link to one file of a delivered digital entry. The response has no body; follow the Location header to receive the file. Each request counts towards the download limit and the access period the merchant set for the product. Two ways to call it:
  • Link from the delivery email or the entry’s download_url. Pass the link token as the t query parameter. No API key and no shopper header is sent; the token is the credential, and sending a shopper header with it returns 400. Requests are limited per address and per entry.
  • Shopper credentials. Omit t, send the API key, and send the shopper’s session token in x-auth-token (or the store’s assertion in x-external-auth, never both). The shopper must be the buyer of the entry. A Connect key needs the fulfilment:read scope.
An entry or file that does not exist, a token that does not match and a shopper who is not the buyer all answer the same 404.
GET /v1/fulfilment/downloads/{fulfilment_id}/{asset_id}

Data requests

A signed-in shopper can ask the store for a copy of their personal data (export) or for their account and that data to be deleted (erasure). The store chooses how requests are handled. By default the store reviews each one: the request is requested until the store approves or declines it. When shoppers complete their own requests, an export is approved at once and an erasure is carried out at once, so the request is completed. All three methods are customer-self calls: they work with a publishable key and the shopper’s credential (xAuthToken, xExternalAuth or xIdpToken; send exactly one), which must resolve to the customer in id, otherwise the call returns 403.

listCustomerDataRequests

The shopper’s requests, newest first (at most 50), with where each stands. A declined request carries the store’s reason in decline_reason; an approved export shows when its download window ends in download_expires_at. A sandbox key sees sandbox requests only.
Response

createCustomerDataRequest

Makes a request for the shopper. requestBody.kind is export or erasure. An erasure must carry requestBody.confirm: true, sent only after the shopper has confirmed in the storefront; confirm is not accepted with export. Each shopper has one open request of each kind. Asking again while one is waiting, or while an export is still downloadable, returns that request with created: false and status 200. A new request returns 201 with created: true. An erasure is refused with 409 while the shopper has a Subscribe & Save subscription still running, paid orders not yet shipped, or a business buyer account; the message says which. After an erasure, records the store must keep, such as sales, remain with the personal details removed, and the shopper’s sign-in no longer resolves to a customer. A shopper is limited to 5 requests an hour.
Response

downloadCustomerDataExport

Returns the shopper’s data as JSON for an export the store approved, or that completed at once, during its seven-day download window. The copy is built when it is downloaded, so it reflects the store’s records at that moment. It is never cached. Secrets, access tokens and the store’s own cost figures are not included. A shopper is limited to 10 downloads an hour. The call answers 409 when the request is still waiting, was declined, or its download window has ended; make a new request for a fresh copy. Another shopper’s request, an erasure request, or an id from the other environment answers 404.
Response

Changing the email address

A shopper changes the sign-in address of a store-managed account in two calls that prove control of the new address with a six-digit code. The account keeps its current address until the code is confirmed. Both calls are customer-self: the publishable key plus the shopper’s xAuthToken, which must resolve to the customer in id (otherwise 403). An account signed in through the store’s own identity system (xExternalAuth or xIdpToken) answers 409 email_managed_externally on both calls, because the store’s identity system owns that address.

requestCustomerEmailChange

Sends a code to the new address and a notice that a change was requested to the current address. The code is valid for 15 minutes, can be tried 5 times and works once; a new request replaces the pending one. The emails carry the store’s name and branding.
Response
409 conflict is returned when the new address is already the account’s address. 429 is returned when a code was already sent to that address in the last minute, or the shopper has made 5 requests in an hour.

confirmCustomerEmailChange

Checks the code and changes the account’s sign-in address and customer record together. The address is read from the pending request, never from this call. The previous address receives a notice.
Response

Customer Utilities

Retention Tip: Use store_metrics to identify your top 10% of customers by lifetime value (LTV) and offer them personalized discount codes via the Promotions Service.

Authentication Flow

The getCustomer and updateCustomer methods require the shopper to be identified in addition to your API key, by exactly one of three headers: a customer session JWT (xAuthToken, obtained via the AuthenticationService through login or verifyOtp), a bring-your-own-auth signed assertion (xExternalAuth), or a raw identity-provider token (xIdpToken) that Galactic Core forwards to your store’s Auth verifier. See Customers and Auth for choosing between them.
Never expose Secret Keys in client-side code. For browser-based customer portals, use a Publishable Key in combination with the customer’s xAuthToken.
createCustomer is intentionally Secret Key only — it is an admin/CRM operation (e.g. bulk imports) and does not involve customer authentication. No xAuthToken is required or accepted.

Response Codes

Data requests

A signed-in shopper can ask the store for a copy of the personal data it holds about them (export), or for their account and that data to be deleted (erasure). The store chooses how requests are handled:
  • The store reviews each request (the default). A request stays requested until the store approves or declines it. An approved export can be downloaded for seven days; an approved erasure is carried out by the store. A declined request carries the store’s reason in decline_reason.
  • Shoppers complete their own requests. An export is ready to download at once, and an erasure is carried out at once.
Each method is customer-self: call it from the browser with the publishable key and the shopper’s credential in exactly one of xAuthToken, xExternalAuth or xIdpToken. The credential must resolve to the customer in id, otherwise the request returns 403. A sandbox key reaches sandbox requests only. A shopper has one open request of each kind. Asking again while one is waiting, or while an export is still downloadable, returns that request with created: false. After an erasure, records the store must keep, such as sales, remain with the personal details removed. The shopper’s sign-in no longer resolves to a customer, so a storefront signs the shopper out once the request is completed.

listCustomerDataRequests

Lists the shopper’s data requests, newest first (at most 50).
Response

createCustomerDataRequest

Makes a request for the shopper. An erasure must carry confirm: true, sent only after the shopper has confirmed in the storefront. Pass an idempotencyKey so a retried request returns the one it created. Limited to 5 requests per shopper per hour.
Response
201 when the request is made, 200 with created: false when an open request of that kind is returned instead. An erasure answers 409 while the shopper has a Subscribe & Save subscription still running, paid orders not yet shipped, or a business buyer account; error.message says which, in words a shopper can read.

downloadCustomerDataExport

Returns the shopper’s data as JSON for an approved export, during its download window. The copy is built when it is downloaded. It is sent as an attachment and never cached. Limited to 10 downloads per shopper per hour.
Response
409 when the request is still waiting, was declined, or its download window has ended; a new request gives a fresh copy. tables holds the shopper’s profile, addresses, orders and their lines, returns, reviews, messages, wishlist, store credit, consents and the store’s custom fields about them. Secrets, access tokens and the store’s own cost figures are not included. Amounts are in major currency units.