Create a U.S. Postal Service (USPS) Shipment

HTTP Request

POST /v1/shipments

Summary

This operation creates a shipment and purchases a shipment label using USPS® as the carrier. The API returns the label as either a Base64 string or a link to a PDF.

Things to Consider

  1. Address Validation: Addresses are verified for accuracy prior to processing the label request. The Pitney Bowes Address Validation (AV) engine validates addresses against current USPS data and makes corrections when possible. You can optionally enable minimal address validation through the MINIMAL_ADDRESS_VALIDATION shipment option.

    Note: When MINIMAL_ADDRESS_VALIDATION is set to true, the shipper takes 100% responsibility for any undelivered packages due to violation of carrier-addressing guidelines and is responsible for any surcharge or adjustment fee levied by the carrier for such a violation.

    The following table describes how address validation works.

    Complete Address Validation Minimal Address Validation
    Evaluates the entire address against the current USPS address information.
    Evaluates the entire address against the current USPS address information.
    If current USPS address information indicates no delivery to the address, the API returns an error. If current USPS address information indicates no delivery to the address, the API returns an error.
    If the address cannot be validated against current USPS address information, the API returns an error.

    If the entire address cannot be validated against current USPS address information, the API checks whether just the last line (city/state/postal code) can be validated:

    • If the last line cannot be validated, the API returns an error.

    • If the last line can be validated, the API checks whether the delivery line (street address) has the correct format (e.g., a street number and street name). If it does, the API returns the address with any corrections only to the last line.

      The API does not verify or change the delivery line. The API returns the delivery line exactly as it is specified in the request.

      The API does not provide a ZIP+4 or 2-digit delivery point.

      If you use minimal address validation, ensure the delivery line you enter is actually deliverable.

    If the API determines the address is a match or close match, the API returns the address with any corrections. The API also returns the ZIP+4 and the 2-digit delivery point. If the API determines the address is a match or close match, the API returns the address with any corrections only to the last line. The API also returns the ZIP+4 and the 2-digit delivery point.


  2. Shipper ID: To print a shipment label, you must specify a SHIPPER_ID in the shipmentOptions array and set its value to the merchant’s postalReportingNumber, which you can retrieve using the Get All Merchants API.

  3. Dimensions: Parcels cannot measure more than 108 inches in length and girth combined, with the exception of those using USPS Parcel Select. Those using Parcel Select can measure up to 130 inches in length and girth combined.

    For all parcels, the PB Complete Shipping APIs configure length as the longest dimension, followed by height, followed by width. The APIs configure girth as twice the sum of the height and width:

    girth = 2 * (height+width)

    In addition to the limit on combined length and girth, other limits also apply. Refer to the USPS rules at https://pe.usps.com/text/qsg300/Q201e.htm.

  4. Soft Packs: For soft packs:

    • the sum of the longest and next-longest dimensions must not exceed 36 inches
    • the longest dimension must not exceed 18 inches
    • the smallest dimension must not exceed 2 inches

    The measurements must be taken prior to placing the item in the envelope.

  5. Services: For available services and special services, see USPS Services, Parcel Types, and Label Sizes.

    To view a service’s compatible special services and to determine any restrictions on a service or special service, use the Carrier Rules API or see the USPS Domestic Mail Manual.

  6. Tracking Requirement: The PB Complete Shipping APIs require that all USPS parcels be trackable. If the parcel uses a service that is not trackable, such as Priority Mail (PM), you must add at least one trackable special service, such as Delivery Confirmation (DelCon). DelCon is a no-charge special service that triggers tracking but does not increase the cost of the shipment.

  7. IMb: To send a letter or flat with an IMb (Intelligent Mail barcode), use the parameters listed in this FAQ when making this API call.

  8. Customs: You must include the customs object for shipments to the following destinations:

    • APO/FPO
    • U.S. territories (except VI & PR)
    • U.S. possessions
    • Freely Associated States
    • Countries outside the U.S.

    You must also set the documents.size field to DOC_4X6 or DOC_8X11.

    The API will automatically provide the correct USPS customs form based on the information supplied in the request. The form is used as both the shipping label and the customs declaration. For shipments to participating countries and to APO/FPO/DPO destinations, the customs form will be a single-ply form. As of this writing, the participating countries are Australia, Canada, and Costa Rica.

  9. SCAN form: To make the shipment eligible for inclusion in a USPS SCAN form, set the ADD_TO_MANIFEST option to true in the shipmentOptions array. To include the shipment in a SCAN form, either issue the Create Manifest API or let Pitney Bowes auto-manifest the shipment at 6 a.m. UTC/GMT the next calendar day.

    Note: The following shipments cannot be added to a SCAN form:

    • First-Class Mail (FCM) flats (FLAT)
    • First-Class Mail (FCM) letters (LETTER)
    • Scan-Based Returns. Note: If you are creating an SBR label, do not use this page but instead use the instructions on this page.
  10. Shipment Options: For additional shipment options, see Shipment Options.

  11. Label: The label is returned as either a Base64 string or a URL that links to a PDF. Labels retrieved through URLs are available for 24 hours after label creation. For label options, see USPS Label Sizes & Formats.

    Note: First-Class (FCM) shipments that use the LETTER or FLAT parcel type are supported only for 6X4 labels. You must set the documents.size field DOC_6X4.

  12. Error Handling: If your request returns the HTTP 500 Internal Server Error, do not resubmit the request without first checking whether the label was created. To check whether the label was created, issue the Retry Shipment API.

