Aadhaar Masking API
Send an image or PDF page of an Aadhaar card. We find the Aadhaar number wherever it appears, black out the first eight digits (and the QR if you want), and send the image back.
- Source
- Our own OCR and image processing on the image you send. Nothing is looked up at UIDAI.
- Turnaround
- Real time, typically one to three seconds per image
- Endpoint
- POST /v1/aadhaar/mask
- Who can use it
- Any business that collects Aadhaar images. No consent step is needed for masking itself, but you still need consent to have collected the image.
Overview
If you collect Aadhaar card images, UIDAI rules say you can't keep the full number visible. This API finds the number on the front and back of the card, including the second copy printed near the address, and masks the first eight digits. Old files can be cleaned in bulk too.
Good to know
Very blurred, cropped or heavily angled photos can hide the number from detection. Check aadhaar_found and send the user back to re-upload if it is false.
What you get
- Finds every copyAadhaar letters and e-Aadhaar PDFs print the number in more than one place. We count and mask each occurrence.
- QR masking optionThe QR holds the full number too. Turn on mask_qr and we blur it.
- Bulk clean-upHave years of unmasked scans in storage? Send them through in batches and replace the originals.
- Image stays usableName, photo and address remain readable, so your operations team can still use the document.
Request
POST https://api.ampletrails.com/v1/aadhaar/mask
| Field | Type | Status | Description |
|---|---|---|---|
image_base64 | string | Required | Front or back image of the Aadhaar card (JPG, PNG or PDF page), base64 encoded |
mask_qr | boolean | Optional | Also blur the QR code on the card (default true) |
output_format | string | Optional | Format of the masked image: jpg or png |
Response
Fields inside data. Every response also carries status, request_id and, on errors, message. See error codes.
| Field | Meaning | Example |
|---|---|---|
masked_image_base64 | The masked image, base64 encoded | /9j/4AAQSkZJRg... |
aadhaar_found | Whether an Aadhaar number was detected on the image | true |
masked_number | The number as now visible on the image | XXXX XXXX 4321 |
occurrences_masked | How many places the number was masked | 2 |
qr_masked | Whether the QR code was masked | true |
side | Detected side of the card: front or back | front |
Example
curl -X POST https://api.ampletrails.com/v1/aadhaar/mask \
-H "Authorization: Bearer $AMPLE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image_base64": "/9j/4AAQSkZJRg...", "mask_qr": true, "output_format": "jpg", "consent": "Y"}'import os, requests
resp = requests.post(
"https://api.ampletrails.com/v1/aadhaar/mask",
headers={"Authorization": f"Bearer {os.environ['AMPLE_API_KEY']}"},
json={
"image_base64": "/9j/4AAQSkZJRg...",
"mask_qr": True,
"output_format": "jpg",
"consent": "Y"
},
timeout=30,
)
resp.raise_for_status()
print(resp.json()["data"])const resp = await fetch("https://api.ampletrails.com/v1/aadhaar/mask", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.AMPLE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"image_base64": "/9j/4AAQSkZJRg...",
"mask_qr": true,
"output_format": "jpg",
"consent": "Y"
}),
});
const { data } = await resp.json();$ch = curl_init("https://api.ampletrails.com/v1/aadhaar/mask");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("AMPLE_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(["image_base64" => "/9j/4AAQSkZJRg...", "mask_qr" => true, "output_format" => "jpg", "consent" => "Y"]),
]);
$data = json_decode(curl_exec($ch), true)["data"];{
"status": "success",
"request_id": "req_7f3a9c21e4",
"data": {
"masked_image_base64": "/9j/4AAQSkZJRg...",
"aadhaar_found": true,
"masked_number": "XXXX XXXX 4321",
"occurrences_masked": 2,
"qr_masked": true,
"side": "front"
}
}Example data. The exact field list for your account comes with your sandbox documentation.
Use cases
Lenders and NBFCs
Mask every uploaded Aadhaar before it lands in the loan file or DMS.
HR and payroll
Employee records often hold full Aadhaar scans from years ago. Clean them in one pass.
Visitor and access logs
Reception desks that photograph IDs can mask them on capture instead of storing raw images.
Questions about this API
Is masking enough to comply with Aadhaar rules?
It covers the storage rule for images. You still need consent to collect the card and a lawful purpose for keeping it.
Do you keep a copy of the unmasked image?
No. The image is processed in memory and discarded after we return the masked version.
Does it work on e-Aadhaar PDFs?
Yes. Send each page as an image or the PDF page itself; the number appears several times on e-Aadhaar and all of them are masked.
What about the VID on the card?
The 16-digit Virtual ID is not covered by the masking rule, but we can mask it too if your policy wants that. Ask us to switch it on for your account.
Try the Aadhaar Masking API
Sandbox keys, the full field reference and a Postman collection, usually within a working day.