PAN Masking API

Redact PAN numbers in one API call

Send a JPG, PNG or PDF. Get the same document back with the middle seven characters of the PAN blacked out, keeping the first two and the last one readable for reference. Built for KYC and document pipelines.

Access is issued per organisation. Email contact@maskaadhaar.com with your expected monthly volume and peak throughput, and we will provision a key with a test quota.

Plug and play in three steps

Synchronous and stateless — no job IDs, no polling, no webhook to configure, no SDK to install.

📄
Step 1

Post the document

One multipart request carrying a JPG, PNG or PDF of the Aadhaar card.

🔍
Step 2

Detect and validate

Server-side OCR scans every orientation, and each candidate is checked against the Aadhaar checksum.

🔐
Step 3

Get it back redacted

The masked document is the response body, with a header telling you how many regions were covered.

Three lines to integrate

The masked file is returned directly in the response body, so there is nothing to poll and no second call to fetch a result.

curl -X POST \
  https://api.maskaadhaar.com/api/v1/mask-pan \
  -H "X-API-Key: $MASKAADHAAR_KEY" \
  -F "file=@pan.jpg" \
  --output pan_masked.jpg

Full reference with Python and Node.js examples, error codes and rate limits is in the API documentation.

Response headers

Every response reports what actually happened, so your pipeline can branch on it rather than assuming.

HeaderMeaning
X-Masked-CountRegions redacted. Zero means nothing was found — treat that as a failure.
X-Quota-UsedDocuments consumed this month
X-Quota-RemainingDocuments left this month

If the number cannot be read — glare on a laminated card, a fold through the digits — the original document is returned with a count of zero rather than the request failing outright. That keeps a customer's onboarding from breaking on a shaky photograph, but it means a 200 status is not by itself proof of masking.

What makes the detection trustworthy

PAN cards are photographed more often than they are scanned, and the number sits in the glossiest part of the card. These are the cases that matter.

💡

Glare-tolerant character repair

A laminated card under an office light produces substitutions: a zero read as the letter O, an eight as a B. Because the PAN format is fixed at five letters, four digits and a letter, characters are corrected by position — and repairs are scored so the least-altered reading wins rather than the first one that happens to look valid.

🗑

Dates are not mistaken for PANs

A PAN card prints a date of birth directly below the number. Joining adjacent text tokens across it can produce something that satisfies the PAN pattern, so token pairs are only ever accepted as exact reads and never as repairs.

🔄

Any orientation

Every rotation is scanned, so a card photographed sideways is handled the same as one held straight.

🇮

Processed in Mumbai

Requests are served from AWS ap-south-1, so processing stays in-country.

🗑

No document retention

Documents are processed in memory and streamed back in the response, with no copy written to a database or object store. The OCR engine writes a short-lived temporary file during processing which is removed when the request completes.

🔑

Keys stored hashed, revocable

Only a SHA-256 hash of your API key is stored, so a breach of our database yields no working credentials. Rate limits apply per key rather than per IP.

Also available: Aadhaar masking

The same interface, for Aadhaar numbers. The first eight digits are redacted and the last four stay readable, which is the format UIDAI describes for shared copies.

curl -X POST https://api.maskaadhaar.com/api/v1/mask-pan \
  -H "X-API-Key: $MASKAADHAAR_KEY" \
  -F "file=@pan.jpg" \
  --output pan_masked.jpg

Try it before you integrate

The browser-based Aadhaar tool runs the same detection logic entirely on your own machine, with no upload at all. It is the fastest way to see how masking behaves on your own difficult documents — a folded printout, a two-sided scan, a photograph with glare — before writing any integration code.

When you are ready, the API documentation has the endpoint reference and examples, and the integration guide covers the parts that cause incidents in production.

You are only billed for documents we process

Quota is consumed when a document is successfully processed and returned. A rejected request costs nothing:

OutcomeCounts against quota?
401 invalid or missing API keyNo
413 file larger than your plan allowsNo
422 unsupported file typeNo
429 rate limited or quota exhaustedNo
500 processing failed on our sideNo
200 document processed and returnedYes

One case deserves stating plainly rather than hiding in the small print: if the document is processed but no number could be read — heavy glare, a fold through the digits — it returns 200 with X-Masked-Count: 0, and that does count, because the OCR work was done. It is rare on legible documents. Check the header and route those to review rather than storing them as masked.

Every request is also recorded with its status code and processing time, so a disputed month can be reconciled line by line.

Request API access

Tell us your expected monthly document volume and peak throughput. We will size a plan, issue a key and give your team a test quota to validate output against your own documents before any commitment.

Frequently asked questions

What does the masked output look like?

The middle seven characters are replaced, keeping the first two and the last one: ABCDE1234F becomes ABxxxxxxxF. That leaves enough to reference the document without exposing the number.

What formats does the API accept?

JPG, JPEG, PNG and PDF. Multi-page PDFs are scanned page by page. The masked document is returned in the input format by default.

Will it mask the date of birth by mistake?

It should not. A PAN card prints a date of birth below the number, and joining text tokens across it can produce something matching the PAN pattern. Token pairs are therefore only accepted as exact reads, never as character repairs, and any candidate read at zero confidence is discarded.

Are documents stored?

No. Documents are processed in memory and streamed back in the response, with no copy written to a database or object store. The OCR engine writes a short-lived temporary file during processing which is removed when the request completes. Processing runs in AWS Mumbai.

How do I know whether a document was actually masked?

Read the X-Masked-Count response header. If the PAN could not be read, the original document is returned unchanged with a count of zero and a 200 status, so the status code alone is not proof of masking.

Can I mask Aadhaar and PAN with the same key?

Yes. One key works against both endpoints and draws on the same monthly quota.