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. This API does not validate addresses.

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

    Important

    You can pass only one Rates object in the request body.

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

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

    Note that for PB Delivery services, the rates.serviceId is always required.

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

  7. PB Delivery services: Rating is available only for the following:

    • Parcel Select (PRCLSEL)

    In the rate PB Delivery response:

    • The rates.baseCharge equals the discounted transportation cost plus any of the following if applicable: Peak Parcel Adjustment fee, NMO charge, Oversize charge, Non-Continental Shipment fee.

    • 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

carrier

CBDS 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 Elements

Important

Please see the Considerations above before issuing this API call.

Required fields are marked Required. All other fields are optional.

Name

Data Type

Description

shipmentType

String

Return Labels Only. For return labels this field is required. Set this to RETURN.

fromAddress

Address Object

Required. The origin address. The following carriers require the following fields:

Carrier

Requirements

PB Expedited

  • postalCode

  • countryCode

PB Delivery

  • addressLines

  • postalCode

  • countryCode

CBDS

  • name

  • addressLines

  • cityTown

  • stateProvince

  • countryCode

UPS

  • name

  • postalCode

  • countryCode

toAddress

Address Object

Required. The destination address. The following carriers require the following fields:

Carrier

Requirements

PB Expedited

  • postalCode

  • countryCode

PB Delivery

  • name

  • addressLines

  • cityTown

  • stateProvince

  • postalCode

  • countryCode

CBDS

  • name

  • addressLines

  • cityTown

  • stateProvince

  • countryCode

UPS

  • name

  • postalCode

  • countryCode

parcel

Parcel Object

Required. The parcel’s weight and dimensions.

rates

Array[Rates Object]

Required. Specifies the carrier, service, and parcel type. The array takes only one rates object.
For available services and parcel types for your carrier, see the carrier reference pages.

Required. DELIVERY_SOLUTION: Enter the value for the shipment’s delivery solution as specified in the Delivery Solutions table above.

The following carriers have the following requirements:

Carrier

Requirements

PB Expedited

The 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 cost. Before adding a special service, check its compatibility.

PB Delivery

  • Set carrier to PBCS

  • Set serviceId to PRCLSEL (Parcel Select). Rating is available only for Parcel Select.

  • Set parcelType to PKG

shipmentOptions

Array[Object]

Required. Each object in this array defines a shipment option. Each object takes the following two fields, which take string values: - name: The shipment option. - value: The option’s value.

The SHIPPER_ID shipment option is required. Set this to the merchant’s Shipper ID. The following carriers require the following additional options in the following cases:

  • Required. DELIVERY_SOLUTION: Enter the value for the shipment’s delivery solution as specified in the Delivery Solutions table above.

  • PB Delivery requires the following shipment options in addition to SHIPPER_ID:

  • CBDS requires the SELLER_ID option if the shipper is a marketplace shipper who uses the same SHIPPER_ID for all sellers. Pass the ID the marketplace shipper has assigned to the seller.

customs

Object

For shipments that use customs forms, this object contains customs information. For required elements, see your carrier’s Create Shipment page.

Response Elements

Name

Data Type

Description

shipmentType

String

Return Labels Only. This returns the following: RETURN

fromAddress

Address Object

The origin address.

toAddress

Address Object

The destination address.

parcel

Parcel Object

The parcel’s weight and dimensions.

rates

Array[Rates Object]

The carrier, service, parcel type, and service charges.

shipmentOptions

Array[Object]

Each object in this array takes a name field and value field that define a shipment option. Note that in some cases, the API does not return the shipmentOptions array, even though the array was required in the request.

customs

Object

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

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 Delivery Sample Request

PB Delivery 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": {
        "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": "1234"
    },{
        "name": "CLIENT_FACILITY_ID",
        "value": "0093"
    },{
        "name": "CARRIER_FACILITY_ID",
        "value": "2594"
    } ]
}'
PB 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": {
            "maxEstimatedNumberOfDays": "4"
            "minEstimatedNumberOfDays": "3"
         },
        "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": "1234"
    },{
        "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"
        } ]
    }
}

CBDS Canada Domestic Sample Request

