Rate a Parcel

HTTP Request

POST /v1/rates

Summary

Use this operation to rate a parcel before you print a shipment label.

Note

This API does not validate addresses.

Considerations

  1. You can rate parcels for the following labels:

  2. The rates array takes one Rates object in the request and returns one or more Rates objects in the response. Each object in the response shows a different rating option.

  3. To rate a parcel for a single service, include the rates.serviceId in the request. The response will return a single Rates object.

    PB Standard Delivery only: The rates.serviceId field is required.

  4. To rate a parcel for multiple services for a given parcel type, omit the rates.serviceId field from the request body. The response will contain a separate Rates object for each service rated.

    PB Standard Delivery only: You can rate a parcel for only one service at a time. The rates.serviceId field is required.

  5. PB Expedited only: To rate a parcel for multiple services and parcel types at once, omit both the rates.serviceId and rates.parcelType fields in the request. The response will contain a separate Rates object for each combination of service and parcel type rated.

  6. This API does not validate addresses.

  7. The fromAddress and toAddress objects require the following address fields:

    Carrier

    Required Fields

    PB Expedited

    postalCode
    countryCode

    PB Standard

    The fromAddress object requires the following fields:

    • addressLines

    • postalCode

    • countryCode

    The toAddress object requires the following fields:

    • name

    • addressLines

    • cityTown

    • stateProvince

    • postalCode

    • countryCode

    CBDS International Outbound

    name
    addressLines
    cityTown
    stateProvince
    countryCode

    UPS

    name
    postalCode
    countryCode

  8. The shipmentOptions array requires the SHIPPER_ID option. This ensures the API returns the correct rates. (Note that in some cases the API leaves the shipmentOptions array out of the response.)

  9. You can pass only one Rates object in the request body, as shown in the Sample Requests below.

  10. For available services and parcel types for your API request, see the carrier page for the carrier you are using.

  11. PB Expedited only: The PB Ecommerce APIs require that all parcels be trackable. If you are rating a service that is not trackable, such as Priority Mail (PM), add at least one trackable special service, such as Delivery Confirmation (DelCon). DelCon is a no-charge service that triggers tracking but does not increase the cost of the shipment. Before adding a special service, check its compatibility with the service.

  12. PB Standard Delivery only: The following additional fields are required in the request body:

    • parcel.weight

    • parcel.dimension

    • rates.carrier: Set this to PBCS.

    • rates.serviceId: Rating is available only for Parcel Select and Parcel Select Lightweight. Set this to either PRCLSEL (Parcel Select) or PSLW (Parcel Select Lightweight).

    • rates.parcelType: Set this to PKG.

    • shipmentOptions: You must include the following options:

  13. PB Standard Delivery only: In the response:

    • The rates.baseCharge equals the discounted transportation cost plus the Peak Parcel Adjustment fee (when applicable).

    • The rates.totalCarrierCharge is the sum of rates.baseCharge and rates.surcharges.

    • The rates.surcharges array shows only the fuel surcharge and does not show any other applicable surcharges.

Request URLs

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

Query Parameter

The query parameter is optional.

Name

Description

includeDeliveryCommitment

When set to true, returns estimated transit time. Transit time is returned as number of days.

Valid values:

  • true

  • false

Note: This parameter is not available for PB Standard Delivery.

carrier

CBDS International Outbound only. Required for CBDS. Set this to PBI.

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.

X-PB-Shipper-Rate-Plan

Shipper rate plan, if applicable. For more information, see this FAQ.

X-PB-Integrator-CarrierId

Negotiated services rate, if applicable.

X-PB-Shipper-Carrier-AccountId

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

Required if the merchant has registered multiple accounts for the same carrier. For more information, see Add Commercial Carrier Accounts.

X-PB-UnifiedErrorStructure

Recommended. Set this to true to use the standard error object if an error occurs.

Request / Response Elements

This POST operation sends and receives the Shipment object, described here. Required fields are marked Required. All other fields are optional, with two exceptions: 1. Fields that are marked RESPONSE ONLY appear only in the response. 2. Fields that are marked as applying only to certain carriers apply only to those carriers.

Name

Data Type

Description

shipmentType

String

Return Labels Only. For return labels, set this to RETURN.

  • Required: Expedited Returns, Standard Returns

  • Recommended: CBDS Returns

fromAddress

Address Object

Required. Origin address. If you want a different address to appear on the label from the one listed here, see this FAQ. The FAQ does not apply to PB Standard.

toAddress

Address Object

Required. Destination address.

