Blog/Category
Shipping Tips & Tricks

Address Validation for Shipping: A Developer's Guide (USPS and UPS)

November 30, 2026
Founder and CEO
Address Validation for Shipping: A Developer's Guide (USPS and UPS)

Updated December 2026. Codes and rules verified against carrier documentation; see references at the end.

To validate a US shipping address, call the USPS Addresses API v3 (GET /addresses/v3/address) and read DPVConfirmation: Y means the primary and any secondary number confirmed, D means the apartment or suite is missing, S means the apartment or suite was not confirmed, and N means the address did not confirm. If you ship UPS, also call UPS Address Validation with request option 2 or 3 to get its Commercial or Residential classification, which matters for the UPS residential surcharge. At checkout, block on N, warn on D, S and vacant addresses, and accept the rest.

What do the USPS and UPS address validation APIs return?

ItemUSPS Addresses API v3UPS Address Validation (Street Level)
EndpointGET https://apis.usps.com/addresses/v3/addressPOST https://onlinetools.ups.com/api/addressvalidation/v2/{requestoption}
InputsstreetAddress (required), secondaryAddress, city + state or ZIPCode, optional ZIPPlus4, firm, urbanizationUp to 3 address lines, city, state, postal code, country code
ModesAlso /city-state and /zipcode lookupsrequestoption 1 = validation, 2 = classification, 3 = both; regionalrequestindicator=True for city, state and ZIP level
ReturnsStandardized address, ZIP+4, delivery point, carrier route, DPV flags, vacant, business, CMRA, record type, return codesValidAddressIndicator, AmbiguousAddressIndicator or NoCandidatesIndicator; candidates (default 15, max 50); classification 0, 1 or 2
Apartments and suitesConfirmed through DPV (D and S codes)UPS FAQ: does not provide any information for apartment or suite
CoverageUS addresses, including APO/FPO/DPO state codes AA, AE, APUS and Puerto Rico
Test hostapis-tem.usps.com (needs production onboarding)wwwcie.ups.com; street level returns results only for New York and California addresses
Usage rulesUSPS FAQ: only for validating shipping addresses during label generation; no bulk, batch or list useOnly for users shipping with UPS; data mining gets access revoked; no batch upload; a required liability notice must appear near the input and output screens

Both APIs take an OAuth 2.0 bearer token. Both document HTTP 429 for rate limiting, and USPS includes a Retry-After header. USPS says higher limits are requested through USPS API Support.

What do USPS DPV confirmation codes Y, D, S and N mean?

Delivery Point Validation (DPV) checks the address against USPS delivery point records. The additionalInfo.DPVConfirmation values, per the spec:

CodeUSPS definitionCheckout action
YConfirmed for both primary and (if present) secondary numbers. Does not necessarily mean USPS delivers there.Accept
DConfirmed for the primary number only; secondary number information was missing.Warn: ask for the apartment or suite
SConfirmed for the primary number only; secondary number was present but not confirmed.Warn: ask the customer to check the unit
NBoth primary and (if present) secondary number failed to confirm.Block, or require explicit confirmation

The response also has DPVEnhancedConfirmation, which adds R: "Address DPV Confirmed but USPS does not deliver to the address." Its D and S definitions are worded differently from DPVConfirmation, so pick one field and code against it. Carrier routes R777 and R779 may mean you need to ask where the recipient receives USPS mail.

Which other USPS response fields should checkout code read?

FieldValues (from the spec)Use
returnCode31 single match, 32 default match (more information such as apartment, suite or box needed), 22 multiple matches with no default, 21 not found, 13 invalid city, 12 invalid state, 11 invalid ZIP, 10 invalid addressShow the right error message
recordTypeG general delivery, P PO Box, R rural route or highway contract, H highrise, F firm, S streetDetect PO Boxes
vacant / DPVVacantY not occupied, N occupiedWarn
DPVCMRAY found in the Commercial Mail Receiving Agency tableFlag private mailboxes
DPVBusiness (business is deprecated)Y business address, N not a businessA hint only; UPS classification decides the UPS surcharge
DPVNoSecureLocationY flagged as not a secure locationSuggest signature or pickup options
ZIPPlus4, deliveryPoint4-digit add-on and 2-digit delivery pointStore the standardized result, not the raw input

A USPS miss comes back as HTTP 404 with examples such as "Address Not Found," "Multiple Addresses Found" and "Insufficient Address Data." Handle a 404 in your checkout logic as a failed validation; save outage handling for timeouts and 5xx responses.

Why does UPS residential classification matter?

