Prompt

How do I create shipments and print labels from an API?

Logistics & Supply Chain / Freight & Shipping1 observationLast seen Oct 5, 2026

Latest observation

Oct 5, 2026OpenAI APIWeb search: off

To create shipments and print labels from an API, the general flow is:

  1. Create a shipment / parcel / order
  2. Rate it (optional but common)
  3. Buy / purchase the label
  4. Download or print the label
  5. Track the shipment

The exact endpoints vary by carrier or shipping platform, but the pattern is usually the same.

Typical API flow

1) Authenticate

Most shipping APIs require an API key or OAuth token.

Example:

Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json

2) Create a shipment request

You send details like:

  • Sender address
  • Recipient address
  • Package weight and dimensions
  • Service level
  • Insurance / customs info if needed

Example JSON:

{
  "ship_to": {
    "name": "Jane Doe",
    "address1": "123 Main St",
    "city": "Austin",
    "state": "TX",
    "postal_code": "78701",
    "country": "US"
  },
  "ship_from": {
    "name": "My Warehouse",
    "address1": "500 Warehouse Rd",
    "city": "Dallas",
    "state": "TX",
    "postal_code": "75201",
    "country": "US"
  },
  "package": {
    "weight": 2.5,
    "weight_unit": "lb",
    "length": 10,
    "width": 6,
    "height": 4,
    "dimension_unit": "in"
  },
  "service": "ground"
}

3) Get rates

The API returns available shipping options and prices.

Example response:

{
  "rates": [
    {
      "carrier": "UPS",
      "service": "Ground",
      "amount": "12.45",
      "currency": "USD",
      "estimated_delivery": "2026-10-08"
    },
    {
      "carrier": "FedEx",
      "service": "Home Delivery",
      "amount": "13.10",
      "currency": "USD",
      "estimated_delivery": "2026-10-07"
    }
  ]
}

4) Purchase the label

Once you choose a rate, submit a “buy label” or “create shipment” request.
The response usually includes:

  • Shipment ID
  • Tracking number
  • Label URL or label binary/base64
  • Carrier details

Example response:

{
  "shipment_id": "shp_12345",
  "tracking_number": "1Z999AA10123456784",
  "label_url": "https://api.example.com/labels/label_123.pdf"
}

5) Print the label

Depending on the API, labels may be returned as:

  • PDF URL — download and print
  • Base64 PDF — decode and print
  • ZPL/PNG — send directly to printer or render first

If it’s a PDF URL:

curl -o label.pdf "https://api.example.com/labels/label_123.pdf"

If it’s base64:

import base64

label_b64 = response["label"]
with open("label.pdf", "wb") as f:
    f.write(base64.b64decode(label_b64))

Example using a generic REST API in Python

import requests

API_TOKEN = "YOUR_API_TOKEN"
BASE_URL = "https://api.example.com"

headers = {
    "Authorization": f"Bearer {API_TOKEN}",
    "Content-Type": "application/json"
}

shipment_data = {
    "ship_to": {
        "name": "Jane Doe",
        "address1": "123 Main St",
        "city": "Austin",
        "state": "TX",
        "postal_code": "78701",
        "country": "US"
    },
    "ship_from": {
        "name": "My Warehouse",
        "address1": "500 Warehouse Rd",
        "city": "Dallas",
        "state": "TX",
        "postal_code": "75201",
        "country": "US"
    },
    "package": {
        "weight": 2.5,
        "weight_unit": "lb",
        "length": 10,
        "width": 6,
        "height": 4,
        "dimension_unit": "in"
    },
    "service": "ground"
}

# Create shipment
resp = requests.post(f"{BASE_URL}/shipments", json=shipment_data, headers=headers)
resp.raise_for_status()
data = resp.json()

print("Shipment created:", data)
print("Tracking number:", data.get("tracking_number"))
print("Label URL:", data.get("label_url"))

Printing the label

If the API gives you a PDF:

  • Open it and print from your computer/server
  • Or send it to a label printer
  • For thermal printers, many APIs support ZPL format

Example label formats:

  • PDF: good for regular printers
  • ZPL: best for Zebra thermal printers
  • PNG: sometimes supported for preview

Important things to check

  • Label size: 4x6 is common for shipping labels
  • Printer compatibility: PDF vs ZPL
  • International shipments: customs forms required
  • Address validation: many APIs provide it
  • Void/cancel endpoint: useful if you create a label by mistake

If you tell me the shipping provider

If you want, I can give you exact code for:

  • Shippo
  • EasyPost
  • UPS
  • FedEx
  • DHL
  • USPS
  • or your own custom API

If you share the provider and language you’re using, I can write a working example.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.