Create a United Parcel Service (UPS) Shipment

Note

This feature is available in the Sandbox environment.

HTTP Request

POST /v1/shipments

Summary

This operation creates a shipment and purchases a shipment label using UPS® (United Parcel Service) as the carrier. The API returns the label as a link to a PDF. Shipments can originate from the U.S. and Canada.

Prerequisites

To create UPS shipments, a merchant must have a UPS account and the merchant’s account must be onboarded with Pitney Bowes. For details, please see Onboard a Merchant to use UPS.

Things to Consider

  1. Shipper ID: To print a 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.

  2. Services: For available services and special services, see UPS Services, Parcel Types, and Label Sizes.

  3. Label: The label is returned as a URL that links to a PDF. A label is available for 24 hours after label creation.

    The DOC_4X6 label size can be used only for domestic shipments with a value of less than $1,000.

    For more information on valid label sizes, see UPS Label Sizes & Formats.

  4. 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
  5. 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

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 The unique identifier returned in the shipperCarrierAccountId field by the Register an Existing Carrier Account API call.
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:


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_id>" \
-H "X-PB-UnifiedErrorStructure: true" \
-d '
{
    "fromAddress": {
        "company": "Supplies",
        "name": "Manager",
        "phone": "415-555-0000",
        "email": "supplies@example.com",
        "residential": false,
        "addressLines": [ "545 Market St" ],
        "cityTown": "San Francisco",
        "stateProvince": "CA",
        "postalCode": "94105",
        "countryCode": "US"
    },
    "toAddress": {
        "company": "Shop",
        "name": "Manager",
        "phone": "620-555-1212",
        "email": "shop@example.com",
        "residential": false,
        "addressLines": [ "643 Greenway RD" ],
        "cityTown": "Boone",
        "stateProvince": "NC",
        "postalCode": "28607",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 38
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": 6,
            "width": 4,
            "height": 6
        },
        "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": "supplies@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": "Manager",
        "phone": "620-555-1212",
        "email": "shop@example.com",
        "residential": false,
        "addressLines": [ "643 Greenway Rd" ],
        "cityTown": "Boone",
        "stateProvince": "NC",
        "postalCode": "28607-4819",
        "countryCode": "US",
        "deliveryPoint": "99",
        "carrierRoute": "C010"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 38
        },
        "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_id>" \