UPS returns AddressClassification.Code 0 (UnClassified), 1 (Commercial) or 2 (Residential) when you call with request option 2 or 3. Classification matters for pricing: UPS's tariff says a Residential Surcharge applies if either the address entered in the UPS shipping system or the actual delivery address is residential, regardless of the shipper calling it commercial. The tariff defines residential as a home, including a business operating out of a home, and says an address that could be either is treated as residential.

Quoting a home delivery at the commercial price means the surcharge shows up later as an adjustment. Classify before you rate, and quote 0 (UnClassified) as residential, since the tariff resolves doubtful addresses that way. The USPS DPVBusiness flag is useful context, but it is not what UPS bills on.

How should you handle apartments, suites and other secondary units?

Collect the unit in its own field and send it as USPS secondaryAddress (USPS also accepts it at the end of streetAddress). USPS Publication 28 lists the approved designators:

DesignatorAbbreviationNeeds a number?
ApartmentAPTYes
SuiteSTEYes
UnitUNITYes
BuildingBLDGYes
FloorFLYes
RoomRMYes
Space, Lot, TrailerSPC, LOT, TRLRYes
Basement, Front, Lobby, Office, Penthouse, RearBSMT, FRNT, LBBY, OFC, PH, REARNo
Unknown designator#Pub 28 requires the pound sign

Because UPS Address Validation does not check apartments or suites, a UPS "valid" result for an apartment building says nothing about the unit. Use the USPS DPV result for units even when the label is UPS.

Can you ship to PO Boxes and APO/FPO/DPO addresses?

USPS delivers to PO Boxes; you can detect one from recordType P. On the UPS side, the UPS tariff says UPS does not deliver to a P.O. Box and that APO and FPO addresses are not accepted. UPS Ground Saver is the exception: UPS lists US PO Boxes and APO, FPO and DPO addresses as Ground Saver destinations, and says Ground Saver packages may be delivered by UPS or the USPS. See Can you ship to a PO Box? and UPS Ground Saver vs USPS Ground Advantage.

Military and diplomatic addresses follow DMM 703. The city line is APO, FPO or DPO, the "state" is AA, AE or AP (used for ZIP Code prefixes 340, 090 to 098 and 962 to 966 respectively), and the address must not include a foreign city or country name. The delivery line carries a unit type and number such as UNIT or PSC plus a box number where applicable. Don't let address autocomplete "fix" APO into a city name.

How do you normalize an address before validating it?

  • Trim and uppercase, and collapse repeated spaces. Strip punctuation except #, hyphens, slashes and apostrophes, which appear in real unit numbers, fractional addresses and street names.
  • Keep the unit in its own field, and make sure your form actually sends line 2. A dropped unit comes back as DPV D.
  • Don't abbreviate street types yourself. USPS returns streetAddressAbbreviation and cityAbbreviation; store what it returns.
  • Send the 5-digit ZIP only. Let the API add ZIP+4 so your stored value matches the delivery point.
  • For Puerto Rico, pass urbanization when the customer gives one.
import re

def normalize_line(line: str) -> str:
    """Light cleanup before calling a validation API: uppercase, drop most
    punctuation, collapse spaces. Leave abbreviation to the carrier."""
    s = line.upper().replace("P.O.", "PO")
    s = re.sub(r"#\s*", "# ", s)            # "#4" -> "# 4"
    s = re.sub(r"[^\w#\-/' ]", " ", s)      # keep #, hyphen, slash, apostrophe
    return re.sub(r"\s+", " ", s).strip()

# normalize_line("123 Main St. #4") returns "123 MAIN ST # 4"

When should checkout block an address and when should it warn?

Block only when the address can't work for the chosen service, and warn when the customer can fix the problem in one step. On a warning, offer "use the address as entered" and log the choice.

SignalAction
DPV N, or a 404 from USPSBlock (or require explicit confirmation)
PO Box or AA/AE/AP address with a UPS service other than Ground SaverBlock; offer USPS or Ground Saver
DPV D or SWarn: ask for or correct the unit
Vacant, CMRA, enhanced R, route R777/R779Warn
DPV Y with no flagsAccept and save the standardized address

