Rate a Package

HTTP Request

POST /v1/rates

Summary

Use this operation to rate a package before printing and purchasing a shipment label. The API lets you rate a package for multiple services and multiple parcel types with a single request.

Things to Consider

  1. To rate a package for multiple services and multiple parcel types at once, omit both the rates.serviceId and rates.parcelType fields. The response’s rates array will contain a separate rates object for each combination of service and parcel type rated.
  2. To rate a package for multiple services but for a single parcel type, omit the rates.serviceId field but keep the rates.parcelType field. The returned rates array will contain a separate rates object for each service rated.
  3. To rate a package for a single service, keep both the rates.serviceId and rates.parcelType fields and ensure the service and parcel type are compatible. Check compatibility in Supported Services & Parcel Types.
  4. When issuing the API call, you can pass only one rates object in the rates array, as shown in the sample request. The response, however, can contain multiple rates objects in the array if the package was rated for multiple services.
  5. The PB Shipping 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.

Request URIs

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

Query Parameter

The query parameter is optional.

Name Data Type Description
includeDeliveryCommitment Boolean Returns estimated transit times, in days, when set to true.

Request Headers

Name Data Type Description
Authorization String Required. OAuth Token generated using the Generate an OAuth Token API.
Content-Type String Required. The media type of the request entity. Set this to application/json.
X-PB-Shipper-Rate-Plan String Shipper rate plan, if applicable. For more information, see this FAQ.
X-PB-Integrator-CarrierId String Negotiated services rate, if applicable.

Request / Response Elements

The API call sends and receives a shipment object. The table below lists all possible fields a shipment object. Some fields might not apply to this 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.
altReturnAddress address object International Shipments Only. If you are sending an international shipment 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] A list of shipment documents pertaining to a shipment, including the label. This field does not apply to Rate a Package requests.
shipmentOptions Array[Object]

Each object in this array defines a shipment option. The available options depend on the carrier, origin country, and destination country.

Required if you are creating a shipment. For shipments the array must contain the SHIPPER_ID option. Other requirements might also apply, depending on the type of shipment.

        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

Applies only to these shipments:

  • International
  • APO/FPO/DPO
  • Territories/Possessions
  • FAS

This field contains customs information.

shipmentType String SBR Labels Only. If you are creating a 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.

Request / Response Elements: Rates Object

The rates array takes one rates object in a request and can return multiple rates objects in a response. Each rates object in a response shows a different rating option.

Name Data Type Description
carrier String

Required. Carrier name. Possible values are:

  • USPS
  • NEWGISTICS
  • PBPRESORT

Note: For the Rates API call, not all values apply.

serviceId String

The ID for the carrier service.

Required if you are creating a shipment. Optional if you are rating a package.

To check which special services and parcel types can be used with the service, see Supported Services & Parcel Types.

To determine any additional restrictions on a service, use the Carrier Rules API. See also the USPS Domestic Mail Manual.

Note: The PB Shipping APIs require that all parcels be trackable. If the parcel uses a service that is not trackable, such as Priority Mail, you must add at least one trackable special service, such as Delivery Confirmation (DelCon). DelCon is a no-charge special service that triggers tracking but does not increase the cost of the shipment.

parcelType String

The carrier parcel type.

Required if you are creating a shipment; optional if you are rating a package.

specialServices Array[Object]

The special services to be applied.

IMPORTANT: Including a special service in this array means you intend to apply the special service.

    specialServiceId String

The abbreviated name of the special service to apply.

IMPORTANT: Do not include a special service unless you intend to apply it.

    inputParameters Array[Object]

The parameters, if any, to set for the special service, such as minimum and maximum values.

To view available parameters and whether parameters are required, issue the Carrier Rules API and locate the special service for the given combination of service and parcel type. The special service’s inputParameterRules array lists the parameter rules. To view how the rules map to this field, see How do I know the input parameters for a special service?.

PMOD: If specialServiceId is set to PMOD_OPTIONS, the inputParameters array must contain each option listed in PMOD Options.

            name String The name of the input parameter. This maps to the inputParameterRules.name field in the Carrier Rules API.
            value String The value of the parameter. The possible values are listed in the inputParameterRules array in the Carrier Rules API.
    fee
Double Response Only. The amount of fee expressed in the currency of the origin country.
inductionPostalCode String

Postal code where the shipment is tendered to the carrier. Postal code of Shipment fromAddress is used in absence of this field.

When an inductionPostalCode is present, this postal code is used instead of the postal code in the shipment’s fromAddress when calculating rates and when determining if the shipment can be added to a manifest.

Note: Not applicable to Newgistics or PB Presort.

dimensionalWeight Object

Response Only. If the dimensionalWeight.weight field has a value other than 0, dimensional-weight pricing applies to the shipment. In general, if a parcel is large and relatively light for its size, it might be subject to dimensional-weight pricing. Dimensional weight, or DIM weight, is calculated based on volume and a volumetric divisor. For information on how USPS calculates DIM weight, see https://www.usps.com/dimensionalweight/.

Note: A parcel might alternatively be subject to balloon or oversize pricing, as explained in the surcharges field below.

    weight Double The calculated DIM weight. For information on how USPS calculates DIM weight, see https://www.usps.com/dimensionalweight/.
    unitOfMeasurement String

