Skip to content

CAPTCHA Result Validation

Here we explain how you call up and evaluate the CAPTCHA result in your backend from our server.

It is possible to retrieve the CAPTCHA verification result from our servers in any programming language using a simple REST API call. To make this process as easy as possible, we provide ready-made integrations for the most popular programming languages and frameworks. The source code for all provided integrations can also be found on Github. The API call is documented in detail here, so that individual integrations are possible.


When the CAPTCHA widget is completely solved, the CAPTCHA returns a so-called verification token. This is a simple text/string. It is available in a hidden input field called tc-verification-token and is also propagated by the trustcaptcha component with the captchaSolved JavaScript event. You can find out more about this in the CAPTCHA widget overview.

Send this token to your backend. For example, when the form containing the CAPTCHA is submitted, or independently via an API interface. With the help of the verification token, you can now retrieve the CAPTCHA verification result from our servers on the server side. Either via an API interface or with the help of one of our ready-made integrations.

The verification token returned by the TrustCaptcha widget is encoded in Base64.

Sample Verification Token (encoded)
eyJhcGlFbmRwb2ludCI6Imh0dHBzOi8vYXBpLmNhcHRjaGEudHJ1c3RjYXB0Y2hhLmNvbSIsInZlcmlmaWNhdGlvbklkIjoiMDdiMDE5MjItM2ZhYS00NjY3LWE0YTYtOTEwYTc2Y2I4YWI3IiwiZW5jcnlwdGVkQWNjZXNzVG9rZW4iOiJtQ2JCZldTS0V5bWQxYjN0cW5ycXZCYURZMER2TkgwK29acHlYdTdSN1pkTUNMcjhhU202TURlM2ltckVPTTVDaFZOeUkvbkFSUFJCalNvV1N1NnNMNVlpUjhlUXU4dDZ3eUVBVDNRc3NwQT0ifQ0=

When you decode the verification token, you get back a JSON object. This contains the apiEndpoint and the verificationId you need to fetch the verification result via the REST-API.

Decoded Sample Token
{
"apiEndpoint": "https://api.trustcomponent.com",
"verificationId": "07b01922-3faa-4667-a4a6-910a76cb8ab7",
"encryptedAccessToken": "mCbBfWSKEymd1b3tqnrqvBaDY0DvNH0+oZpyXu7R7ZdMCLr8aSm6MDe3imrEOM5ChVNyI/nARPRBjSoWSu6sL5YiR8eQu8t6wyEAT3QsspA="
}

Overview of the properties of the token:

KeyValueDescription
apiEndpointTextEndpoint where the verification result can be retrieved. As a rule https://api.trustcomponent.com.
verificationIdUUIDUnique identifier (ID) of the verification.
encryptedAccessTokenTextDeprecated: Encrypted access token for retrieving the verification result.

Below you will be explained how to retrieve the CAPTCHA verification result, what information it contains, and how you can work with it.

You can retrieve the verification result from our servers using the following URL.

Simple REST-API call
curl -X GET "https://{apiEndpoint}/verifications/{verificationId}/assessments" -H "Content-Type: application/json" -H "tc-authorization: {secret-key}"

Overview of request properties:

ParameterTypeDescription
apiEndpointPathEndpoint where the verification result can be retrieved. Can be taken from the verification token. As a rule https://api.trustcomponent.com.
verificationIdPathUnique identifier (ID) of the verification. Can be taken from the verification token.
secret-keyHeaderSecret key of the CAPTCHA. This can be taken from the CAPTCHA administration.

The returned verification result looks like this:

{
"captchaId": "cc2e2d5e-d1ef-4a7f-a7bd-dec5b37df47a",
"verificationId": "cc2e2d5e-d1ef-4a7f-a7bd-dec5b37df47a",
"verificationPassed": true,
"score": 0.5,
"reason": "CALCULATED",
"mode": "STANDARD",
"origin": "https://www.your-website.com/sub-page",
"ipAddress": "2a01:123:33bb:1a1a:0:0:0:1",
"deviceFamily": "Other",
"operatingSystem": "Windows 10",
"browser": "Chrome 119.0.0",
"creationTimestamp": "2020-01-01T13:30:05.941",
"releaseTimestamp": "2020-01-01T13:30:05.941",
"retrievalTimestamp": "2020-01-01T13:30:05.941"
}

Overview of the result properties:

ParameterValueDescription
captchaIdUUIDUnique identifier (ID) of the respective CAPTCHA.
verificationIdUUIDUnique identifier (ID) of the verification.
verificationPassedBooleanStatement on whether the CAPTCHA was fundamentally passed or not.
scoreNumberProbability level that the client is a bot.
reasonTextRationale for calculating verificationPassed and score.
modeTextSelected captcha mode.
originTextThe page where the captcha was solved.
ipAddressTextIP address (IPv4 or IPv6) of the client.
deviceFamilyTextName of the device family used by the client.
operatingSystemTextName and version of the operating system used by the client.
browserTextName and version of the browser used by the client.
creationTimestampTimestamp (UTC)Moment when the verification process (the CAPTCHA) was started by the client.
releaseTimestampTimestamp (UTC)Moment when the verification process (the CAPTCHA) was completed by the client.
retrievalTimestampTimestamp (UTC)Moment when the verification result was called up by the website operator.

