Prompt
How do I book shipments through a shipping API?
Latest observation
Nov 4, 2026
OpenAI APIWeb search: off
Booking shipments through a shipping API usually follows the same high-level flow, even though the exact endpoints vary by provider.
Typical workflow
-
Get an API key / authenticate
- Create an account with the shipping provider.
- Generate credentials like an API key, OAuth token, or HMAC signature.
- Include those credentials in each request.
-
Create a shipment request
- Send shipment details to the API, such as:
- sender/origin address
- recipient/destination address
- package dimensions and weight
- service level (ground, express, etc.)
- shipment date / pickup requirements
- declared value, customs info for international shipments
- The API may return:
- available rates
- estimated transit times
- package validation errors
- Send shipment details to the API, such as:
-
Select a rate / service
- Choose the carrier and service option you want.
- Some APIs let you create a shipment directly with a chosen service.
- Others require you to first “rate” the shipment, then “book” it.
-
Purchase / book the shipment
- Call the booking or label-creation endpoint.
- The API typically returns:
- shipment ID / booking reference
- tracking number
- shipping label URL or base64 label data
- customs documents if needed
-
Print label and hand off
- Print the label and attach it to the parcel.
- Schedule a pickup or drop off at the carrier location if supported.
-
Track and manage
- Use tracking endpoints or webhooks to monitor status updates.
- Handle cancellations, address changes, and delivery exceptions if the API supports them.
Common API objects
Most shipping APIs use similar data structures:
-
Address
- name
- street lines
- city
- state/province
- postal code
- country
- phone/email
-
Parcel
- weight
- length
- width
- height
- unit system
-
Shipment
- shipper
- recipient
- parcels
- carrier/service
- insurance/customs fields
Example request pattern
1. Rate shipment
POST /shipments/rates
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"ship_from": {
"name": "Alice",
"street1": "123 Main St",
"city": "Austin",
"state": "TX",
"postal_code": "78701",
"country": "US"
},
"ship_to": {
"name": "Bob",
"street1": "500 Market St",
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US"
},
"parcels": [
{
"weight": 2.5,
"length": 10,
"width": 8,
"height": 4,
"unit": "in"
}
]
}
2. Book / create label
POST /shipments
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"rate_id": "rate_12345"
}
3. Example response
{
"shipment_id": "shp_67890",
"tracking_number": "1Z999AA10123456784",
"label_url": "https://api.example.com/labels/shp_67890.pdf",
"status": "booked"
}
Important considerations
- Validate addresses before booking to avoid failed labels.
- Watch for dimensional weight pricing if you ship large/light packages.
- Use idempotency keys when creating bookings to prevent duplicate labels if requests are retried.
- Handle customs correctly for cross-border shipments.
- Check rate limits and webhook reliability.
- Store shipment IDs and tracking numbers in your system for later lookup.
If you’re integrating with a specific provider
The details differ by platform, but the process is usually:
- Shippo / EasyPost / AfterShip / carrier-native APIs
- authenticate
- create rate
- purchase label
- retrieve tracking
- cancel if necessary
If you want, I can also show:
- a real example in Python/JavaScript
- how to do this with a specific provider like UPS, FedEx, DHL, Shippo, or EasyPost
- how to design your own shipment booking API