If you are shipping to Puerto Rico or an international destination with FedEx or UPS, and if the importer is different from the final recipient, enter the address of the importer here in the toAddress object. For the address of the recipient, use the soldToAddress object. If the importer is the same as the final recipient, the toAddress and soldToAddress must match.

altReturnAddress

Address Object

For these carriers, sets an address for parcel returns:

  • PB Expedited: If you are sending an international shipment and if you have set the NON_DELIVERY_OPTION option to redirect, use this field to specify the address for a parcel return.

  • PB Presort

  • PMOD

  • CBDS Outbound & CBDS Domestic: By default, parcel returns are sent to a shipment’s fromAddress. (Parcel returns are sent from the CBDS Hub.) If the fromAddress is the wrong address for your returns, then you must use the altReturnAddress to enter the correct address for returns. Failure to do so will result returns to the wrong address.

  • FedEx

  • UPS

additionalAddresses

Array[Additional Addresses Object]

CBDS Returns Only. If the seller’s address is different from the toAddress, enter the seller’s address here.

Required if the toAddress and seller address are different.

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]

Required, except as noted below. Defines the label, manifest, or other shipping document created by the API call. In a response, this array provides the URL or Base64 string for a document and in some cases can contain multiple objects.

This field does not apply to:
- Rate Parcel API.
- Create CBDS Shipment API if the merchant prints the first-mile 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 additional requirements for a carrier, see the Considerations section on the carrier’s Create Shipment page.

shipmentOptions.name

String

The name of the shipment option.

shipmentOptions.value

String

The value of the shipment option.

customs

Object

For shipments that use customs forms, this object contains the customs information.

Required in the following situations:

  • PB Expedited: Required for shipments to international destinations. Conditional for shipments to APO/FPO/DPO, U.S. Territories, and FAS, as explained in this FAQ.

  • 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.

customs.customsInfo

Customs Info Object

Customs clearance information for the commercial invoice.

Required in the customs object.

customs.customsItems

Array[Customs Items Object]

Customs clearance information for each commodity.

Required in the customs object.

Maximum number of objects in the array: 30

domesticShipmentDetails

Domestic Shipment Details Object

CBDS Only. The first-mile label’s tracking number and other information about the first-mile leg.

Required if the merchant prints the first-mile label prior to invoking the API. Send the first-mile label’s tracking number and details.

RESPONSE ONLY for all other CBDS shipment requests.

references

Array[Object]

PB Standard & CBDS Only. Optional reference fields. Each object in the array includes a name-value pair that defines a reference field. See the following, depending on your carrier:

For carriers other than the above, see this FAQ.

hazmatDetails

Hazmat Details Object

PB Standard Only. If shipping hazardous materials with PB Standard, use this object.

carrierPayments

Array[Carrier Payments Object]

FedEx & UPS Only. If one or more of the shipment costs should be charged to a third-party account, enter the information in this array.

soldToAddress

Address Object

FedEx & UPS Only. The final recipient of a the shipment.

Required for shipments from the U.S. to Puerto Rico or international destinations. 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.

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

See the following examples:

PB Expedited Sample Request

PB Expedited Sample Rate Request
curl -X POST ".../v1/rates?includeDeliveryCommitment=true" \
-H "Authorization: Bearer <oauth_token>" \
-H "Content-Type: application/json" \
-H "X-PB-UnifiedErrorStructure: true" \
-d '
{
    "fromAddress": {
        "postalCode": "06484",
        "countryCode": "US"
    },
    "toAddress": {
        "postalCode": "28607",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 1
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": 6,
            "width": 2,
            "height": 4
        }
    },
    "rates": [ {
        "carrier": "USPS",
        "parcelType": "PKG",
        "specialServices": [ {
            "specialServiceId": "Ins",
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "50"
            } ]
        } ]
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ]
}'
PB Expedited Sample Rate Response
{
    "fromAddress": {
        "addressLines": [],
        "postalCode": "06484",
        "countryCode": "US"
    },
    "toAddress": {
        "addressLines": [],
        "postalCode": "28607",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 1.0
        },
        "dimension": {
            "length": 6.0,
            "width": 2.0,
            "height": 4.0,
            "unitOfMeasurement": "IN"
        }
    },
    "rates": [ {
        "carrier": "usps",
        "parcelType": "PKG",
        "specialServices": [ {
            "fee": 2.45,
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "50"
            } ],
            "specialServiceId": "Ins"
        } ],
        "deliveryCommitment": {
            "additionalDetails": "By end of Day",
            "estimatedDeliveryDateTime": "2021-11-22",
            "guarantee": "NONE",
            "maxEstimatedNumberOfDays": "3",
            "minEstimatedNumberOfDays": "3"
        },
        "serviceId": "FCM",
        "baseCharge": 3.36,
        "destinationZone": "4",
        "rateTypeId": "COMMERCIAL_BASE",
        "totalCarrierCharge": 5.81
    },
    ...
    ]
}

