Create a Shipping Label
This guide will walk you through how to create your first shipping label using ShipStation API and provides the details and context you need to understand how this process works.
Before you begin:
- Sign up for a ShipStation API account, if you haven't already.
- Generate an 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 with ShipStation API, 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 ShipStation API account. However, the general steps are the same no matter which carrier you use.
TIP: To access your API key directly in this tutorial, sign into your ShipStation API account first. Your API key will then populate into the example requests so you can easily copy and paste into your own tools.
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. ShipStation API 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 ShipStation API key. This is how the ShipStation API 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 |
TIP:
Phone Number Formatting
The
phoneproperty in theship_toandship_fromobjects is a string and is not validated based on format. However, some carriers may return an error if the format is not valid for the countries they deliver to. Best practice is to use the phone number format specific to the Ship To and Ship From country, including the calling-code prefix.
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 ShipStation Carriers, the label cost will be deducated from your account balance. For your own carriers you've connected to ShipStation API, you'll be invoiced according to that carrier's usual method.
TIP: You can copy/paste the following curl example into your Terminal, or you can change the programming language of this code sample using the dropdown list in the top right corner. We suggest selecting "curl" for this tutorial.
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!
Automated Carrier Selection with Rate Shopper
If you don't want to manually select a carrier and service for each label, you can use the Rate Shopper endpoint to automate this decision based on cost, speed, or value optimization.
When to Use Rate Shopper
Rate Shopper is ideal for:
- Automated fulfillment systems where human review isn't needed
- High-volume operations with consistent shipping priorities
- Standardized workflows where you always choose the cheapest or fastest option
How It Works
Instead of specifying carrier_id and service_code in your shipment, you provide a rate_shopper_id in the URL path. ShipStation API will:
- Retrieve rates from all your connected wallet carriers
- Select the best rate according to your strategy
- Create and return the label in one step
Example Request
POST /v1/labels/rate_shopper_id/{rate_shopper_id}
This example uses the cheapest strategy to automatically select the lowest-cost carrier and service:
Response
The response includes which carrier and service were automatically selected:
Notice the rate_shopper_id field in the response, which confirms the strategy used, and the automatically selected carrier_id, service_code, and carrier_code.
Important Requirements
⚠️ Critical: When using Rate Shopper, you must NOT include any of these fields in your shipment object:
carrier_idservice_codeshipping_rule_idIf any of these fields are present, the API will return a validation error. Rate Shopper determines these values automatically.
Rate Shopper Strategies
| Strategy | Path Parameter | Use Case |
|---|---|---|
| Cheapest | /cheapest | Minimize shipping costs for non-urgent deliveries |
| Fastest | /fastest | Time-critical shipments where speed is paramount |
| Best Value | /best_value | Balance cost and speed (arrives within 4 days) |
Troubleshooting
No rates available
If you receive a 404 error with message "No rates found", verify:
- You have wallet carriers connected to your account
- Your shipment parameters are valid (addresses, package dimensions)
- The destination is supported by your connected carriers
- Package dimensions and weight are within carrier limits
If you need to ship to a specific carrier, use the standard label creation endpoint (POST /v1/labels) with explicit carrier_id and service_code.
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 are multiple ways to create labels with ShipStation API, each suited for different workflows:
- Automated carrier selection with Rate Shopper - Let ShipStation API automatically choose the best carrier and service based on cost, speed, or value
- Create a label from a rate - Display rates to customers or review options before purchasing
- Create a label from a shipment - Create multiple labels from a single shipment
- Create labels in bulk - Process large batches of labels efficiently
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
.pdffile. 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_labeltotrue. 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.