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¶
You can rate parcels for the following labels:
This API does not validate addresses.
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.
To rate a parcel for a single service, include the
rates.serviceId
field in the request. The response will return a single Rates object.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.PB Expedited only: To rate a parcel for multiple services and parcel types at once, omit both the
rates.serviceId
andrates.parcelType
fields in the request. The response will contain a separate Rates object for each combination of service and parcel type rated.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 ofrates.baseCharge
andrates.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 Valid values:
|
carrier |
CBDS only. Required for CBDS. Set this to |
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 |
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 |
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 |
||||||||||
fromAddress |
Required. The origin address. The following carriers require the following fields:
|
|||||||||||
toAddress |
Required. The destination address. The following carriers require the following fields:
|
|||||||||||
parcel |
Required. The parcel’s weight and dimensions. |
|||||||||||
rates |
Array[Rates Object] |
The following carriers have the following requirements:
|
||||||||||
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:
|
||||||||||
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: |
fromAddress |
The origin address. |
|
toAddress |
The destination address. |
|
parcel |
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 |
customs |
Object |
For shipments that use customs forms, this object contains customs information. |
Sample Requests¶
See the following examples:
PB Expedited Sample 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"
} ]
}'
{
"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¶
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"
} ]
}'
{
"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¶
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"
} ]
}
}'
{
"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¶
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"
}
]
}'
{
"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.
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"
} ]
}'
{
"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.
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"
} ]
}'
{
"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.