Create a PB Standard Returns Label

HTTP Request

POST /v1/shipments

Summary

This operation creates a Pitney Bowes Standard Returns label a buyer can use to return a parcel. The label is a post-paid label and incurs no charges unless used. The label contains a USPS-compliant barcode and can be tracked via the Tracking API.

The API provides the option to create a QR code the buyer can bring to a Post Office or other facility to print the label. QR codes allow merchants and buyers to use this service without having a printer. If you provide the buyer a QR code, you can use the Carrier Facility API to provide the buyer with nearby USPS facilities that accept QR codes.

A buyer who has a printer can also print the label by entering the QR code’s Label ID at the USPS Label Broker™ site: https://tools.usps.com/label-broker.htm

Prerequisites

To print Standard Returns labels, a merchant must be enrolled with a PB Standard facility and have received a set of PB Standard IDs. The merchant’s postage account must be enabled for the PB Standard service. Please see the Onboard a Merchant instructions 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 PB Standard Returns service is a post-paid service. Postage is not charged at the time of print.

  2. Standard Returns are supported for domestic shipments only.

  3. Standard Returns use PB Standard as the carrier.

  4. Standard Returns use the Parcel Select Return (PRCLSEL) as the mail class and use package (PKG) as the parcel type. Standard Returns do not support special services.

  5. When issuing the API, you specify whether to create a label or QR code by specifying either SHIPPING_LABEL or QR_CODE in the documents.type field.

  6. If you choose to create a QR code, you can use the Carrier Facility API to provide the buyer with nearby USPS facilities that accept QR codes.

  7. When issuing the API, you must set the following:

    Field

    Value
    shipmentType RETURN
    fromAddress

    The address of the buyer who is returning the parcel. The fromAddress must include one of the following fields:

    • postalCode or
    • cityTown and stateProvince
    toAddress

    The merchant’s address. The API will replace this address with the closest PB Standard facility. The toAddress requires the following fields:

    • postalCode
    • countryCode

    Note that the response returns a different toAddress than the one you send in the request. The response specifies PITNEY BOWES RETURNS in the toAddress.

    parcel.dimension

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

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

    rates.carrier NEWGISTICS (which indicates PB Standard)
    rates.serviceId PRCLSEL
    rates.parcelType PKG
    documents.type
    • To return a label, set this to: SHIPPING_LABEL
    • To return a QR code, set this to: QR_CODE
    documents.size
    • To return a label, set this to: DOC_4X6
    • To return a QR code, do not use this field. This field does not apply to QR codes.
    documents.fileFormat
    • To return a label, see this table for formats compatible with 4X6 labels.
    • To return a QR code, set this to: GIF
    documents.contentType
    • To return a label, see this table for content types compatible with 4X6 labels.
    • To return a QR code, set this to: BASE64
    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.

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

  9. Labels retrieved through URLs are available for 24 hours after label creation.

  10. The API returns a parcel tracking number you can use to track the label via the Tracking API.

  11. You can retry and reprint PB Standard Returns labels.

  12. If your request returns the HTTP 500 Internal Server Error, see Troubleshoot the 500 Internal Server Error.

    For other errors, do not resubmit the request without first checking whether the label was created through the Retry API.

Request URIs

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

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.
Accept-Language Language and country code. Default: en-US
X-PB-TransactionId

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

Important: You must ensure this is a unique id.

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.

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.

Sample Requests

See the following examples:

Create a Standard Returns Label

The following request creates a Standard Returns label.

Request to Create a Standard Returns Label
curl -X POST .../v1/shipments \
-H "Authorization: Bearer <oauth_token>" \
-H "Content-Type: application/json" \
-H "Accept-Language: en-US" \
-H "X-PB-TransactionId: <unique_transaction_id>" \
-d '
{
    "shipmentType": "RETURN",
    "fromAddress": {
        "name": "Mark Twain",
        "phone": "2035551212",
        "email": "mark@example.com",
        "addressLines": [ "351 Farmington Ave" ],
        "cityTown": "Hartford",
        "stateProvince": "CT",
        "postalCode": "06105",
        "countryCode": "US"
    },
    "toAddress": {
        "postalCode": "67401",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 38
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": 8,
            "width": 4,
            "height": 6
        }
    },
    "rates": [ {
        "carrier": "NEWGISTICS",
        "serviceId": "PRCLSEL",
        "parcelType": "PKG"
    } ],
    "documents": [ {
        "type" : "SHIPPING_LABEL",
        "contentType" : "URL",
        "size" : "DOC_4X6",
        "fileFormat" : "PDF",
        "printDialogOption" : "NO_PRINT_DIALOG"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    },{
        "name": "CLIENT_ID",
        "value": "1234"
    },{
        "name": "RETURN_ID",
        "value": "123456789"
    } ]
}'
Response
{
    "fromAddress": {
        "company": "",
        "name": "Mark Twain",
        "phone": "2035551212",
        "email": "mark@example.com",
        "residential": false,
        "addressLines": [
            "351 Farmington Ave"
        ],
        "cityTown": "Hartford",
        "stateProvince": "CT",
        "postalCode": "06105-6400",
        "countryCode": "US",
        "deliveryPoint": "51"
    },
    "toAddress": {
        "name": "PITNEY BOWES RETURNS",
        "addressLines": [
            "Allbirds Returns",
            "",
            ""
        ],
        "postalCode": "56901"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 38.0
        },
        "dimension": {
            "length": 8.0,
            "width": 4.0,
            "height": 6.0,
            "unitOfMeasurement": "IN",
            "irregularParcelGirth": 0.0
        }
    },
    "rates": [ {
        "carrier": "NEWGISTICS",
        "parcelType": "PKG",
        "specialServices": [],
        "serviceId": "PRCLSEL"
    } ],
    "documents": [ {
        "contentType": "URL",
        "contents": "https://.../f42be533cef48c09f76c1908c78a074.pdf",
        "fileFormat": "PDF",
        "size": "DOC_4X6",
        "type": "SHIPPING_LABEL"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    },{
        "name": "CLIENT_ID",
        "value": "1234"
    },{
        "name": "RETURN_ID",
        "value": "123456789"
    },{
        "name": "CLIENT_SERVICE_FLAG",
        "value": "Standard"
    },{
        "name": "SMART_LABEL_BARCODE",
        "value": "7225108105012404020000000195465722I"
    } ],
    "parcelTrackingNumber": "9202390100763900000012487",
    "shipmentId": "NGST220023889032700"
}

