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_KEYwith- https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments?key=API_KEY
- Understand the changes in the assessment's JSON response: - When you use - v1, the- reasonsand- scorefields are encapsulated in- riskAnalysisin the response, and when you use- v1beta1, the- reasonsand- scorefields 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 - reasonsand- scorefields from the JSON response for- v1.- The following sample code shows the fields that are used from the response of - v1and- v1beta1:- 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}:annotatewith- https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments}:annotate
- If you are currently logging your - createand- annotateAPI calls using audit logging it is recommended to use platform logging (available for- v1only).