This function implements that table. Pass the parsed body for a USPS 404 (it blocks) and an empty dict when the call times out or returns 5xx (it warns, so an outage doesn't stop checkout).

MILITARY_STATES = {"AA", "AE", "AP"}

def checkout_decision(usps: dict, service: str = "usps", ups_class=None):  # ups_class: str or None
    """Return {"action": block|warn|accept, "reasons": [...], "residential": bool|None}.
    usps: parsed USPS Addresses v3 /address response. service: "usps", "ups",
    or "ups_ground_saver". ups_class: UPS AddressClassification Code if called."""
    if not usps:  # timeout or 5xx: don't block checkout on a USPS outage
        return {"action": "warn", "reasons": ["Address could not be verified"],
                "residential": None}
    info = usps.get("additionalInfo", {})
    state = usps.get("address", {}).get("state")
    dpv = info.get("DPVConfirmation")           # Y, D, S or N
    reasons = []

    if dpv not in ("Y", "D", "S"):
        return {"action": "block", "reasons": ["USPS could not confirm this address"],
                "residential": None}
    if dpv == "D":
        reasons.append("Add the apartment, suite or unit number")
    if dpv == "S":
        reasons.append("Check the apartment, suite or unit number")
    if info.get("vacant") == "Y":
        reasons.append("USPS lists this address as vacant")
    if info.get("DPVCMRA") == "Y":
        reasons.append("Address is a private mailbox (CMRA)")
    if info.get("DPVEnhancedConfirmation") == "R" or info.get("carrierRoute") in ("R777", "R779"):
        reasons.append("USPS may not deliver here: confirm where the recipient gets mail")

    po_box = info.get("recordType") == "P"
    military = state in MILITARY_STATES
    if service == "ups" and (po_box or military):
        return {"action": "block", "residential": None,
                "reasons": ["Choose USPS or UPS Ground Saver for PO Box or APO/FPO/DPO"]}

    # UPS classification: "1" Commercial, "2" Residential, "0" UnClassified
    residential = {"1": False, "2": True}.get(ups_class or "")
    return {"action": "warn" if reasons else "accept", "reasons": reasons,
            "residential": residential}

A residential value of None means UPS gave no Commercial or Residential answer; rate those as residential. Validate once at submit and cache the result with the order. If an AI agent buys your labels, give it this same decision output so it can ask the user about a unit number instead of guessing; see the shipping API guide for AI agents.

Frequently asked questions

What does DPV confirmation code D mean?

USPS confirmed the building (primary number) but the secondary information, such as an apartment or suite number, was missing. Ask the customer for the unit before you buy the label.

Does the USPS Addresses API tell you if an address is residential?

It returns a DPVBusiness flag (Y or N); the older business field is marked deprecated in the spec. For UPS shipments, the residential surcharge follows UPS's own classification, which you get from UPS Address Validation with request option 2 or 3.

Does UPS Address Validation check apartment numbers?

No. The UPS FAQ says it validates street address, city, state and ZIP Code and does not provide any information for apartment or suite. Use USPS DPV for units.

Can I use the USPS Addresses API to clean my customer list?

No. USPS says the Addresses API is only for validating shipping addresses during label generation, and bulk, batch or mailing list use is not permitted.

Can UPS deliver to an APO, FPO or DPO address?

Through UPS Ground Saver, yes: UPS lists APO/FPO/DPO addresses as Ground Saver destinations, and those packages may be delivered by UPS or the USPS. UPS's general tariff says APO and FPO addresses are not accepted.

More shipping developer references

Build shipping with Ship.com

Ship.com gives you USPS and UPS labels at up to 89% off USPS and up to 87% off UPS without your own carrier accounts, from your code through the REST API or from AI agents through the MCP server. Every account starts with a 30-day free trial, no credit card required. Read the Ship MCP setup guide or See plans and pricing.

References

Joe DiSorbo
About the author
Joe DiSorbo
Founder and CEO

Joe DiSorbo is the founder and CEO of Ship.com, the shipping platform that gives more than 10,000 business customers discounted USPS and UPS rates and simplifies logistics for ecommerce brands and software platforms. Before Ship.com, he founded and led Webgistix, an ecommerce technology and global fulfillment company that grew internationally before Rakuten acquired it in 2013. His background spans global operations, software development, finance and logistics, with experience across the United States and Asia. Joe holds undergraduate degrees in Economics and Geography, masters degrees in Finance and International Management, and is a graduate of Harvard Business School (OPM 41).

Shipping software built for online sellers

Ship.com saves you time and money, giving you more freedom to live your life.

  • No credit card required.
  • Up to 89% off USPS and up to 87% off UPS.
  • Connects with major e-commerce platforms.
  • Free home pickup. Skip the trip to the post office.
Try for free
UPS
UP TO 87% OFF
Daily Rates*
USPS
UP TO 89% OFF
Retail Prices*
Today's orders
Order #1042USPS Ground AdvantageReady
Order #1043UPS Ground SaverReady
Order #1044USPS Priority MailReady
★★★★★Trusted by 10,000+ business customers

More on this topic

See all