Magento 7 min read

Magento reCAPTCHA for APIs: keep headless sign-ups working

Magento reCAPTCHA for APIs now checks REST and GraphQL sign-up, login and coupon calls (Cloud Service release, 18 November 2026). Which calls need a token, front-end code to send one, and fixes for common errors.

Crest Design
Cover for a guide to Magento reCAPTCHA enforcement on REST and GraphQL API calls for headless storefronts and apps.

If your Magento or Adobe Commerce store has a headless front end, a mobile app or a custom sign-up flow, this post is for you. Magento reCAPTCHA for API calls is now enforced: when you switch on CAPTCHA or reCAPTCHA for a storefront form, the matching REST and GraphQL calls get the same check. Adobe shipped this in Adobe Commerce and Magento Open Source 2.4.9 (May 2026), and the Adobe Commerce as a Cloud Service release of 18 November 2026 brought the same enforcement to the SaaS version. You'll learn which calls are affected, how to send a valid token, and how to fix the errors teams hit after the switch.

Why sign-ups suddenly fail after the update

The complaint usually arrives as "new customers can't register on the app" or "our coupon box stopped working on the headless site". Nothing looks broken in the Magento admin. The classic Luma pages still work, because they already render the reCAPTCHA widget and send its answer with the form.

The gap Adobe closed was this: a bot could skip the protected web form and call the API directly to create accounts or try coupon codes. Before the change, the API didn't ask for the token. Now it does. Any front end that talks to Magento through the API, rather than through Magento's own templates, has to collect a token and pass it along, or its requests are refused.

The calls covered in the 2.4.9 notes include customer account creation over REST and GraphQL, the updateCustomer, updateCustomerV2 and contactUs GraphQL mutations, and applyCouponsToCart, each one protected when reCAPTCHA is switched on for the matching storefront form. Adobe's list of protected mutations also covers customer login through generateCustomerToken.

How Magento reCAPTCHA for APIs works

Magento ties protection to a form, not to an endpoint. In the admin you decide that "Create New Customer Account" or "Apply Coupon" is protected. Commerce then maps that form to the API operations that do the same job and checks them too. If a form isn't protected, its API calls behave as before.

For a protected call, Commerce looks for a token in a request header. With Google reCAPTCHA that header is X-ReCaptcha; with Magento's built-in CAPTCHA it's X-Captcha. The token comes from Google's script running in the shopper's browser. Commerce sends it to Google with your secret key, gets a verdict, and only then runs the mutation. A missing, expired or reused token means an error response instead of a new account.

There is one important exception. Adobe's docs say the header isn't needed when the request carries an integration authorization token. That's the token your ERP, CRM sync or import script uses when it is set up under System > Extensions > Integrations. Back-office systems are trusted callers; anonymous shoppers aren't.

Two details catch people out. The token is short-lived and single-use, so you can't fetch one when the page loads and reuse it for every attempt. And GraphQL validation has been built around reCAPTCHA v3 Invisible, so keys created for the v2 checkbox won't validate there. Check the reCAPTCHA types your exact version supports before you create keys.

Flow diagram: a sign-up form gets a reCAPTCHA token and sends it in the X-ReCaptcha header to the Magento API, which checks it before creating the account.
Which API calls need a reCAPTCHA token once the form has protection switched on.

How to send a valid token from a headless front end

1. Check what is switched on

In the admin, open Stores > Settings > Configuration > Security > Google reCAPTCHA Storefront. Note which forms are protected and which reCAPTCHA type each uses. Then check Stores > Settings > Configuration > Customers > Customer Configuration > CAPTCHA for Magento's own CAPTCHA, which can be on at the same time. Write down every protected form; each one is an API call your front end must now handle.

2. Register every domain with Google

A headless site often lives on a different host from Magento, and an app may run inside a web view. In the Google reCAPTCHA admin console, add every domain that renders a protected form, including staging. Tokens issued for an unregistered domain fail validation.

3. Get the public key from Magento, not a hard-coded value

The recaptchaFormConfig and recaptchaFormConfigs GraphQL queries return the settings for each form type, including the public website key. Reading them at build or runtime keeps the front end in step with the admin when someone rotates keys.

4. Fetch a fresh token right before each protected request

