Create a FedEx Shipment

HTTP Request

POST /v1/shipments

Summary

This operation creates a shipment and purchases a shipment label using FedEx® as the carrier. Shipments can originate from the U.S. and Canada.

Prerequisites

The merchant’s FedEx account must be registered with Pitney Bowes. See Carrier Account Registration.

Things to Consider

  1. Shipper ID: To print a label, you must specify a SHIPPER_ID in the shipmentOptions array and set its value to the merchant’s postalReportingNumber, which you can retrieve using the Get All Merchants API.

  2. Services: For available services and special services, see FedEx Services.

  3. Label: For information on label options, see FedEx Labels.

  4. Error Handling: 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. To check whether the label was created, issue the Retry Shipment 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.

X-PB-Shipper-Carrier-AccountId

Conditional. The unique identifier for the carrier account. To retrieve the identifier, see this FAQ.

This header is required if the merchant has registered multiple accounts for the same carrier. For more information, see Carrier Account Registration.

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 might not apply to your 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 Pitney Bowes 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 for Create Shipment requests, except for requests that use the CBDS First-Mile Exclusive solution. This field does not apply to First-Mile Exclusive shipments and does not apply to Rate Parcel requests.
shipmentOptions Array[Object] Conditional. Each object in this array defines a shipment option. Required for Create Shipment requests. Does not apply to Rate Parcel requests. All Create Shipment requests require the SHIPPER_ID option. Please see the Things to Consider section on the carrier’s Create Shipment page for any additional requirements.
        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 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, for shipments to international destinations and to APO/FPO/DPO, Territories/Possessions, and FAS
  • CBDS, for all shipments
  • FedEx, for shipments to international destinations and Puerto Rico
  • UPS, 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 uses the CBDS First-Mile Exclusive solution. Contains information about the domestic leg of the shipment. This field does not apply to the First-Mile Inclusive solution.
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 USPS Return Labels Only. Required for USPS Return Labels. If you are creating an Expedited Return label or Scan-Based Return label, include this field and set the value to RETURN.
references Array[Object]

Enters shipper-generated values. Applies only to the following:

  • Newgistics: Optional. This array maps shipper-generated values to fields in the Newgistics package record. Use this array to pass Order Numbers and other custom values for use in Newgistics manifesting and billing. The values do not appear on the shipping label.

    The array takes up to three objects. Each maps to a specific Newgistics field. The object’s position in the array determines which field. The first object maps to the Newgistics “ReferenceNumber” field; the second to the “AddlRef1” field; and the third to the “AddlRef2” field. For each object you include, enter the name values as shown below. If you enter different values, the system will change them to those below. In the value fields, enter the shipper-generated values as string values of up to 50 characters each.

    {
        "name": "ReferenceNumber",
        "value": "<shipper-generated value>"
    }, {
        "name": "AddlRef1",
        "value": "<shipper-generated value>"
    }, {
        "name": "AddlRef2",
        "value": "<shipper-generated value>"
    }
    
  • CBDS: Contains the the shipper-generated order ID. This is array is optional but is recommended. When you include the order ID in this array, the ID is included in the Pitney Bowes tracking files and invoice, allowing you tie the shipment to your system through the ID. This array takes the following object, where <order_ID> is the shipper-generated order ID:

    {
        "name": "ORDER_NUMBER",
        "value": "<order_ID>"
    }
    
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 Request

FedEx Domestic Shipment Sample Request
curl -X POST .../v1/shipments \
-H "Authorization: Bearer R51KiFMd7ElzoQ09AK8t6q8wsNEP" \
-H "Content-Type: application/json" \
-H "Accept-Language: en-US" \
-H "X-PB-TransactionId: <unique_transaction_id>" \
-H "X-PB-Shipper-Carrier-AccountId: <unique_carrier_account_id>" \
-H "X-PB-UnifiedErrorStructure: true" \
-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": "Shop",
        "name": "Mary Jones",
        "phone": "620-555-0000",
        "email": "mary@example.com",
        "residential": false,
        "addressLines": [
            "284 W Fulton St"
        ],
        "cityTown": "Garden City",
        "stateProvince": "KS",
        "postalCode": "67846",
        "countryCode": "US"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 20
        }
    },
    "rates": [ {
        "carrier": "FEDEX",
        "serviceId": "2DA",
        "parcelType": "PKG",
        "specialServices": [ {
            "specialServiceId": "INS",
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "50"
            } ]
        } ]
    } ],
    "documents": [ {
        "size": "DOC_4X6",
        "printDialogOption": "NO_PRINT_DIALOG",
        "type": "SHIPPING_LABEL",
        "contentType": "URL",
        "fileFormat": "PDF"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ]
}'

Sample Response

FedEx Domestic Shipment 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",
        "carrierRoute": "C010",
        "deliveryPoint": "52"
    },
    "toAddress": {
        "company": "Shop",
        "name": "Mary Jones",
        "phone": "620-555-0000",
        "email": "mary@example.com",
        "residential": false,
        "addressLines": [
            "284 W Fulton St"
        ],
        "cityTown": "Garden City",
        "stateProvince": "KS",
        "postalCode": "67846-5352",
        "countryCode": "US",
        "carrierRoute": "C007",
        "deliveryPoint": "84"
    },
    "parcel": {
        "weight": {
            "unitOfMeasurement": "OZ",
            "weight": 20.0
        }
    },
    "rates": [ {
        "carrier": "FEDEX",
        "parcelType": "PKG",
        "inductionPostalCode": "36830",
        "specialServices": [ {
            "fee": 0.0,
            "inputParameters": [ {
                "name": "INPUT_VALUE",
                "value": "50"
            } ],
            "specialServiceId": "INS"
        } ],
        "deliveryCommitment": {
            "estimatedDeliveryDateTime": "2019-12-18 16:30:00",
            "guarantee": "FULL"
        },
        "serviceId": "2DA",
        "baseCharge": 24.38,
        "currencyCode": "USD",
        "surcharges": [ {
            "fee": 2.85,
            "name": "DELIVERY_AREA"
        },{
            "fee": 2.04,
            "name": "FUEL"
        } ],
        "totalCarrierCharge": 29.27,
        "totalTaxAmount": 0.0
    } ],
    "documents": [ {
        "contentType": "URL",
        "contents": "https://.../d7efae383834ed19a6b733a3818a4.pdf",
        "fileFormat": "PDF",
        "size": "DOC_4X6",
        "type": "SHIPPING_LABEL"
    } ],
    "shipmentOptions": [ {
        "name": "SHIPPER_ID",
        "value": "9024324564"
    } ],
    "parcelTrackingNumber": "79487353815",
    "shipmentId": "FEDEX220012345678182"
}

Error Codes

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