Skip to main content

Quickstart

This guide walks you through creating your first shipping label, retrieving the label document, and tracking the shipment.

Prerequisites

  • An API key and API token (see Authentication for how to obtain them)
  • curl or any HTTP client
  • The development base URL: https://sandbox.flexforwardship.com
Use the development environment for testing. It connects to courier sandbox services and does not create live shipments.

Step 1: Authenticate

Include both headers on every request:
See the Authentication page for credential best practices and error responses.

Step 2: Create a label

Send a POST /labels request with your shipment details. The idempotencyKey ensures that retrying the same request does not create a duplicate label.
Replace idempotencyKey (unique-key-per-request) and order.customerOrderNumber (N-2026-05-27-TEST-03) with values that are unique to each run. Order numbers accept 1–40 ASCII letters, digits, -, and _. Re-sending the sample unchanged returns the stored result from the first run (HTTP 200); changing the body while reusing the key returns 409 IDEMPOTENCY_CONFLICT. See Idempotency and Retries for the legacy-record exception.
Minimum required fields: idempotencyKey, courier, service.productCode, shipment.shipTo (contact with firstName, address with countryCode, city, postalCode, streetLines), and at least one parcel with weight and one item (descriptionEn, quantity, unitPrice, unitWeight). The shipment.shipFrom field is required for certain couriers and shipping lanes — confirm requirements with the Flex Forward team during onboarding.
Use a courier code returned by GET /couriers. The examples below use yunexpress, but your valid values depend on the couriers enabled for your account.
A successful response returns HTTP 201 with the label details:
201 Created
Key fields in the response:
If you retry the same request with the same idempotencyKey, the API returns HTTP 200 with the original result instead of creating a duplicate label. That stored result may have status: failed if the first attempt was rejected by the courier, so always check the status field rather than relying on the HTTP status code alone. See Idempotency and Retries and Error Handling for details.

Step 3: Retrieve the label document

Use the label id from the previous response to retrieve the airway bill document:
200 OK
Download the PDF from the returned url to print the shipping label. This sample requests label.format: "PDF". You can also request "PNG" at creation; the document response then reports labelFormat: "png".

Step 4: Track the shipment

Use the same label id to retrieve tracking information:
200 OK
The tag field provides the high-level shipment status. See Core Concepts for the full list of tracking statuses.

What success looks like

After completing this quickstart, verify you can:
  • Authenticate successfully with your API key and API token
  • Create a test label in the development environment
  • Retrieve a printable label document (PDF)
  • Fetch normalized tracking updates for your test label
  • Parse responses tolerantly — ignore unknown fields and enum values instead of rejecting them (see Versioning)

What’s next

Error Handling

Understand error responses and how to troubleshoot common issues.

Idempotency and Retries

Learn how to retry requests safely without creating duplicate labels.

Core Concepts

Understand the label lifecycle, tracking model, and carrier normalization.