postalref

Merchant Returns API

The Merchant Returns API is a USPS web service that makes return shipping labels for customers of merchants enrolled in the USPS Merchant Return Program. A merchant's application requests one label or a bulk set, as a PDF, TIF or PNG image. Merchants offer the labels from their own websites and pay for them.

Updated October 29, 202646 sources

What it is

The Merchant Returns API is one of two ways into the USPS Merchant Return web service. The other is the USPS Merchant Return website, a label page the merchant links its customers to. The website needs no programming at all.

The API is for experienced programmers who know internet and website development. Its users are merchants that have signed up for Scan Based Payment. A merchant's server talks to a USPS server over HTTP, in XML. Each label carries an Intelligent Mail Package Barcode that tracks on USPS.com.

A merchant can't open an account alone: a USPS administrator registers it. A USPS Merchant Return Administrator enters the merchant's return address and services, then issues a Merchant Account Code. That code is the identifier of the merchant's account in the Merchant Return system.

How it works

A label request is one XML document, URL-encoded and sent with HTTP GET. Single labels go to GetLabel, and bulk sets go to GetBulkLabels.

  1. A USPS Merchant Return Administrator sets up the account and issues its Merchant Account Code.
  2. The merchant's application builds an XML request and sends it to the web service.
  3. The web service returns either a success document or an error document.
  4. A success document carries the label as Base64, with its postal routing and tracking numbers.
  5. The application decodes the Base64 text to get the label image.

The request

A request whose start and end tags don't match exactly gets an error. An empty tag is ignored.

A single-label request carries these tags:

  • MerchantAccountCode, the merchant's Merchant Account Code.
  • MID, the merchant's Mailer ID, which must be the one tied to that account code.
  • CustomerName and the Customer address tags, for the customer returning the package.
  • LabelDefinition, the size of the label.
  • ServiceTypeCode, the service type, from those set up in the merchant's profile.
  • CallCenterOrSelfService, which says whether a call center agent or the customer is asking.

A bulk request uses the same tags and adds two. ConfirmCRID holds the merchant's Customer Registration ID. Quantity sets the number of labels, from 2 to 100.

Some optional tags carry the merchant's own references:

  • PackageInformation, an RMA, invoice or order number that prints on the label.
  • MerchandiseDescription, which the system stores and reports to the merchant but never prints.
  • RecipientEmail, an address the system emails the label to.

Labels

The label is 3 by 6, 4 by 4 or 4 by 6 inches, from the sizes the account allows. Each prints on a full 8 ½ x 11 sheet unless a cropped format trims it.

LabelFormat sets the layout:

  • Left off or blank: a label with instructions, the only format the website makes.
  • NOI: one label per sheet with no instructions.
  • TWO: two labels on one page, each with its own RMA and tracking number, for 4X6 only.
  • HCROP: an image cropped to the label, long side horizontal, for 4X6 only.
  • VCROP: an image cropped to the label, long side vertical, which with 4X6 prints on a Zebra printer.

ImageType picks PDF, TIF or PNG, and a blank or unknown value gives a PDF.

In CallCenterOrSelfService, the display type CallCenter allows insurance and endorsements, and Customer allows neither. A label can carry up to three endorsements, such as TIME SENSITIVE, and automatic hazmat endorsements count toward the three.

Service type codes

The service type code sets the mail class of the label. Each account allows only the codes its merchant chose with a USPS Merchant Return Administrator.

The service type codes the API can put on a label.

IMpb Service Type Code List, Appendix I
CodeDescriptionMail classExtra service codes
019Priority Mail ReturnPM452
020USPS Ground Advantage Return: Up to 15.999ozFC452
022USPS Ground Advantage Return: One Pound or MoreFC452
037Priority Mail Return: Hazardous MaterialsPM452, 857
187USPS Ground Advantage Return: Up to 15.999oz Hazardous MaterialsFC452, 857
190USPS Ground Advantage Return: Up to 15.999oz Insurance <= $500 Hazardous MaterialsFC930, 452, 857
191USPS Ground Advantage Return: Up to 15.999oz Insurance > $500 Hazardous MaterialsFC931, 452, 857
217USPS Ground Advantage Return: Up to 15.999oz Division 6.2 Hazardous MaterialsFC452, 826
218USPS Ground Advantage Return: One Pound or More Division 6.2 Hazardous MaterialsFC452, 826
219Priority Mail Return: Division 6.2 Hazardous MaterialsPM452, 826, 857

