Skip to content

· 15 min read · Nadeera Silva

Payments

Stripe No Such Customer: Fix Connect and Test/Live Mix-Ups

Why Stripe says No such customer for a customer that exists: Connect accounts, test vs live keys, other accounts and deleted customers, with tested Node code.

Two oak card-catalog drawers side by side: a hand holds a blank card over the empty left drawer while the right drawer is full of cards with a teal tab, like a customer record filed in a different account

Stripe "No such customer" means the API key and account that made the request cannot see the cus_... ID you sent. The full error reads No such customer: 'cus_...', with the code resource_missing. If you searched for "stripe no such customer", the customer usually does exist. It just lives somewhere else: on a connected account while your code calls the platform, in test mode while you call with a live key, in another Stripe account, or it was deleted. Below I show how to tell which one it is, how to make Stripe Connect calls that find the customer, and the tested Node/TypeScript code I use so a stale customer ID heals itself instead of breaking checkout.

Quick answer

A customer ID only exists in the account and mode where it was created, so retrieve it with each key you have, with and without stripeAccount, to find where it lives. If it is on a connected account, pass { stripeAccount: 'acct_...' } on every call that uses it, including CustomerSessions and ephemeral keys; if the message says "a similar object exists in test mode, but a live mode key was used", create a new live customer. Long term, store customer IDs per account and mode, and create a fresh customer when Stripe says the old one is missing or deleted.

What this means for your app or business

  • What customers see. A returning buyer taps Pay and gets an error, or the payment sheet never opens. New buyers often work fine, which makes it confusing.
  • When it happens. Right after going live, after changing Stripe keys or accounts, after someone deletes customers in the Dashboard, or when a marketplace starts charging on its sellers' accounts.
  • The cost. No one is charged wrongly, but every affected returning customer is a lost sale until it is fixed.
  • How long the fix takes. A missing stripeAccount is often a one-line fix. Adding a proper customer mapping with self-healing usually takes a few hours plus testing.
  • When to get help. If you run a marketplace on Stripe Connect, or your database holds thousands of customer IDs from an old account, have a developer check it before you migrate or delete anything.

What does the Stripe "No such customer" error look like?

When the ID is in the URL, for example customers.retrieve, the response is HTTP 404 with param set to id. This body is from a Stack Overflow question:

{
  "error": {
    "code": "resource_missing",
    "doc_url": "https://stripe.com/docs/error-codes/resource-missing",
    "message": "No such customer: 'cus_NC2tFwyzx3A4mM'",
    "param": "id",
    "type": "invalid_request_error"
  }
}

When the ID is a parameter of another call, such as a PaymentIntent or Checkout Session, param is customer, and Stripe may add a mode hint, as in this report: "No such customer: 'cus_XXXXXXXXXXXXX'; a similar object exists in test mode, but a live mode key was used to make this request." Stripe's error codes page defines resource_missing as "The ID provided isn't valid. Either the resource doesn't exist, or an ID for a different resource has been provided."

Why does Stripe say "No such customer" when the customer exists?

Every customer belongs to exactly one Stripe account and one mode. Stripe's API keys guide says each mode has its own keys and "objects in one mode aren't accessible to the other". Your secret key picks the account and the mode, and the Stripe-Account header, if present, switches the request to a connected account. Stripe looks in that one place only.

Flow of how Stripe resolves a customer ID: the request, the account chosen by the key and Stripe-Account header, the mode chosen by the key prefix, then found, deleted or No such customer, with fixes
Where Stripe looks for a cus_ ID
CauseSymptomFix
Customer on a connected account, call made on the platformPlain "No such customer", customer visible on the seller's accountPass stripeAccount on every related call
Customer on the platform, call made with stripeAccountPlain "No such customer", customer visible in your own DashboardUse a destination charge, or create the customer on the connected account
Test customer, live key"...exists in test mode, but a live mode key was used"Create a new live customer and store it separately
Live customer, test key"...exists in live mode, but a test mode key was used"Use a sandbox customer for local and preview builds
Key from another Stripe account or sandboxPlain "No such customer"Fix the env var, or create customers in the new account
Customer deletedRetrieve returns deleted: true, payments failCreate a new customer and update your mapping

