Shipping API
Create, retrieve, and manage shipments.
Create shipment
POST /v1/shipments
Creates a new shipment with a label.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
carrier | string | Yes | Carrier code (e.g., usps, fedex) |
service | string | Yes | Service code (e.g., priority, ground) |
from | Address | Yes | Sender address |
to | Address | Yes | Recipient address |
parcel | Parcel | Yes | Package dimensions and weight |
reference | string | No | Your internal reference (e.g., order ID) |
isReturn | boolean | No | Whether this is a return label |
customs | Customs | No | Required for international shipments |
Address object
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Full name |
company | string | No | Company name |
street1 | string | Yes | Street address line 1 |
street2 | string | No | Street address line 2 |
city | string | Yes | City |
state | string | Yes* | State/province (*US/CA/AU) |
zip | string | Yes | Postal code |
country | string | Yes | ISO 3166-1 alpha-2 country code |
phone | string | No | Phone number |
email | string | No | Email address |
Parcel object
| Field | Type | Required | Description |
|---|---|---|---|
weightOz | number | Yes | Weight in ounces |
lengthIn | number | No | Length in inches |
widthIn | number | No | Width in inches |
heightIn | number | No | Height in inches |
Example
curl -X POST https://api.flexops.io/v1/shipments \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"carrier": "usps",
"service": "priority",
"from": { "name": "Warehouse", "street1": "100 Main St", "city": "Denver", "state": "CO", "zip": "80202", "country": "US" },
"to": { "name": "Jane Doe", "street1": "456 Oak Ave", "city": "Portland", "state": "OR", "zip": "97201", "country": "US" },
"parcel": { "weightOz": 16 }
}'
Get shipment
GET /v1/shipments/:id
List shipments
GET /v1/shipments
Query parameters
| Parameter | Type | Description |
|---|---|---|
page | integer | Page number (default: 1) |
pageSize | integer | Items per page (default: 25, max: 100) |
carrier | string | Filter by carrier code |
status | string | Filter by status |
createdAfter | datetime | Filter by creation date |
Cancel shipment
POST /v1/shipments/:id/cancel
Cancels the shipment and voids the label if within the carrier's void window.