Create a United Parcel Service (UPS) Shipment

HTTP Request

POST /v1/shipments

Summary

This operation creates a post-paid shipping label using UPS® as the carrier. Shipments can originate from the U.S. and Canada.

Prerequisites

The merchant must have an existing UPS account and must register the account with Pitney Bowes. See Onboard a Merchant to Print UPS Labels.

Things to Consider

  1. Addresses: The following address fields are required in the fromAddress and toAddress:

    • addressLines
    • postalCode
    • countryCode
  2. Services: For the available services and special services, see Services on the UPS reference page.

  3. Labels: Labels are returned as links to PDFs. Links are available for 24 hours after label creation. For the available label options, see Labels on the UPS reference page.

    Note: The DOC_4X6 label size cannot be used for a domestic shipment if the value is greater than $1,000.

  4. Shipper ID: You must specify a SHIPPER_ID in the shipmentOptions array and set its value to the merchant’s postalReportingNumber. To retrieve a merchant’s postalReportingNumber, use the Get All Merchants API.

  5. Shipping to Puerto Rico: When shipping to Puerto Rico from the U.S., you must set the following:

    • Set rates.serviceId to a U.S. domestic service
    • Include the customs object
    • Set both toAddress.stateProvince and toAddress.countryCode to PR
  6. Error Handling: If your request returns the HTTP 500 Internal Server Error, see Troubleshoot the 500 Internal Server Error.

    For other errors, 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

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-Carrier-AccountId

Conditional. The unique identifier for the carrier account. To retrieve the identifier, see this FAQ.

This header is required if the merchant has registered multiple accounts for the same carrier. For more information, see Carrier Account Registration.

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 following table describes all possible fields in a Shipment Object.

Important

Some fields in the Shipment Object do not apply to this operation and are marked accordingly.

Name Data Type Description
fromAddress Address Object

Required. Origin address.

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

toAddress Address Object

Required. Destination address.

FedEx, UPS: If you are shipping with FedEx or UPS 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 toAddress and soldToAddress must match.

altReturnAddress Address Object

USPS, CBDS Only. Applies as follows:

  • USPS: 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.
  • CBDS: For a Create Shipment request, this is the address used to return a parcel from the CBDS Consolidation Center. If omitted, the fromAddress is used. The altReturnAddress is not returned in the response.
parcel Parcel Object Required. Contains physical characteristics of the parcel.
rates Array[Rates Object]

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

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

documents Array[Documents Object]

Conditional. Defines the label, manifest, or other shipping document created by the API call.

This field is required except in the following cases:

  • This field does not apply to Rate Parcel requests.
  • This field does not apply to the Create CBDS Shipment request if the merchant prints the first-label prior to invoking the API.
shipmentOptions Array[Object]

Required. Each object in this array defines a shipment option. Specify each option as a name-value pair in the array.

The SHIPPER_ID option is required. For any additional requirements for a carrier or service, please see the Things to Consider section on the carrier’s Create Shipment page.

        name String The name of the shipment option.
        value String The value of the shipment option.
customs Object

Conditional. For shipments that use customs forms, this object contains the customs information. This field is required for the following carriers in the following situations:

  • USPS: Required for shipments to international destinations or to APO/FPO/DPO, Territories/Possessions, or FAS.
  • CBDS: Required for all shipments.
  • FedEx: Required for shipments to international destinations and Puerto Rico.
  • UPS: Required for shipments to international destinations and Puerto Rico.
        customsInfo Customs Info Object Customs clearance information used to fill out a commercial invoice.
        customsItems Array[Customs Items Object]

Information about each commodity in the shipment, used for customs clearance.

The maximum number of objects in this array is 30.

domesticShipmentDetails Domestic Shipment Details Object CBDS Only. Required if the merchant prints the first-mile label prior to invoking the Create CBDS Shipment API. This object contains information about the first-mile leg of the shipment.
soldToAddress Address Object

FedEx, UPS Only. The final recipient of a the shipment. Required for a shipment from the U.S. to Puerto Rico or to an international destination. Otherwise optional.

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

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

shipmentType String Return Labels Only. Set this to RETURN. Required for Expedited Returns and Standard Returns.
references Array[Object]

Merchant-defined values. Applies to the following:

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.