Stripe Connect: where does the customer live?

It depends on the charge type. With direct charges, the payment is created on the connected account, so the customer must be on that account too. With destination charges and separate charges and transfers, the payment is created on your platform, so the customer lives on the platform and you do not send stripeAccount.

Stripe's Connect authentication guide says to include the connected account ID in the Stripe-Account header "on each request". Most Connect cases of this error are one call that forgot it. In this Stack Overflow question the invoice had the header but the invoice item did not. In another the customer was on the platform and the PaymentIntent was on the connected account.

If you need the same buyer on several connected accounts, Stripe's current approach is to save the payment method on the platform and clone it to each connected account. The older guide for cloning customers across accounts is marked deprecated. A cloned customer gets a new ID on each account, so a platform cus_ ID never works with stripeAccount.

Deleted customers behave differently

Stripe's delete customer docs say deletion "cannot be undone", and that "deleted customers can still be retrieved". So customers.retrieve does not throw. It returns { id, object: 'customer', deleted: true }. Using that ID in a new subscription or payment fails, and real reports show it as "No such customer". Any check that only catches errors misses this case.

How do I find which account and mode a customer is in?

I run this read-only check with every key and connected account I have access to. The one that returns the customer is where it lives.

import Stripe from 'stripe';
import { isNoSuchCustomer } from './customerErrors.js';

export type Probe = { label: string; stripe: Stripe; stripeAccount?: string };
export type Finding = { label: string; result: 'found' | 'deleted' | 'missing' | 'error'; livemode?: boolean; detail?: string };

// Ask every account and mode you have keys for: "can you see this customer?"
// Read-only: it only calls customers.retrieve.
export async function diagnoseCustomer(customerId: string, probes: Probe[]): Promise<Finding[]> {
  const findings: Finding[] = [];
  for (const p of probes) {
    try {
      const c = await p.stripe.customers.retrieve(
        customerId,
        {},
        p.stripeAccount ? { stripeAccount: p.stripeAccount } : undefined,
      );
      if (c.deleted) findings.push({ label: p.label, result: 'deleted' });
      else findings.push({ label: p.label, result: 'found', livemode: c.livemode });
    } catch (err) {
      if (isNoSuchCustomer(err)) findings.push({ label: p.label, result: 'missing', detail: err.message });
      else findings.push({ label: p.label, result: 'error', detail: (err as Error).message });
    }
  }
  return findings;
}

Call it with probes such as platform test, platform live, and the seller's acct_ ID in each mode. With the Stripe CLI the same check is stripe customers retrieve cus_123 --api-key "$KEY" --stripe-account acct_123.

How do I fix it with Stripe Connect?

Step 1: a narrow error matcher

This only returns true for a missing customer, so a missing price or a card decline still fails loudly.

import Stripe from 'stripe';

// True only for "No such customer". A missing price, a decline or a network error returns false.
export function isNoSuchCustomer(err: unknown): err is Stripe.errors.StripeInvalidRequestError {
  if (!(err instanceof Stripe.errors.StripeInvalidRequestError)) return false;
  if (err.code !== 'resource_missing') return false;
  // param is 'customer' when the ID was a parameter (PaymentIntent, Checkout Session, Subscription...)
  // and 'id' when the ID was in the URL (customers.retrieve / update / del).
  if (err.param === 'customer') return true;
  return err.param === 'id' && err.message.includes('No such customer');
}

// A short hint for logs. Since stripe 23.2.0 err.message starts with "[req_...] ", so use includes().
export function explainNoSuchCustomer(err: unknown, ctx: { stripeAccount?: string } = {}): string | null {
  if (!isNoSuchCustomer(err)) return null;
  const where = ctx.stripeAccount ? `connected account ${ctx.stripeAccount}` : 'the platform account';
  const base = `No such customer (${err.statusCode}, param ${err.param}, request ${err.requestId ?? 'unknown'}) on ${where}`;
  if (err.message.includes('similar object exists in live mode')) {
    return `${base}: the customer is LIVE but this request used a TEST key.`;
  }
  if (err.message.includes('similar object exists in test mode')) {
    return `${base}: the customer was created in TEST mode but this request used a LIVE key.`;
  }
  return `${base}: not in this account and mode. Check the stripeAccount option, the key's account, or whether the customer was deleted.`;
}