This browser-side function creates an account through GraphQL. It loads nothing itself: it assumes Google's reCAPTCHA v3 script is already on the page and that siteKey came from the query above. Put it in your sign-up form handler and adjust the fields you request back.

async function createAccount(siteKey, input) {
  // Ask Google for a new single-use token at submit time
  const token = await new Promise((resolve) =>
    grecaptcha.ready(() =>
      grecaptcha.execute(siteKey, { action: 'customer_create' }).then(resolve)
    )
  );

  const res = await fetch('/graphql', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-ReCaptcha': token,
    },
    body: JSON.stringify({
      query: `mutation Create($input: CustomerCreateInput!) {
        createCustomerV2(input: $input) { customer { email firstname } }
      }`,
      variables: { input },
    }),
  });

  const json = await res.json();
  if (json.errors) throw new Error(json.errors[0].message);
  return json.data.createCustomerV2.customer;
}

REST works the same way: send the token in the X-ReCaptcha header on the anonymous POST /V1/customers call. If your front end proxies requests through its own server, make sure the proxy forwards that header, because some strip unknown headers by default.

5. Move back-office jobs to an integration token

If a CRM sync or marketplace connector creates customers by calling the anonymous endpoints, it will start failing too, and a script can't solve a reCAPTCHA. Set it up as an integration in the admin and send its access token. That keeps the job working without weakening the shopper-facing protection.

What we've learned from rolling it out

The most common mistake is switching protection off to make the errors go away. It works, but it reopens the door to fake accounts and coupon guessing, which is the reason Adobe made the change. We'd rather spend a day wiring tokens into the front end than leave forms unprotected.

The second is treating it as a front-end ticket only. The fix spans three places: admin settings, the front end that collects tokens, and any back-office tool calling the API. If those are owned by different people or vendors, agree who checks what before the upgrade.

When we wouldn't rush: a store with no headless front end, no app and no custom integrations that create customers. Classic Magento templates already send the token, so a quick test of the standard forms is usually enough.

Troubleshooting

Symptom Likely cause Fix
Sign-up or login on the headless site returns a reCAPTCHA validation error The request has no X-ReCaptcha header Fetch a token at submit time and add the header, as in the code above
A token is sent but still rejected Key type doesn't match (v2 keys on a v3 setting), or the domain isn't registered with Google Create keys of the type set in the admin and add every front-end domain, including staging
First attempt fails, a retry works The token was created at page load and expired, or it was reused Request a new token immediately before each protected call
Nightly customer import or CRM sync stops creating accounts The job calls anonymous endpoints without an integration token Register it under System > Extensions > Integrations and send its access token
Works locally, fails in production A proxy or CDN rule strips the custom header Allow and forward X-ReCaptcha and X-Captcha on the API route

Questions people ask

Do I have to turn reCAPTCHA on for the API separately?

No. API enforcement follows the storefront form settings. If a form is protected in the admin, its matching API calls are protected too, and if it isn't, they aren't.

Will this affect our ERP or CRM integration?

Not if it authenticates with an integration token, which Adobe's docs say skips the header requirement. Integrations that call anonymous customer endpoints need to move to an integration token.

Does it apply on Adobe Commerce as a Cloud Service?

Yes. The 18 November 2026 Cloud Service release lists CAPTCHA validation enforced for REST and GraphQL APIs. Because the SaaS version updates for you, test your front ends against a sandbox rather than waiting for a planned upgrade.

Why it matters for your store

Registration, login and coupons are where shoppers commit. If any of them fail quietly on your app or headless site, you lose orders and the team often doesn't notice until customers complain. The change itself is good news: it shuts a route bots used to create junk accounts and test discount codes. It just needs the front end and integrations to catch up.

A short checklist before your next upgrade or Cloud Service release:

  • List every protected form and the API call behind it.
  • Register all front-end domains and use the matching key type.
  • Fetch a fresh token per request and forward the header through any proxy.
  • Move back-office jobs to integration tokens.
  • Test every flow in staging with protection on.

If you're also planning platform changes, read our notes on when a Magento PHP 8.6 upgrade makes sense and the Adobe Commerce Cloud security enforcement steps, and see how Magento websites, stores and views affect where settings apply.

If you'd like a second pair of hands on the front end or integrations, our Magento and Adobe Commerce development team is happy to talk it through.

(over to you)

Planning a build like this?

Tell us what you're building and we'll come back with ideas and next steps.