API Reference · v1

Shipping API docs: drop a shipment in, get a label back

Updated

REST, JSON, idempotency keys, signed webhooks. One auth header, no SDK lock-in. Browse the full reference below — when you're ready, create a key from your dashboard.

Get free rate quotes Free account. No card needed.

Endpoint index

Everything in the v1 API at a glance. Every route requires a Bearer API key.
EndpointWhat it doesNeeds
POST /v1/rates/quoteLive marked-up rates, no draftread
POST /v1/addresses/validateVerify + normalize an addressread
POST /v1/shipmentsCreate a draft shipment (auto-rated)write
GET /v1/shipmentsList shipments (cursor-paginated)read
GET /v1/shipments/:idRetrieve one shipmentread
PATCH /v1/shipments/:idRe-select carrier on a draftwrite
POST /v1/shipments/:id/purchaseBuy the label (wallet debit)write
GET /v1/shipments/:id/labelDownload the label fileread
GET /v1/shipments/:id/documents/:indexDownload one of documents[]read
GET /v1/returns/:id/labelDownload a return labelread
POST /v1/shipments/:id/voidCancel a label + refundwrite
POST /v1/shipments/batchUp to 50 drafts in one callwrite
POST /v1/shipments/batch-purchaseBuy up to 10 labels in one callwrite
GET /v1/shipments/:id/trackingLive tracking + checkpointsread
GET /v1/tracking/:numberSame, by tracking numberread
POST /v1/shipments/:id/returnIssue a return label (wallet debit)write
GET /v1/carriersCarrier + service catalogread
GET /v1/boxesFlat-rate + custom box catalogread
POST /v1/packing/recommendSmallest saved box for an order, with ratesread
GET/POST /v1/addressesAddress book list / saveread / write
GET/PATCH/DELETE /v1/addresses/:idAddress book manageread / write
GET /v1/walletBalance + pending refundsread
GET /v1/wallet/transactionsFull wallet ledger (paginated)read
GET /v1/adjustmentsAll carrier adjustments (paginated)read
GET /v1/shipments/:id/adjustmentsOne shipment's adjustmentsread
GET /v1/pickups/slotsPickup availability, windows + estimated feeread
POST /v1/pickupsSchedule a carrier pickupwrite
GET /v1/pickups · POST /v1/pickups/:id/cancelList / cancel pickupsread / write
POST /v1/claimsFile an insurance claimwrite + live
GET /v1/claims · GET /v1/claims/:idList / retrieve claimsread
GET/POST /v1/productsProduct catalog list / createread / write · hub
GET/PATCH/DELETE /v1/products/:idProduct retrieve / update / deleteread / write · hub
GET /v1/warehousesWarehouses + stock totalsread · hub
GET /v1/inventoryOn-hand per SKU per warehouseread · hub
GET /v1/inventory/movementsStock ledger (cursor-paginated)read · hub
POST /v1/inventory/adjustmentsAdjust stock (delta or set_to)write · hub
POST /v1/inventory/adjustments/batchUp to 200 adjustments in one callwrite · hub
GET/POST /v1/suppliersSuppliers list / createread / write · hub
GET/PATCH/DELETE /v1/suppliers/:idSupplier retrieve / update / archiveread / write · hub
GET/POST /v1/purchase-ordersPurchase orders list / create draftread / write · hub
GET /v1/purchase-orders/:idOne PO by id or number (PO-0012)read · hub
POST /v1/purchase-orders/:id/sendEmail the PO to the supplierwrite + live · hub
POST /v1/purchase-orders/:id/receive|cancel|closePO lifecyclewrite · hub
GET /v1/reports/monthlyMonth-end report (JSON)read · hub
GET /v1/reports/monthly.csvMonth-end report (CSV sheet)read · hub
POST /v1/webhooks · GET /v1/webhooksRegister / list endpointswrite / read
PATCH/DELETE /v1/webhooks/:idUpdate / remove an endpointwrite
GET /v1/webhooks/:id/deliveriesDelivery log (per attempt)read
POST …/deliveries/:id/replayRe-send a recorded deliverywrite
POST /v1/webhooks/:id/testSend a signed ping nowwrite
GET /v1/sandboxTest balance + sandbox shipment countread · sandbox
POST /v1/sandbox/shipments/:id/simulateMove a sandbox shipment's trackingwrite · sandbox
POST /v1/sandbox/walletSet the test balancewrite · sandbox
POST /v1/sandbox/resetDelete all sandbox datawrite · sandbox

Needs: read works with any key; write requires the write scope; live means a Live key only (the sandbox does not cover it); sandbox means a Sandbox key only; everything else works with both kinds of key. hub means the Operations hub must be enabled on the account (otherwise 403 operations_hub_required). Details in Authentication.

Authentication

Every public endpoint is gated by a Bearer-token API key.

Create a key on Sign up to create an API key and store it in an environment variable on your server. There are two kinds and the key itself says which: a Live key starts sk_live_ and buys real labels; a Sandbox key starts sk_sandbox_ and works on test data only (see Sandbox). The full secret is shown once at create time — copy it then.

bash
# Pass the key on every request
curl https://goatlabels.io/api/v1/shipments \
  -H "Authorization: Bearer $GOATLABELS_API_KEY"

Rate limit: every plan gets the same 300 req/min burst window with unlimited monthly calls — it's a shared-pool safety limit, not a tier gate. The exact ceiling for the current request is always echoed back as X-RateLimit-Limit, alongside X-RateLimit-Remaining and X-RateLimit-Reset (unix seconds). Over-limit requests get 429 with a Retry-After header in seconds. Each key's Last used timestamp is shown on the keys page so you can spot stale ones.

Key capability scopes

Each key carries a set of scopes that gate what it can do:

  • Full access (read + write) — can read and mutate (create, purchase, void, schedule pickups, manage webhooks).
  • Read-only (read) — can list, retrieve, track, quote rates, and validate addresses, but every mutating endpoint returns 403 insufficient_scope.

POST /v1/rates/quote, POST /v1/addresses/validate and POST /v1/packing/recommend are POST but non-mutating, so a read-only key can call them. Legacy keys with no scopes set are treated as unrestricted.

Live keys and Sandbox keys

  • Live key (sk_live_) — real shipments. A purchase books the carrier and debits your wallet.
  • Sandbox key (sk_sandbox_) — the same endpoints against test data. No carrier is booked and nothing is charged.

Every response carries GoatLabels-Environment: live or GoatLabels-Environment: sandbox, so your code can check which one it is talking to. Sandbox keys created before November 2026 start sk_test_ and work exactly like sk_sandbox_ keys.

What a key cannot do

A key is for the endpoints in this reference, all under /api/v1. The other /api routes belong to the dashboard: do not call them with a key. They are not supported for integrations and can answer 403 api_key_v1_only. A Sandbox key always gets that answer outside /api/v1: those routes act on your live account.

Some actions need a person signed in to the dashboard and answer 403 session_required to any key: saved cards and bank accounts, a top-up by bank transfer, the auto-reload rule, withdrawals, plan changes, account security, team members, profile and settings, connecting a store, and identity or funding applications.

A key created by a team member is tied to that member. It can do what the member's role allows (403 team_forbidden otherwise) and answers 401 api_key_member_inactive once the member is suspended or removed. A key created with another key starts with that key's allowed IPs. A key cannot clear or widen an allowed-IP list, and a key held to a list cannot rotate a key that is not (403 api_key_ip_list_widened).

Sandbox

Build and test your whole integration with a Sandbox key (sk_sandbox_). Same endpoints, test data, nothing charged.

Create a Sandbox key on Sign up to create an API key and point the same code at the same base URL. Only the key changes. When you are ready to ship for real, swap in a Live key.

bash
# 1. Create a draft (rates are the real, live prices)
curl -X POST https://goatlabels.io/api/v1/shipments \
  -H "Authorization: Bearer $GOATLABELS_SANDBOX_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "from": { ... }, "to": { ... }, "parcel": { ... } }'
# -> { "id": "shp_test_...", "status": "draft", ... }
#    response header: GoatLabels-Environment: sandbox

# 2. Buy it with test funds. No carrier is booked, nothing is charged.
curl -X POST https://goatlabels.io/api/v1/shipments/shp_test_.../purchase \
  -H "Authorization: Bearer $GOATLABELS_SANDBOX_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "acknowledgements": { ... } }'
# -> trackingNumber "GLTEST...", labelUrl to a sample label

# 3. Move its tracking along and receive the webhook
curl -X POST https://goatlabels.io/api/v1/sandbox/shipments/shp_test_.../simulate \
  -H "Authorization: Bearer $GOATLABELS_SANDBOX_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "status": "delivered" }'

What a Sandbox key does

  • Rates are real. Quotes and the rates on a draft are the same live prices a Live key gets.
  • Shipments are sandbox shipments (ids start shp_test_), stored apart from your real ones. A Sandbox key answers 404 for a live shipment id and a Live key does the same for a sandbox one. Sandbox shipments never appear in your dashboard.
  • Purchases use test funds. The sandbox has its own balance, starting at $1,000.00. A purchase takes the label price from it and answers exactly like a live purchase, with a tracking number that starts GLTEST. Your real wallet is never touched. With too little test balance you get the same 402 a live purchase gives.
  • The label is a sample. GET /v1/shipments/:id/label returns a 4×6 PDF, one page per parcel, stamped "SANDBOX SAMPLE - NOT VALID FOR SHIPPING". For USPS, UPS and FedEx the page is arranged the way that carrier's own label is (it is not a copy of one and carries no carrier artwork); other carriers get a plain layout. The tracking bar code is Code 128 and reads as the GLTEST number, so you can test a scanner against it. A carrier will not accept it.
  • Tracking moves when you say so. A purchased sandbox shipment stays at "label created" until you call POST /v1/sandbox/shipments/:id/simulate with a status of in_transit, out_for_delivery, delivered, exception or returned. The tracking endpoints show the new checkpoint and the matching webhook event fires.
  • Voids, returns and pickups are simulated. A void cancels the sandbox label and restores the test balance in the same call; on a Live key the credit posts after the carrier accepts the void. A return label is a sample. A pickup gets a confirmation number that starts TEST-; no driver is sent.
  • Webhooks are split. An endpoint registered with a Sandbox key receives sandbox events only, and a live endpoint never receives them. Every event body carries livemode: true for live, false for sandbox.
  • GET /v1/wallet and GET /v1/wallet/transactions show the test balance and the sandbox ledger.