UPS Domestic Shipment Request

The following is a sample request for a UPS domestic shipment:

curl -X POST .../v1/shipments \
-H "Authorization: Bearer <oauth_token>" \
-H "Content-Type: application/json" \
-H "Accept-Language: en-US" \
-H "X-PB-TransactionId: <unique_transaction_id>" \
-H "X-PB-Shipper-Carrier-AccountId: <unique_carrier_account_id>" \
-H "X-PB-UnifiedErrorStructure: true" \
-d '
{
    "fromAddress": {
        "company": "Supplies",
        "name": "Manager",
        "phone": "415-555-0000",
        "email": "manager@example.com",
        "residential": false,
        "addressLines": [ "545 Market St" ],
        "cityTown": "San Francisco",
        "stateProvince": "CA",
        "postalCode": "94105",
        "countryCode": "US"
    },
    "toAddress": {
        "company": "Shop",
        "name": "Jane Wilson",
        "phone": "620-555-1212",
        "email": "jane@example.com",
        "residential": false,
        "addressLines": [ "643 Greenway RD" ],
        "cityTown": "Boone",
        "stateProvince": "NC",
        "postalCode": "28607",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "weight": 38,
            "unitOfMeasurement": "OZ"
        },
        "dimension": {
            "length": 6,
            "width": 4,
            "height": 6,
            "unitOfMeasurement": "IN"
        },
        "currencyCode": "USD"
    },
    "rates": [ {
        "carrier": "UPS",
        "serviceId": "NDA_AM",
        "parcelType": "PKG",
        "specialServices": [ {
            "specialServiceId": "INS",
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "100.00"
            } ]
        } ]
    } ],
    "documents": [ {
        "size": "DOC_4X6",
        "printDialogOption": "NO_PRINT_DIALOG",
        "type": "SHIPPING_LABEL",
        "contentType": "URL",
        "fileFormat": "PDF"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ]
}'

UPS Domestic Shipment Response

{
    "fromAddress": {
        "company": "Supplies",
        "name": "Manager",
        "phone": "415-555-0000",
        "email": "manager@example.com",
        "residential": false,
        "addressLines": [ "545 Market St" ],
        "cityTown": "San Francisco",
        "stateProvince": "CA",
        "postalCode": "94105-2847",
        "countryCode": "US",
        "deliveryPoint": "45",
        "carrierRoute": "C002"
    },
    "toAddress": {
        "company": "Shop",
        "name": "Jane Wilson",
        "phone": "620-555-1212",
        "email": "jane@example.com",
        "residential": false,
        "addressLines": [ "643 Greenway Rd" ],
        "cityTown": "Boone",
        "stateProvince": "NC",
        "postalCode": "28607-4819",
        "countryCode": "US",
        "deliveryPoint": "99",
        "carrierRoute": "C010"
    },
    "parcel": {
        "weight": {
            "weight": 38,
            "unitOfMeasurement": "OZ"
        },
        "dimension": {
            "length": 6,
            "width": 4,
            "height": 6,
            "unitOfMeasurement": "IN"
        },
        "currencyCode": "USD"
    },
    "rates": [ {
        "carrier": "UPS",
        "parcelType": "PKG",
        "specialServices": [ {
            "specialServiceId": "INS",
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "100.00"
            } ]
        } ],
        "serviceId": "NDA_AM",
        "totalCarrierCharge": 133.23,
        "totalTaxAmount": 0,
        "baseCharge": 134.58,
        "currencyCode": "USD"
    } ],
    "documents": [ {
        "type": "SHIPPING_LABEL",
        "size": "DOC_4X6",
        "fileFormat": "PDF",
        "contentType": "URL",
        "contents": "https://.../ups/258459135/outbound/label/9dbc524171674d4f9b38a17d011664aa.pdf"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ],
    "shipmentId": "UPS2200167767266327",
    "parcelTrackingNumber": "<tracking-number>"
}


UPS Shipment to Puerto Rico Request

The following is a sample request for a UPS shipment to Puerto Rico:

curl -X POST .../v1/shipments \
-H "Authorization: Bearer <oauth_token>" \
-H "Content-Type: application/json" \
-H "Accept-Language: en-US" \
-H "X-PB-TransactionId: <unique_transaction_id>" \
-H "X-PB-Shipper-Carrier-AccountId: <unique_carrier_account_id>" \
-H "X-PB-UnifiedErrorStructure: true" \
-d '
{
    "fromAddress": {
        "company": "Supplies",
        "name": "Manager",
        "phone": "415-555-0000",
        "email": "manager@example.com",
        "residential": false,
        "addressLines": [ "545 Market St" ],
        "cityTown": "San Francisco",
        "stateProvince": "CA",
        "postalCode": "94105",
        "countryCode": "US"
        },
    "toAddress": {
        "company": "Museum",
        "name": "Director",
        "phone": "787 000 0000",
        "email": "museum@example.com",
        "residential": false,
        "addressLines": ["Av. de Diego 299"],
        "cityTown": "San Juan",
        "stateProvince": "PR",
        "postalCode": "00909",
        "countryCode": "PR"
    },
    "soldToAddress": {
        "company": "Solutions",
        "name": "Supervisor",
        "phone": "787 000 0000",
        "email": "solutions@example.com",
        "residential": false,
        "addressLines": ["70 Hanlan RD"],
        "cityTown": "San Juan",
        "stateProvince": "PR",
        "postalCode": "00915",
        "countryCode": "PR"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 32.0
        },
        "dimension": {
            "length": 6.0,
            "width": 4.0,
            "height": 6.0,
            "unitOfMeasurement": "IN"
         }
    },
    "rates": [ {
        "carrier": "UPS",
        "serviceId": "NDA",
        "rateTypeId": "COMMERCIAL",
        "parcelType": "PKG"
    } ],
    "customs": {
        "customsInfo": {
            "EELPFC": "NOEEI30.37A",
            "currencyCode": "USD",
            "customsDeclaredValue": 10.00,
            "reasonForExport": "MERCHANDISE",
            "sdrValue": 0
        },
        "customsItems": [ {
            "description": "Books",
            "originCountryCode": "US",
            "quantity": 1,
            "quantityUOM": "PCS",
            "unitPrice": 10.00,
            "unitWeight": {
                "unitOfMeasurement": "OZ",
                "weight": 16.0
            }
        } ]
    },
    "documents": [ {
        "size": "DOC_8X11",
        "printDialogOption": "NO_PRINT_DIALOG",
        "type": "SHIPPING_LABEL",
        "contentType": "URL",
        "fileFormat": "PDF"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ]
}'

UPS Shipment to Puerto Rico Response

{
    "fromAddress": {
        "company": "Supplies",
        "name": "Manager",
        "phone": "415-555-0000",
        "email": "manager@example.com",
        "residential": false,
        "addressLines": [
            "545 Market St"
        ],
        "cityTown": "San Francisco",
        "stateProvince": "CA",
        "postalCode": "94105-2847",
        "countryCode": "US",
        "carrierRoute": "C002",
        "deliveryPoint": "45"
    },
    "toAddress": {
        "company": "Museum",
        "name": "Director",
        "phone": "787 000 0000",
        "email": "museum@example.com",
        "residential": false,
        "addressLines": [
            "Av. de Diego 299"
        ],
        "cityTown": "San Juan",
        "stateProvince": "PR",
        "postalCode": "00909",
        "countryCode": "PR"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 32.0
        },
        "dimension": {
            "length": 6.0,
            "width": 4.0,
            "height": 6.0,
            "unitOfMeasurement": "IN",
            "irregularParcelGirth": 0.0
        }
    },
    "rates": [ {
        "carrier": "UPS",
        "parcelType": "PKG",
        "inductionPostalCode": "94105",
        "specialServices": [],
        "serviceId": "NDA",
        "baseCharge": 75.4,
        "currencyCode": "USD",
        "rateTypeId": "COMMERCIAL",
        "surcharges": [ {
            "fee": 3.02,
            "name": "FUEL"
        } ],
        "totalCarrierCharge": 77.64,
        "totalTaxAmount": 0.0
    } ],
    "documents": [ {
        "contentType": "URL",
        "contents": "https://.../ups/258459135/outbound/label/b14f7e241d5448eb1fb7900822150c4.pdf"
        "fileFormat": "PDF",
        "size": "DOC_8X11",
        "type": "SHIPPING_LABEL"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ],
    "customs": {
        "customsInfo": {
            "EELPFC": "NOEEI30.37A",
            "currencyCode": "USD",
            "customsDeclaredValue": 10.0,
            "freightCharge": 0.0,
            "handlingCosts": 0.0,
            "otherCharge": 0.0,
            "packingCosts": 0.0,
            "reasonForExport": "MERCHANDISE",
            "sdrValue": 0.0
        },
        "customsItems": [ {
            "description": "Books",
            "originCountryCode": "US",
            "quantity": 1,
            "quantityUOM": "PCS",
            "unitPrice": 10.0,
            "unitWeight": {
                "unitOfMeasurement": "OZ",
                "weight": 16.0
            }
        } ]
    },
    "parcelTrackingNumber": "<tracking-number>",
    "shipmentId": "UPS2200255488613798",
    "soldToAddress": {
        "company": "Solutions",
        "name": "Supervisor",
        "phone": "787 000 0000",
        "email": "solutions@example.com",
        "residential": false,
        "addressLines": [
            "70 Hanlan RD"
        ],
        "cityTown": "San Juan",
        "stateProvince": "PR",
        "postalCode": "00915",
        "countryCode": "PR"
    }
}


