Create a PB Standard Delivery Shipment

HTTP Request

POST /v1/shipments

Summary

This operation prints a domestic, post-paid label with a USPS-compliant barcode for a parcel that is part of a PB Standard Delivery (formerly Newgistics) shipment. Before shipping with PB Standard, please see the PB Standard page, which provides onboarding instructions, supported services, and other information.

Prerequisites

The merchant must be onboarded with PB Standard. Please see the onboarding steps on the PB Standard page.

Testing in Sandbox

You can test this API in the sandbox environment before onboarding a merchant. Use the Sandbox IDs listed in the PB Standard IDs table.

Things to Consider

  1. The label generated is a post-paid label. The label incurs no charges at time of print.

  2. PB Standard Delivery labels are supported for domestic shipments only. You cannot print a PB Standard Delivery label for an international destination.

  3. For the supported services, parcel types, and label sizes, see PB Standard.

  4. When issuing the API call, you must set the following:

    Field Requirement
    fromAddress,
    toAddress

    The following address fields are required:

    • addressLines
    • postalCode
    • countryCode
    • name
    rates.carrier Set this to NEWGISTICS, which indicates the carrier is PB Standard.
    parcel.dimension

    Set this to the correct dimensions. Dimensions are required for PB Standard Delivery shipments.

    Important: Entering incorrect dimensions might result in an undeliverable package or an additional postage fee.

    shipmentOptions

    The following shipment options are required:

    If you set an irregular parcel girth value in the parcel.dimension object, then you must include the IS_RECTANGULAR shipment option and set it to false.

  5. Pitney Bowes verifies addresses for accuracy against current USPS data and makes corrections to delivery lines and last lines when possible. You can optionally limit the extent of corrections by enabling minimal address validation through the MINIMAL_ADDRESS_VALIDATION shipment option. For a comparison of complete and minimal address validation, see What is minimal address validation?

    IMPORTANT: If you enable minimal address validation, the shipper takes 100% responsibility for any undelivered packages due to violation of carrier-addressing guidelines and is responsible for any surcharge or adjustment fee levied by the carrier for such a violation.

  6. To subscribe the shipment to notifications, include the NOTIFICATIONS special service in the request. The merchant must be configured for PB Standard notifications. For more information, see Notifications below.

  7. You can include merchant-defined reference fields in the shipment data and on the shipping label:

  8. To print any type of custom information on the label, whether a reference field or other information, set the PRINT_CUSTOM_MESSAGE_2 shipment option in the shipmentOptions array.

  9. PB Standard Delivery labels use 203 DPI by default. For label settings, see PB Standard Labels. If you use APAC Services, see Label Settings for APAC Services.

  10. The ADD_TO_MANIFEST shipment option is always considered true for PB Standard Delivery labels. If you set the option to false, the PB Shipping APIs ignore the setting and still consider the option to be true.

  11. To close out the day, see Create a PB Standard Manifest (Closeout).

Notifications

Merchants who are configured for PB Standard notifications can subscribe their shipments for notifications. To subscribe a shipment, include the NOTIFICATIONS special service in the rates.specialServices array. Configure the special service as follows:

  • Set specialServiceId to NOTIFICATIONS

  • Set the following parameters in the inputParameters array. All values are String values:

    Parameter Value
    RECIPIENT_NOTIFICATION_TYPE

    Required. The event for which to receive notifications. Set this to either of the following:

    • ON_INTRANSIT
    • ON_DELIVER
    RECIPIENT_NOTIFICATION_EMAIL Required. Enables email notification. Set this to the email address to receive notifications. You must use the same email address for all events. PB Standard accepts only one email address for all notifications.
    RECIPIENT_NOTIFICATION_PHONE Enables text notification. Enter the phone number as a string of continuous numbers, without spaces or punctuation. For example: 1234567890

For example:

"rates": [ {
    "specialServices": [ {
        "specialServiceId":"NOTIFICATIONS",
        "inputParameters":[ {
            "name":"RECIPIENT_NOTIFICATION_TYPE",
            "value":"ON_DELIVER"
        },{
            "name":"RECIPIENT_NOTIFICATION_EMAIL",
            "value":"widgets@example.com"
        },{
            "name":"RECIPIENT_NOTIFICATION_PHONE",
            "value":"8085551234"
        } ]
    }, ... ],
    ...
} ]

Note: To configure PB Standard notifications, contact your PB Standard implementation team or account manager.

Request URIs

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

URIs for APAC Services

For requests that originate in the Asia-Pacific region, Pitney Bowes provides APAC Services to optimize performance. To create a PB Standard Delivery shipment using APAC Services, use the URIs below. Note that if you use APAC Services to create a shipment, you must also use APAC Services if you manifest or void the shipment.

Sandbox URI APAC: https://apac-sandbox.shippingapi.pitneybowes.com/shippingservices/v1/shipments?carrier=Newgistics
Production URI APAC: https://apac.shippingapi.pitneybowes.com/shippingservices/v1/shipments?carrier=Newgistics