Create a Returns Label QR Code

The following request creates a QR code that can be used to print a Standard Returns label.

Request to Create a Returns Label QR Code
curl -X POST .../v1/shipments \
-H "Authorization: Bearer <oauth_token>" \
-H "Content-Type: application/json" \
-H "Accept-Language: en-US" \
-H "X-PB-TransactionId: <unique_transaction_id>" \
-d '
{
    "shipmentType": "RETURN",
    "fromAddress": {
        "name": "Mark Twain",
        "phone": "2035551212",
        "email": "mark@example.com",
        "addressLines": [ "351 Farmington Ave" ],
        "cityTown": "Hartford",
        "stateProvince": "CT",
        "postalCode": "06105",
        "countryCode": "US"
    },
    "toAddress": {
        "postalCode": "67401",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 38
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": 8,
            "width": 4,
            "height": 6
        }
    },
    "rates": [ {
        "carrier": "NEWGISTICS",
        "serviceId": "PRCLSEL",
        "parcelType": "PKG"
    } ],
    "documents": [ {
        "type": "QR_CODE",
        "fileFormat": "GIF",
        "contentType": "BASE64"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    },{
        "name": "CLIENT_ID",
        "value": "1234"
    },{
        "name": "RETURN_ID",
        "value": "123456789"
    } ]
}'
Response
{
    "fromAddress": {
        "company": "",
        "name": "Mark Twain",
        "phone": "2035551212",
        "email": "mark@example.com",
        "residential": false,
        "addressLines": [
            "351 Farmington Ave"
        ],
        "cityTown": "Hartford",
        "stateProvince": "CT",
        "postalCode": "06105-6400",
        "countryCode": "US",
        "deliveryPoint": "51"
    },
    "toAddress": {
        "name": "PITNEY BOWES RETURNS",
        "addressLines": [
            "Allbirds Returns",
            "",
            ""
        ],
        "postalCode": "56901"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 38.0
        },
        "dimension": {
            "length": 8.0,
            "width": 4.0,
            "height": 6.0,
            "unitOfMeasurement": "IN",
            "irregularParcelGirth": 0.0
        }
    },
    "rates": [ {
        "carrier": "NEWGISTICS",
        "parcelType": "PKG",
        "specialServices": [],
        "serviceId": "PRCLSEL"
    } ],
    "documents": [ {
        "contentType": "BASE64",
        "contents": "R0lGODlhWAJYAvAAAAAAAP///ywAAA...",
        "fileFormat": "GIF",
        "type": "QR_CODE"
    } ],
    "shipmentOptions": [ {
        "name": "CLIENT_ID",
        "value": "1234"
    },{
        "name": "CLIENT_SERVICE_FLAG",
        "value": "Standard"
    },{
        "name": "DISPOSITION_RULESET_ID",
        "value": "1"
    },{
        "name": "MINIMAL_ADDRESS_VALIDATION",
        "value": "true"
    },{
        "name": "RETURN_ID",
        "value": "123456789"
    },{
        "name": "SHIPPER_ID",
        "value": "9024324564"
    },{
        "name": "SMART_LABEL_BARCODE",
        "value": "7281006105012404002030000019584657I"
    },{
        "name": "LABEL_ID",
        "value": "93R64M6C"
    } ],
    "parcelTrackingNumber": "9204490188763900000012107",
    "shipmentId": "NGST2200238188944327"
}

Sample PB Standard Returns Label

Sample PB Standard Returns Label

QR Code

A QR code is a two-dimensional barcode a buyer can use to print a PB Standard Returns label at a Post Office or other label-printing facility. The buyer either scans the QR code or enters the QR code label ID. To provide a buyer with a list of nearby facilities that print labels from QR codes, use the Carrier Facility API. A buyer who has a printer can print a label by entering the QR code’s Label ID at the USPS Label Broker™ site: https://tools.usps.com/label-broker.htm

The following is a sample QR code:

Sample QR Code

Error Codes

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