Skip to content

TrustCaptcha API

The TrustCaptcha API is one call from your backend: fetch the result of a verification with the token the widget wrote into your form. Everything before that, creating the verification and solving the challenge, the widget does on its own.

How to judge the result, the recommended score thresholds and the whole flow in your language are in Result Validation.

GET https://api.trustcomponent.com/captcha/v3/verifications/{verificationId}/results

Returns the result of a verification

Call it from your server with the verification id from the token the widget put into your form. Every refusal that will not change on a retry carries a stable code, so your code can tell a visitor who has not finished from a result that was already retrieved or has expired.

Authentication: API key as bearer token. Operation getResultV3.

Example request
Terminal window
# The verification id is the "verificationId" inside the token the widget wrote into your form.
curl "https://api.trustcomponent.com/captcha/v3/verifications/<verification_id>/results" \
-H "Authorization: Bearer <your_api_key>"
Example request
import { TrustComponent } from '@trustcomponent/sdk';
const tc = new TrustComponent('<your_api_key>');
// The token from the form field tc-verification-token.
const result = await tc.captcha.getVerificationResult('<verification_token>');
Example request
use TrustComponent\TrustComponent;
$tc = new TrustComponent('<your_api_key>');
// The token from the form field tc-verification-token.
$result = $tc->captcha()->getVerificationResult('<verification_token>');
Example request
from trustcomponent import TrustComponent
tc = TrustComponent("<your_api_key>")
# The token from the form field tc-verification-token.
result = tc.captcha.get_verification_result("<verification_token>")
Example request
import com.trustcomponent.sdk.TrustComponent;
import com.trustcomponent.sdk.model.CaptchaVerificationResult;
TrustComponent tc = new TrustComponent("<your_api_key>");
// The token from the form field tc-verification-token.
CaptchaVerificationResult result = tc.captcha().getVerificationResult("<verification_token>");
Example request
using TrustComponent;
using var tc = new TrustComponentClient("<your_api_key>");
// The token from the form field tc-verification-token.
var result = await tc.Captcha.GetVerificationResultAsync("<verification_token>");
Example request
import (
"context"
"github.com/trustcomponent/trustcomponent-go"
)
tc := trustcomponent.New("<your_api_key>")
// The token from the form field tc-verification-token.
result, err := tc.Captcha.GetVerificationResult(context.Background(), "<verification_token>")
if err != nil {
panic(err)
}
Example request
require 'trustcomponent'
tc = TrustComponent::Client.new('<your_api_key>')
# The token from the form field tc-verification-token.
result = tc.captcha.get_verification_result('<verification_token>')
Example request
let tc = trustcomponent::TrustComponent::new("<your_api_key>");
// The token from the form field tc-verification-token.
let result = tc.captcha.get_verification_result("<verification_token>").await?;
Example response (200)
{
"captchaId": "cc2e2d5e-d1ef-4a7f-a7bd-dec5b37df47a",
"verificationId": "cc2e2d5e-d1ef-4a7f-a7bd-dec5b37df47a",
"isVerificationPassed": true,
"score": 0.3,
"decisionType": "STANDARD",
"decisionAction": "ALLOW",
"isGatewayFailoverActive": false,
"isRiskScoringEnabled": true,
"isMinimalDataModeEnabled": false,
"origin": "https://www.example.com",
"ipAddress": "203.0.113.7",
"countryCode": "DE",
"deviceFamily": "Mac",
"operatingSystem": "Mac OS X",
"browser": "Firefox",
"verificationStartedAt": "2020-01-01T13:30:05.941Z",
"verificationFinishedAt": "2020-01-01T13:30:09.512Z",
"resultExpiresAt": "2020-01-01T13:45:09.512Z",
"resultFirstFetchedAt": "2020-01-01T13:30:10.106Z",
"resultLastFetchedAt": "2020-01-01T13:30:10.106Z"
}

Path parameters

NameTypeDescription
verificationIdrequiredstring (uuid)ID of a verification

Query parameters

