Document Validation via API
Learn how to perform a document validation using our API, understanding the essential API endpoints, responses and errors.
Prerequisites
Before you begin, make sure you have the following:
-
Truora API-Key: This key grants access to our services. If you don’t have one already, set up an account and then go to Authentication to obtain your Truora API-key.
-
A valid ID: You’ll need a valid identification document to run the document validation.
-
Postman: Use Postman or any other collaboration tool for API development. Although it is not required to perform the integration, it will help perform tests along the way.
Truora provides a Postman collection online that includes the necessary tools to simplify the testing process.
1. Create validation
Setup main Request Headers and Body
To configure the main request headers and body, follow these steps:
- Create a
POST
request to the endpointhttps://api.validations.truora.com/v1/validations
. - Set the Headers
Truora-API-Key
: enter the value obtained in the step of get Truora API-key.Content-Type
: the value should beapplication/x-www-form-urlencoded
.
- Set required values for the request body
type
[Required]: Indicates the type of validation to be performed. Set this value todocument-validation
user_authorized
[Required]: This indicates that you have the authorization of the person to be verified. This is mandatory in order to comply with data protection laws. Value must be set totrue
in order to perform the validation.country
[Required]: Allowed:CO
|CL
|MX
|PE
|BR
|CR
|VE
|PA
|ALL
. Set the country of the document being validated.
UseALL
whendocument_type
is set topassport
.
ForBR
,CR
,VE
,PA
please ask sales team.document_type
[Required]: Allowed:national-id
|foreign-id
|driver-license
|passport
|identity-card
|rut
|ppt
|invoice
|picture-id
|record
|cnh
. Set this value to the type of document been validated. Forppt
please ask sales team.
Refer to Appendix 1: Supported Document Types for a complete reference of supported document types, applicable countries and document front/reverse picture requirements.account_id
[Optional]: Unique user identifier for tracking validations of a user.*custom_type
[Optional]: When specified, indicates the name of the custom type check when a background check linked to this validation is desired.**retry_of_id
[Required if you have active retries and want to retry a previous validation]: Refers to the validation_id of the failed validation.timeout
[Optional]: The time, in seconds, users will have to complete the validation. If omitted, the timeout from the client’s config will be used. The default value is 300 seconds (5 minutes), with a maximum of 21600 seconds (6 hours).
*Only Account IDs following the regex pattern [a-zA-Z0-9_.-]+ are supported. While optional, it’s recommended to provide a unique identifier for accurate monitoring and data isolation between users. Utilize a library for managing user identifiers (User ID) based on your programming language or development framework. Avoid using repetitive number sequences. If left empty, an automatic account_id will be generated. Please go to Create an Account ID to learn more about it.
** Every time you run a document validation our system runs a default Background check (no extra charge), which will only verify datasets related to identity and excludes criminal, legal, international or any other dataset types. If you wish customize the default behavior, use this field to conduct a Background Check with a Custom Type.
- Note 1: You must have enabled the background check (BGC) product to use Custom Type. For each document validation request with a custom background check, you will be charged for it with the BGC price.
- Note 2: If you create a Custom Type, you must add the dataset
dataset_document_validation
key with a value of zero. - You will identify within the Get Validation response that a check_id has been created.
Send the Create validation request you just created. You will receive a response similar to the following:
/v1/validations
-
validation_id
: Unique identifier of the validation. -
account_id
: Unique identifier of the user. -
type
: Type of validation performed. -
validation_status
: The current status of the validation will be pending until the images are submitted. After performing the validation, the status could change to:
- success: Indicates a successful validation.
- failure: Indicates an unsuccessful validation or may also occur due to an internal error. -
creation_date
: Date and time of validation creation. -
front_url
: URL where the image of the front side of the identification document should be sent. -
reverse_url
: URL where the image of the reverse side of the identification document should be sent.
2. Upload document picture
Images must be submitted through a PUT
request to the URLs generated in the previous step, front_url
and reverse_url
, selecting the Binary type in the Body. Make the following requests to upload the front and back of the document:
-
PUT
{{front_url}}
: Upload the front document picture by making a PUT request using the URL returned from the Create validation step. -
PUT
{{reverse_url}}
: Upload the reverse document picture by making a PUT request using the URL returned from the Create validation step.
NOTE 1: It is recommended to upload the document photo horizontally. For more information on how to take a good picture of the document, please visit the Tips for document photo section.- Supported formats are JPEG, JPG and PNG, with a maximum allowed size of 30MB.
- PDF format is allowed when
document_type
is set toinvoice
(Only allowed for Mexico).
NOTE 2: Not all document types will requiere both front and reverse pictures. Please refer to Appendix 1: Supported Document Types for a complete reference of supported document types, applicable countries and document front/reverse picture requirements.
Once the document picture is successfully uploaded, the response code for each of these requests should be 200, as follows:
{{front_url}}
{{reverse_url}}
3. Get Validation
The Get validation request allows you to retrieve the current status and results of a validation. The validation_status
begins as pending
. Upon completion, the validation can either be success
or failure
.
- To obtain the validation results, send a GET request to the endpoint
https://api.validations.truora.com/v1/validations/{{validation_id}}
, wherevalidation_id
is the identifier returned in the Create validation request. - If you want to obtain links the document pictures, use the query parameter
show_details
with the value oftrue
in the request.
Once executed, if the validation is still processing, validation_status
will be pending
and you will receive a response similar to the following:
/v1/validations/{{validation_id}}
When the validation is completed successfully, validation_status
will be success
and you will receive a response similar to the following:
/v1/validations/{{validation_id}}
If you send the query parameter show_details
with value true
in the Get validation request, you will receive the response with the links of the uploaded document pictures in the field input_files
. These links will be valid for 15 minutes:
/v1/validations/{{validation_id}}?show_details=true
Among other details, the following information may be identified in the response:
Main validation data:
validation_id
: Unique identifier of the validation.ip_address
: IP address of the device from which the validation was performed.account_id
: Unique identifier of the user.type
: Type of validation performed.validation_status
: The current status of the validation will be pending until the images are submitted. After performing the validation, the status could change to:
- success: Indicates a successful validation.
- failure: Indicates an unsuccessful validation or may also occur due to an internal error.creation_date
: Date and time of validation creation.
Background check: Information related to the default or custom background check conducted to validate the document:
check_id
: Identifier of the performed checks.check_url
: URL to access the details of the background check.
Document details: Extracted document information through OCR.
User response:
input_files
: If you sent the request with the query parametershow_details
with valuetrue
, the response will show the links of the uploaded document pictures in this field. These links will be valid for 15 minutes.
Declined and Expired reasons
Whenever a validation fails due to inconsistencies in the validation process or expires in the validation process, the API provides a reason to indicate why the validation was declined or expired:
- To learn more about the possible declined reasons, please visit the Declined Reasons section.
- To learn more about the possible expired reason, please visit Expired Reasons section.
Additional configurations
You can configure other parameters to improve the behavior of the validators and the user experience. Please see the Config Validator section for more information on customization.
Getting results automatically (Webhooks)
To get validation results automatically, you must subscribe webhooks. For more information, please see Webhooks section.
Appendix 1. Supported Document Types
Document Type | Applicable Countries | Doc Picture Side |
---|---|---|
national-id | CL, CO, MX, PA, PE, VE, CR | Front/Reverse Front for PA, VE |
foreign-id | CL, CO, MX, PE, CR | Front/Reverse |
driver-license | BR, CL, CO | Front |
passport | ALL * | Front |
identity-card | CO | Front/Reverse |
rut | CO | Front |
ppt | CO | Front/Reverse |
invoice | MX | Front |
picture-id | MX | Front |
record | MX | Front |
cnh | BR | Front |
- Supported document picture formats are JPEG, JPG and PNG, with a maximum allowed size of 30MB.
- PDF format is allowed when
document_type
is set toinvoice
(Only allowed for Mexico). - *You should set
country
toALL
when validating passport.