PRODUCT TEST WORKSPACE

Cloudflare Turnstile

Captcha verification product

CLOUDFLARE_TURNSTILE

01 / CREATE

Create task

The editor starts with required fields and one conditional branch. Optional fields are listed below and can be loaded into the editor.

02 / REQUEST

Request preview

POST /api/validator/create.cgi
{
  "productCode" : "CLOUDFLARE_TURNSTILE",
  "adapter" : {
    "websiteURL" : "https://example.com/register",
    "websiteKey" : "YOUR_WEBSITEKEY"
  }
}

03 / RESULT

Response example

EXAMPLE
Task ID —
{
  "code" : 0,
  "msg" : "Success",
  "data" : {
    "taskId" : "11111111-1111-4111-8111-111111111111",
    "productCode" : "CLOUDFLARE_TURNSTILE",
    "state" : "SUCCEEDED",
    "solution" : {
      "token" : "EXAMPLE_TOKEN",
      "userAgent" : "EXAMPLE_USERAGENT"
    }
  }
}

Illustrative response; not a live task result. Replace all request placeholders before submitting.

Read data.solution after state becomes SUCCEEDED. The solution fields depend on the product; other states may return an empty object.

04 / API REFERENCE

Cloudflare Turnstile · API

For task creation and queries, send the API key in the apiKey HTTP header. JSON request bodies contain business parameters only.

Content-Type: application/json
apiKey: YOUR_API_KEY

Request example

POST /api/validator/create.cgi · JSONC
{
  "productCode": "CLOUDFLARE_TURNSTILE", // Product code matching the adapter parameters.
  "adapter": { // Product-specific parameter object.
    "websiteURL": "https://example.com/register", // Full URL of the page hosting this widget, from the same target session.
    "websiteKey": "YOUR_WEBSITEKEY", // Actual sitekey of this Turnstile widget. Do not use a key from another site.
    "action": "YOUR_ACTION", // Actual render action. Required with challenge-page pagedata; standalone widgets may also set action without pagedata.
    "data": "CURRENT_CDATA", // Actual render cData, sent upstream as data. cData is accepted as an alias; conflicting values are rejected before billing.
    "pagedata": "CURRENT_CHL_PAGE_DATA", // Fresh render chlPageData for a Cloudflare challenge page, sent upstream as pagedata. When supplied, action and data must also be present. Not universally required for standalone widgets.
    "cData": "CURRENT_CDATA", // Compatibility alias of data. Prefer data; omit the alias when data is supplied.
    "chlPageData": "CURRENT_CHL_PAGE_DATA", // Compatibility alias of pagedata. Prefer pagedata; omit the alias when pagedata is supplied.
    "userAgent": "YOUR_BROWSER_USER_AGENT", // Actual browser User-Agent, when available. Preserve the returned solution.userAgent; do not assume the upstream will return the supplied value.
    "proxyType": "http", // Optional proxy protocol: http, socks4 or socks5. Supplying any proxy field requires proxyType, proxyAddress and proxyPort together. Omit all proxy fields to retain proxyless mode.
    "proxyAddress": "YOUR_PROXY_HOST", // Proxy host or IP without scheme, port or credentials. Use the appropriate target-session egress.
    "proxyPort": 8080, // Proxy TCP port: integer from 1 to 65535. Required only when using a proxy.
    "proxyLogin": "YOUR_PROXYLOGIN", // Proxy username only if this proxy requires authentication.
    "proxyPassword": "YOUR_PROXYPASSWORD" // Proxy password only if this proxy requires authentication.
  }
}

Request headers: apiKey: YOUR_API_KEY

Comments explain the fields. Copy produces valid JSON without comments.

Response example

POST /api/validator/query.cgi · JSONC
{
  "code": 0, // Business result code: 0 means success; other values indicate an error.
  "msg": "Success", // Result message; may be empty on success.
  "data": { // Response data; may be null on an error.
    "taskId": "11111111-1111-4111-8111-111111111111", // Task ID returned by task creation.
    "productCode": "CLOUDFLARE_TURNSTILE", // Product code matching the adapter parameters.
    "state": "SUCCEEDED", // Task state: CREATED, SUBMITTING, PROCESSING, SUCCEEDED, FAILED or EXPIRED.
    "solution": { // Product answer when SUCCEEDED; empty while processing or on failure.
      "token": "EXAMPLE_TOKEN", // Verification token to submit to the target website.
      "userAgent": "EXAMPLE_USERAGENT" // Browser User-Agent used to obtain the answer.
    }
  }
}

Creating a task returns its ID and initial state. Query the result or use WebSocket to receive the completed answer shown below.

Request parameters

FieldTypeRequiredDescription
productCodestringYesProduct code matching the adapter parameters.
adapterobjectYesProduct-specific parameter object.
adapter.websiteURLstringYesFull URL of the page hosting this widget, from the same target session.
adapter.websiteKeystringYesActual sitekey of this Turnstile widget. Do not use a key from another site.
adapter.actionstringNoActual render action. Required with challenge-page pagedata; standalone widgets may also set action without pagedata.
adapter.datastringNoActual render cData, sent upstream as data. cData is accepted as an alias; conflicting values are rejected before billing.
adapter.pagedatastringNoFresh render chlPageData for a Cloudflare challenge page, sent upstream as pagedata. When supplied, action and data must also be present. Not universally required for standalone widgets.
adapter.cDatastringNoCompatibility alias of data. Prefer data; omit the alias when data is supplied.
adapter.chlPageDatastringNoCompatibility alias of pagedata. Prefer pagedata; omit the alias when pagedata is supplied.
adapter.userAgentstringNoActual browser User-Agent, when available. Preserve the returned solution.userAgent; do not assume the upstream will return the supplied value.
adapter.proxyTypestringNoOptional proxy protocol: http, socks4 or socks5. Supplying any proxy field requires proxyType, proxyAddress and proxyPort together. Omit all proxy fields to retain proxyless mode.
adapter.proxyAddressstringNoProxy host or IP without scheme, port or credentials. Use the appropriate target-session egress.
adapter.proxyPortintegerNoProxy TCP port: integer from 1 to 65535. Required only when using a proxy.
adapter.proxyLoginstringNoProxy username only if this proxy requires authentication.
adapter.proxyPasswordstringNoProxy password only if this proxy requires authentication.

Response parameters

FieldTypeDescription
codeintegerBusiness result code: 0 means success; other values indicate an error.
msgstringResult message; may be empty on success.
dataobject | nullResponse data; may be null on an error.
data.taskIdstringTask ID returned by task creation.
data.productCodestringProduct code matching the adapter parameters.
data.statestringTask state: CREATED, SUBMITTING, PROCESSING, SUCCEEDED, FAILED or EXPIRED.
data.solutionobjectProduct answer when SUCCEEDED; empty while processing or on failure.
data.failureobject | omittedPublic diagnosis for FAILED/EXPIRED only; no raw provider messages. Follow the failure handling guide.
data.failure.codestringFailure code
data.failure.nextActionstringNext action
data.solution.tokenstringVerification token to submit to the target website.
data.solution.userAgentstringBrowser User-Agent used to obtain the answer.

Responses

HTTP business responses contain code, msg and data; code 0 means success. WebSocket uses a separate message structure.

-1317
Invalid API key.
-1100 / -1101
Invalid or missing request parameters.
-1401
Insufficient balance. Add funds before creating a task.
-1400 / -1001
System or task creation error.
API documentation