1 to 10 of 29 codes in the IMpb Service Type Code List, Appendix I, where Code is 019 or 020 or 022 or 596 or 597 or 598 or 599 or 600 or 601 or 187 or 190 or 191 or 385 or 388 or 399 or 037 or 515 or 517 or 217 or 218 or 219 or 796 or 797 or 798 or 837 or 838 or 839 or 667 or 668.

Hazardous materials

A hazmat return needs a hazmat service type code and one HazmatCode, an extra service code for the kind of material. HazmatCode replaced the ContentType and ExtraServiceCodes tags in Release 2.3 of July 22, 2025.

The hazmat extra service codes HazmatCode takes.

Extra Service Codes, Pub 199 Appendix J Table 7
CodeExtra service
810HAZMAT Air Eligible Ethanol Package
811HAZMAT Class 1 - Toy Propellant/Safety Fuse Package
812HAZMAT Class 3 – Flammable Liquid Package
813HAZMAT Class 7 - Radioactive Materials Package
814HAZMAT Class 8 - Corrosive Materials Package
815HAZMAT Class 8 - Nonspillable Wet Battery Package
816HAZMAT Class 9 - Lithium Battery Marked - Ground Only Package
817HAZMAT Class 9 - Lithium Battery - Returns Package
818HAZMAT Class 9 - Lithium batteries, marked package
819HAZMAT Class 9 - Dry Ice Package

1 to 10 of 23 codes in the Extra Service Codes, Pub 199 Appendix J Table 7, where Code is 810 or 811 or 812 or 813 or 814 or 815 or 816 or 817 or 818 or 819 or 820 or 821 or 822 or 823 or 824 or 825 or 826 or 827 or 828 or 829 or 830 or 831 or 832.

Hazmat from military and territory addresses

Returns from military and diplomatic addresses and from PTFAS, the U.S. possessions, territories and freely associated states, allow only three kinds of hazmat.

The hazmat codes allowed from APO, DPO and PTFAS addresses.

Extra Service Codes, Pub 199 Appendix J Table 7
CodeExtra service
813HAZMAT Class 7 - Radioactive Materials Package
820HAZMAT Class 9 - Lithium batteries, unmarked package
826HAZMAT Division 6.2 – Infectious Substances Package

3 codes in the Extra Service Codes, Pub 199 Appendix J Table 7, where Code is 813 or 820 or 826.

Labels for these addresses print no hazmat markings. The manifest record for the label still carries the hazmat service type code and extra service codes.

Cubic labels

Marking a package cubic gets it better shipping rates, and the API prints the cubic marking, tier and size on the label. A cubic request sets PostalMarking to CUBIC and names a container type, BOX or SOFTPACK.

A cubic package:

  • weighs 20 pounds or less, given in pounds and ounces.
  • has no dimension over 22 inches.
  • goes by USPS Ground Advantage at 1 pound or more, or by Priority Mail.
  • as a box, gives its length, width and height.
  • as a softpack, a padded envelope, gives length and width, which together can't pass 36 inches.

The API calculates the cubic tier from the measurements and prints it on the label. Since Release 2.6 of July 20, 2026, Ground Advantage softpacks use the same cubic tiers as Priority Mail.

The response

A success response carries the label in ReturnLabel, Base64-encoded for transport over the internet. It also carries the PostalRouting number and the TrackingNumber, which prints on the label below the barcode. A TWO request adds TrackingNumber2 for the second label, and the two labels share one postal routing number.

The tracking number in USPS's sample success response, which fails the IMpb length check.

920449378838000030687

The Mailer ID and serial number are examples.

  • FailedThat’s 21 digits. Package barcodes have 22, 26, 30 or 34, so check for a missing or extra digit.

Label Broker

USPS Label Broker is a service for customers without a printer. They print the label at a Post Office or through USPS.com, using a QR code or Label Broker ID.

A request sends its label to Label Broker by setting Broker to Y. It must also ask for a 4X6 label in the VCROP format as a PNG image, and it can't be a bulk request. It needs the customer's ZIP Code.

Label Broker stores the label and returns a unique code for it. The response also carries a notice that Label Broker's terms require the merchant to give the customer. The customer shows the code to a USPS retail associate, who prints the label and applies it.

With the code, a merchant can check a stored label's status or void it so it can't be printed. A merchant can see or void only the labels it stored.

Proximity routing

Proximity Routing is a feature for merchants with several accounts that serve as different return locations. It picks the destination printed on the label by the customer's distance to each return location.

A proximity merchant's requests use the default account's Merchant Account Code, label sizes and service type codes. An error in the distance calculation sends the package to the default account. A single-label request in the TWO format can't use it, because those labels print a blank return address.

The Merchant Return website

Each enrolled merchant gets a free label website for its customers, embedded in the merchant's site or reached directly. USPS gives each merchant four URLs to the site. URL parameters can fill in most of the label form for the customer.