CBDS Canada Domestic Sample 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": {
          "name": "Quemby Gregory",
          "phone": "242-866-7265",
          "email": "seth.eaton@hotmail.net",
          "addressLines": [
               "77 Massachusetts Ave",
               "apt 2113"
         ],
          "cityTown": "Cambridge",
          "company": "TestCompany",
          "stateProvince": "ON",
          "postalCode": "L4V 1K9",
          "countryCode": "CA"
     },
      "toAddress": {
           "name": "Tanner Randolph",
           "phone": "606-968-4589",
           "email": "vincent.blevins@hotmail.edu",
           "addressLines": [
           "31st Ave NW"
        ],
          "cityTown": "DUNDAS",
          "stateProvince": "ON",
          "postalCode": "L9H 6Y1",
          "countryCode": "CA",
          "company": "Test Company1"
    },
          "parcel": {
          "weight": {
          "unitOfMeasurement": "Lb",
          "weight": "66"
   },
          "dimension": {
          "unitOfMeasurement": "in",
          "length": "5",
          "width": "2",
          "height": "3"
     }
    },
     "customs": {
        "customsInfo": {
          "currencyCode": "CAD"
     },
          "customsItems": [
          {
              "unitWeight": {
                   "unitOfMeasurement": "Lb",
              "weight": "66"
         },
              "itemId": "item0552",
              "url": "www.example.com/dress",
              "description": "dress",
              "quantity": 1,
              "unitPrice": "400",
              "originCountryCode": "US",
              "hSTariffCode": "6302600010",
              "hSTariffCodeCountry": "US"
           }
       ]
    },
    "rates": [
       {
           "carrier": "PBI",
          "serviceId": "PBDS",
          "parcelType": "PKG"
        }
      ],
      "shipmentOptions": [
         {
           "name": "SHIPPER_ID",
          "value": "3001852562"
      },
     {
         "name": "DELIVERY_SOLUTION",
          "value": "FIRSTMILE"
    }
  ]
}'
CBDS Canada Domestic Sample Rate Response
 {
      "fromAddress": {
           "addressLines": [
           "77 Massachusetts Ave",
           "apt 2113"
       ],
           "cityTown": "Cambridge",
           "stateProvince": "ON",
           "postalCode": "L4V 1K9",
           "countryCode": "CA",
           "company": "TestCompany",
           "name": "Quemby Gregory",
           "phone": "242-866-7265",
           "email": "seth.eaton@hotmail.net"
       },
       "toAddress": {
          "addressLines": [
               "31st Ave NW"
          ],
          "cityTown": "DUNDAS",
          "stateProvince": "ON",
          "postalCode": "L9H 6Y1",
          "countryCode": "CA",
          "company": "Test Company1",
          "name": "Tanner Randolph",
          "phone": "606-968-4589",
          "email": "vincent.blevins@hotmail.edu"
      },
      "parcel": {
          "dimension": {
              "length": 5,
              "height": 3,
              "width": 2,
              "unitOfMeasurement": "in"
      },
      "weight": {
          "weight": 66,
          "unitOfMeasurement": "Lb"
      },
      "valueOfGoods": 400
   },
   "rates": [
      {
          "carrier": "PBI",
          "serviceId": "PBDS",
          "parcelType": "PKG",
          "baseCharge": 27.39,
          "totalCarrierCharge": 28.14,
          "deliveryCommitment": {
              "minEstimatedNumberOfDays": "3",
              "maxEstimatedNumberOfDays": "7"
          },
          "currencyCode": "CAD",
          "destinationZone": 1,
          "surcharges": [
              {
                  "name": "FUEL",
                  "fee": 0.75
              }
          ]
       }
    ],
    "shipmentOptions": [
          {
              "name": "SHIPPER_ID",
              "value": "3001852562"
          },
         {
          "name": "DELIVERY_SOLUTION",
          "value": "FIRSTMILE"
         }
    ],
    "customs": {
          "customsInfo": {
              "currencyCode": "CAD"
     },
          "customsItems": [
              {
                  "itemId": "item0552",
                  "description": "dress",
                  "quantity": 1,
                  "unitPrice": 400,
                  "url": "www.example.com/dress",
                  "unitWeight": {
                  "weight": 66,
                  "unitOfMeasurement": "Lb"
              },
                  "originCountryCode": "US",
                  "hSTariffCode": "6302600010",
                  "hSTariffCodeCountry": "US"
          }
       ]
     }
  }'

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.