Request URIs

Sandbox: https://api-sandbox.pitneybowes.com/shippingservices/v1/shipments
Production: https://api.pitneybowes.com/shippingservices/v1/shipments

Query Parameter

The query parameter is optional.

Name Description
includeDeliveryCommitment

If set to true, returns estimated transit times in days.

Valid values:

  • true
  • false

See also:

Request Headers

Name Description
Authorization Required. OAuth token generated using the Generate an OAuth Token API.
Content-Type Required. The media type of the request entity. Set this to application/json.
Accept-Language Language and country code. Default: en-US
X-PB-TransactionId

Required. A unique identifier for the transaction, up to 25 characters.

Important: You must ensure this is a unique id.

X-PB-Shipper-Rate-Plan USPS Only. Shipper rate plan, if applicable. For more information, see this FAQ.
X-PB-Integrator-CarrierId USPS Only. Negotiated services rate, if applicable.
X-PB-UnifiedErrorStructure
Recommended. Set this to true to use the standard error object if an error occurs.

Request / Response Elements

The API call sends and receives a shipment object. The table below describes all possible fields in a shipment object.

Some fields might not apply to your operation.

Name Data Type Description
fromAddress address object

Required. Origin address.

If you want a different address to appear on the label, see How do I print a return address that is different from the origin address?

toAddress address object

Required. Destination address.

Note: If you are shipping with UPS (available only in Sandbox) to Puerto Rico or an international destination, and if the importer is different from the final recipient, this is the address of the importer. Enter the recipient’s address in the soldToAddress object. If importer’s address is the same as the final recipient, the entries toAddress and soldToAddress must match.

altReturnAddress address object USPS Only. If you are sending an international shipment through USPS and if you have set the NON_DELIVERY_OPTION shipment option to redirect, then enter the address that a returned parcel should go to.
parcel parcel object Required. Contains physical characteristics of the parcel.
rates Array[rates object]

Required. Specifies carrier, service, parcel type, and other information. In a response, this field specifies the service charges.

Important: In a request, the rates array can contain only one rates object.

documents Array[documents object] Conditional: Required for Create Shipment requests; does not apply to Rate Package requests. Defines the label, manifest, or other shipment document.
shipmentOptions Array[Object] Conditional: Required for Create Shipment requests; does not apply to Rate Package requests. Each object in this array defines a shipment option. Please see the Things to Consider section on your carrier’s Create Shipment page for required options. Note that the SHIPPER_ID option is required for all shipments.
        name String The name of the shipment option. The shipmentOptions array requires this field.
        value String The value of the shipment option. The shipmentOptions array requires this field.
