ID Cropper
The ID Cropper API automatically crops ID images to keep only the document itself and remove any surrounding background. Send the image as a Base64 string, and the API detects the ID area, isolates it, and returns a clean, properly cropped version of the document.
ID Cropper
POST https://valifystage.com/api/v1/id_cropper_register
Headers
Content-Type
string
application/json
Authentication
string
Bearer <access-token>
Request Body
bundle_key
string
A bundle key provided to you by Valify.
img
string
Base64 image that need to be cropped
lang (optional)
string
The error message language
Status Codes
{
"data": {
"img": "<base64_cropped_image>"
},
"transaction_id": <str>,
"trials_remaining": <str>
}{
"message": "Bad Request – invalid request received (e.g. missing Bundle key, required parameters or invalid json) | Make sure all the required parameters are included"
}{
"message": "Unauthorized – your Bundle key is invalid"
}{
"message": "Forbidden – specified access_token could not be found"
}{
"message": "Not Found"
}{
"message": "Unsupported Media Type"
}{
"message": "<error-description>",
"error_code": <valify-error-code>
}{
"message": "Internal Server Error"
}Integration
Download the JSON file from here.
Open Postman and click on Import.

Drop the JSON file.

Click on "Passport" and then click on "Authorization" and replace the <access token> field with your access token and then click on "Body".

Click on "Body" then fill in the required data and hit "Send".

import requests
import base64
def base64_encode(file_name):
with open(file_name, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode()
return encoded_string
return ""
# Encode your image
image = base64_encode('<image path>')
token = "<access-token>" # Place your token here
data = {
"bundle_key": "<bundle_key>", # Place your bundle key here
"img": img,
"lang": "<str>" # optional
}
response = requests.post(
"https://<your-domain>/api/v1/id_cropper/register/",
json=data,
headers={
"Authorization": "Bearer %s" % token,
"Content-Type": "application/json"
}
)
print(response.json())Last updated