Sandbox-only endpoints

  • GET /v1/sandbox — the test balance and how many sandbox shipments you hold.
  • POST /v1/sandbox/shipments/:id/simulate — move a purchased shipment's tracking ({ "status": "in_transit" }).
  • POST /v1/sandbox/wallet — set the test balance ({ "balance": 0 } to test an empty wallet).
  • POST /v1/sandbox/reset — delete every sandbox shipment, return, pickup and ledger row and start the balance again. Your keys and sandbox webhook endpoints are kept.

A Live key calling any of these gets 403 sandbox_only. To test a failed purchase, send the header GoatLabels-Sandbox-Scenario: carrier_failure on the purchase call: it answers as a carrier outage does (503, nothing taken from the test balance) and fires shipment.label.failed. An account can hold 5,000 sandbox shipments; past that, creating one answers 409 sandbox_full until you reset.

What the sandbox does not cover

  • Filing an insurance claim and sending a purchase order to a supplier answer 403 test_mode_unsupported for a Sandbox key. Use a Live key for those.
  • The address book and the Operations endpoints (products, inventory, suppliers, purchase orders) are shared with your live account. What a Sandbox key writes there is real, and a stock change is pushed to a connected store when stock sync is on.
  • Insurance is not simulated, carrier billing adjustments never occur, and account limits that apply to real purchases (identity verification, the monthly label allowance) are not checked.

Rate quote

POST /v1/rates/quote — live, marked-up carrier rates for a parcel. Read-only: no draft, no wallet debit.

Quote rates without creating a shipment. Prices are the same GoatLabels-marked-up rates you'd get on create; the underlying carrier pricing is never exposed. Works with a read-only key.

cURL
curl -X POST https://goatlabels.io/api/v1/rates/quote \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": { "postal_code": "94105", "country": "US" },
    "to":   { "postal_code": "M5H 1A1", "country": "CA" },
    "parcel": { "length": 12, "width": 9, "height": 4, "weight": 2, "weight_unit": "lb" },
    "items": [{ "description": "T-shirt", "quantity": 1, "declared_value": 25,
                "currency": "USD", "country_of_origin": "US", "hs_code": "6109.10" }]
  }'

Lithium items must include both unNumber and packagingMode (same guard as create) or you'll get a 400 hazmat_unNumber_required. Creating a shipment auto-rates and echoes the same rate set inline as shipment.rates[], so a single POST /v1/shipments can skip this call.

Residential default. to.residential defaults to false (commercial) when omitted, so the quote is priced as a business delivery. Send "residential": true for home addresses so the carrier's residential surcharge (FedEx and UPS Ground) is in the quote up front — otherwise the carrier bills it after delivery and it shows up as a residential_surcharge adjustment. Not sure? Validate the address first and copy its residential verdict; the v1 quote has no "auto" mode.

Saturday delivery and signature. Send saturday_delivery: true and/or signature_type (direct, indirect, adult) to get the exact price with those add-ons before you buy. With saturday_delivery the carrier is asked live, so each rate's supportsSaturdayDelivery is true only when the carrier will deliver that service on Saturday for this lane and ship_date (YYYY-MM-DD; defaults to the next ship day). saturdayDeliveryFee and signatureFee are the carrier's own charges passed through at cost, with no markup, and are already inside displayPrice. A fee of 0 with supportsSaturdayDelivery: true means the carrier delivers on Saturday at no extra charge for that service.

cURL
# saturday_delivery: true asks the carrier whether each service can deliver
# on Saturday for this lane and ship date, and prices it. ship_date matters:
# overnight services deliver on Saturday when they ship on Friday.
curl -X POST https://goatlabels.io/api/v1/rates/quote \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": { "postal_code": "94111", "country": "US" },
    "to":   { "postal_code": "11201", "country": "US", "residential": true },
    "parcel": { "length": 10, "width": 8, "height": 4, "weight": 2, "weight_unit": "lb" },
    "ship_date": "2026-12-04",
    "saturday_delivery": true,
    "signature_type": "direct"
  }'

The same three fields are accepted on POST /v1/shipments, where they are stored on the draft. saturday_delivery and signature_type can also be changed with PATCH /v1/shipments/:id or sent on purchase. A rate you name that cannot deliver on Saturday returns 422 saturday_delivery_unavailable on create / update; at purchase the label is re-rated live and a service the carrier will not deliver on Saturday is refused with 400 saturday_delivery_unavailable before anything is debited. Add-ons are charged with the label at purchase and are never billed later as an adjustment. The camelCase spellings (saturdayDelivery, signatureType, shipDate) are accepted too.

Create a shipment

POST /v1/shipments — creates a draft shipment that you can later purchase a label for.

All fields use snake_case. Country codes are 2-letter ISO. The response includes a stable id prefixed shp_ and object: "shipment". Instead of a full from block you can pass from_address_id (a saved address book entry), and parcel.box_slug pins a catalog box (flat-rate pricing included; with a box pinned, dims — and for flat-rate boxes, weight — become optional).

cURL
curl -X POST https://goatlabels.io/api/v1/shipments \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "from": {
      "name": "Warehouse",
      "line1": "1 Market St", "city": "San Francisco",
      "state": "CA", "postal_code": "94105", "country": "US"
    },
    "to": {
      "name": "Jane Doe",
      "line1": "9 King St", "city": "Toronto",
      "state": "ON", "postal_code": "M5H 1A1", "country": "CA"
    },
    "parcel": {
      "length": 12, "width": 9, "height": 4,
      "weight": 2, "weight_unit": "lb"
    },
    "items": [{
      "description": "T-shirt", "quantity": 1,
      "declared_value": 25, "currency": "USD",
      "country_of_origin": "US", "hs_code": "6109.10"
    }],
    "reference": "ORD-1042",
    "acknowledgements": {
      "noHazardous": true,
      "noPerishable": true,
      "noProhibited": true,
      "accurateDeclaration": true,
      "carrierTermsAccepted": true,
      "version": "v1-2026-05",
      "acceptedAt": "2026-05-08T12:00:00Z"
    }
  }'
Node.js
import fetch from "node-fetch";
import { randomUUID } from "node:crypto";

