Skip to main content
The SDK has two error behaviours. Which one you get depends on the layer you call. The facade a loader calls degrades, so a Meridian problem cannot stop a merchant’s app from loading. The low-level clients hand you the error instead, for you to decide on. For 401 and 403 refusals, the facade logs once per method and error code per process. A 403 FEATURE_NOT_AVAILABLE_FOR_PRIVATE_APP explains the private app restriction without asking you to change MERIDIAN_API_KEY. Other 403 codes and messages are logged as received, unless the code identifies a credential rejection. See Facade diagnostics.

MeridianApiError

Branch on code. The message is prose and can be reworded. One failure is not a MeridianApiError: a dated event whose Date is invalid makes track and trackMany throw a TypeError before any request is sent. The createMeridianApp methods resolve null for it, like any other failure.

States worth handling

Seven guards are exported from both entries, for the failures that mean something specific:

Shop token expired or revoked

An expired token has aged past its hour, or a refresh elsewhere replaced it within the last hour. Either way, refreshing it returns a live token. The provider handles this for you: it gets a new token, replays the call, and fires onTokenRefreshed. On the server there is no automatic refresh: call refreshShopToken() and retry, or mint a fresh token. A revoked token belonged to a shop that uninstalled the app. Once the shop reinstalls, a refresh returns the install’s current token, so the provider handles both codes the same way and the merchant sees nothing. While the shop is still uninstalled, or once the revoked token’s original hour is over, the refresh is refused too: mint a fresh token. The createMeridianApp methods do that themselves. See After an uninstall. A refresh itself can answer 401 SHOP_TOKEN_REFRESH_EXPIRED (“Shop token is too old to refresh. Re-identify the shop.”). The token belongs to a chain that identify started more than 7 days ago, and refreshing never extends that. Mint a fresh token. The createMeridianApp methods do that themselves. There is no guard for this code: read err.code. See How long a token can be refreshed. A provider given getShopToken gets its new token from your app’s server instead of refreshing it, on any of these three codes and on a plain 401 (“Invalid shop token.”), which a page left idle for more than an hour after its token was replaced gets. Your server mints that token with identify, so the merchant sees none of these errors, even on a page left open for more than 7 days. When getShopToken has no token to give, the call fails with Meridian’s original refusal. A refresh can also answer 401 SHOP_TOKEN_REFRESH_DISABLED (“Shop token refresh without the app’s API key is turned off for this app. Get a new token from the app’s server.”). Your app set browserTokenRefresh: false on createMeridianApp, and the refresh carried no valid API key of the app. Nothing was rotated or exchanged, and the token keeps working until its hour ends. Get a new token from your server: MeridianProvider does that itself when it has getShopToken, and without it shows the refusal on error like any refused refresh. createMeridianApp sends its API key on every refresh, so its own refreshes are not refused this way. refreshShopToken() on createMeridianServerClient holds no key, so it is. There is no guard for this code: read err.code. See Turning off refresh without the API key.

The shop token belongs to another Meridian API

Off production, Meridian marks the shop tokens it mints with its platform (mrd_shop_stg_… on staging), so another platform’s API can recognise them. A staging, dev or local token sent to the production API answers this code, with err.details.minted_by naming the platform that minted it (staging, dev or local). It almost always means a MeridianProvider mounted without baseUrl off production: pass the API that minted the token, meridian.baseUrl from your loader. See the baseUrl prop. A refresh cannot help, because this API does not know the token. The provider never tries one: it shows the API’s message on error and logs one console.error per mount with the fix.

The merchant must re-authorize

Your app holds no usable Shopify offline session for this shop, or its refresh keeps failing. No retry can fix it: the merchant has to relaunch the app. The provider calls onShopifyAccessTokenStale once per mount, defaulting to a page reload, which in an embedded app puts the merchant back through authorization. It then rethrows, so your component can react too.

Meridian cannot bill this app at all

This one is yours to fix, not the merchant’s: Meridian could not reach your app’s Shopify session store, which in practice means the app is not hosted on Meridian. err.details.plan_builder_billing_status names the missing precondition: Your Meridian dashboard shows the same reason and disables publishing until it is fixed.

