Use a Shipment to Print a Label

tip

Requirements

  • To use this feature, you'll need to have already created a shipment. See our guide on Creating a Shipment for assistance.

Similar to our example in Quickstart: Create a Label, we're going to request a label using USPS with the Stamps.com carrier that's included with your account.

Using a shipment_id to create a label, is the quickest way to create a label after you've successfully planned your shipment. There are additional options you can include to modify the way your label is formatted.

The properties used to set these options can be provided in the body of your request

Example

POST v1/labels/shipment/:shipment_id

curl -iX POST https://api.shipengine.com/v1/labels/shipment/se-2128732 \
-H 'Content-Type: application/json' \
-H 'API-Key: __YOUR_API_KEY_HERE__' \
-d '
{
  "label_format":"pdf",
  "label_layout": "4x6",
  "label_download_type": "url"
}'
{
  "label_id": "se-test-2128732",
  "status": "completed",
  "shipment_id": "se-2128732",
  "ship_date": "2019-07-25T05:00:00.000Z",
  "created_at": "2019-07-25T18:43:15.038Z",
  "shipment_cost": {
    "currency": "usd",
    "amount": 0.0
  },
  "insurance_cost": {
    "currency": "usd",
    "amount": 0.0
  },
  "tracking_number": "9999999999999",
  "is_return_label": false,
  "is_international": false,
  "batch_id": "",
  "carrier_id": "se-0",
  "service_code": "usps_priority_mail",
  "package_code": "package",
  "voided": false,
  "voided_at": null,
  "label_format": "pdf",
  "label_layout": "4x6",
  "trackable": false,
  "carrier_code": "stamps_com",
  "tracking_status": "unknown",
  "label_download": {
    "pdf": "https://api.shipengine.com/v1/downloads/1/s_Tqsu9euEKub6Acc_9UIg/testlabel-2128732.pdf",
    "png": "https://api.shipengine.com/v1/downloads/1/s_Tqsu9euEKub6Acc_9UIg/testlabel-2128732.png",
    "zpl": "https://api.shipengine.com/v1/downloads/1/s_Tqsu9euEKub6Acc_9UIg/testlabel-2128732.zpl",
    "href": "https://api.shipengine.com/v1/downloads/1/s_Tqsu9euEKub6Acc_9UIg/testlabel-2128732.pdf"
  },
  "form_download": null,
  "insurance_claim": null
}

That's it, your label is available for download using the label_download.href URL provided in the response.