Query Parameter

Name Description
carrier APAC Services Only. If your PB Standard Delivery request originates in the Asia-Pacific region and if you use the URIs for APAC Services, you must set the carrier query parameter to Newgistics.

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-TransactionId

Required. A unique identifier for the transaction, up to 25 characters.

Important: You must ensure this is a unique id.

X-PB-UnifiedErrorStructure Recommended. Set this to true to use the standard error object if an error occurs.

Request / Response Elements

The API call sends and receives a Shipment Object. The following table describes all possible fields in a Shipment Object.

Important

Some fields in the Shipment Object do not apply to this operation and are marked accordingly.

Important

Please see Things to Consider on this page for the required values when making this request.

Name Data Type Description
fromAddress Address Object

Required. Origin address.

If you want a different address to appear on the label from the one listed here, see How do I print a return address that is different from the origin address?

toAddress Address Object

Required. Destination address.

FedEx, UPS: If you are shipping with FedEx or UPS to Puerto Rico or an international destination, and if the importer is different from the final recipient, this is the address of the importer. Enter the recipient’s address in the soldToAddress object. If importer’s address is the same as the final recipient, the toAddress and soldToAddress must match.

altReturnAddress Address Object

Applies only to the following:

  • USPS: If you are sending an international shipment through USPS and if you have set the NON_DELIVERY_OPTION shipment option to redirect, then enter the address that a returned parcel should go to.
  • CBDS: For a Create Shipment request, this is the address used to return a parcel from the CBDS Consolidation Center. If omitted, the fromAddress is used. The altReturnAddress is not returned in the response.
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]

Conditional. Defines the label, manifest, or other shipping document created by the API call.

This field is required except in the following cases:

  • This field does not apply to Rate Parcel requests.
  • This field does not apply to the Create CBDS Shipment request if the merchant prints the first-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 any additional requirements for a carrier or service, please see the Things to Consider section on the carrier’s Create Shipment page.

        name String The name of the shipment option.
        value String The value of the shipment option.
customs Object

Conditional. For shipments that use customs forms, this object contains the customs information. This field is required for the following carriers in the following situations:

  • USPS: Required for shipments to international destinations and to APO/FPO/DPO, Territories/Possessions, and FAS
  • 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
        customsInfo Customs Info Object Customs clearance information used to fill out a commercial invoice.
        customsItems Array[Customs Items Object]

Information about each commodity in the shipment, used for customs clearance.

The maximum number of objects in this array is 30.

domesticShipmentDetails Domestic Shipment Details Object CBDS Only. Required if the merchant prints the first-mile label prior to invoking the Create CBDS Shipment API. This object contains information about the first-mile leg of the shipment.
soldToAddress Address Object

Applies only to FedEx and UPS. This contains the final recipient of a United Parcel Service shipment. Required for a shipment from the U.S. to Puerto Rico or to an international destination. 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.

shipmentType String Return Labels Only. Set this to RETURN. Required for Expedited Returns and Standard Returns.
references Array[Object]

Merchant-defined values. Applies to the following:

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.

References Array in a PB Standard Shipment Request

The references array allows a merchant to include reference fields, such as order number or merchant ID, in the shipment data. The information entered in the references array will appear in manifest files and invoices.

The references array takes up to three objects. Each maps to a specific PB Standard field. The object’s position in the array determines which field. The first object maps to the PB Standard “ReferenceNumber” field; the second to the “AddlRef1” field; and the third to the “AddlRef2” field. For each object you include, enter the name string as shown below. If you enter a different string, the system system will change it. For each value field, enter a string of up to 50 characters. The following shows the reference field with the maximum three objects:

{
    "name": "ReferenceNumber",
    "value": "<shipper-generated value>"
}, {
    "name": "AddlRef1",
    "value": "<shipper-generated value>"
}, {
    "name": "AddlRef2",
    "value": "<shipper-generated value>"
}

Note that the values entered in the references array will not appear on shipping labels. To print reference fields on shipping labels, set the PRINT_CUSTOM_MESSAGE_2 shipment option in the shipmentOptions array.

Sample Request

