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.
NOTE: Truora provides a Postman collection online that includes the necessary tools to simplify the testing process.
Create Validation
Setup main Request Headers and Body
To configure the main request headers and body in Postman, follow these steps:
- Create a POST request to
https://api.validations.truora.com/v1/validations
. - Click the Headers tab, create a new key named
Truora-API-Key
and set the Value to the Truora API-key you got previously. - Create a new key named
Content-Type
and set its value toapplication/x-www-form-urlencoded
.
Setup required keys for the request
In Postman, click the Body tab and tick the x-www-form-urlencoded
box. Next, set up the following keys:
type
: [Required]. Indicates the type of validation to be performed. Set this value todocument-validation
country
: [Required]. Set the country of the document being validated:CO
for ColombiaCL
for ChileMX
for MexicoPE
for PeruBR
for BrazilCR
for Costa RicaVE
for VenezuelaPA
for PanamaALL
for passport
document_type
: [Required]. Set this value to the type of document been validated:national-id
passport
foreign-id
pep
ppt
driver-license
invoice
identity-card
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.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.**
*Only Account IDs following the regex pattern [a-zA-Z0-9_.-]+ are supported (for more details visit validators main concepts ). 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.
** 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 POST request
After setting the keys in Postman, click Send to initiate the request. The API will respond with a status code of 200, along with a response similar to the following:
-
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.
Upload document picture
Images must be submitted through a PUT request to the URLs generated in the previous step, 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: It si recommended to upload the document photo horizontally. JPEG, JPG and PNG are the only supported formats and the max allowed size is 30MB. For more information on how to take a good picture of the document, please visit the Tips for document photo* section.
Once successfully uploaded, the response code for each of these requests should be 200, as follows:
Get Validation
This API endpoint allows you to retrieve the current status and information 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}}
, where validation_id
is the identifier returned in the Create validation request.
Once executed, if the validation is still processing, validation_status
will be pending
and you will receive a response similar to the following:
When the validation is completed successfully, validation_status
will be success
and you will receive a response similar to the following:
You can identify the following information 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.
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 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.