Create a PB Returns Label¶
HTTP Request¶
POST /v1/shipments
Summary¶
This operation creates a Pitney Bowes 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 Tracking API. The label also contains a PB Returns barcode. Shippers also have the option of printing a third, custom barcode:
The API provides the option to create a QR code instead of a label. The buyer uses the QR code to print the label on a printer or at a Post Office or other shipping facility. You can use the Carrier Facilities API to provide the buyer with nearby facilities that print labels. A buyer who has a printer can print the label by entering the QR code’s Label ID at the USPS Label Broker website.
Prerequisite¶
To create a PB Returns label, a merchant must first onboard with PB Returns. When a merchant onboards, the merchant is enrolled with a PB Returns facility and receives a set of PB Returns IDs.
Considerations¶
PB Returns is a post-paid service. Postage is not charged at the time of label creation.
PB Returns are supported for domestic shipments only.
PB Returns use the Parcel Select Return service and the package parcel type.
PB Returns do not support special services.
This operation prints either a shipping label or QR code.
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 either with USPS or in the Pitney Bowes Drop Off Network.
To add an optional custom barcode at the bottom of the label, set the custom barcode parameters in the
documents.customerData.labelDetails
array, as described below.Merchants can also set up custom functions, such as printing additional text or applying business rules. To do so, a merchant must set up the function in advance with the PB implementation manager. To add a custom function when printing a label, set the function’s parameters in the
documents.customerData
object.To optionally apply minimal address validation to the
fromAddress
, which is the address of the buyer who is returning the item, set MINIMAL_ADDRESS_VALIDATION totrue
in theshipmentOptions
array. For a comparison of complete and minimal address validation, see this FAQ.If you choose to retrieve the label through a URL, the label is available for 24 hours after label creation.
The API returns a parcel tracking number you can use to track the label via the Tracking API.
If the API call returns the HTTP 500 Internal Server Error, see these troubleshooting steps.
For other errors, do not resubmit the request without first checking whether the label was created through the Retry API.
PB Returns labels are not manifested.
Request URLs¶
Sandbox: https://shipping-api-sandbox.pitneybowes.com/shippingservices/v1/shipments
Production: https://shipping-api.pitneybowes.com/shippingservices/v1/shipments
Request Headers¶
Name |
Description |
---|---|
Authorization |
Required. OAuth token generated using the OAuth Token API. |
Content-Type |
Required. The media type of the request entity. Set this to |
Accept-Language |
Language and country code. Default: |
X-PB-TransactionId |
Required. A unique identifier for the transaction, up to 25 characters. The following characters are allowed: letters, numbers, hyphens ( Important: Ensure this is a unique ID. |
X-PB-Use-Merchant-Logo |
If a merchant is configured to print a custom logo on PB 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 To be configured to print custom logos on PB Returns labels, merchants should contact their Pitney Bowes implementation teams. |
Request Elements¶
Required fields are marked Required. All other fields are optional.
Name |
Data Type |
Description |
---|---|---|
shipmentType |
String |
Required. Set to |
fromAddress |
Required. The address of the buyer who is returning the parcel. The
|
|
toAddress |
Required. The merchant’s address. The API will replace this address with the closest PB Returns facility. The
|
|
parcel |
Required. The parcel’s weight and dimensions. The |
|
rates |
Array[Rates Object] |
Required. Specifies the carrier, service, and parcel type. The array takes one
|
documents |
Array[Documents Object] |
Required. Defines the shipping label or QR code. Set the following, depending on whether you are printing a shipping label or QR code: Shipping label:
QR Code:
|
shipmentOptions |
Array[Object] |
Required. Each object in this array defines a shipment option. Each object has the following two fields:
The following shipment options are required:
|
Label Options¶
size |
fileFormat |
contentType |
resolution |
---|---|---|---|
DOC_4X6 |
PNG ZPL2 |
URL BASE64 BASE64 |
DPI_300 DPI_203, DPI_300 (default) DPI_203, DPI_300 (default) |
DOC_6X4 |
PNG ZPL2 |
URL BASE64 BASE64 |
DPI_300 DPI_203, DPI_300 (default) DPI_203, DPI_300 (default) |
DOC_8X11 |
URL |
DPI_300 |
Custom Barcode Parameters¶
To add an optional custom barcode at the bottom of the label, include the following parameters in the documents.customerData.labelDetails
array.
Parameter |
Value |
---|---|
|
Set this to the information to be encoded in the barcode. |
|
Set this to |
|
Set this to any human-readable information that is to accompany the barcode on the label. |
For example:
"documents": [ {
"customerData": {
"labelDetails": [ {
"name": "barcodeValue",
"value": "10202"
},{
"name": "barcodeType",
"value": "CODE128"
},{
"name": "barcodeHumanReadable",
"value": "Order: 10202"
} ]
}
} ]
Response Elements¶
Name |
Data Type |
Description |
---|---|---|
shipmentType |
String |
Indicates the shipment is a return. This is set to: |
fromAddress |
Address of the buyer who is returning the parcel. |
|
toAddress |
The PB Returns facility. |
|
parcel |
The parcel’s weight and dimensions. |
|
rates |
Array[Rates Object] |
The carrier, service, parcel type, and service charges. |
documents |
Array[Documents Object] |
Defines the shipping label or QR code. The
|
shipmentOptions |
Array[Object] |
Each object in the array defines a shipment option. |
shipmentId |
String |
The unique identifier for the shipment generated by the system. |
parcelTrackingNumber |
String |
The tracking number assigned to the shipment. |
Sample Requests¶
See the following examples:
Create PB Returns Label¶
The following request creates a PB Returns label. For a sample label, click here.
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-555-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": "PBCS",
"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"
} ]
}'
{
"fromAddress": {
"company": "Shop",
"name": "Kathryn Smith",
"phone": "334-555-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": "PBCS",
"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 PB Returns Label QR Code¶
The following request creates a QR code that can be used to print a PB Returns label. For a sample QR code, click here.
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-555-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": "PBCS",
"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"
} ]
}'
{
"fromAddress": {
"company": "Shop",
"name": "Kathryn Smith",
"phone": "334-555-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": "PBCS",
"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 Returns Label¶
QR Code¶
A QR code is a two-dimensional barcode a buyer can use to print a PB 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: Label Broker
The following is a sample QR code:
Error Codes¶
For a list of all error codes returned by the Ecommerce APIs, please see Error Codes.