Step 2: store customer IDs per account and mode

The root fix is your database. A single stripe_customer_id column breaks the moment you add live mode, a second Stripe account or a connected account. I key the mapping by user, account and mode, and heal it when Stripe says the customer is gone:

import Stripe from 'stripe';
import { isNoSuchCustomer } from './customerErrors.js';

// Where a Stripe customer lives: which connected account (or the platform) and which mode.
export type Scope = { stripeAccount: string | null; livemode: boolean };

// Your table: one row per (user, account, mode). Swap in Postgres, Firestore, Prisma...
export interface CustomerStore {
  get(userId: string, scope: Scope): Promise<string | null>;
  set(userId: string, scope: Scope, customerId: string): Promise<void>;
}

export function modeOfKey(secretKey: string): boolean {
  if (/^(sk|rk)_live_/.test(secretKey)) return true;
  if (/^(sk|rk)_test_/.test(secretKey)) return false;
  throw new Error('Not a Stripe secret or restricted key');
}

export async function getOrCreateCustomer(
  stripe: Stripe,
  secretKey: string,
  store: CustomerStore,
  user: { id: string; email: string; name?: string },
  stripeAccount: string | null = null,
): Promise<string> {
  const scope: Scope = { stripeAccount, livemode: modeOfKey(secretKey) };
  const opts = stripeAccount ? { stripeAccount } : {};
  const stored = await store.get(user.id, scope);

  if (stored) {
    try {
      const c = await stripe.customers.retrieve(stored, {}, opts);
      if (!c.deleted) return c.id; // the normal path
    } catch (err) {
      // Only "No such customer" means it is safe to create a new one.
      // Rate limits, auth errors and outages must not create duplicates.
      if (!isNoSuchCustomer(err)) throw err;
    }
  }

  const created = await stripe.customers.create(
    { email: user.email, name: user.name, metadata: { app_user_id: user.id } },
    {
      ...opts,
      // Same user + scope + stale ID = same key, so a double click or a retry
      // within 24 hours returns the same customer instead of a duplicate.
      idempotencyKey: `cus:${user.id}:${stripeAccount ?? 'platform'}:${scope.livemode ? 'live' : 'test'}:${stored ?? 'none'}`,
    },
  );
  await store.set(user.id, scope, created.id);
  return created.id;
}

Only resource_missing on the customer leads to a new customer. A timeout or a Stripe outage rethrows, because creating a second customer on a network error gives you duplicates. The idempotency key makes a retry or a parallel request return the same new customer instead of a second one. Stripe keeps keys for at least 24 hours. If a user can pay in two currencies, add currency to the key too, for the reasons in my post on Stripe "You cannot combine currencies on a single customer".

Step 3: mobile PaymentSheet with direct charges

This is the case I see most in Flutter apps. The backend creates the customer with stripeAccount, then creates the ephemeral key or CustomerSession without it. In stripe-node issue #1232 a Stripe engineer explained that the option used to create the customer has to be passed on all the requests for that account, including the ephemeral key. Stripe's direct charges guide for mobile now uses a CustomerSession instead of an ephemeral key, and sends Stripe-Account on all three calls:

import Stripe from 'stripe';
import { getOrCreateCustomer, type CustomerStore } from './customerMap.js';
import { explainNoSuchCustomer } from './customerErrors.js';