customs customs object

This field contains customs information.

Applies to the following:

  • For USPS, applies to shipments to these locations:
    • International
    • APO/FPO/DPO
    • Territories/Possessions
    • FAS
  • For UPS (available only in Sandbox), applies to shipments to these locations:
    • International
    • Puerto Rico
soldToAddress address object

UPS Only. (Available only in Sandbox)

This object is required for shipments from the U.S. to Puerto Rico or an international destination.

The soldToAddress.countryCode must match the toAddress.countryCode, with the exception of shipments to Canada and to U.S. satellite countries.

Enter the importer’s address in the toAddress object. If importer’s address is the same as the final recipient, the entries in the toAddress object must match the entries in the soldToAddress object.

shipmentType String USPS SBR Only. If you are creating a USPS Scan-Based Return (SBR) label, include this field and set the value to RETURN.
references Array[Object]

Newgistics Only. This array maps client-generated identifiers to fields in the Newgistics package record. The information in this array does not appear on the shipping label.

The array takes up to three objects, and each object maps an identifier to a specific Newgistics field. An object’s sequence in the array determines which Newgistics field the object maps to. The first object in the array maps to the Newgistics “ReferenceNumber” field; the second to the “AddlRef1” field; and the third to the “AddlRef2” field.

Use the syntax shown below. Enter the names in the order shown. If you enter different names, the system will change them to the names below. In the value fields, enter the client-generated identifiers. The values must be strings of no more than 50 characters each. For additional information on using references, merchants can contact their Newgistics representatives.

{
    "name": "ReferenceNumber",
    "value": "<client identifier 1>"
}, {
    "name": "AddlRef1",
    "value": "<client identifier 2>"
}, {
    "name": "AddlRef2",
    "value": "<client identifier 3>"
}
shipmentId String Response Only. Unique identifier for the shipment, generated by the system in response to shipment purchase.
parcelTrackingNumber String Response Only. Tracking number assigned to the shipment by the system.

Sample Requests and Responses

See the following examples:

For a sample request for a Doc Tab label, see How do I print a Doc Tab label?

Domestic Shipment Sample Request

The following example includes the includeDeliveryCommitment query parameter.

curl -X POST .../v1/shipments?includeDeliveryCommitment=true \
-H "Authorization: Bearer l8wHkQKaBjC5VEaYldQnFXnzoqNj" \
-H "Content-Type: application/json" \
-H "X-PB-TransactionId: 76e4498e-85fe-43a1-b6d0" \
-H "X-PB-UnifiedErrorStructure: true" \
-d '
{
    "fromAddress" : {
        "company" : "Supplier",
        "name" : "J. Smith",
        "phone" : "303-555-1213",
        "email" : "js@example.com",
        "residential" : false,
        "addressLines" : [ "4750 Walnut Street" ],
        "cityTown" : "Boulder",
        "stateProvince" : "CO",
        "postalCode" : "80301",
        "countryCode" : "US"
    },
    "toAddress": {
        "company": "Shop",
        "name": "J. Jones",
        "phone": "203-000-1234",
        "email": "jjones@example.com",
        "residential": false,
        "addressLines": [ "771 Orange St" ],
        "cityTown": "New Haven",
        "stateProvince": "CT",
        "postalCode": "06511",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 8
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": 6.0,
            "width": 1.0,
            "height": 4.0
        }
    },
    "rates": [ {
        "carrier": "USPS",
        "serviceId": "PM",
        "parcelType": "PKG",
        "specialServices": [ {
            "specialServiceId": "Ins",
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "50"
            } ]
        }, {
            "specialServiceId": "DelCon",
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "0"
            } ]
        } ],
        "inductionPostalCode": "06484"
    } ],
    "documents": [ {
        "type": "SHIPPING_LABEL",
        "contentType": "BASE64",
        "size": "DOC_4X6",
        "fileFormat": "PNG",
        "resolution": "DPI_203",
        "printDialogOption": "EMBED_PRINT_DIALOG"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    }, {
        "name": "ADD_TO_MANIFEST",
        "value": "true"
    }, {
        "name": "MINIMAL_ADDRESS_VALIDATION",
        "value": "true"
    } ]
}'