Shopify billing is not set up

err.details.reasons is an array of reason names. Each one identifies something you must fix, rather than asking the merchant to re-authorize: A SHOPIFY_API_KEY or SHOPIFY_API_SECRET variable set on the app or an environment is not enough: billing reads only the client ID and secret saved in App settings > Meridian SDK credentials, so missing_shopify_client_id or missing_shopify_client_secret stays until you save them there too. This check runs on every subscribe in every environment, including test charges, development stores and staging. It runs before the session-store check that can return PLAN_BUILDER_UNAVAILABLE. The provider logs one console.error for each refused subscribe, including calls from MeridianPricingPage, custom grids using useMeridian().subscribe, and an onSubscribe override that throws this error. In the default flow it appears in the browser console, in production as well as development, because the browser calls Meridian directly. The line names all the reasons, tells you what to fix and links here:
The merchant’s banner keeps the neutral message, “This app is not ready for live Shopify billing.” It never shows the reason names or credential instructions. The provider rethrows the original MeridianApiError, so your code can still read code and details. createMeridianServerClient throws without logging. On Node, your own console.error(err) includes those fields in your server logs. Saving the missing settings takes effect immediately for Meridian’s billing check. On a hosted app, the updated client secret reaches your app’s SHOPIFY_API_SECRET environment variable only at its next deploy.

The app’s own Meridian plan ran out

Your app’s Meridian plan meters how many SDK requests and usage events it may make per month (see the comparison). Past the allowance the API answers 402 PLAN_LIMIT_REACHED, and err.details carries meter, limit and used. Importing history from before the app joined Meridian uses neither allowance during the app’s first 30 days. See History from before Meridian. This is yours to fix, not the merchant’s, and it is not retried: the answer will be the same until the allowance resets at the start of next month or you upgrade the app’s plan. Meridian emails your organization’s owners at 80%, 95% and 100% of the allowance, so a 402 here should never be the first you hear of it. Treat it like any other Meridian outage in your app: let the facade degrade, or fall back to your own behaviour. Do not surface it to the merchant.

One store used its share of the plan

One store cannot use up your app’s SDK requests for all the others. On a plan that caps SDK requests (see the comparison), each store has a share of the monthly allowance. Past it, that store’s calls answer 402 SHOP_LIMIT_REACHED while your other stores keep working, and err.details carries meter, limit (the store’s share) and used (the store’s count this month). The share is set well above what a store using your app normally makes. Requests from development stores are not counted at all. It is not retried: the store gets its share back at the start of next month. Handle it like PLAN_LIMIT_REACHED for that one store: let the facade degrade, and do not surface it to the merchant. A real store that reaches it is usually calling Meridian in a loop, which is worth a look on your side.

Plan change refusals

These come back from subscribe, cancelSubscription, undoScheduledChange and updateUsageCap around a scheduled change. There is no guard for them: branch on err.status and err.code. Like every billing write, none of them is retried for you.

A scheduled change that cannot be undone

After either refusal, refresh the snapshot: the banner your UI shows is out of date. After a 409 the cancellation will happen on its date. The merchant can still pick another plan, or the same plan again once the date has passed. The provider handles one of these for you: when undoScheduledChange meets a change that has just taken effect (404 NO_SCHEDULED_CHANGE), it refreshes the snapshot and resolves { undone: false } instead of throwing. The server client throws it like any other error. The built-in pages show “Cancellations cannot be undone in the final 24 hours of the billing period.” for the 409.

Choosing a plan the shop already has

409 CONFLICT with “Already subscribed to this plan” answers a subscribe to the shop’s current plan, and also to the plan a scheduled downgrade already moves it to. While a change is scheduled, the way back to the current plan is undoScheduledChange.

Two changes at the same time

409 CONFLICT with “Another plan change for this store is still going through. Try again in a moment.” can answer subscribe, cancelSubscription, undoScheduledChange and updateUsageCap. Another of those calls for the same store has not finished, or a scheduled change whose date has just passed could not be applied before this request. Nothing was changed, so it is safe to try again: let the merchant retry after a moment, which is what the built-in pages do. They show the message and enable the button again. Inside one provider, a second billing write started while another is still in flight never reaches Meridian. It rejects at once with a plain Error, “Another billing action is in progress. Please wait.” See useMeridian.

