Create a Shipping Label
This guide will walk you through how to create your first shipping label in ShipEngine as well as provide the details and context you need to understand how this process works.
Before you begin:
- Sign up for a ShipEngine account, if you haven't already.
- Generate a ShipEngine API key. A sandbox API key will work for this tutorial.
- You'll need a tool to make an API call, like curl or Postman.
When you create a shipping label in ShipEngine, you'll generally follow these basic steps (described in detail below):
In this tutorial, you'll request a label using the UPS services that are included with your ShipEngine account. However, the general steps are the same no matter which carrier you use.
Step 1: Prepare Your Request
To create a label, you'll send an HTTP POST
request to https://api.shipengine.com/v1/labels
. From now on we'll refer to this as the /v1/labels
endpoint.
Headers
There are two HTTP headers that you need to set in your request:
HTTP Header | Desription |
---|---|
Content-Type | The Content-Type header specifies the media type of your API request. ShipEngine requires all requests to be in JSON format, so this header should always be set to application/json . |
API-Key | For this header you'll need to pass your ShipEngine API key. This is how ShipEngine knows who you are. |
Request Body
The body of your request is where you'll specify all the information about the shipping label you want to create, such as the "from" and "to" addresses, the package weight and dimensions, etc.
For this tutorial, we'll create a label with the following details:
Field | Value |
---|---|
Delivery Service | UPS Ground |
Ship from address | John Doe 4301 Bull Creek Rd Austin, TX 78731 +1 555-555-5555 |
Ship to address | Jane Doe 525 S Winchester Blvd San Jose, CA 95128 +1 444-444-4444 |
Package weight | 20 ounces |
Package dimensions | 12 x 24 x 6 inches |
Here's what our label request body will look like using the above shipment details. There are additional optional fields that are left out of this request, but it does include the minimum fields recommended for shipping a package.
Step 2: Send the Request
Now, we'll take the request body from Step 1 for the POST /v1/labels call and put it all together using curl. When you use POST /v1/labels to create labels with your production API key, you are purchasing the label from the selected carrier. For ShipEngine Carriers, the label cost will be deducated from your account balance. For your own carriers you've connected to ShipEngine, you'll be invoiced according to that carrier's usual method.
Example Request & Response
Response
If your request was successful, you'll receive an HTTP 200 response. The response payload includes all the details you need about the label, including (but not limited to):
- Status: completed
- Label and shipment IDs
- Label cost
- Link to download the label in different formats (PNG, PDF, ZPL)
- Service type
- Package type
- Label size
- Tracking number
Step 3: Download the Label
In your response, the label_download
object includes the URLs you can use to download the label in various formats.
The label download formats include:
Format | Description | Uses |
---|---|---|
pdf | Adobe PDF file | A common format that's supported by most printers. Also a good format for email attachments when sending shipping labels to customers. |
png | PNG image file | PNG images are great for embedding in emails, web pages, or mobile apps. |
zpl | Zebra Printer file | If you print labels using a Zebra Printer, then ZPL is probably the best file format to use. However, please note that not all carriers support the ZPL format. |
These URLs are just like any other URLs in that you can paste them into a browser to download the file. You can also download the label using curl.
Copy the curl request below and replace the __YOUR_LABEL_URL_HERE__
placeholder with the URL of the label format you wish to download.
Congratulations! You've downloaded your first label!
Cancel a Label
If you need to cancel a label due to a mistake or because something about the package changed after you created the label, you can do so! Check out our guide on voiding a label to learn more.
What's Next?
There is more than one way to create a label in ShipEngine. Explore the options below for ways to improve your label flow.
Finally, explore the following options to customize or make your workflow more efficient:
- Request and download in one call: In the example above, two requests were necessary... one to create the label, and another to download the
.pdf
file. You can accomplish both steps in a single request by settinglabel_download_type: "inline"
. See Download a Label for more details. - Create a return label with an outgoing label: You can create return labels by setting
is_return_label
totrue
. See our Return Shipping Labels page for more details. - Create branded labels: Learn how to customize your labels so they print with your brand's logo or other images and see which carriers support this feature on the Create Custom Shipping Labels page.
- Add messages to labels: Show your customers an additional level of care and detail by adding a personal or customized message. See the Custom Label Messages page for details.