Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Payments and webhooks

Stripe says there is no such token when your server uses it

Errorresource_missing

Short answer

Stripe answers with a missing-resource error when the ID you send does not exist for the key you use. In practice: the token came from a test key and the server uses a live key (or the reverse), the token was already spent once, or the value is not a token ID at all. Compare the key modes first.

  • Applies to Stripe API 2026, stripe-node, Stripe.js
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Look at the prefixes. The publishable key in the app and the secret key on the server must both be test or both be live, and the token ID you send must come from that same pair.

    # In the app or page: pk_test_... or pk_live_...
    # On the server:      sk_test_... or sk_live_... (or rk_test_/rk_live_)
    # Token ID sent:      tok_...
  2. 2Match what you see, then jump to its fix

    1. 1The app uses a pk_test_ key and the server a live key, or the other way round; the error code may be livemode_mismatch or resource_missing.Test and live modes are mixedFix
    2. 2The error code is token_already_used, or a second attempt with the same token fails.The token was already usedFix
    3. 3The error code is resource_missing and the ID does not start with tok_.The value sent is not a token ID, or belongs to another objectFix

What does the error look like?

  • resource_missing
  • livemode_mismatch
  • token_already_used

Cause 1 of 3

Test and live modes are mixed

1Check

Each mode has its own keys and objects in one mode are not reachable from the other. A token made with a test publishable key does not exist for a live secret key.

# Print only the prefix, never the full key
echo "${STRIPE_SECRET_KEY:0:8}"

2Fix

Use the key pair of one mode everywhere: the test publishable key in the client with the test secret key on the server, or both live. Restart the server after changing the environment variable.

# .env on the server
STRIPE_SECRET_KEY=sk_test_xxx
# client: use the matching pk_test_xxx

3Verify

Create a fresh token in the client and send it again.

# retry the payment request from the app

Confirmed by docs.stripe.com

Did this fix it?

Cause 2 of 3

The token was already used

1Check

A token cannot be stored or used more than once. Retries, double taps and a server that charges and then saves the card with the same token all spend it twice.

# check your server log for two requests carrying the same tok_ value

2Fix

Create a new token for each attempt. To keep a card for later, save it to a Customer instead of reusing the token.

// server: attach the card once, then use the Customer afterwards
// see Stripe docs: Customers

3Verify

The second attempt works with a freshly created token.

# repeat the payment from the app with a new card entry

Confirmed by docs.stripe.com

Did this fix it?

Cause 3 of 3

The value sent is not a token ID, or belongs to another object

1Check

resource_missing means the ID is not valid: the resource does not exist, or the ID is for a different kind of resource. Look at which ID the client actually posts to your server.

# log the field your server reads, and check it starts with tok_

2Fix

Send the token ID the client library returned, not a customer, card or payment method ID, and read that same field on the server.

// client: send token.id
// server: read the same body field

3Verify

The server log shows a tok_ value and the call succeeds.

# repeat the request and read the server log

Confirmed by docs.stripe.com

Did this fix it?

How do I stop it coming back?

  • Keep test and live keys in separate environment files and print only the key prefix in logs.
  • Disable the pay button after the first tap so one token is not sent twice.
  • Check the Stripe Dashboard request log for the exact ID that failed.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Payments

Stripe Elements shows console warnings or errors in a Next.js checkout

Could not find Elements context; You need to wrap the part of your app that calls useElements() in an <Elements> provider.

Most React Stripe.js warnings come from four mistakes: calling loadStripe inside a component, using useStripe or useElements outside the Elements provider, using the objects before they have loaded, and a Content Security Policy that blocks js.stripe.com.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.