Fix: The cf-turnstile-response Field Is Required Error

cf-turnstile-response field is required - Fix: The cf-turnstile-response Field Is Required Error

The message "The cf-turnstile-response field is required" comes from the site’s own form validation, and it means the form post arrived with no field of that name, or an empty one. The fix depends on who sent the form. In a browser, the Turnstile widget didn’t produce a token. In your own script, nobody asked for one. This guide shows both causes, then fixes the script case in Python with a token from CapSkip.

What the message means

It is not a Cloudflare error. Validation layers such as the one in Laravel build this sentence from the field name, in the pattern "The :attribute field is required", so the name inside the message is the name the server looked for and didn’t find. The check runs before the server calls Cloudflare at all. When a server does call the Cloudflare siteverify endpoint with no response value, Cloudflare answers with its own code, missing-input-response, which is a different message.

The Cloudflare widget documentation says an invisible input named cf-turnstile-response is created for a widget placed inside a form, and that it travels with the other fields. So the field only exists after the widget has run and produced a token.

Why the field is missing

CauseHow to tellFix
The widget never renderedNo Turnstile box on the page, and a blocked request for the widget script in the browser’s network tabAllow the script, and load it from the exact URL Cloudflare gives, because Cloudflare says a proxied or cached copy breaks on updates
The widget sits outside the formThe box shows, but the hidden input is not inside the form elementMove the widget into the form, or copy the token into a field yourself
The form was sent before the widget finishedThe error shows up only when the visitor submits at once, and a second try worksDisable the submit button until the widget has produced its token
The field has another nameThe message names a different field, or the page sets a custom response field nameSend the name the message shows. Cloudflare documents a response-field-name option whose default is cf-turnstile-response
The widget’s response field is turned offThe box shows, but the form has no input named cf-turnstile-response, and the page sets data-response-field to falseRemove that setting, or read the token from the widget callback and put it in a field yourself
A script submits the formNo browser is involved, and the submission carries only your own fieldsGet a token and send it, which is the rest of this guide

The last row is the one you can fix in code, and the message helps with the field name: it prints the name the server wants, so copy it exactly. The "how to tell" column is my reading of how the widget behaves. Cloudflare documents the hidden input, the response-field and response-field-name options, and the rule about the script URL.

What you need

  • A Windows PC with CapSkip running. The Cloudflare Turnstile solver page lists the widget request: a sitekey and the page address.
  • Python 3.10 or newer, which is the floor declared by capskip 1.7.0, plus requests. The first line of the first block shows the pip command that installs both. I ran the blocks on Python 3.11.7, 3.13.7 and 3.14.0 with capskip 1.7.0 and requests 2.34.2.
  • A form you are allowed to submit to. The sample uses the placeholder address https://example.com/contact, a form with a hidden CSRF field named _token, an email field and a message field.
  • For a script on another machine, switch CapSkip to Server mode and pass that PC’s address as host. The setup guide describes the switch under connection settings. Starting Server mode makes CapSkip accept connections from any address. To keep the port for the machines you trust, add a Windows Firewall block rule for the rest.

I ran everything against two mocks I wrote: one plays CapSkip, one plays a form site. The mock site refuses a form submission without the field and prints the message from this post. Every rule on it is mine, and I sent no task to the real CapSkip app, so nothing here shows that a real site accepts a token.

Step 1: set up the session

Save the first block as turnstile_form.py. The two blocks after it go at the end of the same file. The helper named read_input reads a hidden input, and send_form posts your fields. It sets the Referer header to the form page, as a browser would, because requests sends none by itself.

# python -m pip install capskip requests
import re

import requests
from capskip import CapSkip

FORM_URL = "https://example.com/contact"  # the page that shows the form

# Local mode. In Server mode, use your server's address as the host.
solver = CapSkip(host="127.0.0.1", port=8080)


def read_input(html, name):
    tag = re.search(r'<input[^>]*name="' + re.escape(name) + r'"[^>]*>', html)
    value = re.search(r'value="([^"]*)"', tag.group(0)) if tag else None
    return value.group(1) if value else None