Rules

To use the USPS Label Broker®, Merchants must abide by the terms and conditions.

A merchant that uses Label Broker must follow its terms and conditions. The customer must ask for Label Broker delivery before the merchant's application stores a label. USPS watches each merchant's ratio of stored labels to printed ones to enforce this.

When sending a request, the MID must be passed with the specific Merchant Account Code it is associated with.

Each request must pair the merchant's MID with the Merchant Account Code that MID belongs to. A merchant with several accounts has a MID for each one.

You do not have the ability to self-register or make changes to your account, you must work through an administrator.

A merchant must go through a USPS Merchant Return Administrator to open or change an account, such as its service types and label sizes.

Whether APO/DPO/PTFAS addresses are sent to or returned from these locations they must adhere to international HAZMAT/Dangerous Goods rules, therefore the domestic HAZMAT labels should not be applied.

Hazmat sent to or returned from these addresses must follow international dangerous goods rules. Domestic hazmat labels should not go on these packages.

Only 1 hazmat extra service code is allowed per request.

A request must not carry more than one hazmat extra service code.

The hazmat information can’t be bypassed, the customer must declare whether hazmat is included in the package.

On the website, the customer must say whether the package holds hazardous materials, and URL parameters can't answer for them.

If CUBIC is requested, the Container Type is required.

A cubic request must name its container type.

All requests should be made via HTTP GET.

Requests should use HTTP GET. Other methods get errors.

What goes wrong

A value longer than a tag's maximum gets no error. The web service keeps the characters up to the maximum and drops the rest. The cut value can prevent delivery.

A failed request gets an error response instead of a label. It holds an error number and description from the API, and sometimes an error number from an external system. Some errors a merchant meets:

  • 1062: the service type code isn't in the merchant's profile.
  • 1063: the label size isn't one the account allows.
  • 1070: the merchant account wasn't found.
  • 2000: an address problem, such as an address that needs an apartment or suite number.
  • 4001: the MID doesn't belong to the Merchant Account Code.
  • 4002: the CRID doesn't belong to the Merchant Account Code.
  • 4003: a label request for a deactivated account.

The API checks each customer address with a USPS Address Validation API. AddressValidation set to false skips that check. AddressOverrideNotification bypasses an address that lacks a unit number or can't be found, when a valid ZIP Code comes with it.

The API takes no password. A request's only credentials are the merchant's account identifier and its MID.

The label tester's images are valid shipping labels for the merchant code used.

A merchant that generates many unused Label Broker labels may lose its use of Label Broker.

A website link whose URL parameters cause an error shows the customer a generic error page. The page's HTML source holds the error number in a hidden field.

The system rejects misspelled versions of common email domains, such as aol.com and gmail.com.

Terms

USPS Merchant Return web service
provides free and easy generation of USPS® return labels for customers of merchants enrolled in the USPS® Merchant Return Program.
USPS Merchant Return website
Each merchant enrolled is automatically provided (free of charge) a website for their customers to generate return labels.
Mailer IdentifierMID, Mailer IDs, Mailer Identification, Mailer Identification Number, USPS Mailer ID
MID is a unique 6- or 9-digit number that identifies the mailer or the mailer’s client.
Customer Registration IDCRID, Customer Registration Identification Number, Customer Registration Identifier, Customer Identifier, Customer Reference ID, Customer Registration Identifications
a USPS-generated numeric code of up to 15 digits that uniquely identifies a business at a specific location
Service Type CodeSTC
Service Type Codes are designators used to represent USPS classes of mail in conjunction with the type of Extra Service(s) being requested.
return merchandise authorizationRMA, Return Merchant Authorization
Return Merchandise Authorization (also known as “package information” or “packageInfo”. Maps to “Customer Reference 1” in the shipping services file.
No InstructionsNOI
A label without instruction at the bottom
USPS Label Broker serviceUSPS Label Broker
facilitates shipping for consumers without access to a printer. It allows customers to print labels using a QR Code or Label Broker Label ID at a USPS® Post Office® or via USPS.com.
Proximity Routing
Proximity Routing is a feature on the Return tool intended for merchants who have multiple accounts that serve as different return locations.
PTFAS
U.S. Possessions, Territories, and Freely Associated States
USPS Address Validation API
to validate the customers address passed with the request

Documents

Contacts

For help with the Merchant Returns API, email the Merchant Return Support Team at Merchant.Returns.Support@usps.gov. The team monitors the mailbox daily. For Label Broker requirements and best practices, contact a USPS account manager or labelbroker@usps.gov.

Sources