-H "X-PB-UnifiedErrorStructure: true" \
-d '
{
    "fromAddress": {
        "company": "Supplies",
        "name": "Manager",
        "phone": "415-555-0000",
        "email": "supplies@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.000
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": 6.00,
            "width": 4.00,
            "height": 6.00
        }
    },
    "rates": [ {
        "carrier": "UPS",
        "serviceId": "NDA",
        "rateTypeId":"COMMERCIAL",
        "parcelType": "PKG"
    } ],
    "customs": {
        "customsInfo": {
        "reasonForExport":"MERCHANDISE",
            "insuredAmount":0,
            "sdrValue":0,
            "customsDeclaredValue":1,
            "currencyCode":"USD",
            "EELPFC":"NOEEI30.37A"
        },
        "customsItems": [ {
        "description":"Books",
            "quantity":1,
            "quantityUOM":"PCS",
            "unitPrice":1,
            "originCountryCode":"US",
            "unitWeight": {
            "unitOfMeasurement":"OZ",
            "weight":16.000
            }
        } ]
    },
    "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": "supplies@example.com",
        "residential": false,
        "addressLines": [ "545 Market St" ],
        "cityTown": "San Francisco",
        "stateProvince": "CA",
        "postalCode": "94105-2847",
        "countryCode": "US",
        "deliveryPoint": "45",
        "carrierRoute": "C002"
    },
    "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
        },
        "dimension": {
            "length": 6,
            "width": 4,
            "height": 6,
            "unitOfMeasurement": "IN"
        }
    },
    "rates": [ {
        "carrier": "UPS",
        "parcelType": "PKG",
        "inductionPostalCode": "94105",
        "specialServices": [],
        "serviceId": "NDA",
        "rateTypeId": "COMMERCIAL",
        "totalCarrierCharge": 76.92,
        "totalTaxAmount": 0,
        "baseCharge": 72.11,
        "surcharges": [ {
            "name": "FUEL",
            "fee": 5.59
        } ],
        "currencyCode": "USD"
    } ],
    "documents": [ {
        "type": "SHIPPING_LABEL",
        "size": "DOC_8X11",
        "fileFormat": "PDF",
        "contentType": "URL",
        "contents": "https://.../ups/258459135/outbound/label/b14f7e241d5448eb1fb7900822150c4.pdf"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ],
    "customs": {
        "customsInfo": {
            "reasonForExport": "MERCHANDISE",
            "insuredAmount": 0,
            "sdrValue": 0,
            "customsDeclaredValue": 1,
            "currencyCode": "USD",
            "freightCharge": 0,
            "packingCosts": 0,
            "handlingCosts": 0,
            "otherCharge": 0,
            "EELPFC": "NOEEI30.37A"
        },
        "customsItems": [ {
            "description": "Business Books",
            "quantity": 1,
            "quantityUOM": "PCS",
            "unitPrice": 1,
            "unitWeight": {
                "unitOfMeasurement": "OZ",
                "weight": 16
            },
            "originCountryCode": "US"
        } ]
    },
    "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"
    },
    "shipmentId": "UPS2200171079847106",
    "parcelTrackingNumber": "<tracking-number>"
}


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": "supplies@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": {
            "unitOfMeasurement": "OZ",
            "weight": 38
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": 31,
            "width": 25,
            "height": 25
        }
    },
    "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": {
            "reasonForExport": "GIFT",
            "reasonForExportExplanation": "",
            "comments": "",
            "termsOfSale": "CIF",
            "EELPFC": "NOEEI 30.37(j)",
            "customsDeclaredValue": 245.0,
            "currencyCode": "USD",
            "shippingDocumentType": "NAFTA"
        },
        "customsItems": [ {
            "description": "Product no 1 - Type A",
            "quantity": 1,
            "quantityUOM": "lb",
            "unitPrice": 245.0,
            "unitWeight": {
                "weight": 1.0,
                "unitOfMeasurement": "OZ"
            },
            "hSTariffCode": "PR0001",
            "originStateProvince": "PA",
            "originCountryCode": "US",
            "preferenceCriterion": "A",
            "producerDetermination": "NO_1",
            "netCostMethod": "NET_COST",
            "producerId": "CANADA",
            "producerAddress": {
                "addressLines": ["900 Canada Pl"],
                "cityTown": "Vancouver",
                "stateProvince": "BC",
                "postalCode": "V6C 3L5",
                "countryCode": "CA",
                "company": "Fairmont  Groups",
                "name": "Fairmont Vancouver",
                "phone": "6046911991",
                "email": ""
            }
        } ]
    },
    "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": "supplies@example.com",
        "residential": false,
        "addressLines": [ "545 Market St" ],
        "cityTown": "San Francisco",
        "stateProvince": "CA",
        "postalCode": "94105-2847",
        "countryCode": "US",
        "deliveryPoint": "45",
        "carrierRoute": "C002"
    },
    "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
        },
        "dimension": {
            "length": 31,
            "width": 25,
            "height": 25,
            "unitOfMeasurement": "IN"
        }
    },
    "rates": [ {
        "carrier": "UPS",
        "parcelType": "PKG",
        "inductionPostalCode": "94105",
        "specialServices": [],
        "serviceId": "XPP",
        "totalCarrierCharge": 1920.76,
        "totalTaxAmount": 0,
        "baseCharge": 1649.06,
        "surcharges": [ {
            "name": "FUEL",
            "fee": 156.1
        },{
            "name": "LARGE_PACKAGE",
            "fee": 95
        } ],
        "currencyCode": "USD"
    } ],
    "documents": [ {
        "type": "SHIPPING_LABEL",
        "size": "DOC_8X11",
        "fileFormat": "PDF",
        "contentType": "URL",
        "contents": "https://.../ups/258499135/outbound/label/3fdc7fa973d748c19fa1c697d1a12eda.pdf"
        }
    ],
    "shipmentOptions": [ {
        "name": "PRINT_CUSTOM_MESSAGE_1",
        "value": "Geschenk"
    },{
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ],
    "customs": {
        "customsInfo": {
            "reasonForExport": "GIFT",
            "termsOfSale": "CIF",
            "customsDeclaredValue": 245,
            "currencyCode": "USD",
            "freightCharge": 0,
            "packingCosts": 0,
            "handlingCosts": 0,
            "otherCharge": 0,
            "shippingDocumentType": "NAFTA",
            "EELPFC": "NOEEI 30.37(j)"
        },
        "customsItems": [ {
            "description": "Product no 1 - Type A",
            "quantity": 1,
            "quantityUOM": "lb",
            "unitPrice": 245,
            "unitWeight": {
                "unitOfMeasurement": "OZ",
                "weight": 1
            },
            "originStateProvince": "PA",
            "originCountryCode": "US",
            "preferenceCriterion": "A",
            "producerDetermination": "NO_1",
            "netCostMethod": "NET_COST",
            "producerAddress": {
                "company": "Fairmont  Groups",
                "name": "Fairmont Vancouver",
                "phone": "6046911991",
                "email": "",
                "addressLines": [ "900 Canada Pl" ],
                "cityTown": "Vancouver",
                "stateProvince": "BC",
                "postalCode": "V6C 3L5",
                "countryCode": "CA"
            },
            "producerId": "CANADA",
            "hSTariffCode": "PR0001"
        } ]
    },
    "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"
    },
    "shipmentId": "UPS2200171201666166",
    "parcelTrackingNumber": "<tracking-number>"
}


Sample UPS Label

Sample UPS Label


Sample UPS Control Log

Sample UPS Control Log

Error Codes

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