A driving licence verification API checks a licence number and a date of birth against the licensing record and returns the licence record: the holder's name, the father's or husband's name, addresses, the validity by class, the transport badge details with the classes of vehicle covered, the issue date and a link to the holder's photograph. With StampMitra the call is POST /v1/verify/driving-license with dlNumber and dob, both required, from a key that carries the verification.dl.read scope. The response includes a valid flag, the profile fields, dlValidity with the dates by class, badgeDetails, detailsOfDrivingLicence, validUpto, dlStatus and the two identifiers referenceId and verificationId.
Teams usually reach for this when they put people behind a wheel: ride-hailing and delivery fleets, self-drive rental companies, logistics operators, corporate vehicle programmes and insurers pricing driver risk. This page is written for those teams. It explains what the check can and cannot establish, why the date of birth is part of the request, how to read the validity dates and status without inventing rules, how far to trust the classes of vehicle the response lists, how often to re-check a driver, and how to run the call safely given that this endpoint is one of the most tightly controlled in the verification family.
The facts about the call are taken from StampMitra's Driving Licence API reference, and where that reference is silent the page says as much. This is general information, not legal advice.
Key takeaways
- Endpoint:
POST https://api-b2b.stampmitra.in/v1/verify/driving-license. Body:dlNumberanddob(both required, date asYYYY-MM-DD). Scope:verification.dl.read. - The response has
valid,status,dlNumber,dob,badgeDetails,dlValidity,detailsOfDrivingLicenceand the two idsreferenceIdandverificationId. For existing integrations it still hasname,fatherOrHusbandName,address,validUptoanddlStatusat the top level, with the same values as before. - Every field except
referenceId,verificationIdandvalidis optional. A value the licence record holds asnull(no badge, no transport class, no last transaction) comes back asnull; a field the record does not carry is left out. - Validity and issue dates are strings exactly as supplied,
dd/mm/yyyyin the documented example, so parse them defensively.dobis ISOyyyy-mm-dd. - The response lists the classes of vehicle in
badgeDetails[].classOfVehiclebut not endorsements or offences, and a class on the record is not proof that the driver may drive the particular vehicle you are handing over. - Driving Licence calls need an IP-allowlisted key. The server's message is passed through to the caller when a key does not qualify. Check that your plan includes an IP allowlist before you plan a launch date.
- The price is the standard verification rate, ₹5 per completed call on pay-as-you-go, excluding GST. Sandbox is free and never debits the wallet.
- Because
dobis a required input, a wrong date of birth can look exactly like a wrong licence number. Design the form and the error messages for that. - Name, address and date of birth are personal data. Store the decision and the
referenceId, not the profile. - A malformed number returns
400and is not billed. A negative result is a completed, billed check.
What the check returns
A driving licence is a card issued by a state transport authority that says a person may drive particular classes of vehicle. The verification lookup resolves the number, uses the date of birth as a second key, and returns what the record holds. The StampMitra reference does not name the upstream source or how often it refreshes, so read the response as a snapshot at the moment of the call. Each call also returns verificationId, StampMitra's own id for that one verification (VRF- followed by twelve characters), which is new for every call; quote it, with the referenceId, in a support request.
The documented request and response:
Request parameters
| Field | Type | Description |
|---|---|---|
Authorizationrequired | header | Bearer <api-key> (e.g. sk_test_... in sandbox, sk_live_... in production). The x-api-key header is also accepted. |
dlNumberrequired | string | Driving licence number. |
dobrequired | string | Date of birth (YYYY-MM-DD). |
Response fields
| Field | Type | Description |
|---|---|---|
referenceId | string | StampMitra's own transaction id for this call (SMV-YYYYMMDD-XXXXXXX). Always present, including on a negative result. |
verificationId | string | StampMitra's own id for this verification (VRF- followed by 12 base32 characters). Generated for every call, unique to it. Always present. Quote it in support requests. |
valid | boolean | Whether the driving licence is valid. Always present. |
dlNumber | string | The driving licence number that was looked up. |
dob | string | The licence holder's date of birth, ISO yyyy-mm-dd. |
status | string | Outcome of the lookup: VALID or INVALID. |
dlStatus | string | Same value as status. Kept so existing integrations keep working. |
name | string | The licence holder's registered name. Same as detailsOfDrivingLicence.name. Kept for existing integrations. |
fatherOrHusbandName | string | Name of the holder's father or husband. Same as detailsOfDrivingLicence.fatherOrHusbandName. Kept for existing integrations. |
address | string | The registered address as one string. Same as detailsOfDrivingLicence.address. Kept for existing integrations. |
validUpto | string | End of validity of the non-transport classes, a date string exactly as supplied (dd/mm/yyyy in the example). Same as dlValidity.nonTransport.to. Kept for existing integrations. |
badgeDetails | array or null | Transport badge details and the classes of vehicle covered. null when the record carries no badge block. |
badgeDetails[].badgeIssueDate | string or null | Date the transport badge was issued, as supplied. null when the licence has no badge. |
badgeDetails[].badgeNo | string or null | Transport badge number. null when the licence has no badge. |
badgeDetails[].classOfVehicle | array of string or null | Classes of vehicle the licence covers, for example LMV. |
dlValidity | object or null | Validity periods of the licence by class: non-transport, transport, hazardous goods and hill area. |
dlValidity.nonTransport | object or null | Validity of the non-transport (private vehicle) classes. |
dlValidity.nonTransport.to | string or null | End of the validity period, a date string exactly as supplied (dd/mm/yyyy in the example). null when the class does not apply. |
dlValidity.nonTransport.from | string or null | Start of the validity period, a date string exactly as supplied (dd/mm/yyyy in the example). null when the class does not apply. |
dlValidity.hazardousValidTill | string or null | Validity end for hazardous-goods vehicles, as supplied. null when not applicable. |
dlValidity.transport | object or null | Validity of the transport (commercial vehicle) classes. Both dates are null when the licence has no transport class. |
dlValidity.transport.to | string or null | End of the validity period, as supplied. null when the licence has no transport class. |
dlValidity.transport.from | string or null | Start of the validity period, as supplied. null when the licence has no transport class. |
dlValidity.hillValidTill | string or null | Validity end for hill-area driving, as supplied. null when not applicable. |
detailsOfDrivingLicence | object or null | Details held on the licence record: issue date, holder names, addresses, photograph link and class-of-vehicle details. |
detailsOfDrivingLicence.dateOfIssue | string or null | Date the licence was issued, a date string exactly as supplied (dd/mm/yyyy in the example). |
detailsOfDrivingLicence.dateOfLastTransaction | string or null | Date of the last transaction on the licence record, as supplied. null when there is none. |
detailsOfDrivingLicence.status | string or null | Status text on the licence record. null when the record carries none. |
detailsOfDrivingLicence.lastTransactedAt | string or null | Office where the last transaction was made. null when there is none. |
detailsOfDrivingLicence.name | string or null | Name of the licence holder. |
detailsOfDrivingLicence.fatherOrHusbandName | string or null | Name of the holder's father or husband. |
detailsOfDrivingLicence.addressList | array or null | Addresses on record, each with its type (permanent or temporary). |
detailsOfDrivingLicence.addressList[].completeAddress | string or null | The complete address as one string. |
detailsOfDrivingLicence.addressList[].type | string or null | Address type: permanent or temporary. |
detailsOfDrivingLicence.addressList[].splitAddress | object or null | The same address split into parts. |
detailsOfDrivingLicence.addressList[].splitAddress.district | array of string or null | District name(s). |
detailsOfDrivingLicence.addressList[].splitAddress.state | array of string or null | State name and code as one flat list. Can be [""] when the record carries no state. |
detailsOfDrivingLicence.addressList[].splitAddress.city | array of string or null | City or locality name(s). |
detailsOfDrivingLicence.addressList[].splitAddress.pincode | string or null | Six-digit PIN code. |
detailsOfDrivingLicence.addressList[].splitAddress.country | array of string or null | Country code(s) and name. |
detailsOfDrivingLicence.addressList[].splitAddress.addressLine | string or null | The address as one line. |
detailsOfDrivingLicence.address | string or null | The holder address as one string. |
detailsOfDrivingLicence.photoUrl | string or null | A link to the licence holder photograph (a URL, never image data). The link is temporary: download the image promptly if you need it. |
detailsOfDrivingLicence.splitAddress | object or null | The holder address split into parts. |
detailsOfDrivingLicence.splitAddress.district | array of string or null | District name(s). |
detailsOfDrivingLicence.splitAddress.state | array of string or null | State name and code as one flat list. Can be [""] when the record carries no state. |
detailsOfDrivingLicence.splitAddress.city | array of string or null | City or locality name(s). |
detailsOfDrivingLicence.splitAddress.pincode | string or null | Six-digit PIN code. |
detailsOfDrivingLicence.splitAddress.country | array of string or null | Country code(s) and name. |
detailsOfDrivingLicence.splitAddress.addressLine | string or null | The address as one line. |
detailsOfDrivingLicence.covDetails | array or null | Class-of-vehicle detail entries when the record carries any; an empty list otherwise. |
Taking the fields in turn:
valid is the headline. When it is false, the number and date of birth together did not resolve to a licence. That can mean a wrong number, a wrong date of birth or no such licence, and the response will not tell you which, which is deliberate behaviour for a lookup that uses date of birth as part of the key.
name and fatherOrHusbandName are the holder's name and the name of a relative as recorded. The second field is often a useful tie-breaker when two people share a common name, and it is personal data. The same two values sit inside detailsOfDrivingLicence; the top-level copies are kept so existing integrations keep working.
dob echoes the date of birth held in the record. Compare it with the value you sent; they should agree if the lookup resolved.
address is a single free-text string of the address on record. It is not proof of where the person lives today. detailsOfDrivingLicence.addressList carries each address on record with its type (permanent or temporary), as a complete string and split into district, state, city, PIN code, country and an address line. Read the list parts as lists: state is one flat list of the state name and code, for example ["KARNATAKA", "KA"], and it can be [""] when the record holds no state, so do not index into it without checking.
dlValidity holds the validity by class: nonTransport and transport each with a from and a to, plus hazardousValidTill and hillValidTill. These are date strings exactly as the licensing record supplies them, dd/mm/yyyy in the documented example, so parse them defensively rather than with a date constructor that assumes ISO. A null means the class does not apply to this licence: in the example the transport period and both extra dates are null. validUpto is the same string as dlValidity.nonTransport.to, the date to which the non-transport classes are valid as the record shows it. How you treat the days after that date is a policy question, covered below.
status is the outcome of the lookup, VALID or INVALID, and dlStatus carries the same value for existing integrations. Write handling as an allow-list. detailsOfDrivingLicence.status is a separate status text held on the licence record; it is null in the example and not something to branch on.
badgeDetails lists transport badges. Each entry has badgeIssueDate and badgeNo, both null when the licence has no badge, and classOfVehicle, the classes of vehicle covered, ["LMV"] in the example. The whole list can itself be null or empty.
detailsOfDrivingLicence carries the licence record: dateOfIssue (a string as supplied, dd/mm/yyyy in the example), dateOfLastTransaction and lastTransactedAt (both null when there has been no transaction), the holder names, addressList, address, splitAddress, covDetails and photoUrl. covDetails is an empty list in the example. photoUrl is a link to the holder's photograph: it is a URL, never image data, and it is temporary, so download the image when you receive it if you need it and treat it as personal data.
A field the record does not carry is left out of the response, and a field the record holds as null is returned as null, so test for both: dl.badgeDetails?.[0]?.badgeNo ?? null is the safe read.
referenceId is StampMitra's transaction identifier in the format SMV-YYYYMMDD-XXXXXXX, present on every completed call and not an idempotency key. verificationId is StampMitra's own id for this one verification, VRF- followed by twelve characters, also present on every call and different every time.
What a valid licence does not tell you
It lists classes, but not endorsements, and not always. badgeDetails[].classOfVehicle names the classes of vehicle the record covers, and dlValidity says for which periods. When the licence has no badge the badge fields are null, and the list can be missing or empty, so an absent class is not the same as "no class". The response has no field for endorsements or restrictions beyond that. If you are onboarding a bus driver or handing over a heavy vehicle, compare the class with the physical licence, and your process must say what happens when the two differ or the class is missing.
It does not prove who is holding the card. The response links to a photograph in detailsOfDrivingLicence.photoUrl, which a reviewer can compare with the person, but the check itself does not compare faces. Someone can submit a real number and date of birth that belong to another person. In person, a person checking the physical card against the face is the control that matters. Remotely, a selfie and liveness step is the common companion.
It does not show offences or points. The record carries no endorsement history or suspension reason, and detailsOfDrivingLicence.status is null in the documented example.
It does not predict future behaviour. A licence that is active today can be suspended tomorrow. See the re-check section.
Putting these limits into your onboarding policy and your customer-facing wording prevents the most common error with this product: describing a licence check as a driver safety check.
Why `dob` is a required input
Many lookups need only an identifier. This one needs the identifier and the date of birth, which has three practical consequences.
First, the date of birth works as a second factor. That reduces the chance that someone enumerates numbers to learn about strangers, which is one reason the product is tightly controlled.
Second, a failure is ambiguous. A valid: false result can be a typo in either input. A good product therefore asks the driver to re-check both fields, and shows the number back in a clear typeface before the call.
Third, you are collecting a date of birth you may not otherwise need. Be careful where that value goes. Treat it as personal data from the first keystroke: do not log it, and do not keep it after the decision unless you have a stated purpose.
export function normaliseDl(raw) {
return String(raw).toUpperCase().replace(/[\s\-.]/g, "");
}
export function isIsoDate(s) {
return /^\d{4}-\d{2}-\d{2}$/.test(s) && !Number.isNaN(Date.parse(s));
}Collect the date of birth with a date picker that produces YYYY-MM-DD, not a free-text field, because a day-month swap such as 03-04 versus 04-03 is the most common reason a genuine licence fails.
The licence number format
The documented sample is MH1420110012345, and the validation message reads "dlNumber must match the format MH1420110012345". The shape is commonly described as a two-letter state code, a two-digit registering authority number, a four-digit year and a seven-digit serial, fifteen characters in all. The sample fits that shape: MH for Maharashtra, 14, 2011 and 0012345.
Real cards are messier. Licences are printed with spaces or hyphens (MH-14 2011 0012345), older licences may not follow the pattern at all, and some states have used their own layouts over the years. Do not write a strict pattern on your side. Normalise by uppercasing and stripping separators, and let the API validate. A malformed value returns 400 BAD_REQUEST before verification, is not billed, and the message names the field.
Reading the validity dates and `status` without inventing rules
You will be tempted to hard-code rules such as "reject if expired" or "allow thirty days after expiry". Resist the second kind. Whether a lapsed licence can be renewed within a grace period, and what a driver may do during that time, is set by the Motor Vehicles Act, 1988, the rules made under it and state practice, and it changes. Your process should not encode a grace period that you have not checked against the current rules and your own legal advice.
A defensible default is simple. Compare the validity date for the class you need (validUpto, which is dlValidity.nonTransport.to, for a private vehicle; dlValidity.transport.to for a commercial one) with today's date in Indian Standard Time. If it is earlier than the end of the period you need the driver to be licensed for, or the date is null or cannot be read, route the case to review and ask for the renewed licence. For a rental, that period runs to the end of the rental; for a fleet driver, to at least the next scheduled re-check.
The dates are strings exactly as supplied, dd/mm/yyyy in the documented example, so do not hand them to a date constructor that expects ISO. Parse the form you see, accept ISO as well, and treat anything else as unreadable.
// Dates arrive as supplied: dd/mm/yyyy in the documented example. Accept ISO too; anything else is unreadable.
export function parseLicenceDate(value) {
if (typeof value !== "string") return null;
const dmy = /^(\d{2})\/(\d{2})\/(\d{4})$/.exec(value);
const iso = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
const [y, m, d] = dmy ? [dmy[3], dmy[2], dmy[1]] : iso ? [iso[1], iso[2], iso[3]] : [];
return y ? new Date(`${y}-${m}-${d}T23:59:59+05:30`) : null;
}
export function licenceCoversPeriod(dl, endDateIso) {
const validUpto = parseLicenceDate(dl.dlValidity?.nonTransport?.to ?? dl.validUpto);
const end = new Date(`${endDateIso}T23:59:59+05:30`);
return validUpto !== null && validUpto >= end; // null or unreadable: not covered, so it goes to review
}
const ACCEPTED_STATUS = new Set(["VALID"]); // extend only after your team decides
export function assessDl(dl, { rentalEnd, expectedName, dob }) {
const reasons = [];
if (dl.valid !== true) return { outcome: "reject", reason: "not_found", referenceId: dl.referenceId };
if (!ACCEPTED_STATUS.has(dl.status ?? dl.dlStatus)) reasons.push("status_not_in_allow_list");
if (rentalEnd && !licenceCoversPeriod(dl, rentalEnd)) reasons.push("expires_before_period_ends");
if (dl.dob !== dob) reasons.push("dob_mismatch");
if (expectedName && nameOverlap(expectedName, dl.name) < 0.8) reasons.push("name_unclear");
return { outcome: reasons.length ? "review" : "approve", reasons, referenceId: dl.referenceId, verificationId: dl.verificationId };
}nameOverlap is a token comparison that tolerates initials and transliteration, like the one on the Voter ID page. Set its threshold from real data, not sandbox.
The access control you need to plan for
This endpoint is one of two in the verification family, with Passport, that the StampMitra SDK documentation describes as needing an IP-allowlisted key. When a key does not meet the requirement, the server's message is passed through to your code as a permission error, so you will see it in the response rather than a silent failure.
There are three practical points.
Plan the allowlist early. An allowlist is a list of IP addresses or CIDR ranges from which the key may be used. You need stable egress addresses for the backend that calls the endpoint. If your servers sit behind dynamic addresses, put the verification calls behind a small proxy or NAT with a fixed address.
Check your plan. An IP allowlist is a plan feature on the pricing page, and not every plan includes it. If you are on a plan without it, you may be unable to use this endpoint in production until you move to one that does. Find out before you commit to a launch date.
Keep the key narrow. Give it only verification.dl.read, store it in a secrets manager, and use a separate key from the rest of your verification traffic. See the authentication docs.
Never call this endpoint from a browser or a mobile app. Besides exposing the key, the call would originate from an address outside your allowlist.
Billing and failure behaviour
Each completed call is metered as dl.verify. In production the standard verification rate applies, ₹5 per call on pay-as-you-go and lower on higher plans, excluding 18% GST; the pricing page has the numbers for your plan.
A negative answer counts. If the lookup completes and reports that the number and date of birth do not resolve, you have received a determination, it is recorded and billed, and you get a referenceId. Calls that never reach verification, whether because of a malformed number (400), a bad key (401) or a missing scope or a key that is not allowlisted (403), are not billed.
Other outcomes follow the same shared behaviour as every verification endpoint. A short wallet returns 402, and the answer is to top up. Exceeding the rate limit returns 429; the documented example reads "Rate limit exceeded: 60 requests per 60 seconds for this endpoint." If the upstream service cannot be reached you get 502, no verification completes and nothing is charged for it. A timeout leaves you uncertain, since the route documents no idempotency header and the referenceId is not an idempotency key.
| Status | Code | Meaning | Your action |
|---|---|---|---|
| 400 | BAD_REQUEST | dlNumber or dob malformed | Show the message, ask for correction |
| 401 | UNAUTHORIZED | Missing or invalid key | Fix deployment |
| 402 | PAYMENT_REQUIRED | Wallet balance insufficient | Top up, alert operations |
| 403 | FORBIDDEN | Missing scope, or key not IP-allowlisted | Fix the key, scope or allowlist |
| 429 | TOO_MANY_REQUESTS | Rate limit or sandbox limit (SANDBOX_RATE_LIMIT, SANDBOX_DAILY_LIMIT or SANDBOX_IP_LIMIT) | Back off with jitter |
| 502 | INTERNAL_ERROR | Upstream unreachable | Retry with backoff |
Every error uses the same envelope, { "error": { "code", "message", "requestId" } }.
400Validation errorBAD_REQUESTdlNumber must match the format MH1420110012345
401Missing or invalid API keyUNAUTHORIZEDMissing or invalid API key.
402Insufficient wallet balancePAYMENT_REQUIREDInsufficient fulfilment wallet balance to cover this call.
403Valid key, missing required scopeFORBIDDENAPI key is valid but lacks the required scope for this endpoint.
429Rate limitedTOO_MANY_REQUESTSRate limit exceeded: 60 requests per 60 seconds for this endpoint.
502Upstream verification service unreachableINTERNAL_ERRORUnable to reach the order/customer service right now
Why a check fails and what to tell the driver
valid: false. Ask the driver to check the number against the card and re-pick the date of birth. Do not say which field is wrong, because you do not know.- Valid but expired. Ask for the renewed licence. A driver who renewed last week may be ahead of the record, so offer to retry in a day.
- Valid but name unclear. Show the name on record and let the driver confirm which is theirs. Differences are usually initials or spelling.
403on your side. This is a configuration problem. Tell the driver the check is temporarily unavailable and alert your own team.429or502. Tell the driver to wait a moment. These are transient.
Where driving licence checks fit in a workflow
Ride-hailing and delivery onboarding. The driver provides a licence number and date of birth, the backend verifies, compares the name with the identity document the driver already supplied, and checks the validity date. The classes of vehicle come from badgeDetails[].classOfVehicle, which a reviewer compares with the licence image, because a class missing from the record is a reason to look rather than to guess.
Self-drive rental. Before handing over keys, the customer's licence is verified, the licence's validity is compared with the rental end date, and a person at the counter compares the card and the face. The verification is evidence for your records and a quick screen, not the final control.
Logistics and fleet operators. Pair Vehicle RC verification with this check so each vehicle is matched to a licensed driver. Commercial vehicles need the right class and badge: badgeDetails and dlValidity.transport show what the record holds, and the physical card remains the check you confirm it against.
Corporate vehicle programmes. Employers who allow staff to drive company vehicles check licences at issue and at renewal dates, without collecting more personal data than the programme needs.
Insurance. Insurers and brokers can use the check to confirm that a named driver holds a licence, as one input into underwriting, with their own rules for the rest.
Combining with other checks
A licence check answers "does this licence exist and is it active". Wider onboarding asks more.
| Question | Check |
|---|---|
| Is this who they say they are (tax identity, registered name)? | PAN verification |
| Is there a government identity document that agrees on name and date of birth? | Voter ID or Passport |
| Can we pay them? | Bank account verification |
| Is the vehicle valid and who owns it? | Vehicle RC verification |
| Is the person a business? | GSTIN verification |
The agreement of name and date of birth across independent records is the useful signal. A licence whose holder name and date of birth agree with the PAN and the bank account holder name is a strong picture. A disagreement on any one is a reason to look. Run the cheapest decisive check first and stop on a hard failure.
How often to re-check a driver
A licence can be suspended, cancelled, renewed or lapse. A one-time check at onboarding goes stale. A sensible cadence ties re-checks to dates and events.
- Store
validUptoafter each successful check and schedule a refresh a few days before it. - Re-check after an incident or a complaint.
- Re-check at a fixed outer interval, such as annually, for drivers you work with continuously, with the interval set by your risk appetite and any regulatory or contractual duty you have.
- Do not poll every driver weekly. It adds cost and personal-data handling without adding decisions.
Integration walkthrough
cURL
curl -X POST "https://api-b2b.stampmitra.in/v1/verify/driving-license" \
-H "Authorization: Bearer $STAMPMITRA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"dlNumber":"MH1420110012345","dob":"1990-01-01"}'Node.js
The Node.js SDK and Python SDK wrap this endpoint. The raw calls below show what they do. Remember that the key must be IP-allowlisted, so run this from the backend whose address is on the list.
// Node 18+ (built-in fetch)
const BASE = "https://api-b2b.stampmitra.in";
export async function verifyDrivingLicence({ dlNumber, dob }, { timeoutMs = 20000 } = {}) {
if (!isIsoDate(dob)) return { kind: "invalid_input", message: "Date of birth must be YYYY-MM-DD." };
const res = await fetch(`${BASE}/v1/verify/driving-license`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.STAMPMITRA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ dlNumber: normaliseDl(dlNumber), dob }),
signal: AbortSignal.timeout(timeoutMs),
});
const body = await res.json().catch(() => ({}));
if (res.ok) return { kind: "completed", result: body };
const { code, message, requestId } = body.error ?? {};
const retryable = res.status === 429 || res.status === 502;
return { kind: retryable ? "retry" : "failed", status: res.status, code, message, requestId };
}Python
import os, re, requests
BASE = "https://api-b2b.stampmitra.in"
def verify_driving_licence(dl_number: str, dob: str, timeout: int = 20) -> dict:
if not re.fullmatch(r"\d{4}-\d{2}-\d{2}", dob):
return {"kind": "invalid_input", "message": "Date of birth must be YYYY-MM-DD."}
resp = requests.post(
f"{BASE}/v1/verify/driving-license",
headers={"Authorization": f"Bearer {os.environ['STAMPMITRA_API_KEY']}"},
json={"dlNumber": re.sub(r"[\s\-.]", "", dl_number.upper()), "dob": dob},
timeout=timeout,
)
body = resp.json() if resp.content else {}
if resp.ok:
return {"kind": "completed", "result": body}
err = body.get("error", {})
return {
"kind": "retry" if resp.status_code in (429, 502) else "failed",
"status": resp.status_code,
"code": err.get("code"),
"message": err.get("message"),
"requestId": err.get("requestId"),
}A 403 from a key that is valid but not allowlisted is not retryable. The function marks it failed, and your monitoring should treat any 403 on this endpoint as a configuration alarm, not a driver problem.
Edge cases and odd inputs
- Day and month swapped. The classic reason for a false negative. Use a date picker.
- Older licence formats. A licence issued decades ago may not look like the sample. Test the ones your drivers actually hold.
- Licences issued by another state. The state code in the number is the issuing state, which may differ from where the driver lives or where you operate.
- Recently renewed licences. The record may lag, so a renewed card can look expired for a short time.
- Name differences. Initials, a married name, transliteration. Keep a review path.
- Missing relative's name. Treat
fatherOrHusbandNameas possibly blank. - Separators in the number. Spaces, hyphens, dots. Normalise.
- Duplicate submissions. The same driver submitting twice by mistake. De-duplicate on the normalised number and date of birth hash within a short window, to avoid billing twice.
- Class and badge needs.
badgeDetailscan benull, empty or havenullbadge fields, so route to a manual check where the job needs a specific class or badge. - Dates in two forms. The validity and issue dates are strings as supplied,
dd/mm/yyyyin the documented example. A parser that accepts only ISO will fail on them; one that accepts onlydd/mm/yyyywill fail if a record arrives in ISO. - Empty state.
splitAddress.statecan be[""], a list holding one empty string, not an empty list. - Nulls.
nullmeans the record holds nothing for that field; a missing key means the record did not carry it. Do not treat either as an error.
Audit logging and monitoring
Plan the log around the question a transport or insurance auditor would ask: on what basis did you let this person drive? You need your own driver or application ID, the referenceId and verificationId, the outcome and reason codes, the HTTP status, the requestId on errors, the key that made the call, and the time. You do not need, and should not log, the licence number, date of birth, name, relative's name, addresses, photograph link or raw payload. A keyed hash covers the occasional debugging link to a licence number.
StampMitra's request logs can be fetched with GET /v1/logs or browsed in the dashboard; how far back they go depends on the plan, up to 365 days on Scale. Decision records of your own are kept for whatever period your audits require.
This endpoint is unusual in that a 403 almost always means configuration, so it deserves a pager rule of its own. Beyond that, watch the share of valid: false results (a jump suggests the date picker broke), the review share, and 429 and 402 counts.
Modelling the cost
The cost driver is how often you re-check, not the first check.
export function monthlyDlCost({ newDrivers, retryShare = 0.15, activeDrivers = 0, recheckPerDriverPerMonth = 1 / 12, pricePerCall }) {
const calls = newDrivers * (1 + retryShare) + activeDrivers * recheckPerDriverPerMonth;
return { calls: Math.ceil(calls), cost: Math.ceil(calls) * pricePerCall };
}A delivery fleet onboards 600 drivers a month, 15 percent need a second attempt because of a swapped date or a misread number, and it re-checks each of 4,000 active drivers once a year. That is 690 calls for new drivers plus about 333 calls a month spread over the year, around 1,023 calls. Multiply by your plan's standard rate and add 18% GST on the top-up. A date picker and a number confirmation screen can cut the retry share from 15 to 5 percent, saving about sixty calls a month. Re-checking every driver quarterly instead of annually adds roughly 1,000 calls a month for a risk reduction you should first justify.
Sandbox and production
Sign up and you get an sk_test_ key that never debits the wallet and answers with sample data. The answer comes from a stored sample, not from the licensing records: the test values table on this page lists the licence numbers that select each outcome (valid, not found, expired and the error responses), and any other well-formed number returns the success example with invented values, the same every time, with the licence number and date of birth you sent echoed back. A valid answer carries the same fields as the documented example, nulls and dd/mm/yyyy dates included, and the sandbox marker fields. Use it for the date picker, normalisation, error handling and every screen, and keep a few responses as fixtures. You can build the parser against it. It says nothing about how real licences or your name thresholds will behave, and its limits are not production limits. The quickstart shows a first call.
Production needs an sk_live_ key, issued after your organisation's KYC and a Driving Licence production application are approved; the server reads the environment from the key. Since production also demands an IP-allowlisted key, rehearse that path before launch: configure the key, call from a listed address, and confirm that a call from elsewhere is refused with a 403. A passing sandbox does not prove production access.
Privacy and consent, in general terms
A name, an address and a date of birth together pin down a person closely, and a licence number adds to it. India's Digital Personal Data Protection Act, 2023 and its rules govern processing; your counsel should say how they apply. These are common practices, not legal advice.
- Before the driver types anything, explain that you verify the licence with a verification service, why, and what you keep.
- Treat the date of birth as collected for the lookup only, and do not reuse it elsewhere without a basis.
- Keep the outcome, reason codes,
validUptoif you schedule re-checks, thereferenceIdandverificationIdand a timestamp. The addresses and the photograph link are rarely needed, and the link is temporary, so do not keep it. - Let only reviewers see profile fields.
- Set a retention period and enforce it.
- Give people a way to request access or correction.
- Do not stretch the check to a conclusion it cannot support: a licence lookup says nothing about how safely someone drives.
- Agree processor terms with StampMitra as your counsel advises.
A worked scenario: a self-drive rental counter
A fictional rental company, Roadrunner Rentals, wants customers to upload their licence before arrival so handover takes five minutes.
- The customer enters the licence number and picks their date of birth. The app shows the number back in large type for confirmation.
- The backend calls the endpoint from its fixed egress address with a ten-second timeout. On
429it asks the customer to wait; on502it saves the booking and retries in the background. - A
valid: falseresult produces a message asking the customer to re-check the number and the date of birth, without saying which is wrong. - A valid result is compared with the booking: the name overlaps with the booked driver's name, the date of birth equals what was typed,
statusis in the accepted set. - Validity against the rental. The backend parses the
dd/mm/yyyydate and checks that it is on or after the planned return date. If not, the booking moves to review with the message "your licence expires during the rental". - The class check has a person in it. The response lists
badgeDetails[].classOfVehicle, but the counter staff still look at the physical card to confirm it covers the vehicle category, and compare the face with the photograph on the card. - Records kept. Roadrunner stores the
referenceId, outcome, reasons and timestamp on the booking. It does not keep the licence number, date of birth or address after handover, beyond what its insurer requires, and its notice says so.
The check shortens the counter process and gives an audit trail. It does not replace the person looking at the card.
Production checklist
Before launch you should be able to answer yes to each of these.
- A dedicated key exists with only
verification.dl.read, stored in a secrets manager and bound to your listed addresses. - Your plan includes the allowlist feature and you have rehearsed success and refusal.
- Only your backend calls the endpoint.
- The date picker emits
YYYY-MM-DD. - Unknown
statusvalues route to review rather than guessing. - Expiry is compared in IST against the period you need cover for.
- Only
429and502are retried. - A
403pages someone. - Logs carry reference IDs and outcomes, never personal fields.
- Someone owns the class and badge check, with a written step for a missing or
nullclass. - Re-checks are scheduled from
validUpto. - The notice and retention schedule cover the data.
Common mistakes
The costliest error is a description error: calling this a driver safety check, when it confirms a licence record and nothing about driving history. A close second is assuming the vehicle class or badge is always in the response. badgeDetails can be null, empty or have null fields, so a manual step has to own the case where it is missing.
Parsing mistakes come next: handing dd/mm/yyyy dates to a date constructor that expects ISO, indexing into splitAddress.state without allowing for [""], and treating a null as an error.
Form mistakes follow. A free-text date of birth invites swapped day and month and a stream of false negatives. Telling the driver which field is wrong is a small lie, since you cannot know. Hard-coding a grace period after expiry bakes in a rule that may no longer hold.
Operational mistakes finish the list: calling the endpoint from a browser, which exposes the key and bypasses the allowlist; logging the response; polling every driver on a timer instead of re-checking around validUpto; and discovering the allowlist requirement on launch day.
What to read next
Pair this check with Vehicle RC verification, PAN verification, Voter ID verification, Passport verification and bank account verification. Sandbox vs production API keys explains key handling and IP allowlisting, API errors and handling covers retries, and the complete reference is in the Driving Licence API docs.
Sources
- Driving Licence API reference, StampMitra product data: request fields, response example, scope and validation message, checked October 2026.
- Pricing, StampMitra: per-call rates, plan features including the IP allowlist, and log retention, checked October 2026. Rates exclude 18% GST.
- Motor Vehicles Act, 1988 and the Central Motor Vehicles Rules, 1989, Government of India, and the Parivahan portal, for licence classes, validity and renewal. Check the current text, since both have been amended.
- Digital Personal Data Protection Act, 2023, Government of India. Read the current Act and the rules made under it on the official government sites.
Sandbox test values
Send one of these values as dlNumber with a sandbox key (sk_test_...) to get that outcome. They are fake, valid in format, and never reach a real source or your wallet. Send with it: dob: 1990-01-01. Add the header X-Sandbox-Delay-Ms (up to 3000) to hold the reply and test your client timeout.
| Scenario | Input to send | What you get back |
|---|---|---|
| Valid, active licence | SB0000000000001 | 200 |
| Licence not found | SB0000000000002 | 200 |
| Licence expired | SB0000000000004 | 200 |
| Verification source times out | SB0000000000005 | 502INTERNAL_ERROR |
| Verification source unavailable | SB0000000000006 | 502INTERNAL_ERROR |
| Rate limited | SB0000000000007 | 429TOO_MANY_REQUESTS |
| Wallet balance too low | SB0000000000008 | 402PAYMENT_REQUIRED |
| Invalid format | SB0000000000 | 400BAD_REQUEST |
Frequently asked questions
What does the driving licence verification API return?
It returns the licence record: valid and status, the validity by class in dlValidity, badgeDetails with the classes of vehicle, detailsOfDrivingLicence with the issue date, names, addresses and a photograph link, and the old top-level name, fatherOrHusbandName, address, validUpto and dlStatus, plus a referenceId and a verificationId. It does not list endorsements or offences, and a class on the record does not tell you the driver may drive the particular vehicle you are handing over.
Why does the request need a date of birth?
The date of birth works as a second key for the lookup, which reduces the risk of someone enumerating licence numbers. The consequence is that a false result can mean a wrong number or a wrong date, so ask the driver to re-check both and use a date picker that produces YYYY-MM-DD.
What format is the driving licence number?
The documented sample is MH1420110012345, commonly described as a state code, a registering authority number, a four-digit year and a seven-digit serial. Older licences and some states differ, so uppercase and strip separators, then let the API validate instead of writing a strict pattern.
Does this endpoint need an IP-allowlisted key?
Yes. StampMitra's SDK documentation describes Driving Licence and Passport as needing an IP-allowlisted key, and the server's message is passed through as a permission error otherwise. An IP allowlist is a plan feature on the pricing page, so confirm your plan includes it before you plan a launch date.
How should I treat a licence that has just expired?
Compare the validity date for the class you need, validUpto for non-transport, with today's date in Indian Standard Time against the period you need the driver licensed for, and send anything earlier, null or unreadable to review. The dates are strings as supplied, dd/mm/yyyy in the documented example, so parse that form. Do not hard-code a grace period, because renewal rules come from the Motor Vehicles Act, its rules and state practice, and they change.
When am I billed for a driving licence check?
Usage is recorded and the production wallet debited when the verification completes. A valid false result is still a completed, billed determination. A malformed number, a bad key or a missing scope or allowlist returns 400, 401 or 403 and is not billed, and sandbox calls never debit your wallet.
How often should I re-check a driver?
Tie re-checks to dates and events. Store the validity date and refresh a few days before it, re-check after an incident or complaint, and add a fixed outer interval for drivers you work with continuously. Weekly polling of every driver adds cost and personal-data handling without improving decisions.
Why does a genuine licence sometimes return valid false?
The most common cause is a swapped day and month in the date of birth, then a misread number or a record that lags a recent renewal. Ask the driver to re-enter both fields and offer a retry later, without saying which field is wrong, because the response does not tell you.
Can I test driving licence verification for free?
Yes. A sandbox key starting with sk_test_ never debits your wallet and returns sample data with synthetic values and the same fields as the documented example, so the same input always gives the same answer. Test the date picker, error handling and screens there, and test the IP allowlist path before go-live because sandbox does not prove production access.
What should I store after the check?
Usually the outcome, reason codes, the validity date if you schedule re-checks, the referenceId and verificationId and a timestamp. Avoid keeping the licence number, date of birth, names, addresses or the photograph link beyond what you need, keep them out of logs, set a retention period and explain what you keep in your notice.
Can I use this check for driver safety decisions?
Not on its own. It confirms that a licence record exists and is active, not how someone drives, and it shows no offences or points. Describe it accurately to customers as a licence check, and pair it with identity checks and a manual class and badge check where the job needs one, since a class can be missing or null on the record.
What does a 403 on this endpoint mean?
Usually a missing verification.dl.read scope or a key that is not IP-allowlisted, both configuration problems. It is not retryable, so raise an alert, check the key, scope and allowlist, and tell the driver the check is temporarily unavailable rather than suggesting they did something wrong.