Email Validation via API
Verifies the ownership or permissions a person has over an email by comparing the code the person enters and the one that is mailed to the email address provided.Prerequisites
Before you begin, make sure you have the following:
- Truora API-Key: You should already have your Truora API-Key. If you don’t, set up an account and then go to Authentication to obtain your Truora API-key.
- Email: If you already know the email number you want to validate, please provide it yourself. Otherwise, request it from your user.
- 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 Enrollment
Create an email validation associated with an account. The account allows a user to be identified on the Truora platform and is represented by the account_id
.
Setup main Request Headers and Body
To configure the main request headers and body, follow these steps:
- Create a
POST
request tohttps://api.validations.truora.com/v1/enrollments
. - Set the Headers
Truora-API-Key
enter the value obtained in the step of get 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 toemail-verification
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.email
[Required]: Email to be associated with the user account.account_id
[Optional]: The account_id is a unique value assigned to each user in the system to distinguish them and access their information and processes. Only Account IDs following the regex pattern [a-zA-Z0-9_.-]+ are supported. Please go to Create an Account ID to learn more about it.
If everything goes well with the enrollment, you should receive a response similar to the following:
/v1/enrollments
Note: The
enrollment_id
andaccount_id
of the response on this endpoint will be used in later steps.
2. Get Enrollment
Allows searching for an enrollment in order to verify its progress, this step is optional.
The enrollment status will be success
or failure
depending on the internal verifications performed on the number.
-
Create a GET request to the endpoint
https://api.validations.truora.com/v1/enrollments/{{enrollment_id}}
. -
If everything goes well with the enrollment, you should receive a response similar to the following:
GET
/v1/enrollments/{{enrollment_id}}
3. Create validation
Setup main Request Headers and Body
To configure the main request headers and body, follow these steps:
- Create a POST request to
https://api.validations.truora.com/v1/validations
. - Set the Headers
Truora-API-Key
enter the value obtained in the step of get 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 toemail-verification
.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
[Required]: Use the same account_id that was used in Create Enrollment.language
[Optional]: Allowed:es
|en
. Language of the email that the final user receives.user_name
[Optional]: Custom name for verification messages.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 600 seconds (10 minutes).
If everything goes well with the Create Validation, you should receive a response similar to the following:
/v1/validations
Note: The
validation_id
of the response on this endpoint will be used in later steps.
4. Perform Validation
Setup main Request Headers and Body
To configure the main request headers and body, follow these steps:
- Create a POST request to
https://api.validations.truora.com/v1/validations/{{validation_id}}
. - Set the Headers
Truora-API-Key
enter the value obtained in the step of get 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 toemail-verification
.token
[Required]: Validation code sent via email.
If everything goes well with the Perform Validation, you should receive a response similar to the following:
/v1/validations/{{validation_id}}
By default, the user will have 2 retries to enter the code. You can see the remaining retries in the field
remaining_retries
.
5. 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}}
, wherevalidation_id
is the identifier returned in the Create validation request. -
If you want to obtain details such as the inputs of the validation, you can send the query parameter
show_details
with the value oftrue
. -
Once executed, if the validation is still processing,
validation_status
will bepending
and you will receive a response similar to the following:GET
/v1/validations/{{validation_id}} -
When the validation is completed successfully,
validation_status
will besuccess
and you will receive a response similar to the following:GET
/v1/validations/{{validation_id}} -
If you send the query parameter
show_details
, you will receive a response similar to the following:GET
/v1/validations/{{validation_id}}?show_details=true
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.