The CAPTCHA verification result contains two important pieces of information: verificationPassed and score. Based on this information, you can define your individual rules and determine how to proceed.

  • verificationPassed: Provides information on whether the CAPTCHA has been completed and passed

  • score: The bot score indicates how likely a request is to originate from a bot. The value always ranges between 0 and 1, and the higher the value, the higher the bot risk.

As a starting point for your individual CAPTCHA validation, we recommend checking whether verificationPassed is true and whether the bot score value is below 0.5.

Simple desicion example (typescript)
if (!verificationResult.verificationPassed || verificationResult.score > 0.5) {
console.log("Verification failed or bot score > 0.5 – possible automated request.");
} else {
console.log("Everything looks good - probably a human.");
}

We recommend always checking expressions to see if verificationPassed is true. If you don’t want to check for bot probability but only the dynamic proof-of-work, you can skip the bot score check.

Simple check without score (typescript)
if (!verificationResult.verificationPassed) {
console.log("Verification failed");
} else {
console.log("Verification passed.");
}

The score threshold of 0.5 is not suitable for everyone. Everyone has different security needs or a higher tolerance for false positives detected as bots or spam messages. So experiment with the threshold value of 0.5 and adjust it to your individual needs. Note: 0 = probably human, 1 = probably bot/automated.

Individual threshold value (typescript)
const threshold = 0.75; // allow more false positives
if (!verificationResult.verificationPassed || verificationResult.score > threshold) {
console.log("Verification failed or bot score > "+threshold+" – possible automated request.");
} else {
console.log("Everything looks good - probably a human.");
}

A multi-stage process is also possible. For example, you could take different approaches based on the score and thus based on individual risk. This means that a user does not have to be excluded immediately or a message blocked; instead, you could simply add an additional security check in the event of an increased risk.

Multi level desicion (typescript)
if (!verificationResult.verificationPassed) {
console.log("Captcha failed → reject.");
} else if (verificationResult.score >= 0.8) {
console.log("High bot risk → reject.");
} else if (verificationResult.score >= 0.4) {
console.log("Elevated risk → e.g. require email verification or 2FA.");
} else {
console.log("Low risk → allow / proceed.");
}

The reason provides insight into why the bot score and the statement about verificationPassed were made accordingly.

ReasonPassedScoreDescription
ONLY_PROOF_OF_WORKtrue0Verification passed without bot-score (e.g. minimal data mode).
CALCULATEDtrueIndividualThe bot score was calculated based on data analysis.
BYPASS_KEYtrue0The captcha was solved using a bypass token.
CUSTOM_ALLOW_LISTtrue0The client’s IP address is on the custom allow list.
CUSTOM_BLOCK_LISTfalse1The client’s IP address is on the custom block list.
GLOBAL_ALLOW_LISTtrue0The client’s IP address is on TrustCaptcha’s global allow list.
GLOBAL_BLOCK_LISTfalse1The client’s IP address is on TrustCaptcha’s global block list.
GEOBLOCKINGfalse1The client’s region is blocked on the country list.
REQUEST_REJECTEDfalse1The verification attempt was rejected by TrustCaptcha.
CHALLENGES_NOT_SOLVED_CORRECTLYfalse1The client did not correctly calculate the Proof-of-Work challenges.
CHALLENGES_NOT_SOLVED_IN_SPECIFIED_TIMEfalse1The client did not submit the Proof-of-Work challenges within the specified time.
FAILOVERtrue0.3There is a malfunction on our servers and the failover mechanism is active.
FAILOVER_TOLERANCEtrue0.3There was a malfunction and the aftereffects of the failover are temporarily accepted.

Errors can occur when retrieving the “erification result`. Below you will find an overview of all status codes along with a description of what went wrong and what you should consider.

Status CodeStatus NameDescription
400Bad RequestThe request was made under false assumptions. Possibly the verification ID (verificationId) is not a UUID or the access token (accessToken) does not match the specified format.
403ForbiddenThe secret key in the header (old versions the access token as query parameter) is missing in the HTTP request or is invalid. Please check the request and access data.
404Not FoundThe verification does not exist. Please check the verification ID. It is also possible that the verification has already been retrieved a while ago and is now deleted.
410GoneThe verification result has either already been retrieved or has expired. The CAPTCHA must be solved again. Unless otherwise specified, each verification result can be retrieved exactly once within 15 minutes after solving the CAPTCHA.
423LockedThe verification result has not yet been released. Please wait until the verification is complete.
422Unprocessable ContentThe set captcha mode of the TrustCaptcha component does not match the set mode in the captcha settings.
500Internal Server ErrorAn internal server error has occurred. If this happens repeatedly and persists over time, please contact support.