const res = await fetch("https://goatlabels.io/api/v1/shipments", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.GOATLABELS_API_KEY}`,
    "Content-Type": "application/json",
    // A fresh UUID per *intent*. Reuse the same key on retries.
    "Idempotency-Key": randomUUID(),
  },
  body: JSON.stringify({
    from: { name: "Warehouse", line1: "1 Market St", city: "San Francisco",
            state: "CA", postal_code: "94105", country: "US" },
    to:   { name: "Jane Doe",  line1: "9 King St",   city: "Toronto",
            state: "ON", postal_code: "M5H 1A1",     country: "CA" },
    parcel: { length: 12, width: 9, height: 4, weight: 2, weight_unit: "lb" },
    items:  [{ description: "T-shirt", quantity: 1, declared_value: 25,
               currency: "USD", country_of_origin: "US", hs_code: "6109.10" }],
    reference: "ORD-1042",
    // Compliance attestation. Strongly encouraged on create;
    // REQUIRED on POST /v1/shipments/:id/purchase.
    acknowledgements: {
      noHazardous: true,
      noPerishable: true,
      noProhibited: true,
      accurateDeclaration: true,
      carrierTermsAccepted: true,
      version: "v1-2026-05",
      acceptedAt: new Date().toISOString(),
    },
  }),
});

if (!res.ok) throw new Error(`GoatLabels: ${res.status} ${await res.text()}`);
const shipment = await res.json();
console.log(shipment.id, shipment.status);
Python
import os, uuid, requests

res = requests.post(
    "https://goatlabels.io/api/v1/shipments",
    headers={
        "Authorization": f"Bearer {os.environ['GOATLABELS_API_KEY']}",
        "Content-Type": "application/json",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "from": {"name": "Warehouse", "line1": "1 Market St", "city": "San Francisco",
                 "state": "CA", "postal_code": "94105", "country": "US"},
        "to":   {"name": "Jane Doe",  "line1": "9 King St",   "city": "Toronto",
                 "state": "ON", "postal_code": "M5H 1A1",     "country": "CA"},
        "parcel": {"length": 12, "width": 9, "height": 4, "weight": 2, "weight_unit": "lb"},
        "items":  [{"description": "T-shirt", "quantity": 1, "declared_value": 25,
                    "currency": "USD", "country_of_origin": "US", "hs_code": "6109.10"}],
        "reference": "ORD-1042",
        # Compliance attestation. Strongly encouraged on create;
        # REQUIRED on POST /v1/shipments/:id/purchase.
        "acknowledgements": {
            "noHazardous": True,
            "noPerishable": True,
            "noProhibited": True,
            "accurateDeclaration": True,
            "carrierTermsAccepted": True,
            "version": "v1-2026-05",
            "acceptedAt": "2026-05-08T12:00:00Z",
        },
    },
    timeout=10,
)
res.raise_for_status()
print(res.json()["id"])
Example response (201 Created)
JSON
{
  "id": "shp_1731000000000_abc123",
  "object": "shipment",
  "created": 1731000000,
  "status": "draft",
  "reference": "ORD-1042",
  "from": { "name": "Warehouse", "line1": "1 Market St", "city": "San Francisco", "state": "CA", "postal_code": "94105", "country": "US", ... },
  "to":   { "name": "Jane Doe",  "line1": "9 King St",   "city": "Toronto",       "state": "ON", "postal_code": "M5H 1A1", "country": "CA", ... },
  "parcel": { "length": 12, "width": 9, "height": 4, "dimension_unit": "in", "weight": 2, "weight_unit": "lb" },
  "items": [{ "description": "T-shirt", "quantity": 1, "declared_value": 25, "currency": "USD", "country_of_origin": "US", "hs_code": "6109.10", "sku": null, "manufacturer_part_number": null, "gtin": null, "pid_exempt": false }],
  "service": { "rate_id": "rate_a…", "carrier": "USPS", "name": "USPS Priority Mail International", "incoterms": "DDU" },
  "signature_type": "carrier_default",
  "saturday_delivery": false,
  "tracking_number": null,
  "label_url": null,
  "documents": [],
  "amount": { "subtotal": 41.85, "duty_and_tax": 0, "signature_fee": 0, "saturday_delivery_fee": 0, "total": 41.85, "currency": "USD" },
  "rates": [
    { "rate_id": "rate_a…", "carrier": "USPS", "serviceName": "USPS Priority Mail International", "displayPrice": 41.85, "currency": "USD", "deliveryDays": 8, "source": "live", ... },
    { "rate_id": "rate_b…", "carrier": "UPS", "serviceName": "UPS Standard", "displayPrice": 44.1, "currency": "USD", "deliveryDays": 5, "source": "live", ... }
  ]
}

Which rate the shipment holds: service.carrier and service.name are the selected carrier and service, and amount.total is that rate's price. They match one entry of rates[], where the same values are named carrier, serviceName and displayPrice. service.rate_id is that entry's rate_id. GET /v1/shipments/:id returns the same shipment object without rates[], so read service and amount there to check a draft before you purchase it. service is null only while no rate is selected, for example a draft from POST /v1/shipments/batch before it is rated.

service.rate_id: the id the selected rate had in the quote made when the shipment was created or last re-rated. It is the same string as that rate's rates[].rate_id in the create or PATCH response, and you can send it as rate_id to select the same service again. Do not compare it with a rate_id you took from an earlier quote: that id names the same service, but an id carries the rate's position in its quote, so the two strings can differ. To learn whether the rate you asked for was stored, read rate_fell_back. It is null when the rate was not picked from a quote.

Status values: draft → purchased → in_transit → delivered. Other terminal states are exception, returned, and voided.

Customs items (items[]): optional for domestic shipments (from.country = to.country) — omit it and a default package item is used. For international shipments items is required and every item's declared_value must be greater than 0 (it's used as the customs declared value); requests that violate this return a 422 items_invalid pointing at the offending index (e.g. items[0].declared_value).

EU product identifiers (items[].manufacturer_part_number, gtin, pid_exempt): EU customs require a product identifier on every item of a consumer sale shipped into the EU from outside it. That is a shipment whose to.country is an EU member, whose to.company is empty, and whose reason_for_export is merchandise or omitted. On those shipments each item needs either manufacturer_part_number (the brand's part or model number, up to 100 characters) or pid_exempt: true for goods that have no identifier, such as handmade, one-off or used items. Send your own sku with the part number where you have one. gtin (the EAN / UPC barcode, 8 to 14 digits) is optional and is sent in addition to the part number, not instead of it.

JSON
"to": { "name": "Aoife Byrne", "line1": "12 Grafton Street", "city": "Dublin", "postal_code": "D02 X285", "country": "IE" },
"reason_for_export": "merchandise",
"items": [
  {
    "description": "Wireless earbuds", "quantity": 1,
    "declared_value": 59, "currency": "USD",
    "country_of_origin": "CN", "hs_code": "8518.30",
    "sku": "EARBUD-BLK",
    "manufacturer_part_number": "WF-C510",
    "gtin": "4548736157415"
  },
  {
    "description": "Hand-bound notebook", "quantity": 1,
    "declared_value": 31.42, "currency": "USD",
    "country_of_origin": "US", "hs_code": "4820.10",
    "pid_exempt": true
  }
]

The three fields are accepted on POST /v1/shipments, POST /v1/shipments/batch and POST /v1/rates/quote, and are echoed on every shipment object. A quote for one of these shipments carries customsAdvisory; when its blocking is true, the items listed in missingItemIndexes still need an identifier, and purchase will refuse the shipment with 422 eu_product_identifier_required. Shipments to other destinations, to a company, or sent as a gift, sample or return are not affected.

Reason for export (reason_for_export): optional customs declaration for international shipments — one of merchandise, gift, sample, documents, return, repair, personal_effects, or other. It prints on the commercial invoice and is passed through to the carrier's electronic trade documents; it never changes rates or duty estimates. Ignored (stored as null) on domestic lanes, and echoed back on the shipment object.

Tax IDs (from.tax_id / to.tax_id): optional party-level identifier (EORI, VAT, EIN, ABN, CPF). Sender tax ID goes on from, recipient on to. Forwarded to the carrier as the address-level tax ID on international labels and printed on the commercial invoice. You can also save tax_id on an address book entry so from_address_id carries it automatically.

Customs overrides (customs_overrides): per-shipment override of the account-level IOSS / EORI / UK VAT numbers (Settings → Company) and of auto-attached US Section 321. Keys: ioss_number, eori_number, uk_vat_number, section_321_opt_out. Omitted keys keep the account default — those defaults already auto-apply to international v1 shipments by destination and declared-value threshold. Echoed on the shipment as an object of only the keys that were stored (empty object when none).

Catalog boxes (parcel.box_slug): when a catalog box is pinned, length / width / height are optional — the box's dimensions are used, and for flat-rate-priced slugs the box dimensions always override anything you send (the container fixes the size). Flat-rate slugs also make weight optional (defaults to 1 lb — flat-rate pricing is weight-independent) up to the carrier's cap: 70 lb for USPS flat rate, 50 lb for FedEx One Rate (a structured 400 invalid_request_error beyond that). Without box_slug, dims and weight stay required. Same rules apply on POST /v1/rates/quote.

Flat-rate service inference: if box_slug is omitted but service clearly names a USPS flat-rate product (e.g. "USPS Medium Flat Rate", "flat rate envelope"), the matching catalog box is pinned automatically so you get the flat-rate price instead of silent weight-based pricing. When you supply dims, the best-fitting variant is chosen (e.g. medium box 1 vs 2); otherwise variant 1. An explicit box_slug always wins, and non-USPS carriers never infer.

Rate fallback (rate_fell_back): when the request asked for a specific rate or service (rate_id, courier_settings, or service), the 201 response carries a rate_fell_back boolean — true means the requested service couldn't be matched and the persisted rate is a substitute (cheapest eligible). Absent when no specific selection was requested. To fail instead of substituting, set courier_settings.allow_courier_fallback: false — you'll get 422 courier_not_available whenever the requested rate or service can't be matched, including when the carrier itself is available but the specific service isn't.

Pinning a rate: a rate_id identifies the carrier service, not its position in the list — it is matched across quotes even when the create-time quote orders rates differently. Quote POST /v1/rates/quote with the same incoterms you will create with (a DDP rate list differs from the DDU one), and always read the returned service.carrier, service.name and amount.total from the created shipment rather than echoing your original quote.

Dangerous goods (parcel.hazmat)

Send a parcel.hazmat block when the package carries regulated items (lithium batteries, aerosols, perfume, dry ice, etc.). The block mirrors the dashboard's HazmatDeclaration / HazmatItem schemas — same wizard data, re-shaped for partners that don't go through the customer UI. Mixed-DG packages use items[]; single-class packages may pass only the top-level mirror fields.

Lithium metadata is required. Items whose category is lithium_ion or lithium_metal MUST include both unNumber (e.g. UN3480 / UN3481 / UN3090 / UN3091) and packagingMode (standalone | with_equipment | in_equipment). Both populate the Shipper's Declaration for Dangerous Goods (IATA / 49 CFR §172.204): unNumber fills the "UN" column and packagingMode selects PI965 / PI966 / PI967. Missing either field returns a 400 hazmat_unNumber_required with an offenders array pointing at the failing item indices. The server re-derives unNumber, packingInstruction, hazmatClass, and requiredLabels at quote / purchase time, so client-supplied values for those fields are accepted but ignored.

cURL
curl -X POST https://goatlabels.io/api/v1/shipments \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "from": {
      "name": "Warehouse",
      "line1": "1 Market St", "city": "San Francisco",
      "state": "CA", "postal_code": "94105", "country": "US"
    },
    "to": {
      "name": "Jane Doe",
      "line1": "9 King St", "city": "Toronto",
      "state": "ON", "postal_code": "M5H 1A1", "country": "CA"
    },
    "parcel": {
      "length": 8, "width": 6, "height": 3,
      "weight": 1.2, "weight_unit": "lb",
      "hazmat": {
        "items": [{
          "category": "lithium_ion",
          "unNumber": "UN3481",
          "packagingMode": "with_equipment",
          "wattHours": 50,
          "quantityPerPackage": 1
        }]
      }
    },
    "items": [{
      "description": "Power bank (lithium-ion, 50Wh)",
      "quantity": 1, "declared_value": 40, "currency": "USD",
      "country_of_origin": "CN", "hs_code": "8507.60"
    }],
    "reference": "ORD-2099"
  }'

Other structured 400 errors

The error envelope's code field distinguishes the structured cases so your integration can branch without parsing messages:

  • hazmat_unNumber_required — a lithium_ion / lithium_metal item is missing unNumber and/or packagingMode. See the lithium example above.
  • hs_code_required — an international shipment (from.country ≠ to.country) has one or more items missing a real HS tariff code on items[].hs_code. We refuse at create so partners don't 400 at mid-checkout.
  • otherwise — generic schema validation failure; see issues for the Zod path / message detail.

Compliance attestation (acknowledgements)

Send an acknowledgements block on every shipment you intend to buy a label for. By including it you confirm — on behalf of the shipper of record — that the parcel contains no hazardous or prohibited items, that any perishable or live contents follow the carrier's rules, that the declared contents, weight, and customs value are accurate, and that you accept the carrier and GoatLabels terms. We stamp your request IP and user-agent server-side and persist the full record so compliance can prove what you agreed to.

Policy: the field is strongly encouraged on create and required on POST /v1/shipments/:id/purchase. When omitted on create, the response carries the header Warning: 299 - "GOAT_ACK_RECOMMENDED: …" so you can wire the upgrade in advance.

Required fields: noHazardous, noPerishable, noProhibited, accurateDeclaration, carrierTermsAccepted (all must be true), version (the disclaimer version your integration showed the shipper, e.g. "v1-2026-05"), and acceptedAt (ISO 8601 timestamp of when the shipper accepted).

noPerishable attests that perishable or live contents follow the carrier's rules: shelf-stable goods ship on any service; perishable food and other temperature-sensitive contents ship at the shipper's risk on a 2-day or overnight service (spoilage is not covered by the carrier or by shipping insurance); dry ice must be declared as hazmat; live animals ship only on an overnight (next-day) service the carrier permits. A live-looking item description on any other service is refused at purchase with 409 live_animals_require_overnight.

Retrieve a shipment

GET /v1/shipments/:id — fetch a single shipment you own.
cURL
curl https://goatlabels.io/api/v1/shipments/shp_… \
  -H "Authorization: Bearer $GOATLABELS_API_KEY"

Returns the full shipment object (same shape as create). A 404 not_found is returned for ids that don't belong to the calling key — shipments are never visible across accounts.

Change carrier

PATCH /v1/shipments/:id — re-price / re-select the carrier on a draft, before you buy the label.

Re-runs the rate engine against the draft's saved address / parcel / items, picks the requested rate, and updates the courier and total cost. Only works while the shipment is a draft (to_ship); a purchased or voided shipment returns 409. Returns the updated shipment plus the fresh rates[].

cURL
# Re-select the carrier on a draft (re-quotes + updates total cost).
curl -X PATCH https://goatlabels.io/api/v1/shipments/shp_… \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "service": "UPS Ground" }'

# Or pin an exact rate id returned by POST /v1/shipments (shipment.rates[].rate_id):
#   { "rate_id": "rate_…" }
# Or the structured courier-settings block:
#   { "courier_settings": { "courier_service_id": "…", "allow_courier_fallback": false } }

Select a carrier by friendly service string, an exact rate_id from shipment.rates[], or the structured courier_settings block (courier_service_id, allow_courier_fallback). When the requested carrier isn't available and fallback is disabled you get 422 courier_not_available; otherwise it falls back to the cheapest rate.

Reason for export (reason_for_export): the customs declaration (same enum as create: merchandise, gift, sample, documents, return, repair, personal_effects, other) can be updated here too. International only — it prints on the commercial invoice and is stored as null on domestic lanes. Sent on its own (no carrier-selection field), the update is applied directly: no re-rate runs and the response omits rates[].

Purchase a label

POST /v1/shipments/:id/purchase — debits your wallet for the carrier-quoted price and issues the label.

This is the wallet-debit moment for partners. The acknowledgements block is required on this endpoint — there's no deprecation window because the v1 purchase surface is brand-new. Validation, persisted shape, and IP/user-agent stamping mirror the dashboard checkout flow exactly.

The response is the updated shipment in the dashboard (camelCase) shape: trackingNumber, labelUrl and documents[].url. Those two are rooted paths on this API (/api/v1/shipments/:id/label) — see Download a label. GET /v1/shipments/:id returns the same shipment in the snake_case shape, with label_url as a full URL.

cURL
curl -X POST https://goatlabels.io/api/v1/shipments/shp_…/purchase \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "acknowledgements": {
      "noHazardous": true,
      "noPerishable": true,
      "noProhibited": true,
      "accurateDeclaration": true,
      "carrierTermsAccepted": true,
      "version": "v1-2026-05",
      "acceptedAt": "2026-05-08T12:00:00Z"
    }
  }'

Compliance attestation (acknowledgements)

By including this block your integration confirms — on behalf of the shipper of record — that the parcel contains no hazardous or prohibited items, that any perishable or live contents follow the carrier's rules, that the declared contents, weight, and customs value are accurate, and that you accept the carrier and GoatLabels terms. We stamp your request IP and user-agent server-side and persist the full record on shipment.purchaseAcknowledgements so compliance can prove what you agreed to at the moment the wallet was debited.

Required fields (the request 400s if any is missing or set to anything other than true): noHazardous, noPerishable, noProhibited, accurateDeclaration, carrierTermsAccepted, version (the disclaimer version your integration showed the shipper, e.g. "v1-2026-05"), and acceptedAt (ISO 8601 timestamp of when the shipper accepted).

Other responses: 402 when the wallet has insufficient funds (top up via the dashboard wallet and retry the same Idempotency-Key); 409 when the shipment has already been purchased or voided, or (code live_animals_require_overnight) when the items look like live animals and the service is not overnight; 503 with a Retry-After header during a carrier upstream outage (your wallet is automatically refunded).

Recipient address check (422 address_needs_confirmation)

Before the wallet is debited we validate the recipient address with the carrier. When the carrier would print a different city, state, or ZIP than the one on the shipment (US and Canada), the purchase is refused with 422 code: "address_needs_confirmation" and nothing is charged. The body carries entered, suggested, changedFields, customer-ready lines[] / summary, and an enteredKey.

To resolve: either PATCH the shipment's to with the suggested address and purchase again, or purchase again with "addressConfirmation": { "to": { "keepEntered": "<enteredKey>" } } to keep the address exactly as entered. The key is bound to that address — if the address changes, the gate re-evaluates and issues a new key. Street-only corrections (abbreviations, suite formatting) never trigger this; the label still prints the carrier's canonical city for the ZIP.

EU product identifier check (422 eu_product_identifier_required)

A consumer sale going into the EU is refused with 422 code: "eu_product_identifier_required" when an item has neither manufacturer_part_number nor pid_exempt: true. Nothing is charged. The body carries error (a message you can show the shipper), missingItemIndexes (zero-based positions in items) and enforceFrom.

To resolve: create the shipment again with the identifier or the exemption on those items, then purchase the new shipment. See EU product identifiers for the fields.

Download a label

GET /v1/shipments/:id/label — the label file for a purchased shipment, with your API key.

label_url on a shipment and url on each entry of documents[] are addresses on this API. Fetch them with the same Authorization: Bearer header as every other call; the body is the file itself, normally a PDF. A read-scope key is enough and a download never touches your wallet. With a Sandbox key the file is a sample label marked not valid for shipping, arranged like the carrier's own label for USPS, UPS and FedEx.

cURL
# The label file. This is the address label_url points at.
curl https://goatlabels.io/api/v1/shipments/shp_…/label \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -o label.pdf

# One entry of documents[] (0-based), e.g. the commercial invoice.
curl https://goatlabels.io/api/v1/shipments/shp_…/documents/1 \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -o commercial-invoice.pdf

# A return label.
curl https://goatlabels.io/api/v1/returns/ret_…/label \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -o return-label.pdf

label_url is null until the label exists. Asking early returns 409 label_not_ready (not purchased yet, or the carrier is still generating it — retry shortly); a voided shipment returns 409 shipment_voided. 404 for ids that don't belong to the calling key, and 503 with a Retry-After header when the file is temporarily unreachable. Downloads count toward your plan's request limits like any other call.

Void a label

POST /v1/shipments/:id/void — cancel a purchased label and refund your wallet.

Cancels the label with the carrier, transitions the shipment to voided, and refunds your wallet (net of any non-refundable debit), following the same void/refund policy as the dashboard. Returns the updated shipment.

cURL
curl -X POST https://goatlabels.io/api/v1/shipments/shp_…/void \
  -H "Authorization: Bearer $GOATLABELS_API_KEY"

404 if the shipment isn't yours, 409 if it can't be voided in its current state, and 503 service_unavailable if the carrier cancel is temporarily unreachable.

Batch create + buy

Create up to 50 drafts and purchase up to 10 labels per call, with per-item results.

POST /v1/shipments/batch creates up to 50 drafts in one request. Each entry is the same body as POST /v1/shipments. Batch drafts aren't auto-rated (50 synchronous rate calls won't fit one request) — rate each later via PATCH or at purchase. A partial failure doesn't lose the good ones.

cURL
# Up to 50 drafts in one call. Each entry is the SAME body as POST /v1/shipments.
# Drafts are NOT auto-rated in batch — rate each via PATCH or at purchase.
curl -X POST https://goatlabels.io/api/v1/shipments/batch \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "shipments": [
      { "from": { … }, "to": { … }, "parcel": { … }, "reference": "ORD-1" },
      { "from": { … }, "to": { … }, "parcel": { … }, "reference": "ORD-2" }
    ]
  }'
JSON
{
  "object": "batch",
  "created_count": 2,
  "error_count": 0,
  "created": [ { "id": "shp_…", "object": "shipment", "status": "draft", ... } ],
  "errors": []
}

POST /v1/shipments/batch-purchase buys labels for up to 10 drafts. One acknowledgements block covers the whole batch (same shape as single purchase). Each item is independently atomic — wallet debit with refund-on-carrier-failure — so a mid-batch failure never corrupts the others. An item whose recipient city/state/ZIP the carrier would print differently comes back with status: 422 and code: "address_needs_confirmation" (nothing charged for that item) — resolve it with a PATCH of its to with the suggested address, or purchase that item individually with addressConfirmation.to.keepEntered (see Purchase a label).

cURL
# Buy labels for up to 10 drafts. One acknowledgements block covers the batch.
# Each item is independently atomic (debit + refund-on-failure).
curl -X POST https://goatlabels.io/api/v1/shipments/batch-purchase \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "shipment_ids": ["shp_a", "shp_b"],
    "acknowledgements": {
      "noHazardous": true, "noPerishable": true, "noProhibited": true,
      "accurateDeclaration": true, "carrierTermsAccepted": true,
      "version": "v1-2026-05", "acceptedAt": "2026-05-08T12:00:00Z"
    }
  }'
JSON
{
  "object": "batch_purchase",
  "purchased_count": 1,
  "failed_count": 1,
  "results": [
    { "shipment_id": "shp_a", "ok": true,  "status": 200, "response": { ... } },
    { "shipment_id": "shp_b", "ok": false, "status": 402, "response": { "error": { ... } } }
  ]
}

List shipments

GET /v1/shipments — newest first. Paginated by limit (1–100, default 25).
cURL
curl https://goatlabels.io/api/v1/shipments?limit=25 \
  -H "Authorization: Bearer $GOATLABELS_API_KEY"
JSON
{
  "object": "list",
  "has_more": false,
  "data": [ { "id": "shp_…", "object": "shipment", "status": "purchased", ... } ]
}

Live tracking

GET /v1/shipments/:id/tracking and GET /v1/tracking/:tracking_number — live status, ETA, and per-scan checkpoints.

Both routes return the same live snapshot: normalized status, the carrier's eta_date, a hosted tracking_page_url for your end customers, and the full scan-by-scan checkpoints[] timeline (newest first). The shipment-id route works even before the carrier's first scan.

cURL
# By tracking number…
curl https://goatlabels.io/api/v1/tracking/1Z999AA10123456784 \
  -H "Authorization: Bearer $GOATLABELS_API_KEY"

# …or by shipment id (works before the first carrier scan too)
curl https://goatlabels.io/api/v1/shipments/shp_…/tracking \
  -H "Authorization: Bearer $GOATLABELS_API_KEY"
JSON
{
  "object": "tracking",
  "tracking_number": "1Z999AA10123456784",
  "shipment_id": "shp_…",
  "carrier": "UPS",
  "status": "in_transit",
  "live": true,
  "eta_date": "2026-07-08",
  "tracking_page_url": "https://…",
  "checkpoints": [
    { "time": "2026-07-03T09:12:00Z", "location": "San Francisco, CA", "message": "Departed facility", "status": "in_transit" },
    { "time": "2026-07-02T18:40:00Z", "location": "San Francisco, CA", "message": "Origin scan",       "status": "in_transit" }
  ]
}

live: true means the carrier feed was reached on this request; live: false means the persisted record is being reported (feed temporarily unreachable or the label is too new) — we never invent a timeline. checkpoints is empty until the first physical scan. Rather than polling, subscribe to the tracking webhook events (shipment.in_transit → shipment.out_for_delivery → shipment.delivered) and use these routes for the detail view. Returns 404 if the shipment or tracking number isn't owned by the calling key.

Return labels

POST /v1/shipments/:id/return — issue a return label for a purchased shipment. Wallet debit, refunded automatically on carrier failure.

Pass the original outbound shipment's id. Origin and destination are swapped automatically and the same carrier + service the outbound label used is pinned, so the return matches the outbound format. The label cost is debited from your wallet at the same marked-up price you'd see in the dashboard; if the carrier fails to issue the label, the debit is refunded automatically.

cURL
curl -X POST https://goatlabels.io/api/v1/shipments/shp_…/return \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "reason": "Customer return — wrong size", "refund_amount": 25 }'
JSON
{
  "object": "return",
  "id": "ret_…",
  "shipment_id": "shp_…",
  "status": "label_created",
  "carrier": "USPS",
  "tracking_number": "9400…",
  "label_url": "https://goatlabels.io/api/v1/returns/ret_…/label",
  "reason": "Customer return — wrong size",
  "refund_amount": 25,
  "cost": 6.42,
  "created": 1731000000
}

refund_amount is bookkeeping only (what you intend to refund your buyer) — GoatLabels doesn't move that money. Requires a write-scope live key. 402 when the wallet can't cover the label, 409 when the outbound label was never issued (draft / voided) or no return rates are available, 503 + auto-refund on a carrier outage.

Carrier catalog

GET /v1/carriers — every carrier + service the rate engine quotes, with transit windows. Build service pickers from this.
cURL
curl https://goatlabels.io/api/v1/carriers \
  -H "Authorization: Bearer $GOATLABELS_API_KEY"
JSON
{
  "object": "list",
  "data": [
    {
      "object": "carrier",
      "id": "usps",
      "name": "USPS",
      "services": [
        { "name": "USPS Priority Mail", "international": false, "ddp_supported": false, "transit_time": "2-3 working days" },
        { "name": "USPS Priority Mail Express", "international": false, "ddp_supported": false, "transit_time": "1-3 working days" }
      ]
    }
  ],
  "has_more": false
}

Service name strings are valid values for the loose service selector on POST /v1/shipments / PATCH. Which services actually quote for a given parcel depends on route and size — treat this as the menu, and the rate response as the truth.

Boxes catalog

GET /v1/boxes — discoverable box_slug values: carrier flat-rate packaging + your saved custom parcels.

Pass a carrier box's slug as parcel.box_slug on quotes and creates to pin that packaging — flat_rate: true slugs get the carrier's flat-rate price (fixed by the container, not the weight, up to the carrier's cap) and the box's dimensions are used to quote every other carrier too. With a box pinned, length / width / height are optional (flat-rate slugs always use the box's own dimensions), and flat-rate slugs make weight optional too.

cURL
curl https://goatlabels.io/api/v1/boxes \
  -H "Authorization: Bearer $GOATLABELS_API_KEY"
JSON
{
  "object": "box_catalog",
  "carrier_boxes": [
    {
      "object": "carrier_box",
      "slug": "usps_priority_flat_medium_1",
      "carrier": "USPS",
      "name": "Priority Mail Medium Flat Rate Box — 1",
      "length": 11.25, "width": 8.75, "height": 6,
      "dimension_unit": "in",
      "flat_rate": true
    }
  ],
  "custom_boxes": [
    {
      "object": "custom_box",
      "id": "box_…",
      "name": "Sneaker box",
      "length": 14, "width": 10, "height": 5,
      "dimension_unit": "in",
      "weight": 2, "weight_unit": "lb",
      "type": "box",
      "default": true
    }
  ]
}

custom_boxes are the parcel presets saved in your dashboard (Settings → Boxes) — returned here so integrations can mirror the same presets. Unknown box_slug values are rejected with 400.

Recommend a box

POST /v1/packing/recommend — the smallest of your Auto-select boxes that holds an order, with the packed weight. Read-only.

Send the order as items. An item with a sku uses the size and weight saved on that product; an item without one must carry its own length, width, height and weight (inches and pounds unless you send dimension_unit / weight_unit; the units taken are in / cm and lb / kg, anything else is a 400). Only your own saved boxes with Auto-select on (Settings → Boxes) are considered; the built-in flat-rate boxes are not. weight in the answer is the items plus the empty box, and box_weight is the box's share. An item sent without a SKU is listed as (line N), its position in items.

cURL
curl -X POST https://goatlabels.io/api/v1/packing/recommend \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      { "sku": "MUG-01", "quantity": 4 },
      { "length": 30, "width": 20, "height": 10, "dimension_unit": "cm",
        "weight": 0.8, "weight_unit": "kg", "quantity": 1 }
    ],
    "to": { "postal_code": "90210", "country": "US" }
  }'
JSON
{
  "packages": [
    {
      "box_id": "box_…",
      "box_name": "Medium carton",
      "location": "Shelf B2",
      "type": "box",
      "length": 12, "width": 10, "height": 8,
      "dimension_unit": "in",
      "weight": 6.25, "box_weight": 0.75, "weight_unit": "lb",
      "items": [{ "sku": "MUG-01", "quantity": 4 }, { "sku": "(line 2)", "quantity": 1 }],
      "own_carton": false
    }
  ],
  "confidence": "exact",
  "unmatched_skus": [],
  "reason": null,
  "message": "",
  "rates": [
    { "rate_id": "rate_…", "carrier": "UPS", "serviceName": "UPS Ground",
      "displayPrice": 9.4, "currency": "USD", "deliveryDays": 3, "source": "live" }
  ]
}

Add to to get live rates for the recommended box; the origin is from, else ship_from_location_id, else your default ship-from address. When no box can be recommended, packages is empty, confidence is fallback and reason says why: unmatched_items (listed in unmatched_skus), no_boxes, no_fit, multi_box_off or too_many_boxes. confidence: "estimated" means a large order was sized by total volume and weight. A product marked as shipping in its own carton comes back as its own package with own_carton: true and a null box_id.

Address book

GET/POST /v1/addresses, GET/PATCH/DELETE /v1/addresses/:id — saved addresses, usable as from_address_id on shipment creates.

Save your warehouses once, then create shipments with from_address_id instead of repeating the full from block. Exactly one of the two must be present on POST /v1/shipments.

cURL
# Save a warehouse once…
curl -X POST https://goatlabels.io/api/v1/addresses \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "label": "SF Warehouse", "default": true,
    "name": "Warehouse", "line1": "1 Market St",
    "city": "San Francisco", "state": "CA",
    "postal_code": "94105", "country": "US",
    "phone": "+14155550100"
  }'

# …then create shipments with just the id
curl -X POST https://goatlabels.io/api/v1/shipments \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from_address_id": "adr_…",
    "to": { … }, "parcel": { … }
  }'

default: true marks the account default Ship From (only one at a time — setting it clears the previous default); default_return: true works the same for returns. Saving a duplicate (same line1 + postal code + country) returns 409 with the existing entry's id. DELETE is a soft-delete — historical shipments keep their address snapshot. PATCH is partial: unspecified fields keep their saved values. Optional tax_id (EORI / VAT / EIN) is stored on the entry and copied onto shipments created with from_address_id.

Wallet

GET /v1/wallet and GET /v1/wallet/transactions — read your balance and the complete ledger. Read-only; top-ups stay in the dashboard.
cURL
curl https://goatlabels.io/api/v1/wallet \
  -H "Authorization: Bearer $GOATLABELS_API_KEY"

curl "https://goatlabels.io/api/v1/wallet/transactions?limit=25" \
  -H "Authorization: Bearer $GOATLABELS_API_KEY"
JSON
{
  "object": "wallet",
  "balance": 142.55,
  "currency": "USD",
  "pending_refund_amount": 6.42,
  "next_refund_available_at": 1731600000
}

Check the balance before batch purchases to avoid mid-batch 402s. pending_refund_amount is void refunds still being returned by the carrier. /wallet/transactions is cursor-paginated (limit, starting_after) and each entry carries the linked shipment_id where applicable, so you can reconcile every debit/credit programmatically. There is deliberately no top-up endpoint — card operations stay in the dashboard.

Carrier adjustments

GET /v1/adjustments and GET /v1/shipments/:id/adjustments — post-purchase carrier billing corrections (re-weighs, dimension corrections, surcharges, credits).

Carriers re-weigh and re-measure parcels after pickup. When the billed price changes, the difference hits your wallet and shows up here — tied to the exact shipment and wallet transaction — so you can reconcile or re-bill your own customers.

cURL
# Everything on the account, newest first (cursor-paginated)…
curl "https://goatlabels.io/api/v1/adjustments?limit=25" \
  -H "Authorization: Bearer $GOATLABELS_API_KEY"

# …or just one shipment's adjustments
curl https://goatlabels.io/api/v1/shipments/shp_…/adjustments \
  -H "Authorization: Bearer $GOATLABELS_API_KEY"
JSON
{
  "object": "list",
  "has_more": false,
  "data": [{
    "object": "adjustment",
    "id": "adj_…",
    "shipment_id": "shp_…",
    "reason": "reweigh",
    "description": "Carrier re-weigh: billed weight 3.2 lb vs declared 2 lb",
    "original_amount": 8.40,
    "adjusted_amount": 10.29,
    "delta_amount": 1.89,
    "currency": "USD",
    "wallet_transaction_id": "txn_…",
    "posted_at": 1731000000,
    "created": 1731000000
  }]
}

delta_amount > 0 means your wallet was charged; negative means credited. reason is one of reweigh, dim_correction, residential_surcharge, address_correction, additional_handling, duties_taxes, refund, other. To be pushed instead of polling, subscribe to the shipment.adjustment.created webhook event.

Validate an address

POST /v1/addresses/validate — normalize and verify an address before you ship. Read-only.

Catch undeliverable or mistyped addresses up front (fewer failed deliveries and surcharges). Stateless and owner-agnostic, but still requires a Bearer key. A read-only key can call it.

cURL
curl -X POST https://goatlabels.io/api/v1/addresses/validate \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "line1": "9 King St", "city": "Toronto",
    "state": "ON", "postal_code": "M5H 1A1", "country": "CA"
  }'
JSON
{
  "object": "address_validation",
  "status": "verified",
  "address_type": "commercial",
  "residential": false,
  "corrected": {
    "line1": "9 King St W", "line2": null, "city": "Toronto",
    "state": "ON", "postal_code": "M5H 1A1", "country": "CA"
  },
  "warnings": []
}

corrected is null when no normalization was applied. Required fields: line1, city, postal_code, and a 2-letter country.

Schedule a pickup

Arrange a courier collection for purchased labels — handy for 3PLs handing off in bulk. Drop-off is the default for every label.

Every label can be dropped off at the carrier — you never need a pickup to ship. When you want a courier collection instead, check availability first with GET /v1/pickups/slots?shipment_ids=shp_a,shp_b. It tells you whether the carrier schedules pickups for those labels at all (supports_pickup), the dates and windows on offer, and a best-effort estimated_pickup_fee. All shipment ids must share one carrier and one origin address.

cURL
curl "https://goatlabels.io/api/v1/pickups/slots?shipment_ids=shp_a,shp_b" \
  -H "Authorization: Bearer $GOATLABELS_API_KEY"
JSON
{
  "object": "pickup_slots",
  "shipment_ids": ["shp_a", "shp_b"],
  "carrier": "UPS",
  "supports_pickup": true,
  "dropoff_reason": null,
  "estimated_pickup_fee": 7.75,
  "fee_note": "Estimated carrier pickup fee for the first available window; the carrier confirms the final charge when the pickup is booked.",
  "currency": "USD",
  "slots": [
    { "date": "2026-07-01", "time_windows": [
      { "from_time": "09:00", "to_time": "12:00", "time_window": "09:00 — 12:00" },
      { "from_time": "13:00", "to_time": "17:00", "time_window": "13:00 — 17:00" }
    ] }
  ]
}
CarrierPickup via APIFee before booking
UPSYes — business-day ready/close windowsRated live for the first window; null if the rating call fails
USPSYes — business-day windowsnull — USPS does not quote one up front (package pickup is usually free)
FedExDepends on the carrier account the label was bought on. When scheduling is unavailable the response is supports_pickup: false with a dropoff_reason — drop the parcels at a FedEx locationCarrier minimum pickup fee when the account reports one; otherwise null
Other carriersDrop-off (supports_pickup: false)—

estimated_pickup_fee is an estimate in USD and is never charged by the slots call. The confirmed fee lands on the scheduled pickup as pickup_fee; carriers that only bill after collection report it there once known. supports_pickup: false is a normal 200 — not an error — so you can decide before booking.

POST /v1/pickups then schedules the pickup. Pass one of the offered dates as pickup_date (YYYY-MM-DD) and the time_window string exactly as returned (e.g. "09:00 — 12:00").

cURL
curl -X POST https://goatlabels.io/api/v1/pickups \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "shipment_ids": ["shp_a", "shp_b"],
    "pickup_date": "2026-07-01",
    "time_window": "09:00 — 12:00"
  }'
JSON
{
  "object": "pickup",
  "id": "pck_…",
  "pickup_date": "2026-07-01",
  "time_window": "09:00 — 12:00",
  "carrier": "UPS",
  "shipment_ids": ["shp_a", "shp_b"],
  "status": "scheduled",
  "confirmation_number": "WP12345",
  "pickup_fee": 0,
  "created": 1731000000
}

GET /v1/pickups lists your pickups (newest first); POST /v1/pickups/:id/cancel cancels one. With a Sandbox key both are simulated: the pickup gets a confirmation number that starts TEST- and no driver is sent.

Insurance + claims

One shipping-insurance product on every carrier option, priced as a pass-through; file and track claims on the same key.

Send insurance: true on POST /v1/rates/quote or POST /v1/shipments and every rate carries an insurance object: the insured value (goods value plus the label price when your account's Insurance setting includes shipping), the premium, and an eligibility verdict with the reason when cover is unavailable on that option. The premium is the insurer's fee with nothing added and is folded into displayPrice only when you asked for insurance. Published rate: 1% of the insured value for US shipments, 1.5% international, $0.49 minimum, up to $10,000 per package — the terms, exclusions and claim windows are on goatlabels.io/shipping-insurance.

cURL
# insurance: true adds an "insurance" object to every rate and folds the
# premium into displayPrice. Needs a value to insure: items[].declared_value
# or declared_value_usd.
curl -X POST https://goatlabels.io/api/v1/rates/quote \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": { "postal_code": "10001", "country": "US" },
    "to":   { "postal_code": "94105", "country": "US" },
    "parcel": { "length": 12, "width": 9, "height": 4, "weight": 2, "weight_unit": "lb" },
    "declared_value_usd": 500,
    "insurance": true
  }'
JSON
{
  "object": "rate",
  "id": "rate_…",
  "carrier": "UPS",
  "service": "Ground",
  "displayPrice": 14.87,
  "insurance": {
    "insured_value_usd": 509.77,
    "premium_usd": 5.10,
    "max_insured_value_usd": 10000,
    "eligible": true,
    "ineligible_reason": null
  }
}

Buying a rate quoted with insurance binds the cover with the label; the shipment then carries an insurance object with insured, insured_value_usd and premium_usd. A void accepted before the parcel ships returns the premium with the label price.

Claims

POST /v1/claims files a claim on a shipment you insured through GoatLabels (or, on an uninsured label, against what the carrier includes). reason is lost, damaged, missing_contents or stolen (delivered scan, never received); amount_claimed_usd is capped at the insured value (422 claim_amount_exceeds_cover). Lost claims open after a waiting period (422 claim_not_yet_eligible carries the date); damage, missing contents and theft can be filed on discovery; every claim must be filed inside the filing window published by GET /insurance/program. Evidence is required per reason — an invoice, the product URL and a recipient statement, plus photos or video for damage and a police report for theft (422 claim_evidence_missing lists what is missing).

cURL
# Evidence URLs come from your own storage or the dashboard uploader; the
# insurer needs an invoice, the product URL and a recipient statement for a
# lost parcel, plus photos or video for damage.
curl -X POST https://goatlabels.io/api/v1/claims \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Idempotency-Key: 2b1f4c9e-…" \
  -H "Content-Type: application/json" \
  -d '{
    "shipment_id": "shp_…",
    "reason": "lost",
    "amount_claimed_usd": 500,
    "description": "No scan since 2026-10-02; recipient confirms non-receipt.",
    "evidence": [
      { "type": "invoice", "url": "https://files.example.com/inv-1042.pdf" },
      { "type": "product_url", "url": "https://shop.example.com/products/lamp" },
      { "type": "recipient_statement", "url": "https://files.example.com/stmt-1042.pdf" }
    ]
  }'
JSON
{
  "object": "claim",
  "id": "ins_…",
  "shipment_id": "shp_…",
  "status": "submitted",
  "reason": "lost",
  "amount_claimed_usd": 500,
  "insured_value_usd": 509.77,
  "amount_approved_usd": null,
  "decision_reason": null,
  "filed_with_insurer_at": null,
  "paid_at": null,
  "wallet_transaction_id": null,
  "created": 1761300000,
  "updated": 1761300000
}

status moves submitted → under_review → filed_with_insurer → approved → paid, or denied with the insurer's reason in decision_reason. We file with the insurer within one business day, chase it, and relay its decision; the insurer decides the claim. On paid the approved amount is credited to your wallet and wallet_transaction_id points at the ledger entry. GET /v1/claims lists (cursor-paginated) and GET /v1/claims/:id retrieves one; subscribe to the claim.updated webhook event instead of polling. Claims have no sandbox: filing one needs a Live key, and a Sandbox key gets 403 test_mode_unsupported.

Operations (inventory + POs)

Products, warehouses, stock ledger, suppliers, purchase orders and the month-end report — the Operations hub on the Pro plan, for ERP / WMS integrations.

Requires the Operations hub, part of the Pro plan

Every endpoint in this section answers 403 operations_hub_required until the Operations hub, part of the Pro plan and not on Free, is enabled on the account (the response carries upgrade_required: true when only the plan stands in the way). Reads need the read scope, writes the write scope. Nothing here moves money or calls a carrier, so Sandbox keys can use these endpoints, writes included, except sending a purchase order (it emails a real supplier). The Operations hub has no sandbox: those writes are real, they change your live catalog and stock, and reach a connected store when stock sync is on.

Products

GET /v1/products lists the catalog (cursor-paginated, sku filters to an one SKU, capitals ignored); POST creates, PATCH /v1/products/:id partially updates, DELETE removes. Fields: sku, name, gtin, unit_cost (your landed cost per unit — drives stock value and the report), reorder_point, track_inventory, pick_location, created. SKUs are trimmed and must be unique, capitals ignored (MUG-01 and mug-01 are one SKU), so a duplicate is refused with 409 duplicate_sku.

cURL
curl -X POST https://goatlabels.io/api/v1/products \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "sku": "MUG-BLK-11", "name": "Black mug 11oz", "unit_cost": 3.4, "reorder_point": 24 }'

Warehouses + inventory

GET /v1/warehouses returns your ship-from warehouses (address-book entries with a nickname) plus the synthetic unassigned bucket, each with sku_count and on_hand_total; use id as warehouse_id everywhere else. GET /v1/inventory is the on-hand grid — one inventory_level per product per warehouse, filterable by sku, warehouse_id and filter=low|oversold, with totals and the unmatched_skus / duplicate_skus hygiene lists. GET /v1/inventory/movements is the append-only ledger (newest first; opaque cursor → next_cursor, limit up to 500).

POST /v1/inventory/adjustments records one movement: identify the product by sku or product_id, pick a warehouse_id (omit for unassigned), and send exactly one of delta (signed) or set_to (absolute count — the delta is computed under the row lock, so concurrent sales can't be lost). The movement is stored with actor api, fires inventory.adjusted, and runs the low-stock check. Send an Idempotency-Key — a replay returns the original response without a second movement. POST /v1/inventory/adjustments/batch takes up to 200 entries, each succeeding or failing on its own.

cURL
# Cycle count: set MUG-BLK-11 in warehouse BK01 to exactly 140 units
curl -X POST https://goatlabels.io/api/v1/inventory/adjustments \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Idempotency-Key: count-2026-10-29-mug-blk-11" \
  -H "Content-Type: application/json" \
  -d '{ "sku": "MUG-BLK-11", "warehouse_id": "addr_bk01…", "set_to": 140, "reason": "Cycle count" }'
json
{
  "object": "inventory_adjustment",
  "movement_id": "mov_…",
  "product_id": "prd_…",
  "sku": "MUG-BLK-11",
  "warehouse_id": "addr_bk01…",
  "kind": "adjust",
  "delta": -3,
  "on_hand": 140,
  "no_op": false
}

Suppliers + purchase orders

GET/POST /v1/suppliers and GET/PATCH/DELETE /v1/suppliers/:id manage vendors (DELETE archives — POs keep the reference). POST /v1/purchase-orders creates a draft from lines of { sku | product_id, qty, unit_cost_usd? }; GET /v1/purchase-orders?status= lists summaries and GET /v1/purchase-orders/:id (id or PO-0012) returns the detail with lines. Lifecycle: POST …/send (emails the PDF when the supplier has an address; fires purchase_order.sent), POST …/receive, POST …/cancel, POST …/close. A transition the status machine refuses returns 409 invalid_status.

POST /v1/purchase-orders/:id/receive books stock into the PO's warehouse from either lines: [{ line_id, qty, unit_cost_usd? }] or all: true (every remaining unit). receipt_id is your delivery-note / GRN number and is the idempotency handle at the ledger level: the same receipt never books units twice, even without the header, and replayed lines come back with duplicate: true. A receipt fires purchase_order.received with the receipt object.

cURL
# Goods-in: receive GRN 4471 against PO-0012
curl -X POST https://goatlabels.io/api/v1/purchase-orders/PO-0012/receive \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "receipt_id": "GRN-4471", "lines": [{ "line_id": "pol_…", "qty": 48, "unit_cost_usd": 3.25 }] }'

Month-end report

GET /v1/reports/monthly?month=YYYY-MM&timezone= returns the same report the dashboard shows — orders, units, SKUs, channels, carriers, warehouses, and your label spend and COGS for the month (never GoatLabels' costs). month defaults to last month in the account timezone. GET /v1/reports/monthly.csv?view= streams one sheet as CSV (summary, orders, skus, channels, carriers, warehouses).

Idempotency

Send Idempotency-Key on every POST so retries are safe.

Generate a fresh UUID per intent (one shipment = one key). On a network blip, retry the request with the same key and the same body — you'll get the original response back, with Idempotent-Replayed: true in the headers, and we won't create a duplicate shipment.

  • Same key, same body → cached response replayed.
  • Same key, different body → 409 idempotency_error (we refuse to pin two different intents to one token).
  • Keys are scoped per API key — no cross-account collisions.
  • Only POST endpoints honour the header; GETs are already idempotent.
bash
# Retry-safe: same key + same body = same result, no duplicate shipment
curl -X POST https://goatlabels.io/api/v1/shipments \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Idempotency-Key: 7c1e4f2a-…" \
  -H "Content-Type: application/json" \
  -d @shipment.json

Webhooks

Register endpoints, then verify the HMAC-SHA256 signature on every delivery before trusting the body.

Manage endpoints

Register an endpoint with POST /v1/webhooks. The signing secret is returned once in secret — store it now; later reads only show a masked secret_preview. Rotate by recreating. Omit events to subscribe to all of them. URLs must be https://.

cURL
# The signing secret is returned ONCE in "secret" — store it now.
curl -X POST https://goatlabels.io/api/v1/webhooks \
  -H "Authorization: Bearer $GOATLABELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/webhooks/goatlabels",
    "events": ["shipment.label.created", "shipment.cancelled"]
  }'
JSON
{
  "object": "webhook",
  "id": "whk_…",
  "url": "https://example.com/webhooks/goatlabels",
  "events": ["shipment.label.created", "shipment.cancelled"],
  "enabled": true,
  "secret_preview": "whsec_…ab12",
  "created": 1731000000,
  "secret": "whsec_…"   // shown ONCE — store it now
}
  • GET /v1/webhooks — list your endpoints (secrets masked).
  • GET /v1/webhooks/:id — retrieve one.
  • PATCH /v1/webhooks/:id — update url / events / enabled. Re-enabling an auto-disabled webhook clears its failure count for a fresh start.
  • DELETE /v1/webhooks/:id — remove the endpoint and its delivery log.
  • GET /v1/webhooks/:id/deliveries — the per-attempt delivery log (event, response code, duration, next retry, exact payload sent).
  • POST /v1/webhooks/:id/deliveries/:deliveryId/replay — re-send a recorded delivery with the original byte-identical body (signature still verifies). Use after fixing an outage on your side.
  • POST /v1/webhooks/:id/test — deliver a synthetic ping now to confirm reachability + signature verification.

Retries: a non-2xx (or timeout) is retried with exponential backoff; an endpoint that keeps failing is auto-disabled and we notify your other endpoints via webhook.delivery.failed. Deliveries can arrive more than once in rare edge cases — key your processing on the payload's id field to stay idempotent.

Verify the signature

The X-GoatLabels-Signature header is t=<unix>,v1=<hex>. Compute HMAC_SHA256(secret, "{t}.{rawBody}").hex() and compare in constant time. Reject anything older than 5 minutes to mitigate replay.

Node.js (Express)
import crypto from "node:crypto";
import express from "express";

const app = express();
// Webhook verification needs the *raw* bytes — JSON-parsing first will
// re-serialize and break the signature.
app.use("/webhooks/goatlabels", express.raw({ type: "application/json" }));

app.post("/webhooks/goatlabels", (req, res) => {
  const sig = req.headers["x-goatlabels-signature"];
  if (typeof sig !== "string") return res.status(400).end();

  // Header is "t=<unix>,v1=<hex>"
  const parts = Object.fromEntries(
    sig.split(",").map((p) => p.split("=") as [string, string]),
  );
  const t = parts.t;
  const v1 = parts.v1;
  if (!t || !v1) return res.status(400).end();

  const expected = crypto
    .createHmac("sha256", process.env.GOATLABELS_WEBHOOK_SECRET)
    .update(`${t}.${req.body.toString("utf8")}`)
    .digest("hex");

  // Constant-time compare to avoid timing oracles.
  const ok =
    expected.length === v1.length &&
    crypto.timingSafeEqual(Buffer.from(expected, "hex"), Buffer.from(v1, "hex"));
  if (!ok) return res.status(401).end();

  // Optional: reject events older than 5 minutes to mitigate replay.
  if (Math.abs(Math.floor(Date.now() / 1000) - Number(t)) > 300) {
    return res.status(401).end();
  }

  const event = JSON.parse(req.body.toString("utf8"));
  // ... handle event.event (shipment.* | batch.* | credit.balance.low | payment.confirmed | ping)
  res.status(200).end();
});
Python (Flask)
import os, hmac, hashlib, time
from flask import Flask, request, abort

app = Flask(__name__)
SECRET = os.environ["GOATLABELS_WEBHOOK_SECRET"].encode()

@app.post("/webhooks/goatlabels")
def goatlabels_hook():
    sig = request.headers.get("X-GoatLabels-Signature", "")
    parts = dict(p.split("=", 1) for p in sig.split(",") if "=" in p)
    t, v1 = parts.get("t"), parts.get("v1")
    if not t or not v1:
        abort(400)

    # Use raw body bytes — re-serializing JSON would break the signature.
    payload = f"{t}.{request.get_data(as_text=True)}".encode()
    expected = hmac.new(SECRET, payload, hashlib.sha256).hexdigest()

    if not hmac.compare_digest(expected, v1):
        abort(401)
    if abs(int(time.time()) - int(t)) > 300:
        abort(401)  # replay window

    event = request.get_json()
    # ... handle event["event"] (shipment.* | batch.* | credit.balance.low | payment.confirmed | ping)
    return "", 200

Supported events

  • Shipment lifecycle: shipment.created, shipment.label.created, shipment.label.failed, shipment.cancelled.
  • Tracking (fired once per transition, deduped across pollers/sweepers): shipment.in_transit, shipment.out_for_delivery, shipment.delivered, shipment.exception, shipment.returned. Subscribe to these instead of polling the tracking endpoints.
  • Billing adjustments: shipment.adjustment.created — a carrier re-weigh / correction hit your wallet. Payload carries the adjustment id, shipment id, signed delta, and the wallet transaction id.
  • Batch import: batch.started, batch.item.finished, batch.finished.
  • Wallet & payments: credit.balance.low, payment.confirmed, payment.expired.
  • Refunds: refund.requested, refund.completed.
  • Insurance claims: claim.updated — fired on every status change (filed with the insurer, approved, paid, denied). Payload carries the claim object.
  • Operations hub: inventory.adjusted (a manual / API / import / receipt movement — payload is the inventory_movement with the new on_hand), inventory.low_stock (a level crossed its reorder point — payload is the inventory_level), purchase_order.sent (the PO detail plus emailed) and purchase_order.received (the receipt object). Only accounts with the Operations hub ever emit these.
  • Self-monitoring: webhook.delivery.failed (fired to your other endpoints when one exhausts all retries).
  • Synthetic: ping (the Send-test button / /test endpoint).

Sample event payloads

JSON
// Tracking lifecycle (shipment.in_transit / out_for_delivery / delivered / exception / returned)
{
  "id": "evt_…",
  "event": "shipment.delivered",
  "createdAt": "2026-07-08T16:22:04.000Z",
  "livemode": true,
  "data": {
    "shipmentId": "shp_…",
    "orderNumber": "ORD-1042",
    "trackingNumber": "1Z999AA10123456784",
    "carrier": "UPS",
    "status": "delivered"
  }
}

// Carrier billing adjustment
{
  "id": "evt_…",
  "event": "shipment.adjustment.created",
  "createdAt": "2026-07-08T16:22:04.000Z",
  "livemode": true,
  "data": {
    "adjustmentId": "adj_…",
    "shipmentId": "shp_…",
    "deltaAmount": 1.89,
    "direction": "charge",
    "balanceAfter": 140.66,
    "walletTransactionId": "txn_…"
  }
}

livemode is true on a live event and false on an event a Sandbox key caused. A sandbox endpoint only ever receives the second kind, a live endpoint only the first.

Errors

Every 4xx / 5xx from /v1/* returns the same JSON envelope. Branch on error.type, not the message.

All partner-API errors share one stable shape so your integration can write a single error handler. Validation failures (missing field, wrong type, out-of-range value) come back as 400 invalid_request_error with an issues[] array describing every offending field — the same Zod issue objects our server uses internally, so path points straight at the field you sent.

JSON
HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "error": {
    "type": "invalid_request_error",
    "message": "Request body failed validation.",
    "issues": [
      {
        "code": "invalid_type",
        "expected": "string",
        "received": "undefined",
        "path": ["to", "postal_code"],
        "message": "Required"
      },
      {
        "code": "too_small",
        "minimum": 1,
        "type": "number",
        "inclusive": true,
        "exact": false,
        "path": ["parcel", "weight"],
        "message": "Number must be greater than or equal to 1"
      }
    ]
  }
}

Known error.type values

  • invalid_request_error — 400. Body or query failed schema validation. Walk issues[] for the field paths. Also returned when the Idempotency-Key header is malformed.
  • authentication_error — 401. Missing or invalid Bearer key on a /v1/* route. Rotate the key from Sign up to create an API key.
  • plan_quota_error — 402. You've hit the monthly shipment cap on your current plan. Upgrade from the dashboard and retry.
  • rate_limit_error — 429. Per-key rate limit exceeded. Honour the Retry-After header.
  • idempotency_error — 409. You reused an Idempotency-Key with a different body. See Idempotency.
  • not_found — 404. Returned for shipments / tracking numbers that don't belong to the calling key — never leaks data across accounts.
  • insufficient_scope — 403. A read-only key tried to call a mutating endpoint (create, purchase, void, pickups, webhooks). Use a key with the write scope. See Authentication.
  • test_mode_unsupported — 403. A Sandbox key tried to file an insurance claim or send a purchase order, which the sandbox does not cover. Use a Live key.
  • sandbox_only — 403. A Live key called a /v1/sandbox endpoint. Use a Sandbox key.
  • sandbox_full — 409. The sandbox holds its limit of 5,000 shipments. Call POST /v1/sandbox/reset.
  • operations_hub_required — 403. An Operations endpoint was called on an account without the Operations hub; upgrade_required: true means a plan change would unlock it. Related Operations types: duplicate_sku and warehouse_cap (both 409), invalid_status (409, a purchase-order transition the status machine refuses).
  • service_unavailable — 503. A carrier upstream (e.g. void or pickup) was temporarily unreachable; honour Retry-After and retry. On purchase, your wallet is auto-refunded (code: carrier_unavailable).
  • carrier_rejected — 409 on void (code: carrier_void_rejected), 422 on purchase (code: carrier_rejected, with carrierDetail). The carrier refused the request; fix the shipment or retry later. Nothing is left charged — a refused purchase is refunded and a refused void leaves the label live.
  • hazmat_unNumber_required, hs_code_required — 400. Structured domain-specific cases on POST /v1/shipments. See Create a shipment for the full payload shape — these carry an offenders array of item indices instead of issues[].
  • eu_product_identifier_required — 422 on purchase. A consumer sale into the EU has an item with no manufacturer_part_number and no pid_exempt. Nothing is charged; missingItemIndexes lists the items. See EU product identifiers.

Handling a validation error

Node.js
const res = await fetch(`${baseUrl}/shipments`, {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.GOATLABELS_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify(shipment),
});

if (!res.ok) {
  const { error } = await res.json();
  switch (error.type) {
    case "invalid_request_error":
      // error.issues is a ZodIssue[] — surface field-level errors in your UI.
      for (const issue of error.issues ?? []) {
        const field = issue.path.join(".");
        console.warn(`${field}: ${issue.message}`);
      }
      break;
    case "authentication_error":
      throw new Error("Rotate the GoatLabels API key.");
    case "rate_limit_error":
      await sleep(Number(res.headers.get("retry-after") ?? 1) * 1000);
      // retry…
      break;
    case "idempotency_error":
      // Same key was used with a different body — generate a fresh key per intent.
      throw new Error("Idempotency-Key collision.");
    default:
      throw new Error(error.message ?? "Unknown GoatLabels error");
  }
}

5xx responses follow the same envelope. 503 GOAT_TEMP_OUTAGE on /v1/shipments/:id/purchase means a carrier upstream is down — your wallet is automatically refunded; safe to retry the same Idempotency-Key after the Retry-After window.

OpenAPI spec

The complete, machine-readable description of every /v1 endpoint — generate clients, import into Postman, or browse the reference.

Everything documented here is generated from an authoritative OpenAPI 3.1 document. Point your codegen, Postman, or Insomnia at it, or browse the interactive reference.

bash
# Generate a typed client from the spec (example: openapi-typescript)
npx openapi-typescript https://goatlabels.io/api/v1/openapi.yaml -o goatlabels.d.ts

Need something not in here? Open a ticket from Contact.

Before calling the validate endpoint on real orders, read address validation before buying a label for the defects it catches and how to fix them. Shipping a file rather than a loop? Bulk shipping labels from a CSV covers the dashboard importer, its column aliases and a downloadable template.

For an overview of creating shipments, see the GoatLabels shipping API. Weighing a script against a dashboard? Read when an API beats a dashboard. Coming from another tool? See why Pirate Ship has no public API. To build a typed client from the spec, read how to generate a shipping API client from OpenAPI. For webhook handlers, see the shipping webhook recipes. Need several carriers behind one integration? Read about the multi-carrier shipping API. Building your own checkout? See shipping for custom storefronts. Starting from zero? Follow the shipping API quickstart in five languages. Integrating a carrier directly instead? Compare the USPS, UPS and FedEx developer APIs. Before you go live, read the terms that cover your account.