PB Standard Delivery Sample Request

PB Standard Delivery Sample Rate Request
curl -X POST ".../v1/rates" \
-H "Authorization: Bearer <oauth_token>" \
-H "Content-Type: application/json" \
-H "X-PB-UnifiedErrorStructure: true" \
-d '
{
    "fromAddress": {
        "addressLines": [ "27 Waterview Drive" ],
        "postalCode": "06484",
        "countryCode": "US"
    },
    "toAddress": {
        "name": "Jane Wilson",
        "addressLines": [ "643 Greenway RD" ],
        "cityTown": "Boone",
        "stateProvince": "NC",
        "postalCode": "28607",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 90
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": 8,
            "width": 4,
            "height": 6
        }
    },
    "rates": [ {
        "carrier": "PBCS",
        "serviceId": "PRCLSEL",
        "parcelType": "PKG",
        "specialServices": [ {
            "specialServiceId": "DelCon"
        } ]
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    },{
        "name": "CLIENT_ID",
        "value": "2689"
    },{
        "name": "CLIENT_FACILITY_ID",
        "value": "0093"
    },{
        "name": "CARRIER_FACILITY_ID",
        "value": "2594"
    } ]
}'
PB Standard Delivery Sample Rate Response
{
    "fromAddress": {
        "addressLines": [ "27 Waterview Drive" ],
        "postalCode": "06484",
        "countryCode": "US"
    },
    "toAddress": {
        "name": "Jane Wilson",
        "addressLines": [ "643 Greenway RD" ],
        "cityTown": "Boone",
        "stateProvince": "NC",
        "postalCode": "28607",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 90.0
        },
        "dimension": {
            "length": 8.0,
            "width": 4.0,
            "height": 6.0,
            "unitOfMeasurement": "IN"
        }
    },
    "rates": [ {
        "carrier": "PBCS",
        "parcelType": "PKG",
        "specialServices": [ {
            "specialServiceId": "DelCon"
        } ],
        "deliveryCommitment": {},
        "serviceId": "PRCLSEL",
        "baseCharge": 5.62,
        "destinationZone": "4",
        "surcharges": [ {
            "fee": 0.28,
            "name": "FUEL"
        } ],
        "totalCarrierCharge": 5.9
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    },{
        "name": "CLIENT_ID",
        "value": "2689"
    },{
        "name": "CLIENT_FACILITY_ID",
        "value": "0093"
    },{
        "name": "CARRIER_FACILITY_ID",
        "value": "2594"
    } ]
}

CBDS International Outbound Sample Request

