This document shows you how to migrate from the v1beta1
version to the v1
version of the reCAPTCHA Enterprise API.
To migrate your assessment calls from v1beta1
to v1
, do the following:
-
Replace calls to create assessments.
Replace
https://recaptchaenterprise.googleapis.com/v1beta1/projects/PROJECT_ID/assessments?key=API_KEYwithhttps://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments?key=API_KEY -
Understand the changes in the assessment's JSON response:
When you use
v1, thereasonsandscorefields are encapsulated inriskAnalysisin the response, and when you usev1beta1, thereasonsandscorefields are not encapsulated in the response.v1
{ "event" : { "expectedAction" : " EXPECTED_ACTION " , "hashedAccountId" : " ACCOUNT_ID " , "siteKey" : " KEY_ID " , "token" : " TOKEN " , "userAgent" : "(USER-PROVIDED STRING)" , "userIpAddress" : " USER_PROVIDED_IP_ADDRESS " } , "name" : " ASSESSMENT_ID " , "riskAnalysis" : { "reasons" : [] , "score" : " SCORE }, " tokenProperties ":{ " action ":" USER_INTERACTION ", " createTime ":" TIMESTAMP ", " hostname ":" HOSTNAME ", " invalidReason ":" ( ENUM ) ", " valid ":(BOOLEAN) } }
v1beta1
{ "event" : { "expectedAction" : " EXPECTED_ACTION " , "hashedAccountId" : " ACCOUNT_ID " , "siteKey" : " KEY_ID " , "token" : " TOKEN " , "userAgent" : "(USER-PROVIDED STRING)" , "userIpAddress" : " USER_PROVIDED_IP_ADDRESS " } , "name" : " ASSESSMENT_ID " , "reasons" : [] , "score" : " SCORE " , "tokenProperties" : { "action" : " USER_INTERACTION " , "createTime" : " TIMESTAMP " , "hostname" : " HOSTNAME " , "invalidReason" : "(ENUM)" , "valid" : ( BOOLEAN ) } }
-
Update your environment to use the
reasonsandscorefields from the JSON response forv1.The following sample code shows the fields that are used from the response of
v1andv1beta1:v1
..... ..... # Get the risk score and the reason(s) for reason in response.risk_analysis.reasons: print ( reason ) print ( "The reCAPTCHA score for this token is: " + str ( response.risk_analysis.score ) ) .... ....
v1beta1
..... ..... # Get the risk score and the reason(s) for reason in response.reasons: print ( reason ) print ( "The reCAPTCHA score for this token is: " + str ( response.score ) ) .... ....
-
Replace calls to annotate assessments.
Replace
https://recaptchaenterprise.googleapis.com/v1beta1/projects/PROJECT_ID/assessments}:annotatewithhttps://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments}:annotate -
If you are currently logging your
createandannotateAPI calls using audit logging it is recommended to use platform logging (available forv1only).