// Direct charge for a mobile PaymentSheet (Flutter, React Native, iOS, Android).
// Every call carries the SAME stripeAccount: the customer, the CustomerSession
// (or an ephemeral key in older integrations) and the PaymentIntent all live on the connected account.
export async function preparePaymentSheet(
  stripe: Stripe,
  secretKey: string,
  store: CustomerStore,
  user: { id: string; email: string },
  connectedAccountId: string, // acct_...
  amount: number,
  currency: string,
) {
  const opts = { stripeAccount: connectedAccountId };
  try {
    const customer = await getOrCreateCustomer(stripe, secretKey, store, user, connectedAccountId);
    const session = await stripe.customerSessions.create(
      { customer, components: { mobile_payment_element: { enabled: true, features: { payment_method_save: 'enabled', payment_method_redisplay: 'enabled', payment_method_remove: 'enabled' } } } },
      opts,
    );
    const intent = await stripe.paymentIntents.create(
      { amount, currency, customer, automatic_payment_methods: { enabled: true }, application_fee_amount: Math.round(amount * 0.1) },
      opts,
    );
    return {
      paymentIntentClientSecret: intent.client_secret,
      customerSessionClientSecret: session.client_secret,
      customerId: customer,
      stripeAccountId: connectedAccountId, // the app must use this too
    };
  } catch (err) {
    const hint = explainNoSuchCustomer(err, opts);
    if (hint) console.error(`[stripe] ${hint}`);
    throw err;
  }
}

The app must use the same account. In Flutter with flutter_stripe 15.0.0:

import 'package:flutter_stripe/flutter_stripe.dart';

// data = the JSON your server returned from preparePaymentSheet()
Future<void> openPaymentSheet(Map<String, dynamic> data) async {
  // Direct charges: the app must talk to the SAME connected account as the server.
  Stripe.stripeAccountId = data['stripeAccountId'] as String;
  await Stripe.instance.applySettings();

  await Stripe.instance.initPaymentSheet(
    paymentSheetParameters: SetupPaymentSheetParameters(
      merchantDisplayName: 'Seller name',
      paymentIntentClientSecret: data['paymentIntentClientSecret'] as String,
      customerId: data['customerId'] as String,
      customerSessionClientSecret: data['customerSessionClientSecret'] as String,
    ),
  );
  await Stripe.instance.presentPaymentSheet();
}

How do I test this without a real Stripe account?

stripe-mock is stateless, so it returns a customer for any ID and never says "No such customer". I used it only to check that the request parameters are valid for Stripe's API spec. For the error cases I wrote a small stateful fake that keeps customers per account and mode and returns Stripe's error JSON (404 with param: id on retrieve, 400 with param: customer otherwise). Output from node --test:

