Skip to content

USPS Intelligent Mail (USPS 4-State Customer Code)

License

Notifications You must be signed in to change notification settings

lnashier/usps-imb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3844ee0 · Mar 5, 2025

History

12 Commits
Feb 29, 2024
Feb 26, 2024
Feb 26, 2024
Mar 6, 2024
Mar 21, 2024
Feb 29, 2024
Feb 29, 2024
Mar 5, 2025
Feb 29, 2024
Feb 26, 2024

Repository files navigation

USPS Intelligent Mail (USPS 4-State Customer Code)

GoDoc Go Report Card

This module provides a function named func IMb(track, route string) (string, int) for generating USPS Intelligent Mail barcode (IMb), also known as 4-State Customer Barcode. The Intelligent Mail barcode is used by the United States Postal Service (USPS) for sorting and tracking letters and flats, offering enhanced visibility into the mailstream.

Parameters

  • track: Tracking information for the mailpiece.
  • route: Routing information for the mailpiece.

Returns

  • The generated Intelligent Mail barcode string. (len: 64)
  • Status code. (0 for success)

Structure of Intelligent Mail Barcode (IMb)

The Intelligent Mail barcode consists of the following components:

  1. Barcode ID: A 2-digit field reserved to encode the presort identification.

    • Should be "00" if an Optional Endorsement Line (OEL) is not printed on the mailpiece.
  2. Service Type ID (STID): A 3-digit field used to identify the class of mail and additional services.

    • Defines the mailpiece as Full-Service, Basic, or Non-Automation.
    • Determines the disposition of Undeliverable-As-Addressed (UAA) mail.
  3. Mailer ID (MID): A unique identifier assigned by USPS to Mail Owners or Preparer, Mailing Agents, or service providers based on annual mail volume criteria.

    • 9-digit or 6-digit numeric code.
  4. Serial Number: A 6 or 9-digit field defined by the mailer.

  5. Routing Code: A 5, 9, or 11-digit field identifying the delivery ZIP Code data in the address.

Data Type Data Field # of Digits
Tracking Code Barcode Identifier 2 (2nd digit must be 0-4)
Service Type Identifier 3
Mailer Identifier 6 or 9
Serial Number 6 (with 6-digit MID)
9 (with 9-digit MID)
Routing Code Delivery Point ZIP Code 0, 5, 9, or 11
Total 31 maximum

Additional Resources

License

  • MIT License
  • USPS License Agreement USPS License Agreement