def open_form():
    session = requests.Session()  # keeps the session cookie
    return session, session.get(FORM_URL, timeout=30).text


def send_form(session, html, extra):
    fields = {"_token": read_input(html, "_token"), "email": "[email protected]", "message": "Hello"}
    fields.update(extra)
    return session.post(FORM_URL, data=fields, headers={"Referer": FORM_URL}, timeout=30)

Step 2: reproduce the error

Post the form the way a script usually first does, with your own fields and nothing else. Add this block next. Against my mock the reply was status 200 with the page shown again and the message in its error list. Your site may redirect or answer 422, so look for the sentence in the body.

session, html = open_form()
reply = send_form(session, html, {})  # no cf-turnstile-response at all
print(reply.status_code, re.findall(r"<li>(.*?)</li>", reply.text))
# 200 ['The cf-turnstile-response field is required.']

Step 3: fix it with a token from CapSkip

Read the sitekey from the widget’s data-sitekey attribute, ask CapSkip for a token with the turnstile method of the solver, and send the code value of the result under the exact field name. The CapSkip API docs say the solver uses a specific browser User-Agent for Turnstile and that you must send the same one with the token, and that the answer includes it. The block copies it onto the session when it is there. My mock returned one, and I haven’t seen what the real app returns for a widget.

A token works once. Cloudflare says each token is valid for 300 seconds and meant for a single use, so request it just before the form post, not at the top of a long script. If the sitekey is not in a data-sitekey attribute because the page calls the render function instead, copy it from that call once.

session, html = open_form()
sitekey = re.search(r'data-sitekey="([^"]+)"', html).group(1)

result = solver.turnstile(sitekey, FORM_URL)
if result.get("userAgent"):  # the docs say the answer names the browser to present
    session.headers["User-Agent"] = result["userAgent"]

reply = send_form(session, html, {"cf-turnstile-response": result["code"]})
print(reply.status_code, re.findall(r"<p>(.*?)</p>", reply.text))
# 200 ['Message sent. Thank you.']  (your site's success text will differ)

Against the mock, all three Python versions gave these results:

Mock settingWhat happened
Step 2, no field sentThe message appeared and the CapSkip mock received no task
Step 3, token sent under the right nameOne task, the form post was accepted
The site expects another field nameThe message named that other field, and sending the token under it was accepted
Token sent a second timeA different message, "The captcha could not be verified", so the field was present but the token was spent
Field sent with an empty valueThe same required message, so an empty field counts as missing
Mock set to check the User-AgentToken sent without copying the returned User-Agent was refused, and with the copy it was accepted
Same token, no Referer header403 from the mock, whose own rule is to require a same-origin Referer

Read the table as a test of my mock. The message wording, the single use and the Referer rule are mine, and a real site decides for itself.

If the message stays after you add the token

  • A different message, such as one about failed verification, means the field arrived. Look at the token: used twice, older than five minutes, or requested for another page address.

FAQ

Is the cf-turnstile-response required error a Cloudflare error?

No. It is the site’s validation reporting a missing form field. Cloudflare only gets involved when the site sends a token to its verification endpoint.

Does this apply to a Cloudflare challenge page?

No. A full page challenge is not a form field. CapSkip answers it with a cookie, and the API docs describe that method separately. The PHP and Node.js guides show the two extra values a Turnstile challenge page needs. See solving Turnstile in PHP for how they are sent. The Node.js version is in solving Turnstile in Node.js.

Can the script run on a different machine from CapSkip?

Yes, through Server mode. Pass the CapSkip PC’s address as host. The setup guide says a static public IP gives the most stable remote access for a server setup, and Server mode needs CapSkip to run as administrator. Your solver still runs on your own Windows hardware, with no per-solve billing.

The short version

The error means the server saw no cf-turnstile-response value. In a browser, get the widget to render. In a script, ask for a token just before the form post and send it under the name the message shows. Because CapSkip is a local captcha solver that runs on your own PC, every retry costs no extra fee on a licensed copy. The Python CAPTCHA solver page lists the other SDK calls, and the API docs give the raw request.