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 Standard Delivery, 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 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 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:
Note: This parameter is not available for PB Standard Delivery. |
carrier |
CBDS International Outbound 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 / Response Elements¶
Important
Please see the Considerations above before issuing this API call.
Required fields are marked Required. All other fields are optional, except fields marked RESPONSE ONLY, which appear only in the response.
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] |
Required. Specifies the carrier, service, and parcel type. In the response, this field also contains the service charges. In the request, the For available services and parcel types for your carrier, see the carrier’s reference page. 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:
The SHIPPER_ID shipment option is required. Set this to the merchant’s Shipper ID. For all available options, see Shipment Options. Note that in some cases the API leaves the PB Standard Delivery requires the following shipment options in addition to SHIPPER_ID:
|
||||||||||
customs |
Object |
For shipments that use customs forms, this object contains customs information. For required elements, see your carrier’s Create Shipment page. |
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 Standard Delivery Sample 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"
} ]
}'
{
"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¶
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"
} ]
}
}
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.