Domestic Shipment Sample Response

{
    "fromAddress": {
        "company": "Supplier",
        "name": "J. Smith",
        "phone": "303-555-1213",
        "email": "js@example.com",
        "residential": false,
        "addressLines": [
            "4750 Walnut Street"
        ],
        "cityTown": "Boulder",
        "stateProvince": "CO",
        "postalCode": "80301-2532",
        "countryCode": "US",
        "deliveryPoint": "99",
        "carrierRoute": "C033"
    },
    "toAddress": {
        "company": "Shop",
        "name": "J. Jones",
        "phone": "203-000-1234",
        "email": "jjones@example.com",
        "residential": false,
        "addressLines": [
            "771 Orange St"
        ],
        "cityTown": "New Haven",
        "stateProvince": "CT",
        "postalCode": "06511-2536",
        "countryCode": "US",
        "deliveryPoint": "71",
        "carrierRoute": "C008"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 8
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": 6,
            "width": 1,
            "height": 4,
            "irregularParcelGirth": 0
        }
    },
    "rates": [ {
        "carrier": "USPS",
        "parcelType": "PKG",
        "inductionPostalCode": "06484",
        "specialServices": [ {
            "specialServiceId": "Ins",
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "50"
            } ],
            "fee": 0
        }, {
            "specialServiceId": "DelCon",
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "0"
            } ],
            "fee": 0
        } ],
        "serviceId": "PM",
        "deliveryCommitment": {
            "minEstimatedNumberOfDays": "1",
            "maxEstimatedNumberOfDays": "1",
            "estimatedDeliveryDateTime": "2018-02-15",
            "guarantee": "NONE",
            "additionalDetails": "By end of Day"
        },
        "dimensionalWeight": {
            "weight": 0,
            "unitOfMeasurement": "OZ"
        },
        "baseCharge": 5.81,
        "totalCarrierCharge": 5.81,
        "currencyCode": "USD",
        "destinationZone": "1"
    } ],
    "documents": [ {
        "size": "DOC_4X6",
        "type": "SHIPPING_LABEL",
        "contentType": "BASE64",
        "fileFormat": "PNG",
        "pages": [ {
            "contents": "iVBORw0KGgoAAAANSUhEUgAABLAAAAcIAQAAAAAEKwXnAAAACXBIWXMAAC..."
        } ]
    } ],
    "shipmentOptions": [ {
        "name": "HIDE_TOTAL_CARRIER_CHARGE",
        "value": "true"
    }, {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    }, {
        "name": "ADD_TO_MANIFEST",
        "value": "true"
    }, {
       "name": "FUTURE_SHIPMENT_DATE",
        "value": "2018-02-14"
    },
    {
        "name": "MINIMAL_ADDRESS_VALIDATION",
        "value": "true"
    },
    {
        "name": "SHIPPING_LABEL_RECEIPT",
        "value": "noOptions"
    } ],
    "shipmentId": "USPS2200145762537624",
    "parcelTrackingNumber": "9405509898642000588417"
}

International Shipment Sample Request