✔ retrieve of an unknown customer: 404, resource_missing, param id
✔ customer as a parameter: 400, param customer, matcher true
✔ matcher ignores other errors (No such price, generic Error)
✔ test customer with live key: explained as TEST customer / LIVE key
✔ Connect: customer on connected account, call without stripeAccount fails; with it succeeds
✔ ephemeral key created on the platform for a connected-account customer fails (stripe-node #1232 shape)
✔ deleted customer: retrieve returns deleted:true (no throw), using it in a PaymentIntent fails
✔ diagnoseCustomer finds which account and mode can see the ID
✔ getOrCreateCustomer: creates once, then reuses the stored ID (one create call)
✔ getOrCreateCustomer: separate rows per account and per mode
✔ getOrCreateCustomer self-heals a stale ID (test ID stored under live scope) and a deleted customer
✔ getOrCreateCustomer: a retry with the same stale ID reuses the idempotency key (no duplicate)
✔ getOrCreateCustomer does NOT create a customer when Stripe cannot be reached
✔ preparePaymentSheet (fake): customer, CustomerSession and PaymentIntent all on the connected account
✔ preparePaymentSheet against stripe-mock 0.206.0: request params are valid for the real API spec
ℹ tests 15
ℹ pass 15
ℹ fail 0

To see the real message once, retrieve a live customer ID with your test key. It is a read, so nothing is charged.

How do I verify the fix?

  • stripe customers retrieve <id> with the deployed key, plus --stripe-account for Connect, returns the customer with the livemode you expect.
  • A returning user can pay in the sandbox (test cards are in my 3D Secure test cards guide), and one small live payment works.
  • The Dashboard request log shows the call on the right account, and the old 404 or 400 is gone.
  • Your logs show any self-healing event with the user, scope and old ID, so you can see how many stale rows existed.

How do I stop "No such customer" coming back?

  • Store customer IDs with the account (platform or acct_...) and the mode next to them. Never one bare column.
  • Wrap Connect calls in a helper that always takes the account ID, so no call can forget stripeAccount.
  • Before go-live or an account migration, decide what happens to test customer IDs. The mapping above simply creates live ones on first payment.
  • Do not delete customers in the Dashboard to tidy up without checking which users point at them.
  • Check deleted after every customers.retrieve.
  • Log err.code, err.param, err.statusCode and err.requestId. account_invalid (HTTP 403) is a different problem: the acct_ ID itself is wrong or no longer connected.

Frequently asked questions

What does the Stripe "No such customer" error mean?

The key and account that made the request cannot see the customer ID you sent. The customer may exist, but on a connected account, in the other mode, in another Stripe account, or it was deleted.

What is Stripe error code resource_missing?

Stripe returns resource_missing when an ID is not valid for the request: the object does not exist in that account and mode, or the ID is for a different kind of object. The param field tells you which ID, for example customer or id.

Why do I get No such customer with Stripe Connect?

Usually one call is missing the stripeAccount option, so it runs on the platform while the customer is on the connected account, or the reverse. For direct charges, create the customer, the CustomerSession or ephemeral key, and the PaymentIntent with the same connected account ID.

Can I use a test mode customer ID in live mode?

No. Each mode has its own objects, and the error then says a similar object exists in test mode, but a live mode key was used. Create a new customer in live mode and store it separately from the test one.

What happens when I retrieve a deleted Stripe customer?

Retrieving it still works and returns the customer ID with deleted set to true, so no error is thrown. Using that ID in a new payment or subscription fails, and deletion cannot be undone.

Why does the ephemeral key or PaymentSheet fail with No such customer?

The customer was created on a connected account but the ephemeral key or CustomerSession was created on the platform. Pass the same stripeAccount on that call, and set the same account ID in the mobile app, for example Stripe.stripeAccountId in Flutter.

Should my app create a new Stripe customer when it gets No such customer?

Yes, but only for resource_missing on the customer parameter, or when retrieve returns deleted true. Never create one on timeouts, rate limits or outages, or you will end up with duplicate customers.

Sources

  1. Error codes (resource_missing, account_invalid) (Stripe)
  2. Errors (HTTP status codes and error object) (Stripe)
  3. API keys (sandbox versus live mode) (Stripe)
  4. Make API calls for connected accounts (Stripe)
  5. Create a charge (direct, destination, separate charges and transfers) (Stripe)
  6. Create direct charges (mobile, CustomerSession with Stripe-Account) (Stripe)
  7. Share payment methods across multiple accounts for direct charges (Stripe)
  8. Clone customer payment information across connected accounts (deprecated) (Stripe)
  9. Delete a customer (Stripe)
  10. Retrieve a customer (Stripe)
  11. Idempotent requests (Stripe)
  12. stripe-node changelog (23.2.0) (Stripe on GitHub, 2026-11-18)
  13. Error: No such customer on stripe.ephemeralKeys.create() (stripe-node #1232) (GitHub, 2021-09-03)
  14. Stripe No such customer (Express connected account) (Stack Overflow, 2020-09-20)
  15. Create Stripe charge for connected account: No such customer (Stack Overflow)
  16. Stripe error with PrestaShop payment module (test customer, live key) (Stack Overflow, 2024-10-21)
  17. Stripe API documentation commands returning errors (404, param id) (Stack Overflow)
  18. Problem creating customer in Stripe which was deleted earlier (Stack Overflow)
  19. flutter_stripe 15.0.0 (pub.dev, 2026-11-13)
  20. stripe-mock (Stripe on GitHub, 2026-10-01)
SharePost on XLinkedIn

Comments

Share a question or note about this article.

Loading comments…