VALIDPDF417

Guide · generate a payload

AAMVA PDF417 generator.

An AAMVA PDF417 generator does two jobs a barcode library does not: it builds the AAMVA file around your fields, and it encodes the result as PDF417. This page gives the exact request that does both for any of the 51 US jurisdictions or the 12 Canadian provinces, the header it writes, and the rules that reject a field before anything is encoded.

aamva encoder
Raw AAMVA payload

    
idle

The request

One endpoint, POST /api/v1/aamva, with a bearer key and a JSON body. The jurisdiction decides the IIN, the element list and the default error correction level; the field map carries only values. The panel above sends this same body, so every field below appears in the form.

json
{
  "state": "CA",
  "eclevel": 5,
  "format": "png",
  "dpi": 600,
  "generate": {"dd": true, "icn": true},
  "fields": {
    "DAQ": "A1234567",
    "DCS": "SAMPLE",
    "DAC": "JORDAN",
    "DBB": "19900314",
    "DBA": "20300115",
    "DBC": "1",
    "DAG": "1234 SAMPLE ST",
    "DAI": "BEVERLY HILLS",
    "DAK": "90210",
    "DCA": "C",
    "DCB": "NONE",
    "DCD": "NONE",
    "DDA": "F",
    "DDB": "20220101",
    "DDD": "1",
    "DDE": "N",
    "DDF": "N",
    "DDG": "N"
  }
}

The response is image/png at 600 DPI by default, or image/svg+xml when format is svg. A complete field map for a given jurisdiction is on its state page, with the same body and a copy-ready cURL.

The response, byte for byte

That request, with the defaults the encoder fills and the two generated discriminators, produces a 281-byte payload. The first 31 bytes are header and directory, and they look like this:

payload, bytes 0–30
@ LF RS CR ANSI 636014100001 DL 0031 0250
BytesValue hereWhat it is
0–3@ LF RS CRCompliance indicator and three separators
4–8ANSI Five bytes, including the trailing space
9–14636014California's six-digit IIN
15–1610AAMVA version, the version 10 rules
17–1800Jurisdiction version for California
19–2001Entry count: one subfile, not one element
21–22DLSubfile designator
23–260031Offset to the subfile, always 31 for one DL entry
27–300250Subfile length, including the two-byte designator
31 onwardDLDAQA1234567…Subfile designator, then the element stream, then a closing CR

The subfile length is the number that goes wrong. Here it is 0250: two bytes of designator, 246 bytes of elements and one closing 0x0D. A hand-built payload often counts only the characters between the designators, which is short by three, and the result still scans, so the error survives until a verifier reads the directory.

The element stream is 26 lines for this body, in the order the jurisdiction declares: DAQ through DDL, with DAJ written from the state code rather than from the field map. DCF and DCK come from the generator because the request asked for them, and the defaults fill the required elements that were omitted, including the issue date.

How the values are rewritten

The field map is not copied into the subfile verbatim. The encoder uppercases values, converts dates to the version's order, and pads the postal code to a fixed width:

FieldYou sendVersion 10 writesVersion 11 writes
DBB1990031403141990 (MMDDYYYY)19900314 (CCYYMMDD)
DBA203001150115203020300115
DAK9021090210 plus six spaces, 11 bytes902100000, 9 bytes
DCSsampleSAMPLESAMPLE

Those two versions are why the same field map can produce a valid symbol on one state and an invalid one on another. The version comes from the jurisdiction record, not from the request, so a caller cannot accidentally mix a version 11 date order with a version 10 header. The revision comparison lists the differences between the two, and the byte layout documents every position.

Validation before encoding

The encoder refuses a field that would produce an unusable record, and it returns every failure at once rather than the first. The response is a 422 with an error string and a details list, so a form with 27 required elements does not need 27 round trips.

What you sentThe detail string you get back
No family nameDCS (Family name) is required for California
A postal code of 9021DAK does not match ^[0-9]{5}([0-9]{4})?$
A licence number with a spaceDAQ does not match ^[A-Z0-9-]+$
A sex value of 3DBC must be one of ['1', '2', '9']
A birth date of 19900230DBB is not a real calendar date
An issue date after the expiryDBD (issue date) is after DBA (expiry date)
A code the encoder does not carryunknown element: XYZ

An unknown jurisdiction is not a validation failure: POST /api/v1/aamva answers 404 with the code in the message, because a guessed IIN is worse than no symbol. A symbol with the wrong issuer number parses, decodes and then fails at the counter.

Version and jurisdiction version

Bytes 15 and 16 are the AAMVA version; bytes 17 and 18 are the jurisdiction's own version. California is version 10 with jurisdiction version 00, so the header reads 10 then 00. A version 11 record reads 11 and still writes the jurisdiction's own two digits. The values live in the IIN table alongside the issuer number, so the header can be checked against the published record before a batch is printed.

The jurisdiction version is not decoration. It tells a reader which revision of that state's element set the record follows, and a state that adds an element without changing the number produces a record that older readers interpret under the older revision.

DCF and DCK generation

Two required elements are jurisdiction-assigned and cannot be derived from the licence number. When the request sets "generate": {"dd": true, "icn": true}, the encoder fills them deterministically from DAQ, DBB and DCS: the same record yields the same pair on every call, and an explicit value always wins. For this request the pair is N328YW52NHDF and 880015373258; change the licence number and both change, change nothing and they do not. Generated values are for tests and fixtures. A production batch should carry the values printed on the card.

Coverage

All 51 US jurisdictions, including DC, have a page with their IIN, required elements and a sample payload. The 12 Canadian provinces are promoted for indexing, but their element lists remain the US base set as a placeholder: provincial schemas can diverge and have not been verified here, and each province page says so. Northwest Territories is absent because the IIN registry source has no number for it.

To compare this with a general PDF417 library, read the alternatives page; to check the cost at your volume, use the calculator; to confirm a finished symbol, decode it and paste the string into the inspector.

Questions

Is this the same as a PDF417 library?

No. A library turns bytes into a symbol. This builds the AAMVA file first: the 31-byte header, the directory with its offset and length, and the element set for the jurisdiction. Then it encodes the result.

Why is the offset always 0031?

Because the header is 21 bytes and the directory entry is 10, so a single DL subfile starts at byte 31. The offset exists so a reader can find the subfile without parsing the header again, and it stays fixed for every one-entry AAMVA payload.

What does the 0250 in the directory mean?

The subfile length: two bytes of designator, every element line and the closing carriage return. It is recomputed on each request, so adding one field changes both the length and the total payload size.

Can I send dates as CCYYMMDD?

Yes. The encoder reads eight digits beginning 19 or 20 as CCYYMMDD and rewrites them into the version's wire order. A version 10 record still carries MMDDYYYY in the subfile, because that is what a version 10 reader expects.

What happens if a required field is missing?

A 422 with a details list naming every missing element for that jurisdiction, not just the first. The encoder does not substitute a blank or drop the element, because either would produce a record that decodes and then fails validation.

Are the generated DCF and DCK valid on a real card?

They are deterministic placeholders for tests and fixtures, not issuer values. A production batch should send the values printed on the card, and an explicit field always overrides the generator.

The first barcode is $2.00 and is refunded if a hardware scanner will not read it. Three symbols are free per session if you want to see the payload before paying: the free generator page explains exactly what that allowance does and does not include.

Generate barcode now