No subscription to raise the cap on

updateUsageCap answers 404 RESOURCE_NOT_FOUND (“No active subscription”) while Shopify is not billing the shop’s current subscription:
  • Right after a subscribe, until Shopify has activated the new subscription.
  • In the last 24 hours of a scheduled cancellation.
  • During a scheduled downgrade, once Shopify has ended the current subscription.
The first case clears by itself within moments, so let the merchant try again. The account page shows a notice and keeps its dialog open for that.

What gets retried

The SDK retries 429 and 5xx responses up to three attempts, with exponential backoff from 250 ms, capped at 5 seconds, honouring a Retry-After header when one is sent. Network errors are retried the same way. It only does that where a retry is safe: A billing write is never retried on its own. Where accuracy matters for tracking, send an idempotencyKey. See Usage tracking. A dated event always carries one, so it is always retried.

Rate limits

Reads and tracking share 120 requests per minute; billing writes share 30. A batch of up to 50 events counts as one request. Both budgets belong to the store, not to the token: one shop cannot exhaust another’s, and a refreshed token keeps the budget of the one it replaces. On top of them, all the reads and tracking of one app share a ceiling of 6,000 requests per minute. An address that sends many unknown tokens is refused with a 429 for the rest of the minute. Tokens and keys that worked in the last hour keep working from that address. A 429 on a retryable call is handled for you; on a billing write it reaches your code, and backing off is the correct response. MeridianApiError.retryAfterSeconds carries the wait the API asked for, in seconds. createMeridianApp goes one step further with a breaker: after a 429, every later call on that app instance is skipped locally, without touching the network, until the Retry-After deadline passes. The breaker logs one console.error naming the deadline when it opens, and nothing for the calls it skips. During that window gates come back with status: "rate_limited" and every feature off (unless failOpen, or the shop’s entitlements are still cached), and shop tokens are null for every shop, so a rate-limited app degrades deterministically instead of a random share of its calls failing. Nothing ever sleeps or retries on a deadline inside a loader. If you see the breaker’s log line in normal operation, your app is calling Meridian more often than its budget allows. The usual cause is minting a shop token per request on hosting where the in-process cache cannot help; persist the token instead.

Loading and error state in React

Every feature reads as off until the first load succeeds (while status is "loading", and when that load fails), so gating without checking it flashes the upgrade prompt at someone who has already paid. In SDK 3.5.0 and later, status is "failed" or "rate_limited" when the first load failed, and "ok" once a snapshot has loaded, even if a later refresh fails (error is then set and the gates keep answering from that snapshot). The provider’s failOpen prop turns features on when the first load failed. See fail open or fail closed.

Running unconfigured

An app with no Meridian credentials keeps running: configured is false, shop tokens are null, and every feature reads as off. In SDK 3.5.0 and later, gatesForShop returns gates with status: "unconfigured", which failOpen never turns on. Events are not recorded, the pricing and account pages render empty, and installs and subscriptions are not reported. In SDK 3.4.0 and later, createMeridianApp() logs one [Meridian] console.warn per process at construction, naming the missing variables and linking to Running without Meridian, including in production. Unconfigured calls add no per-call log. The page components keep their own warning. track and trackMany still return null. In SDK 3.4.0 and later, use trackDetailed or trackManyDetailed to get status: "unconfigured" separately from "failed" or "rate_limited". Only "recorded" confirms the API result. Mount the provider conditionally and your app renders either way.

What is silent on purpose

Two things swallow every failure and log nothing:
  • Contact capture, which runs beside the provider’s load rather than gating it.
  • captureReferral, so a bad URL or an unreachable API cannot break the page a merchant is on. Whatever was resolved before the failure, notably the cookie, still comes back.
Both report what happened in their return value. Read stashed and cookieSkipped to know whether a capture worked.
Last modified on November 22, 2026