UPS International Shipment Request

The following is a sample request for a UPS shipment to Germany:

{
    "fromAddress": {
        "company": "Supplies",
        "name": "Manager",
        "phone": "415-555-0000",
        "email": "manager@example.com",
        "residential": false,
        "addressLines": [ "545 Market St" ],
        "cityTown": "San Francisco",
        "stateProvince": "CA",
        "postalCode": "94105",
        "countryCode": "US"
    },
    "toAddress": {
        "company": "Imports",
        "name": "Manager",
        "phone": "49 89 00000",
        "email": "imports@example.com",
        "residential": "false",
        "addressLines": [ "Prinzregentenstraße 3" ],
        "cityTown": "Munchen",
        "stateProvince": "",
        "postalCode": "80331",
        "countryCode": "DE"
    },
    "soldToAddress": {
        "company": "Museum",
        "name": "Director",
        "phone": "49 89 0000000",
        "email": "museum@example.com",
        "residential": "false",
        "addressLines": [ "Museumsinsel 1" ],
        "cityTown": "Munchen",
        "stateProvince": "",
        "postalCode": "80538",
        "countryCode": "DE"
    },
    "parcel": {
        "weight": {
            "weight": 38,
            "unitOfMeasurement": "OZ"
        },
        "dimension": {
            "length": 31,
            "width": 25,
            "height": 25,
            "unitOfMeasurement": "IN"
        }
    },
    "rates": [ {
        "carrier": "UPS",
        "serviceId": "XPP",
        "parcelType": "PKG",
        "specialServices": []
    } ],
    "documents": [ {
        "size": "DOC_8X11",
        "printDialogOption": "EMBED_PRINT_DIALOG",
        "type": "SHIPPING_LABEL",
        "contentType": "URL",
        "fileFormat": "PDF"
    } ],
    "customs": {
        "customsInfo": {
            "comments": "",
            "currencyCode": "USD",
            "customsDeclaredValue": 245.0,
            "EELPFC": "NOEEI 30.37(j)",
            "reasonForExport": "GIFT",
            "reasonForExportExplanation": "",
            "shippingDocumentType": "NAFTA",
            "termsOfSale": "CIF"
        },
        "customsItems": [ {
            "description": "Product no 1 - Type A",
            "hSTariffCode": "49011000",
            "netCostMethod": "NET_COST",
            "originCountryCode": "US",
            "originStateProvince": "PA",
            "preferenceCriterion": "A",
            "producerAddress": {
                "addressLines": ["900 Canada Pl"],
                "cityTown": "Vancouver",
                "stateProvince": "BC",
                "postalCode": "V6C 3L5",
                "countryCode": "CA",
                "company": "Fairmont  Groups",
                "name": "Fairmont Vancouver",
                "phone": "6046911991",
                "email": ""
            },
            "producerDetermination": "NO_1",
            "producerId": "CANADA",
            "quantity": 1,
            "quantityUOM": "lb",
            "unitPrice": 245.0,
            "unitWeight": {
                "weight": 1.0,
                "unitOfMeasurement": "OZ"
            }
        } ]
    },
    "shipmentOptions": [ {
        "name": "PRINT_CUSTOM_MESSAGE_1",
        "value": "Geschenk"
    },{
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ]
}'

UPS International Shipment Response

{
    "fromAddress": {
        "company": "Supplies",
        "name": "Manager",
        "phone": "415-555-0000",
        "email": "manager@example.com",
        "residential": false,
        "addressLines": [ "545 Market St" ],
        "cityTown": "San Francisco",
        "stateProvince": "CA",
        "postalCode": "94105-2847",
        "countryCode": "US",
        "carrierRoute": "C002",
        "deliveryPoint": "45"
    },
    "toAddress": {
        "company": "Imports",
        "name": "Manager",
        "phone": "49 89 00000",
        "email": "imports@example.com",
        "residential": false,
        "addressLines": [ "Prinzregentenstraße 3" ],
        "cityTown": "Munchen",
        "stateProvince": "",
        "postalCode": "80331",
        "countryCode": "DE"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 38.0
        },
        "dimension": {
            "length": 31.0,
            "width": 25.0,
            "height": 25.0,
            "unitOfMeasurement": "IN"
        }
    },
    "rates": [ {
        "carrier": "UPS",
        "parcelType": "PKG",
        "inductionPostalCode": "94105",
        "specialServices": [],
        "serviceId": "XPP",
        "baseCharge": 1649.06,
        "currencyCode": "USD",
        "surcharges": [ {
            "fee": 147.19,
            "name": "FUEL"
        },{
            "fee": 95.0,
            "name": "LARGE_PACKAGE"
        } ],
        "totalCarrierCharge": 1911.94,
        "totalTaxAmount": 0.0
    } ],
    "documents": [ {
        "contentType": "URL",
        "contents": "https://.../ups/258499135/outbound/label/3fdc7fa973d748c19fa1c697d1a12eda.pdf",
        "fileFormat": "PDF",
        "size": "DOC_8X11",
        "type": "SHIPPING_LABEL"
        }
    ],
    "shipmentOptions": [ {
        "name": "PRINT_CUSTOM_MESSAGE_1",
        "value": "Geschenk"
    },{
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ],
    "customs": {
        "customsInfo": {
            "currencyCode": "USD",
            "customsDeclaredValue": 245.0,
            "EELPFC": "NOEEI 30.37(j)",
            "freightCharge": 0.0,
            "handlingCosts": 0.0,
            "otherCharge": 0.0,
            "packingCosts": 0.0,
            "reasonForExport": "GIFT",
            "shippingDocumentType": "NAFTA",
            "termsOfSale": "CIF"
        },
        "customsItems": [ {
            "description": "Product no 1 - Type A",
            "hSTariffCode": "9810.00.35",
            "netCostMethod": "NET_COST",
            "originStateProvince": "PA",
            "originCountryCode": "US",
            "preferenceCriterion": "A",
            "producerAddress": {
                "company": "Fairmont  Groups",
                "name": "Fairmont Vancouver",
                "phone": "6046911991",
                "email": "",
                "addressLines": [ "900 Canada Pl" ],
                "cityTown": "Vancouver",
                "stateProvince": "BC",
                "postalCode": "V6C 3L5",
                "countryCode": "CA"
            },
            "producerDetermination": "NO_1",
            "producerId": "CANADA",
            "quantity": 1,
            "quantityUOM": "lb",
            "unitPrice": 245.0,
            "unitWeight": {
                "unitOfMeasurement": "OZ",
                "weight": 1.0
            }
        } ]
    },
    "parcelTrackingNumber": "1Z06XV245495105936",
    "shipmentId": "UPS2200171201666166",
    "soldToAddress": {
        "company": "Museum",
        "name": "Director",
        "phone": "49 89 0000000",
        "email": "museum@example.com",
        "residential": false,
        "addressLines": [ "Museumsinsel 1" ],
        "cityTown": "Munchen",
        "stateProvince": "",
        "postalCode": "80538",
        "countryCode": "DE"
    }
}


Sample UPS Label

Sample UPS Label


Sample UPS Control Log

Sample UPS Control Log

Error Codes

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