Create a PB Standard Returns Label

HTTP Request

POST /v1/shipments

Summary

This operation creates a Pitney Bowes Standard Returns label for a buyer to use if returning 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 Track a Package API. The label also contains a PB Standard Returns barcode. The label might also contain a third, custom barcode.

The API provides the option to create a QR code instead of a label. A QR code allows a buyer without a printer to print the label at a Post Office or other shipping facility. To provide the buyer with nearby facilities that print labels, issue the Carrier Facilities API.

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

Prerequisites

To create a PB Standard Returns label, a merchant must first onboard with PB Standard. When a merchant onboards, the merchant is enrolled with a PB Standard facility and receives a set of PB Standard IDs.

Testing in Sandbox

To test this API in the Sandbox environment, use the following values in the shipmentOptions array:

Shipment Option:
Value:
SHIPPER_ID Use any Shipper ID. If you have not yet onboarded a merchant, use the default Shipper ID that comes with your Developer Account.
CLIENT_ID NGST
RETURN_ID 123456789a

Things to Consider

  1. The PB Standard Returns service is a post-paid service. Postage is not charged at the time of label creation.

  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 the following:

    • addressLines
    • Either:
      • cityTown and stateProvince, or
      • postalCode
    toAddress

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

    • postalCode: This can be populated with any five numerical digits. For example 00000.
    • countryCode: Set this to US.

    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.weight The parcel.weight object is required, but the object can contain any number for the weight value. The actual weight value is determined during handling and need not be accurate in this object.
    rates.carrier NEWGISTICS (which indicates PB Standard)
    rates.serviceId PRCLSEL
    rates.parcelType PKG
    documents.type
    • To create a label, set this to: SHIPPING_LABEL
    • To create a QR code, set this to: QR_CODE
    documents.size
    • To create a label, see this table.
    • To create a QR code, do not use this field.
    documents.fileFormat
    • To create a label, see this table.
    • To create a QR code, set this to: GIF
    documents.contentType
    • To create a label, see this table.
    • To create a QR code, set this to: BASE64
    shipmentOptions

    The following shipment options are required:

    • SHIPPER_ID: The merchant’s Shipper ID.
    • CLIENT_ID: The merchant’s PB Standard Client ID.
      Note: When testing in the Sandbox environment, set this to NGST.
    • RETURN_ID: A merchant-generated identifier for the label. The identifier does not appear on the label.
      Note: When testing in the Sandbox environment, set this to 123456789a.
    • CLIENT_SERVICE_FLAG: Set this to Standard.
    • DISPOSITION_RULESET_ID: The ruleset (sort code) assigned to the merchant during onboarding for PB Standard Returns.

    Note: For the optional shipment options that apply to PB Standard Returns, see the Shipment Options page.

  8. The documents.customerData.labelDetails array allows merchants to perform additional functionalities, such as printing a custom barcode, printing custom human-readable text, or applying business rules. Merchants must set up the customizations in advance with their PB implementation teams.

  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 Track a Package 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.

  13. PB Standard Returns labels are not manifested.

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.

X-PB-Use-Merchant-Logo

If a merchant is configured to print a custom logo on PB Standard Returns labels, the custom logo is printed on the label by default. You can optionally leave the logo off a given label by setting this header to false.

To be configured to print custom logos on PB Standard Returns labels, merchants should contact their Pitney Bowes implementation teams.

Request / Response Elements

Important

The API call sends and receives a Shipment Object. The following table describes all possible fields in a Shipment Object. Some fields 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

USPS, CBDS Only. Applies as follows:

  • 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 or to APO/FPO/DPO, Territories/Possessions, or 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

FedEx, UPS Only. The final recipient of a the 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 Standard Returns Label

