Retry a Shipment

HTTP Request

GET /v1/shipments?originalTransactionId={transaction_id}&carrier={carrier}

Summary

If a Create Shipment request received no response or returned a 500 error, use this operation to check whether the request succeeded and the label exists. If the label exists, the API returns the label. If the label does not exist, the API returns an error message.

Important: Retries should be used only if the original shipment request received no response or returned a 500 error. The number of retries of a label is scrutinized and restricted.

Things to Consider

  1. Use this operation in the following situations:
    • If the original Create Shipment request received no response at all and therefore gave no indication of success or failure.
    • If the original Create Shipment request returned the HTTP 500 Internal Server Error.
  2. You can retrieve a label with the Retry Shipment API for up to 24 hours after the initial request to create the shipment.

Request URIs

Sandbox: https://api-sandbox.pitneybowes.com/shippingservices/v1/shipments?originalTransactionId={transaction_id}&carrier={carrier}
Production: https://api.pitneybowes.com/shippingservices/v1/shipments?originalTransactionId={transaction_id}&carrier={carrier}

Query Parameters

Name Description
originalTransactionId Required. The X-PB-TransactionId that was used when the original shipment was submitted.
carrier

The name of the carrier. The carrier query parameter is optional if the carrier is USPS. The query parameter is required for all other carriers.

Valid values are:

  • USPS
  • Newgistics
  • PBPresort
  • UPS (Available only in Sandbox)

The values are not case-sensitive.

Request Header

Name Description
Authorization Required. OAuth token generated using the Generate an OAuth Token API.
X-PB-UnifiedErrorStructure
Recommended. Set this to true to use the standard error object if an error occurs.

Response Elements: Shipment Object

If the label was created, the response returns a shipment object. The following table describes all possible fields in a shipment object.

Some fields might not apply to your 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.

Note: If you are shipping with UPS (available only in Sandbox) 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 entries toAddress and soldToAddress must match.

altReturnAddress address object USPS Only. 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.
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] Conditional: Required for Create Shipment requests; does not apply to Rate Package requests. Defines the label, manifest, or other shipment document.
shipmentOptions Array[Object] Conditional: Required for Create Shipment requests; does not apply to Rate Package requests. Each object in this array defines a shipment option. Please see the Things to Consider section on your carrier’s Create Shipment page for required options. Note that the SHIPPER_ID option is required for all shipments.
        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

This field contains customs information.

Applies to the following:

  • For USPS, applies to shipments to these locations:
    • International
    • APO/FPO/DPO
    • Territories/Possessions
    • FAS
  • For UPS (available only in Sandbox), applies to shipments to these locations:
    • International
    • Puerto Rico
soldToAddress address object

UPS Only. (Available only in Sandbox)

This object is required for shipments from the U.S. to Puerto Rico or an international destination.

The soldToAddress.countryCode must match the toAddress.countryCode, with the exception of shipments to Canada and to U.S. satellite countries.

Enter the importer’s address in the toAddress object. If importer’s address is the same as the final recipient, the entries in the toAddress object must match the entries in the soldToAddress object.

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

Sample Requests and Responses

This section contains examples for the following carriers:

USPS Sample Request

curl -X GET .../v1/shipments?originalTransactionId=12345678901234567890 \
-H "Authorization: Bearer <oauth_token>" \
-H "X-PB-UnifiedErrorStructure: true"

USPS Sample Response

{
    "fromAddress": { ... },
    "toAddress": { ... },
    "parcel": {
        "weight": {
            "weight": 1,
            "unitOfMeasurement": "OZ"
        },
        "dimension": {
            "length": 6,
            "width": 0.25,
            "height": 4,
            "unitOfMeasurement": "IN",
            "irregularParcelGirth": 0
        }
    },
    "rates": [ {
        "carrier": "USPS",
        "parcelType": "PKG",
        "serviceId": "PM",
        "rateTypeId": "<rate_type>",
        "specialServices": [ {
            "specialServiceId": "DelCon",
            "fee": 0,
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "0"
            } ]
        }, {
            "specialServiceId": "Ins",
            "fee": 0,
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "50"
            } ]
        } ],
        "totalCarrierCharge": 5.95,
        "baseCharge": 5.95,
        "deliveryCommitment": {
            "minEstimatedNumberOfDays": "1",
            "maxEstimatedNumberOfDays": "1",
            "estimatedDeliveryDateTime": "2018-06-03",
            "guarantee": "NONE",
            "additionalDetails": "By end of Day"
        },
        "currencyCode": "USD"
    } ],
    "shipmentId": "USPS2200070298237396",
    "parcelTrackingNumber": "9405509898641491051189",
    "documents": [ {
        "fileFormat": "PDF",
        "contentType": "URL",
        "contents": "https://.../usps/872060188/outbound/label/208b56a6d2b84baeaa18dc23075bc1b4.pdf"
    } ],
    "shipmentOptions": [ {
        "name": "HIDE_TOTAL_CARRIER_CHARGE",
        "value": "false"
    }, {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    }, {
        "name": "ADD_TO_MANIFEST",
        "value": "true"
    }, {
        "name": "FUTURE_SHIPMENT_DATE",
        "value": "2018-06-02"
    }, {
        "name": "MINIMAL_ADDRESS_VALIDATION",
        "value": "true"
    } ]
}

