USPS (Apps step)
USPS
Standardizes US addresses, tracks USPS packages and looks up domestic postage prices through the USPS APIs (version 3).
Use it to work with USPS from a workflow: clean up a customer address before it is printed on a label, follow small parcels shipped by mail, or price a parcel before choosing USPS over another carrier.
Beta. This step has not yet been checked against a live USPS account, so treat its first runs as a test, and tell us if an operation does not answer as described.
Find it in the workflow editor's palette under Apps. See Apps steps for what every Apps step has in common.
Set it up
- Sign in at developers.usps.com with a USPS Business account, open Apps › Add App, and add the Addresses, Tracking and Domestic Prices APIs to it.
- Copy the app's Consumer Key and Consumer Secret.
- In DataMagik, open Script Engine › Credentials and add an OAuth 2.0 credential with grant "Client credentials", the Consumer Key as the client ID and the Consumer Secret as the client secret, token URL https://apis.usps.com/oauth2/v3/token, the client sent in the body, and scope addresses tracking prices.
- Add apis.usps.com to Allowed Domains in the workflow's Script settings.
Credential: An OAuth 2.0 client credentials credential for an app on developers.usps.com: its Consumer Key as the client ID and Consumer Secret as the client secret, sent in the body to the USPS token URL.
Signing in with OAuth 2.0
| Grant type | Client credentials |
| Token URL | https://apis.usps.com/oauth2/v3/token |
| Scope | addresses tracking prices |
USPS reads the client ID and secret from the request body, so set the credential to send the client in the body, not as a Basic header. The scope lists the APIs the token may call, separated by spaces; keep only the ones your app has. The app signs in as itself, so no one clicks Connect.
Hosts it calls: apis.usps.com
Operations
| Operation | What it does |
|---|---|
| Address › Standardize | Checks a US address against the USPS database and returns it in the standard USPS form, with the ZIP+4 code. |
| Tracking › Track | Reads the status and scan history of one USPS package by its tracking number, with USPS's Tracking 3.0 API. USPS lists it as legacy: apps created before its retirement keep it until July 31, 2027, and new apps get Tracking 3.2 instead (use an HTTP Request for that one until this step supports it). |
| Price › Domestic base price | Looks up the base postage price of one domestic package for a mail class. |
Address › Standardize
Checks a US address against the USPS database and returns it in the standard USPS form, with the ZIP+4 code.
Calls GET /addresses/v3/address.
| Field | Required | What to put |
|---|---|---|
| Street address | Yes | The street line: number and street name. For example 2100 N Main St. |
| Suite or apartment | No | The second line, such as Ste 4 or Unit B. Leave empty when there is none. For example Ste 4. |
| City | No | The city. Needed when the ZIP code is empty. |
| State | Yes | The two-letter state code, such as IN. For example IN. |
| ZIP code | No | The five-digit ZIP code. Needed when the city is empty. For example 46526. |
What comes out: One item: {{ $json.address }} with the standardized {{ $json.address.streetAddress }}, {{ $json.address.secondaryAddress }}, {{ $json.address.city }}, {{ $json.address.state }}, {{ $json.address.ZIPCode }} and {{ $json.address.ZIPPlus4 }}, and {{ $json.additionalInfo }} with {{ $json.additionalInfo.DPVConfirmation }} (Y when USPS delivers to it) and {{ $json.additionalInfo.business }}. An address USPS cannot find fails the step with HTTP 404 unless "Fail on a non-2xx response" is off.
Example: Standardize each new customer address and save the ZIP+4 code on the customer's lookup table row.
Tracking › Track
Reads the status and scan history of one USPS package by its tracking number, with USPS's Tracking 3.0 API. USPS lists it as legacy: apps created before its retirement keep it until July 31, 2027, and new apps get Tracking 3.2 instead (use an HTTP Request for that one until this step supports it).
Calls GET /tracking/v3/tracking/{trackingNumber}.
| Field | Required | What to put |
|---|---|---|
| Tracking number | Yes | The package's USPS tracking number. For example 9400100000000000000000. |
| Detail | No | Latest status only is enough to see whether it was delivered; Every scan adds the full history. One of: Latest status only, Every scan. |
What comes out: One item: {{ $json.trackingNumber }}, {{ $json.statusCategory }} (such as Delivered or In Transit), {{ $json.status }}, {{ $json.statusSummary }} (a sentence describing it) and, with every scan, {{ $json.trackingEvents }}, the list of scans with their eventType, eventTimestamp, eventCity and eventState.
Example: Track each sample shipped by USPS Ground Advantage and mark it received in the sample log when its status category is Delivered.
Price › Domestic base price
Looks up the base postage price of one domestic package for a mail class.
Calls POST /prices/v3/base-rates/search.
| Field | Required | What to put |
|---|---|---|
| Price request | Yes | The whole request body, as in the USPS Domestic Prices API reference: weight in pounds, sizes in inches, and the mail class, such as USPS_GROUND_ADVANTAGE or PRIORITY_MAIL. For example {"originZIPCode": "46526", "destinationZIPCode": "{{ $json.zip }}", "weight": {{ $json.weight_lb }}, "length": 12, "width": 9, "height": 6, "mailClass": "USPS_GROUND_ADVANTAGE", "processingCategory": "MACHINABLE", "rateIndicator": "SP", "destinationEntryFacilityType": "NONE", "priceType": "RETAIL"}. |
What comes out: One item: {{ $json.totalBasePrice }}, the price in US dollars, and {{ $json.rates }}, the price's parts with their description and price.
Example: Price a 3 lb parcel to each order's ZIP code by Ground Advantage and compare it with the UPS quote before choosing the carrier.
Example
When a customer ship-to is added, USPS › Address › Standardize checks it, and {{ $json.address.streetAddress }}, {{ $json.address.city }} and {{ $json.address.ZIPCode }}-{{ $json.address.ZIPPlus4 }} replace what was typed when {{ $json.additionalInfo.DPVConfirmation }} is Y.
Tips
- The free USPS app tier allows a limited number of calls an hour; set "Most requests per second" when a workflow checks many addresses or tracking numbers in one run.
- Standardize address needs the street and state, and either the city or the ZIP code.
- Tracking is for USPS tracking numbers only; UPS and FedEx numbers that move into USPS for final delivery are tracked with those carriers.
- Prices are the published base prices for the mail class asked for, not your contract or commercial pricing unless the request asks for it with priceType.
- Since April 1, 2026 USPS tracking access needs your Mailer ID authorized for it and is a paid service; ask USPS to enable tracking for your app before using Track.
Settings every Apps step has
- More query parameters: any query parameter the fields do not offer, sent as is.
- More body fields: a JSON object merged into the request body; nested objects merge, other values replace.
- Most requests per second: spaces the calls out for rate limits. A "too many requests" (429) answer is retried after the wait the API asks for.
- Most pages: for operations that follow pages, the most pages to fetch (10 unless you change it, up to 100). The run warns when it stops with more to get.
- Fail on a non-2xx response: on by default. Turn it off to handle errors yourself.
USPS's own API documentation: https://developers.usps.com/apis