curl -X POST .../v1/shipments?includeDeliveryCommitment=true \
-H "Authorization: Bearer l8wHkQKaBjC5VEaYldQnFXnzoqNj" \
-H "Content-Type: application/json" \
-H "X-PB-TransactionId: 93e30b6f-b6cc-4528-bef0" \
-H "X-PB-UnifiedErrorStructure: true" \
-d '
{
    "fromAddress": {
        ...
    },
    "toAddress": {
        ...
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 9
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": 8.0,
            "width": 1.0,
            "height": 2.0
        }
    },
    "rates": [ {
        "carrier": "USPS",
        "serviceId": "EMI",
        "parcelType": "FRE",
        "specialServices": [ {
            "specialServiceId": "Ins",
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "100"
            } ]
        } ],
        "inductionPostalCode": "06510"
    } ],
    "customs": {
        "customsInfo": {
            "reasonForExport": "MERCHANDISE",
            "comments": "Books",
            "invoiceNumber": "001189223",
            "importerCustomsReference": "987654",
            "insuredNumber": "insuredNumber0",
            "insuredAmount": 100.0,
            "sdrValue": 66.87,
            "fromCustomsReference": "11111",
            "currencyCode": "GBP",
            "licenseNumber": "456ABC123",
            "certificateNumber": "987"
        },
        "customsItems": [ {
            "description": "Books",
            "quantity": 3,
            "unitPrice": 33.00,
            "unitWeight": {
                "weight": 3.0,
                "unitOfMeasurement": "OZ"
            },
            "hSTariffCode": "AST559",
            "originCountryCode": "US"
           } ]
       },
    "documents": [ {
        "type": "SHIPPING_LABEL",
        "contentType": "URL",
        "size": "DOC_4X6",
        "fileFormat": "PDF",
        "printDialogOption": "EMBED_PRINT_DIALOG"
    } ],
    "shipmentOptions": [{
        "name": "SHIPPER_ID",
        "value": "9024324564"
    }, {
        "name": "ADD_TO_MANIFEST",
        "value": "true"
    } ]
}

International Shipment Sample Response

{
    "fromAddress": {
        ...
    },
    "toAddress": {
        ...
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 9
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": 8,
            "width": 1,
            "height": 2,
            "irregularParcelGirth": 0
        }
    },
    "rates": [ {
        "carrier": "USPS",
        "parcelType": "FRE",
        "inductionPostalCode": "06510",
        "specialServices": [ {
            "specialServiceId": "Ins",
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "100"
            } ],
            "fee": 0
        } ],
        "serviceId": "EMI",
        "dimensionalWeight": {
            "weight": 0,
            "unitOfMeasurement": "OZ"
        },
        "baseCharge": 56.61,
        "totalCarrierCharge": 56.61,
        "currencyCode": "USD",
        "destinationZone": "4"
    } ],
    "documents": [ {
        "type": "SHIPPING_LABEL",
        "contentType": "URL",
        "fileFormat": "PDF",
        "contents": "https://.../usps/198715941/outbound/label/8649470d08564e88b716255f64f6b18d.pdf"
    } ],
    "shipmentOptions": [ {
        "name": "HIDE_TOTAL_CARRIER_CHARGE",
        "value": "false"
    }, {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    }, {
        "name": "ADD_TO_MANIFEST",
        "value": "true"
    }, {
        "name": "FUTURE_SHIPMENT_DATE",
        "value": "2018-02-14"
    }, {
        "name": "MINIMAL_ADDRESS_VALIDATION",
        "value": "false"
    }, {
        "name": "SHIPPING_LABEL_RECEIPT",
        "value": "noOptions"
    } ],
    "shipmentId": "USPS2200146002128591",
    "customs": {
        "customsInfo": {
            "reasonForExport": "MERCHANDISE",
            "comments": "Books",
            "invoiceNumber": "001189223",
            "importerCustomsReference": "987654",
            "insuredNumber": "insuredNumber0",
            "insuredAmount": 100,
            "sdrValue": 66.87,
            "fromCustomsReference": "11111",
            "currencyCode": "GBP",
            "licenseNumber": "456ABC123",
            "certificateNumber": "987",
            "freightCharge": 0,
            "packingCosts": 0,
            "handlingCosts": 0,
            "otherCharge": 0
        },
        "customsItems": [ {
            "description": "Books",
            "quantity": 3,
            "unitPrice": 33,
            "unitWeight": {
                "weight": 3,
                "unitOfMeasurement": "OZ"
            },
            "hSTariffCode": "AST559",
            "originCountryCode": "US"
        } ]
    },
    "parcelTrackingNumber": "EP863272143US"
}

Error Codes

For a list of all PB Complete Shipping APIs error codes, see Error Codes.