Prompt
How do I book shipments and create tracking numbers via API?
Latest observation
Nov 4, 2026
OpenAI APIWeb search: off
To book shipments and create tracking numbers via API, the basic flow is usually:
-
Authenticate
- Get an API key / OAuth token from your carrier or shipping platform.
- Include it in every request.
-
Create a shipment
- Send sender, recipient, package, service level, and pickup/delivery details.
- The API returns a shipment ID and often a tracking number.
-
Purchase / confirm the label
- Some APIs create a draft shipment first, then you “buy” or “confirm” it.
- This step may return the printable label URL/PDF/ZPL and tracking number if not already returned.
-
Store the tracking number
- Save the tracking number in your system and use it for notifications, tracking pages, and webhook subscriptions.
-
Track the shipment
- Call a tracking endpoint or subscribe to webhooks for status updates.
Typical API request pattern
POST /shipments
Authorization: Bearer <token>
Content-Type: application/json
{
"shipper": {
"name": "Sender Name",
"address": "123 Main St",
"city": "Austin",
"state": "TX",
"postal_code": "78701",
"country": "US"
},
"recipient": {
"name": "Receiver Name",
"address": "500 Market St",
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US"
},
"package": {
"weight": 2.5,
"weight_unit": "lb",
"length": 10,
"width": 8,
"height": 6,
"dimension_unit": "in"
},
"service": "ground",
"reference": "ORDER-12345"
}
Example response
{
"shipment_id": "shp_12345",
"tracking_number": "1Z999AA10123456784",
"label_url": "https://api.example.com/labels/shp_12345.pdf",
"status": "booked"
}
If you’re using a shipping aggregator
Platforms like Shippo, EasyPost, Sendcloud, or ShipStation typically provide:
- shipment creation
- rate shopping
- label purchase
- tracking webhooks
- address validation
Important considerations
- Idempotency: Use an idempotency key so retries don’t create duplicate shipments.
- Validation: Validate addresses and package dimensions before booking.
- Webhooks: Use them for real-time tracking updates instead of polling.
- Error handling: Handle rate not available, invalid address, label purchase failed, etc.
If you tell me which API/provider you’re using, I can give you the exact endpoint, request body, and sample code in Python, JavaScript, or cURL.