Newgistics Sample Request

curl -X GET .../v1/shipments?originalTransactionId=n6721a207a60867e6176&carrier=newgistics \
-H "Authorization: Bearer <oauth_token>" \
-H "X-PB-UnifiedErrorStructure: true"

Newgistics Sample Response

{
    "fromAddress": { ... },
    "toAddress": { ... },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 32
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": 10,
            "width": 10,
            "height": 10,
            "irregularParcelGirth": 0
        }
    },
    "rates": [ {
        "carrier": "NEWGISTICS",
        "parcelType": "PKG",
        "specialServices": [ {
            "specialServiceId": "DelCon",
            "inputParameters": []
        } ],
        "serviceId": "PRCLSEL"
    } ],
    "documents": [ {
        "type": "SHIPPING_LABEL",
        "contentType": "BASE64",
        "fileFormat": "ZPL2",
        "pages": [ {
            "contents": "XMwxNX5..."
        } ]
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564
    }, {
        "name": "CLIENT_FACILITY_ID",
        "value": "0093"
    }, {
        "name": "CARRIER_FACILITY_ID",
        "value": "1585"
    } ],
    "shipmentId": "NEWGISTICS2200115577794836",
    "parcelTrackingNumber": "4200651192612123456789000000225251"
}

PB Presort Sample Request

curl -X GET .../v1/shipments?originalTransactionId=prs71480691704c91815&carrier=PBPresort \
-H "Authorization: Bearer <oauth_token>" \
-H "X-PB-UnifiedErrorStructure: true"

PB Presort Sample Response

{
    "fromAddress": { ... },
    "toAddress": { ... },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 3
        },
        "dimension": {
            "unitOfMeasurement": "IN",
            "length": 6,
            "width": 0.25,
            "height": 4,
            "irregularParcelGirth": 0
        }
    },
    "rates": [ {
        "carrier": "PBPRESORT",
        "parcelType": "LGENV",
        "serviceId": "BPM",
        "baseCharge": 0,
        "totalCarrierCharge": 0,
        "currencyCode": "USD"
    } ],
    "documents": [ {
        "type": "SHIPPING_LABEL",
        "contentType": "URL",
        "fileFormat": "PDF",
        "contents": "https://.../pbpresort/198715841/outbound/label/c9a8140f4f4c440ab6a8775eb0c67730.pdf"
    } ],
    "shipmentOptions": [ {
        "name": "MINIMAL_ADDRESS_VALIDATION",
        "value": "true"
    }, {
        "name": "PERMIT_NUMBER",
        "value": "SHFL"
    }, {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ],
    "shipmentId": "PBPRESORT2203115777806755",
    "parcelTrackingNumber": "0070698765432100005006512253671"
}

UPS Sample Request

Available only in Sandbox

curl -X GET .../v1/shipments?originalTransactionId=4e01a996dc2060f188&carrier=ups \
-H "Authorization: Bearer <oauth_token>" \
-H "X-PB-UnifiedErrorStructure: true"

UPS Sample Response

Available only in Sandbox

{
    "fromAddress": { ... },
    "toAddress": { ... },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 38
        },
        "dimension": {
            "length": 6,
            "width": 4,
            "height": 6,
            "unitOfMeasurement": "IN",
            "irregularParcelGirth": 0
        },
        "currencyCode": "USD"
    },
    "rates": [ {
        "carrier": "UPS",
        "parcelType": "PKG",
        "specialServices": [ {
            "specialServiceId": "INS",
            "fee": 0,
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "100.00"
            } ]
        } ],
        "deliveryCommitment": {
            "minEstimatedNumberOfDays": "1",
            "maxEstimatedNumberOfDays": "1",
            "estimatedDeliveryDateTime": "2019-04-09 11:00:00",
            "guarantee": "FULL"
        },
        "serviceId": "NDA_AM",
        "rateTypeId": "COMMERCIAL",
        "totalCarrierCharge": 133.23,
        "totalTaxAmount": 0,
        "baseCharge": 122.24,
        "surcharges": [ {
            "name": "DELIVERY_AREA",
            "fee": 2.95
        }, {
            "name": "FUEL",
            "fee": 9.39
        } ],
        "currencyCode": "USD"
    } ],
    "documents": [ {
        "size": "DOC_4X6",
        "fileFormat": "PDF",
        "contentType": "URL",
        "contents": "https://.../ups/258459135/outbound/label/aba74cb1c830451fa29031611c15a658.pdf"
        }
    ],
    "shipmentId": "UPS2200169981629768",
    "parcelTrackingNumber": "<tracking-number>"
}

Error Codes

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

Error Code Message
1090001 Original Transaction not found.
1090006 Time limit has passed.