CBDS International Outbound Sample Rate Request
curl -X POST ".../v1/rates?includeDeliveryCommitment=true&carrier=PBI" \
-H "Authorization: Bearer <oauth_token>" \
-H "Content-Type: application/json" \
-H "X-PB-UnifiedErrorStructure: true" \
-d '
{
    "fromAddress": { ... },
    "toAddress": { ... },

    "parcel": {
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": "12",
            "width": "5",
            "height": "10"
        },
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 80
        }
    },
    "rates": [ {
        "carrier": "PBI",
        "serviceId": "PBXPS",
        "parcelType": "PKG"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ],
    "customs": {
        "customsInfo": {
            "currencyCode": "USD"
        },
        "customsItems": [ {
            "description": "dress",
            "itemId": "B004LB5FB9",
            "quantity": 2,
            "unitPrice": 25,
            "url": "www.example.com/dress/a"
        },{
            "description": "dress",
            "itemId": "B004LB5FB4",
            "quantity": 2,
            "unitPrice": 35,
            "url": "www.example.com/dress/b"
        } ]
    }
}'
CBDS International Outbound Sample Rate Response
{
    "fromAddress": { ... },
    "toAddress": { ... },
    "parcel": {
        "dimension": {
            "length": 12,
            "height": 10,
            "width": 5,
            "unitOfMeasurement": "IN"
        },
        "weight": {
            "weight": 80,
            "unitOfMeasurement": "OZ"
        },
        "valueOfGoods": 120.00
    },
    "rates": [ {
        "carrier": "PBI",
        "serviceId": "PBXPS",
        "parcelType": "PKG",
        "baseCharge": 52.25,
        "totalCarrierCharge": 69.05,
        "deliveryCommitment": {
            "minEstimatedNumberOfDays": "6",
            "maxEstimatedNumberOfDays": "9"
        },
        "currencyCode": "USD",
        "totalTaxAmount": 16.80
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ],
    "customs": {
        "customsInfo": {
            "currencyCode": "USD"
        },
        "customsItems": [ {
            "itemId": "B004LB5FB9",
            "description": "dress",
            "quantity": 2,
            "unitPrice": 25.00,
            "url": "www.example.com/dress/a"
        }, {
            "itemId": "B004LB5FB4",
            "description": "dress",
            "quantity": 2,
            "unitPrice": 35.00,
            "url": "www.example.com/dress/b"
        } ]
    }
}

FedEx Sample Request

The following request omits the serviceId field in order to rate the parcel for multiple services.

FedEx Sample Rate Request
curl -X POST ".../v1/rates?includeDeliveryCommitment=true" \
-H "Authorization: Bearer <oauth_token>" \
-H "Content-Type: application/json" \
-H "Accept-Language: en-US"
-H "X-PB-Shipper-Carrier-AccountId: <unique_carrier_account_id>" \
-H "X-PB-UnifiedErrorStructure: true" \
-d '
{
    "fromAddress": { ... },
    "toAddress": { ... },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 8.0
        }
    },
    "rates": [ {
        "carrier": "FEDEX",
        "parcelType": "PKG"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ]
}'
FedEx Sample Rate Response
{
    "fromAddress": { ... },
    "toAddress": { ... },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 8.0
        }
    },
    "rates": [ {
        "carrier": "fedex",
        "parcelType": "PKG",
        "specialServices": [],
        "deliveryCommitment": {
            "additionalDetails": "By 12:00 of THU",
            "estimatedDeliveryDateTime": "2020-12-19 12:00:00",
            "guarantee": "FULL"
        },
        "serviceId": "2DA_AM",
        "baseCharge": 34.48,
        "currencyCode": "USD",
        "rateTypeId": "COMMERCIAL",
        "surcharges": [ {
            "fee": 2.85,
            "name": "DELIVERY_AREA"
        },{
            "fee": 2.8,
            "name": "FUEL"
        } ],
        "totalCarrierCharge": 40.13,
        "totalTaxAmount": 0.0
    },
    ...
    ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ]
}

UPS Sample Request

The following request omits the serviceId field in order to rate the parcel for multiple services.

UPS Sample Rate Request
curl -X POST ".../v1/rates?includeDeliveryCommitment=true" \
-H "Authorization: Bearer <oauth_token>" \
-H "Content-Type: application/json" \
-H "Accept-Language: en-US"
-H "X-PB-Shipper-Carrier-AccountId: <unique_carrier_account_id>" \
-H "X-PB-UnifiedErrorStructure: true" \
-d '
{
    "fromAddress": {
        "postalCode": "94105",
        "countryCode": "US"
    },
    "toAddress": {
        "postalCode": "28607",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 38
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": 6,
            "width": 4,
            "height": 4
        }
    },
    "rates": [ {
        "carrier": "UPS",
        "parcelType": "PKG"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ]
}'
UPS Sample Rate Response
{
    "fromAddress": {
        "addressLines": [],
        "postalCode": "94105",
        "countryCode": "US"
    },
    "toAddress": {
        "addressLines": [],
        "postalCode": "28607",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 38.0
        },
        "dimension": {
            "length": 6.0,
            "width": 4.0,
            "height": 4.0,
            "unitOfMeasurement": "IN"
        }
    },
    "rates": [ {
        "carrier": "ups",
        "parcelType": "PKG",
        "specialServices": [],
        "deliveryCommitment": {
            "estimatedDeliveryDateTime": "2021-11-29 23:00:00",
            "guarantee": "FULL",
            "maxEstimatedNumberOfDays": "5",
            "minEstimatedNumberOfDays": "5"
        },
        "serviceId": "GRD",
        "baseCharge": 14.03,
        "currencyCode": "USD",
        "rateTypeId": "COMMERCIAL",
        "surcharges": [ {
            "fee": 3.1,
            "name": "DELIVERY_AREA"
        },{
            "fee": 1.88,
            "name": "FUEL"
        } ],
        "totalCarrierCharge": 19.01
    },
    ...
    ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ]
}

Error Codes

For a list of all error codes returned by the Ecommerce APIs, please see Error Codes.