curl -X POST .../v1/shipments \
-H "Authorization: Bearer l8wHkQKaBjC5VEaYldQnFXnzoqNj" \
-H "Content-Type: application/json" \
-H "X-PB-TransactionId: 5a2d2cf4-f2c4-41ba-91e2" \
-d '
{
    "fromAddress": {
        "company": "Supplies",
        "name": "Kathryn Smith",
        "phone": "334-000-0000",
        "email": "kathryn@example.com",
        "residential": false,
        "addressLines": [ "2352 Bent Creek Rd" ],
        "cityTown": "Auburn",
        "stateProvince": "AL",
        "postalCode": "36830",
        "countryCode": "US"
    },
    "toAddress": {
        "company": "Books",
        "name": "Jane",
        "phone": "785-000-0000",
        "email": "books@example.com",
        "residential": false,
        "addressLines": [ "400 S Santa Fe Ave" ],
        "cityTown": "Salina",
        "stateProvince": "KS",
        "postalCode": "67401",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": "32"
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": "10",
            "width": "4",
            "height": "6",
            "irregularParcelGirth": "20"
        }
    },
    "rates": [ {
        "carrier": "NEWGISTICS",
        "serviceId": "PRCLSEL",
        "parcelType": "PKG",
        "specialServices": [ {
            "specialServiceId": "DelCon"
        }, {
            "specialServiceId":"NOTIFICATIONS",
            "inputParameters":[ {
                "name":"RECIPIENT_NOTIFICATION_TYPE",
                "value":"ON_DELIVER"
            },{
                "name":"RECIPIENT_NOTIFICATION_EMAIL",
                "value":"kathryn@example.com"
            } ]
        } ]
    } ],
    "documents": [ {
        "type": "SHIPPING_LABEL",
        "contentType": "BASE64",
        "size": "DOC_4X6",
        "fileFormat": "ZPL2"
    } ],
    "references": [ {
        "name": "ReferenceNumber",
        "value": "OR1234"
    }, {
        "name": "AddlRef1",
        "value": "CC123456"
    }, {
        "name": "AddlRef2",
        "value": "CC4321"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    }, {
        "name": "IS_RECTANGULAR",
        "value": "false"
    }, {
        "name": "CLIENT_FACILITY_ID",
        "value": "0093"
    }, {
        "name": "CARRIER_FACILITY_ID",
        "value": "1585"
    }, {
        "name": "NON_DELIVERY_OPTION",
        "value": "ChangeServiceRequested"
    } ]
}'

Sample Response

{
    "fromAddress": {
        "company": "Supplies",
        "name": "Kathryn Smith",
        "phone": "334-000-0000",
        "email": "kathryn@example.com",
        "residential": false,
        "addressLines": [
            "2352 Bent Creek Rd"
        ],
        "cityTown": "Auburn",
        "stateProvince": "AL",
        "postalCode": "36830-6433",
        "countryCode": "US",
        "deliveryPoint": "52"
    },
    "toAddress": {
        "company": "Books",
        "name": "Jane",
        "phone": "785-000-0000",
        "email": "books@example.com",
        "residential": false,
        "addressLines": [
            "400 S Santa Fe Ave"
        ],
        "cityTown": "Salina",
        "stateProvince": "KS",
        "postalCode": "67401-4144",
        "countryCode": "US",
        "deliveryPoint": "21"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 32.0
        },
        "dimension": {
            "length": 10.0,
            "width": 4.0,
            "height": 6.0,
            "unitOfMeasurement": "IN",
            "irregularParcelGirth": 20.0
        }
    },
    "rates": [ {
        "carrier": "NEWGISTICS",
        "parcelType": "PKG",
        "specialServices": [ {
            "specialServiceId": "DelCon",
            "inputParameters": []
        }, {
            "specialServiceId":"NOTIFICATIONS",
            "inputParameters":[ {
                "name":"RECIPIENT_NOTIFICATION_TYPE",
                "value":"ON_DELIVER"
            },{
                "name":"RECIPIENT_NOTIFICATION_EMAIL",
                "value":"kathryn@example.com"
            } ]
        } ],
        "serviceId": "PRCLSEL"
    } ],
    "documents": [ {
        "type": "SHIPPING_LABEL",
        "contentType": "BASE64",
        "fileFormat": "ZPL2",
        "pages": [ {
            "contents": "XlhBXkxIMCwxNX5TRDIwXkxSTl5DSTI3Xk..."
        } ]
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    }, {
        "name": "IS_RECTANGULAR",
        "value": "false"
    }, {
        "name": "CLIENT_FACILITY_ID",
        "value": "0093"
    }, {
        "name": "CARRIER_FACILITY_ID",
        "value": "1585"
    }, {
        "name": "NON_DELIVERY_OPTION",
        "value": "ChangeServiceRequested"
    } ],
    "references": [ {
        "name": "ReferenceNumber",
        "value": "OR1234"
    }, {
        "name": "AddlRef1",
        "value": "CC123456"
    }, {
        "name": "AddlRef2",
        "value": "CC4321"
    } ],
    "shipmentId": "NGST2200744454",
    "parcelTrackingNumber": "4209004692612123456789000000130487"
}

Sample PB Standard Delivery Label

  • The top of label displays the Return Address, the Endorsement (for example: “Return Service Requested”), and the Ship To Address.
  • The middle of label displays the Mail Class (for example: Parcel Select) and displays information used internally by PB Standard.
  • The bottom of label displays the USPS Tracking Barcode and the Delivery Post Office.
Sample PB Standard Delivery Label

Error Codes

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