The unit of measure for the calculated DIM weight. Possible values:

  • GM: Grams
  • OZ: Ounces
baseCharge Double

Response Only. The base service charge payable to the carrier, excluding special service charges. If your request includes a shipper rate plan, please see this FAQ for information on whether the shipper rate affects this field.

Note: This field is not applicable to Newgistics or PB Presort.

totalCarrierCharge Double

Response Only. The total amount payable to the carrier, including special service charges. If your request includes a shipper rate plan, please see this FAQ for information on whether the shipper rate affects this field.

Note: This field is not applicable to Newgistics or PB Presort.

surcharges Array[Object] Response Only. A fee charged if balloon pricing or oversized pricing applies.
    name String

The type of pricing used to calculate the surcharge. Possible values are:

  • balloon: The balloon price applies if all the following are true:
    • The parcel uses Priority Mail (Zones 1-4) or Parcel Select (all zones).
    • The parcel weighs less than 20 pounds.
    • The parcel’s combined length plus girth falls between 84 and 108 inches.
  • oversize: The oversized price applies if the parcel’s combined length plus girth falls between 108 and 130 inches.
    fee Double The amount of the surcharge.
alternateBaseCharge Double

Response Only. Applies only if your request includes a shipper rate plan and if the shipper does not have an NSA.

The value is the base service charge payable by the shipper, excluding special service charges. The rate is based on the plan specified in the X-PB-Shipper-Rate-Plan parameter.

If the shipper has an NSA, do not use this field. Use the response’s baseCharge field instead. For more information, see this FAQ.

Note: This field is not applicable to Newgistics or PB Presort.

alternateTotalCharge Double

Response Only. Applies only if your request includes a shipper rate plan and if the shipper does not have an NSA.

The value is the total charge payable by the shipper, including special service charges. The rate is based on the plan specified in the X-PB-Shipper-Rate-Plan parameter.

If the shipper has an NSA, do not use this field. Use the response’s totalCarrierCharge field instead. For more information, see this FAQ.

Note: This field is not applicable to Newgistics or PB Presort.

deliveryCommitment Object

Response Only. Time in transit for the shipment.

See also: Pitney Bowes Complete Delivery

Note: Not applicable to Newgistics or PB Presort.

    minEstimatedNumberOfDays String The minimum number of delivery days.
    maxEstimatedNumberOfDays String The maximum number of delivery days.
    estimatedDeliveryDateTime String The estimated delivery date and time.
    guarantee String States whether the carrier deliver is guaranteed.
    additionalDetails String These are carrier specific details that may be provided.
currencyCode String

Type of currency referenced in the piece price. For example: USD, CAD, EUR

Note: Not applicable to Newgistics or PB Presort.

destinationZone
Number

Response Only. Destination Zone based on the fromAddress and toAddress specified.

Note: Not applicable to Newgistics or PB Presort.

Sample Request

curl -X POST .../v1/rates?includeDeliveryCommitment=false \
-H "Authorization: Bearer <oauth_token>" \
-H "Content-Type: application/json" \
-d '
{
    "fromAddress": { ... },
    "toAddress": { ... },
    "parcel": {
        "weight": {
            "weight": 1,
            "unitOfMeasurement": "OZ"
        },
        "dimension": {
            "length": 5,
            "width": 0.25,
            "height": 4.0,
            "unitOfMeasurement": "IN",
            "irregularParcelGirth": 1.0
        }
    },
    "rates": [ {
        "carrier": "USPS",
        "parcelType": "PKG",
        "inductionPostalCode": "06484"
    } ]
}'

Sample Response

{
    "fromAddress": { ... },
    "toAddress": { ... },
    "parcel": {
        "weight": {
            "weight": 1,
            "unitOfMeasurement": "OZ"
        },
        "dimension": {
            "length": 5,
            "width": 0.25,
            "height": 4.0,
            "unitOfMeasurement": "IN",
            "irregularParcelGirth": 1.0
        }
    },
    "rates": [ {
        "carrier": "USPS",
        "parcelType": "PKG",
        "serviceId": "EM",
        "dimensionalWeight": {
            "weight": 0.0,
            "unitOfMeasurement": "OZ"
        },
        "totalCarrierCharge": 39.45,
        "baseCharge": 39.45,
        "deliveryCommitment": {
            "minEstimatedNumberOfDays": "3",
            "maxEstimatedNumberOfDays": "5",
            "estimatedDeliveryDateTime": "",
            "guarantee": "NONE",
            "additionalDetails": "3 - 5 business days to many major markets"
        },
        "currencyCode": "USD"
    }, {
        "carrier": "USPS",
        "parcelType": "PKG",
        "serviceId": "PM",
        "dimensionalWeight": {
            "weight": 0.0,
            "unitOfMeasurement": "OZ"
        },
        "totalCarrierCharge": 39.45,
        "baseCharge": 39.45,
        "deliveryCommitment": {
            "minEstimatedNumberOfDays": "3",
            "maxEstimatedNumberOfDays": "5",
            "estimatedDeliveryDateTime": "",
            "guarantee": "NONE",
            "additionalDetails": "3 - 5 business days to many major markets"
        },
        "currencyCode": "USD"
    } ]
}

Error Codes

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