Shipping Label PDF generation API

Generate a shipping label PDF from a template and your shipment JSON in a single call. Docweave binds carrier, tracking number, ship-to/ship-from addresses, and package details into an HTML label template and returns a print-ready PDF — no headless browser to run yourself.

Generate a shipping label PDF via the API

POST your template and data to /api/v1/pdf:

curl https://docweave.dev/api/v1/pdf \
  -H "Authorization: Bearer dw_live_your_key" \
  -H "Content-Type: application/json" \
  -H "Accept: application/pdf" \
  --output label-1Z999AA10123456784.pdf \
  -d '{
    "source": {
      "type": "template",
      "template": "<div><h2>{{ carrier }}</h2><p>Tracking: {{ tracking_number }}</p><p>To: {{ ship_to_name }}, {{ ship_to_address }}</p><p>From: {{ ship_from_name }}</p><p>Weight: {{ weight_lbs }} lbs</p></div>",
      "data": {
        "carrier": "UPS Ground",
        "tracking_number": "1Z999AA10123456784",
        "ship_to_name": "Jordan Ellis",
        "ship_to_address": "742 Evergreen Terrace, Springfield, IL 62704",
        "ship_from_name": "Acme Warehouse",
        "weight_lbs": "3.2"
      }
    },
    "options": { "format": "4x6" },
    "idempotencyKey": "ship-1Z999AA10123456784"
  }'

…or from an AI agent

Add the Docweave MCP server and your agent gets a generate_pdf tool — the same orchestration, no HTTP boilerplate:

// From an AI agent over MCP — no HTTP plumbing:
generate_pdf({
  source: {
    type: "template",
    template: "<div><h2>{{ carrier }}</h2><p>Tracking: {{ tracking_number }}</p><p>To: {{ ship_to_name }}, {{ ship_to_address }}</p><p>From: {{ ship_from_name }}</p><p>Weight: {{ weight_lbs }} lbs</p></div>",
    data: {
      carrier: "UPS Ground",
      tracking_number: "1Z999AA10123456784",
      ship_to_name: "Jordan Ellis",
      ship_to_address: "742 Evergreen Terrace, Springfield, IL 62704",
      ship_from_name: "Acme Warehouse",
      weight_lbs: "3.2"
    }
  },
  outputPath: "/tmp/label-1Z999AA10123456784.pdf"
})

Template example

Any HTML works as a template. Use {{ placeholders }} for the values you pass in data:

<div style="width:4in; height:6in; font-family: sans-serif; border:1px solid #000; padding:12px; box-sizing:border-box;">
  <div style="display:flex; justify-content:space-between; align-items:center;">
    <h2 style="margin:0;">{{ carrier }}</h2>
    <div style="text-align:right;">
      <div>{{ service_level }}</div>
      <div>Zone {{ zone }}</div>
    </div>
  </div>

  <hr style="margin:8px 0;" />

  <p style="margin:0; font-size:12px;">FROM</p>
  <p style="margin:0 0 8px;">{{ ship_from_name }}<br />{{ ship_from_address }}</p>

  <p style="margin:0; font-size:12px;">SHIP TO</p>
  <p style="margin:0 0 8px; font-size:18px; font-weight:bold;">{{ ship_to_name }}<br />{{ ship_to_address }}</p>

  <table style="width:100%; font-size:12px; border-collapse:collapse;">
    <tr>
      <td>Weight: {{ weight_lbs }} lbs</td>
      <td>Dimensions: {{ dimensions_in }}</td>
    </tr>
    <tr>
      <td>Order #{{ order_number }}</td>
      <td>Ref: {{ reference_code }}</td>
    </tr>
  </table>

  <div style="margin-top:12px; text-align:center;">
    {{{ barcode_svg }}}
    <p style="letter-spacing:2px; font-weight:bold;">{{ tracking_number }}</p>
  </div>
</div>

FAQ

How do I generate a shipping label PDF from the API?

Send a POST to /api/v1/pdf with a source of type "template": pass your label HTML template and a data object with the carrier, tracking number, ship-to/ship-from addresses, and package weight. Docweave binds the JSON into the {{ placeholders }} and returns the label PDF, sized for a 4x6 label or standard page.

Can I use the same shipping label layout for every carrier?

Yes. Keep one template with placeholders for carrier, service level, tracking number, and addresses, then pass different data per shipment. Swap in a carrier-specific barcode or logo via the same {{ placeholders }} without touching the layout.

How do I avoid printing a duplicate label for the same shipment?

Include an idempotencyKey (for example the tracking number or order ID). A repeat request with the same key returns the stored PDF instead of re-rendering or re-billing, so a retried request or a flaky network call never produces two labels.

How is shipping label PDF generation priced, and how does it compare to other label APIs?

Docweave bills per document, not per page, so a single-page label costs the same whether it's plain text or includes a barcode and logo. Other shipping-label and carrier APIs price and structure their label generation differently — check the provider's current docs/pricing to compare.

Ready to generate shipping label PDFs in production?

Get an API key