The following request creates a Standard Returns label. For a sample label, click here.

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": {
        "company": "Shop",
        "name": "Kathryn Smith",
        "phone": "334-000-0000",
        "email": "kathryn@example.com",
        "addressLines": [ "2352 Bent Creek Rd" ],
        "cityTown": "Auburn",
        "stateProvince": "AL",
        "postalCode": "36830",
        "countryCode": "US"
    },
    "toAddress": {
        "postalCode": "00000",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 0
        }
    },
    "rates": [ {
        "carrier": "NEWGISTICS",
        "serviceId": "PRCLSEL",
        "parcelType": "PKG"
    } ],
    "documents": [ {
        "type": "SHIPPING_LABEL",
        "size": "DOC_4X6",
        "contentType": "URL",
        "fileFormat": "PDF",
        "resolution": "DPI_300",
        "customerData": {
            "labelDetails": [ {
                "name": "<custom_value>",
                "value": "<custom_value>"
            } ]
        },
        "printDialogOption" : "NO_PRINT_DIALOG"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    },{
        "name": "CLIENT_ID",
        "value": "NGST"
    },{
        "name": "RETURN_ID",
        "value": "123456789a"
    },{
        "name": "CLIENT_SERVICE_FLAG",
        "value": "Standard"
    },{
        "name": "DISPOSITION_RULESET_ID",
        "value": "1"
     } ]
}'
Response for a Standard Returns Label
{
    "fromAddress": {
        "company": "Shop",
        "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": {
        "name": "PITNEY BOWES RETURNS",
        "addressLines": [
            "PARCEL RETURN SERVICE",
            "",
            ""
        ],
        "postalCode": "56901"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 0.0
        }
    },
    "rates": [ {
        "carrier": "NEWGISTICS",
        "parcelType": "PKG",
        "specialServices": [],
        "serviceId": "PRCLSEL"
    } ],
    "documents": [ {
        "contentType": "URL",
        "contents": "https://.../f42be533cef48c09f76c1908c78a074.pdf",
        "customerData": {
            "labelDetails": [ {
                "name": "<custom_value>",
                "value": "<custom_value>"
            } ],
        },
        "fileFormat": "PDF",
        "size": "DOC_4X6",
        "type": "SHIPPING_LABEL"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    },{
        "name": "CLIENT_ID",
        "value": "NGST"
    },{
        "name": "RETURN_ID",
        "value": "123456789a"
    },{
        "name": "CLIENT_SERVICE_FLAG",
        "value": "Standard"
    },{
         "name": "DISPOSITION_RULESET_ID",
         "value": "1"
    },{
        "name": "SMART_LABEL_BARCODE",
        "value": "7225108105012404020000000195465722I"
    } ],
    "parcelTrackingNumber": "9202390100763900000012487",
    "shipmentId": "NGST220023889032700"
}

Create a Standard Returns Label QR Code

The following request creates a QR code that can be used to print a Standard Returns label. For a sample QR code, click here.

Request to Create a Standard 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": {
        "company": "Shop",
        "name": "Kathryn Smith",
        "phone": "334-000-0000",
        "email": "kathryn@example.com",
        "addressLines": [ "2352 Bent Creek Rd" ],
        "cityTown": "Auburn",
        "stateProvince": "AL",
        "postalCode": "36830",
        "countryCode": "US"
    },
    "toAddress": {
        "postalCode": "00000",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 0
        }
    },
    "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": "NGST"
    },{
        "name": "RETURN_ID",
        "value": "123456789a"
    },{
        "name": "CLIENT_SERVICE_FLAG",
        "value": "Standard"
    },{
        "name": "DISPOSITION_RULESET_ID",
        "value": "1"
     } ]
}'
Response for a Standard Returns Label QR Code
{
    "fromAddress": {
        "company": "Shop",
        "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": {
        "name": "PITNEY BOWES RETURNS",
        "addressLines": [
            "PARCEL RETURN SERVICE",
            "",
            ""
        ],
        "postalCode": "56901"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 0.0
        }
    },
    "rates": [ {
        "carrier": "NEWGISTICS",
        "parcelType": "PKG",
        "specialServices": [],
        "serviceId": "PRCLSEL"
    } ],
    "documents": [ {
        "contentType": "BASE64",
        "contents": "R0lGODlhWAJYAvAAAAAAAP///ywAAAAAWAJYAkAC/4yPqcvtD6OctNq...",
        "fileFormat": "GIF",
        "type": "QR_CODE"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    },{
        "name": "CLIENT_ID",
        "value": "NGST"
    },{
        "name": "RETURN_ID",
        "value": "123456789a"
    },{
        "name": "CLIENT_SERVICE_FLAG",
        "value": "Standard"
    },{
         "name": "DISPOSITION_RULESET_ID",
         "value": "1"
    },{
        "name": "SMART_LABEL_BARCODE",
        "value": "7281006105012404002030000019584657I"
    },{
        "name": "LABEL_ID",
        "value": "93R64M6C"
    } ],
    "parcelTrackingNumber": "9204490188763900000012107",
    "shipmentId": "NGST220023818484327"
}

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.