NameTypeDescription
clientFailoveroptionalbooleanSet when the widget could not reach TrustCaptcha (clientFailover in its token). The public gateway then answers on its own and lets the visitor pass only while it has seen an outage itself.

Response 200 · application/json

FieldTypeDescription
captchaIdstring (uuid)Id of the captcha (in the dashboard) the verification ran on.
verificationIdstring (uuid)Id of the verification, the one from the token.
isVerificationPassedbooleanWhether the visitor passed the CAPTCHA. The field most integrations act on.
scorenumberRisk that the request is automated, from 0 (probably human) to 1 (probably automated). · 0 to 1
decisionTypestringHow the verification outcome was determined. Possible values include STANDARD, BYPASS_KEY, CUSTOM_ACCESS_RULE, GLOBAL_IP_ACCESS_RULE, FAILOVER, FAILOVER_TOLERANCE.
decisionActionstringThe recommended action for this verification. Possible values include NO_ACTION, ALLOW, BLOCK, CUSTOM.
isGatewayFailoverActivebooleanTrue when the gateway synthesized this result because the captcha service was unreachable.
isRiskScoringEnabledbooleanWhether the risk analysis of the captcha was switched on for this verification.
isMinimalDataModeEnabledbooleanWhether the captcha runs in minimal data mode; then origin, IP address and device fields are empty.
originstringOrigin of the page the widget ran on.
ipAddressstringIP address of the visitor.
countryCodestringTwo-letter ISO 3166-1 alpha-2 country code derived from the client IP. Empty string if not resolvable.
deviceFamilystringDevice family of the visitor, from the user agent.
operatingSystemstringOperating system of the visitor, from the user agent.
browserstringBrowser of the visitor, from the user agent.
verificationStartedAtstringWhen the widget started the verification.
verificationFinishedAtstringWhen the visitor finished the verification.
resultExpiresAtstringUntil when the result can be retrieved.
resultFirstFetchedAtmay be nullstringWhen the result was retrieved for the first time.
resultLastFetchedAtmay be nullstringWhen the result was retrieved for the last time.

Status codes

StatusMeaning
200Result object
401API key missing (code: credentials_missing) or invalid (code: credentials_invalid)
403The API key has no access to the project of this verification (code: access_denied)
404No verification with this id
409The visitor has not finished the verification yet (code: result_not_released)
410The result can no longer be retrieved: its retrieval limit is reached (code: result_retrieval_limit_reached) or it has expired (code: result_expired)
412Client failover claimed, but no recent outage is on record (code: client_failover_rejected)
429Too many requests (code: rate_limit_exceeded); retry after the seconds in Retry-After

The SDKs take the whole token and read the verification id and the clientFailover flag from it. With cURL, decode the token (Base64 of JSON) and send both yourself; see The verification token.

  • A result can be retrieved for 15 minutes after the verification, so fetch it when the form arrives.
  • By default it can be retrieved once; a second fetch answers 410 with code: result_retrieval_limit_reached. Validity and the number of retrievals can be changed per captcha environment.
  • While the visitor has not finished, the answer is 409 with code: result_not_released.

When the widget cannot reach TrustCaptcha, its token says so, and the public gateway decides on its own whether the visitor may pass: only while it has seen the outage itself. A token that claims a failover the gateway has not seen answers 412 with code: client_failover_rejected. What your backend should do in each case is in Failover Behavior.

These verification ids answer with a fixed result, without a real verification, with any API key of a project that has TrustCaptcha. The last digit picks the answer:

verificationIdAnswer
00000000-0000-0000-0000-000000000000200 with a passed sample result
00000000-0000-0000-0000-000000000001404
00000000-0000-0000-0000-000000000002409, code: result_not_released
00000000-0000-0000-0000-000000000003410, code: result_expired
00000000-0000-0000-0000-000000000004410, code: result_retrieval_limit_reached

To try the SDK examples above, use the token eyJ2ZXJpZmljYXRpb25JZCI6IjAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMCJ9 as <verification_token>: it carries the first of them.