Buy label
Creates an order using rate_id and purchases the label. The amount is deducted from the balance in advance; if the label creation fails, the money is automatically refunded.
POST /shipments
- Key Permission:
labels:create - Key: only live key sk_live (test key will get 403 test_key_cannot_buy)
- Idempotency-Key: required. Idempotency
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
rate_id |
string | yes | Rate ID from the POST /rates response, valid for 15 minutes. |
from.country |
string | yes | Country, two-letter ISO 3166-1 code (US, DE). |
from.postal_code |
string | yes | Postal code. |
from.name |
string | yes | Recipient's or sender's name. |
from.line1 |
string | yes | Address: street and house number. |
from.city |
string | yes | City. |
from.line2 |
string | no | Apartment, office, floor. |
from.state |
string | no | State or region, e.g., NY. |
from.company |
string | no | Company. |
from.phone |
string | no | Phone number in international format. |
from.email |
string | no | Email address. |
to.country |
string | yes | Country, two-letter ISO 3166-1 code (US, DE). |
to.postal_code |
string | yes | Postal code. |
to.name |
string | yes | Recipient's or sender's name. |
to.line1 |
string | yes | Address: street and house number. |
to.city |
string | yes | City. |
to.line2 |
string | no | Apartment, office, floor. |
to.state |
string | no | State or region, e.g., NY. |
to.company |
string | no | Company. |
to.phone |
string | no | Phone number in international format. |
to.email |
string | no | Email address. |
parcel.weight_g |
integer | yes | Weight in grams, integer, no more than 70000. |
parcel.length_mm |
integer | yes | Length in millimeters, integer, no more than 2000. |
parcel.width_mm |
integer | yes | Width in millimeters, integer, no more than 2000. |
parcel.height_mm |
integer | yes | Height in millimeters, integer, no more than 2000. |
items[].description |
string | no | Product description. |
items[].quantity |
integer | no | Quantity, from 1. |
items[].unit_value_cents |
integer | no | Price per item in cents. |
items[].origin_country |
string | no | Country of origin, two-letter code. |
items[].hs_code |
string | no | HS code (optional). |
items[].category |
string | no | Product category (optional). |
declared_value_cents |
integer | no | Declared value in US cents. In the purchase method, defaults to the sum of the items. |
reference |
string | no | Your order number (up to 64 characters). Optional when creating and unique within the account; in the list, this is an exact filter. |
Important to know
- For international shipments, the
itemsfield is mandatory: each item must includedescription,quantity(1–10000), andunit_value_cents(price per unit in cents). declared_value_centsmust equal the sum ofquantity × unit_value_centsfor all items. If not provided, it is calculated automatically.- The route and parcel in the purchase request must match those used to calculate the rate, otherwise a 409
rate_expirederror will occur. Declare the same value in both places. - If the carrier fails to create the label, a 502
provider_errorwill be returned, and the deducted funds will be automatically refunded to the balance. - Retrying with the same
Idempotency-Keydoes not create a second order; see the “Idempotency” section. referenceэто ваш номер заказа (необязательно, до 64 знаков). Он уникален в пределах аккаунта: тот же номер с другимIdempotency-Keyдаст 409. Заказ потом находится поGET /shipments?reference=....- In the response, the field
label_available: truemeans the label is ready. The label PDF can be downloaded viaGET /shipments/{id}/labelor from the dashboard in the orders section, where it can also be printed.
Request example
curl -X POST https://api.shippickup.com/v1/shipments \
-H "Authorization: Bearer $SHIPPICKUP_API_KEY" \
-H "Idempotency-Key: order-10452-label-v1" \
-H "Content-Type: application/json" \
-d '{
"rate_id": "<rate_id>",
"from": {
"name": "Acme Store",
"company": "Acme Inc",
"line1": "350 5th Ave",
"city": "New York",
"state": "NY",
"postal_code": "10001",
"country": "US",
"phone": "+12125550100",
"email": "shipping@example.com"
},
"to": {
"name": "Anna Schmidt",
"line1": "Unter den Linden 1",
"city": "Berlin",
"postal_code": "10117",
"country": "DE",
"phone": "+493012345678",
"email": "anna@example.com"
},
"parcel": {
"weight_g": 800,
"length_mm": 250,
"width_mm": 180,
"height_mm": 80
},
"items": [
{
"description": "T-shirts",
"quantity": 2,
"unit_value_cents": 2500,
"origin_country": "US"
}
],
"declared_value_cents": 5000,
"reference": "ORDER-10452"
}'<?php
$body = [
'rate_id' => '<rate_id>',
'from' => [
'name' => 'Acme Store',
'company' => 'Acme Inc',
'line1' => '350 5th Ave',
'city' => 'New York',
'state' => 'NY',
'postal_code' => '10001',
'country' => 'US',
'phone' => '+12125550100',
'email' => 'shipping@example.com',
],
'to' => [
'name' => 'Anna Schmidt',
'line1' => 'Unter den Linden 1',
'city' => 'Berlin',
'postal_code' => '10117',
'country' => 'DE',
'phone' => '+493012345678',
'email' => 'anna@example.com',
],
'parcel' => [
'weight_g' => 800,
'length_mm' => 250,
'width_mm' => 180,
'height_mm' => 80,
],
'items' => [
[
'description' => 'T-shirts',
'quantity' => 2,
'unit_value_cents' => 2500,
'origin_country' => 'US',
],
],
'declared_value_cents' => 5000,
'reference' => 'ORDER-10452',
];
$ch = curl_init('https://api.shippickup.com/v1/shipments');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SHIPPICKUP_API_KEY'),
'Idempotency-Key: order-10452-label-v1',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($body),
]);
$response = json_decode((string) curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
print_r([$status, $response]);
import os
import requests
body = {
"rate_id": "<rate_id>",
"from": {
"name": "Acme Store",
"company": "Acme Inc",
"line1": "350 5th Ave",
"city": "New York",
"state": "NY",
"postal_code": "10001",
"country": "US",
"phone": "+12125550100",
"email": "shipping@example.com",
},
"to": {
"name": "Anna Schmidt",
"line1": "Unter den Linden 1",
"city": "Berlin",
"postal_code": "10117",
"country": "DE",
"phone": "+493012345678",
"email": "anna@example.com",
},
"parcel": {
"weight_g": 800,
"length_mm": 250,
"width_mm": 180,
"height_mm": 80,
},
"items": [
{
"description": "T-shirts",
"quantity": 2,
"unit_value_cents": 2500,
"origin_country": "US",
},
],
"declared_value_cents": 5000,
"reference": "ORDER-10452",
}
r = requests.post(
"https://api.shippickup.com/v1/shipments",
headers={
"Authorization": "Bearer " + os.environ["SHIPPICKUP_API_KEY"],
"Idempotency-Key": "order-10452-label-v1",
},
json=body,
timeout=30,
)
print(r.status_code, r.json())
const body = {
"rate_id": "<rate_id>",
"from": {
"name": "Acme Store",
"company": "Acme Inc",
"line1": "350 5th Ave",
"city": "New York",
"state": "NY",
"postal_code": "10001",
"country": "US",
"phone": "+12125550100",
"email": "shipping@example.com"
},
"to": {
"name": "Anna Schmidt",
"line1": "Unter den Linden 1",
"city": "Berlin",
"postal_code": "10117",
"country": "DE",
"phone": "+493012345678",
"email": "anna@example.com"
},
"parcel": {
"weight_g": 800,
"length_mm": 250,
"width_mm": 180,
"height_mm": 80
},
"items": [
{
"description": "T-shirts",
"quantity": 2,
"unit_value_cents": 2500,
"origin_country": "US"
}
],
"declared_value_cents": 5000,
"reference": "ORDER-10452"
};
const res = await fetch("https://api.shippickup.com/v1/shipments", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.SHIPPICKUP_API_KEY}`,
"Idempotency-Key": "order-10452-label-v1",
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
console.log(res.status, await res.json());
Response example 201
JSON
{
"data": {
"id": "4f2a9c1e7b3d48a6c5e0f1d2b3",
"reference": "ORDER-10452",
"status": "label_ready",
"carrier": "UPS",
"service": "Express Saver",
"tracking_number": "1Z999AA10123456784",
"price_cents": 4120,
"currency": "USD",
"from": {
"name": "Acme Store",
"company": "Acme Inc",
"line1": "350 5th Ave",
"line2": "",
"city": "New York",
"state": "NY",
"postal_code": "10001",
"country": "US"
},
"to": {
"name": "Anna Schmidt",
"company": "",
"line1": "Unter den Linden 1",
"line2": "",
"city": "Berlin",
"state": "",
"postal_code": "10117",
"country": "DE"
},
"declared_value_cents": 5000,
"chargeable_weight_g": 800,
"label_available": true,
"eta_from": "2026-12-10",
"eta_to": "2026-12-12",
"source": "api",
"created_at": "2026-12-04T10:15:30+00:00",
"delivered_at": null,
"cancelled_at": null,
"pickup": null
},
"meta": {
"duplicate": false
}
}When repeating a request with the same Idempotency-Key, the response returns status 200 and meta.duplicate: true, the order is the same, money is not charged twice.
Possible errors
| HTTP | Code | Description |
|---|---|---|
| 403 | test_key_cannot_buy | Test key does not purchase labels or order pickups, use a live key. |
| 422 | idempotency_key_required | Missing or invalid Idempotency-Key header: must be 16–64 characters A-Za-z0-9_-. |
| 422 | validation_failed | Error in request fields. error.details specifies the reason for each field. |
| 402 | insufficient_funds | Insufficient funds on balance. Please top up your balance and retry. |
| 409 | rate_expired | Rate is outdated or calculated for a different parcel or route. Request rates again. |
| 409 | conflict | Action is currently not possible for this order (e.g., order cannot be canceled or pickup already ordered). Reason text in error.message. |
| 502 | provider_error | The carrier did not complete the operation. The money has been refunded automatically. |
| 403 | insufficient_scope | Key lacks the required permission, specified in error.details.required_scope. |