Skip to content
Gaurav TiwariDocs

Set Up Headless Forms

Version 5.2.5 Updated November 22, 2026

Headless access has three switches: the module, a site API key and a setting on each form. Set them up once in WordPress before you add code to your front end.

You need an administrator account, a form and a WordPress site whose REST API your front end can reach. These guides describe Core Forms 5.2.2 or newer, which includes security fixes, so update first.

Turn On the Module

  1. Go to Core Forms > Modules.
  2. Turn on Headless API. It’s off by default.

With WP-CLI:

wp core-forms module enable headless

While the module is off, the headless routes don’t exist and WordPress answers 404 with rest_no_route.

Create the API Key

  1. Go to Core Forms > Settings and open Headless / REST.
  2. Click Generate next to API key. The key starts with cf_.
  3. Save the settings.
Headless / REST settings with a masked API key, Generate and Copy buttons and the Allowed origins box

The site has one key for all headless forms. Saving a new key stops every client that uses the old one.

To keep the key out of the database, define it in wp-config.php:

define( 'CORE_FORMS_HEADLESS_API_KEY', 'cf_...' );

The constant takes priority over the saved setting. See Keys in wp-config.php for other credentials.

Set Allowed Origins

In Allowed origins, enter each front end on its own line as scheme, host and optional port:

https://www.example.com
https://staging.example.com
http://localhost:4321

An origin has no path and no trailing slash. List www and non-www hosts separately if you use both.

  • A filled list is enforced on the form routes. An entry without a scheme isn’t valid, and a list with no valid entry allows no origin.
  • A single * allows any origin.
  • An empty box accepts whatever origin the browser sends. That helps during setup, but add your origins before launch.

One WordPress site can serve several front ends. List each one here and keep the forms and their actions in one place.

Enable the Form

  1. Edit the form and open its Headless tab.
  2. Turn on Headless mode.
  3. Click Save Form.
  4. Note the form’s numeric ID and slug. The URLs accept either.

Use the ID in server code because a slug can be renamed. If draft publishing is on, publish the form. Headless requests always use the published version.

Set Up a Captcha

Set up Turnstile or reCAPTCHA before the form goes public. The Headless tab shows Ready to embed once the key and a captcha are both in place.

The drop-in embed loads the captcha for you. With your own markup or a proxy starter, use the script in Security and Spam Protection.

Pass Visitor IPs from a Proxy

A server route can tell WordPress each visitor’s IP. This is optional and needs a separate proxy secret, set under Settings > Headless / REST or as CORE_FORMS_HEADLESS_PROXY_SECRET in wp-config.php. See Pass the Visitor IP.

Test the Connection

Request the form first. This endpoint is public and should return 200 with html, fields and submit_url:

curl -i "https://cms.example.com/wp-json/core-forms/v1/forms/123"

Then send a submission from your terminal. Change the field names to match your form:

curl -i "https://cms.example.com/wp-json/core-forms/v1/forms/123/submit" \
  -H "Content-Type: application/json" \
  -H "X-Core-Forms-Key: $CORE_FORMS_API_KEY" \
  --data '{"name":"Ada","email":"ada@example.com","_cf_page_url":"https://www.example.com/contact"}'

This creates a real entry and runs the form’s emails and integrations, so use a test form. A form with a captcha rejects this request because it has no token.

A successful response looks like this:

{
  "message": { "type": "success", "text": "Thank you! We will be in touch soon." },
  "hide_form": false
}

Check the form’s Submissions tab for the entry. Then return to Headless and follow the guide for your stack.

Share

Was this helpful?

Still stuck? Open a support ticket