> ## Documentation Index
> Fetch the complete documentation index at: https://docs.loopreturns.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search shipments

> Look up an order's shipments by order name or tracking code.

Look up shipments for the authenticated shop by order name or tracking code.

```
GET https://api.wonderment.com/2022-10/shipments/search/{searchTerm}
```

The shop is taken from the access token. A successful search returns the order and its packages. Call this endpoint from your server. The access token is a secret, and a token placed in a URL is rejected.

## Authentication

Send the access token on every request:

```
X-Wonderment-Access-Token: sk_live_...
```

Create the token in the app under **Settings → Integrations → Access Tokens**. The token is shown once, when you create it.

Use HTTPS. Send the token in the header above. If the token appears anywhere in the URL, the API responds with `400` and this body:

```json theme={null}
{
  "error": "API keys must not be sent in the URL. Send them in a request header (x-wonderment-access-token, or Authorization for tools API keys), and rotate any key that has been sent in a URL."
}
```

Rotate any token that has been sent in a URL.

## Search term

`searchTerm` is one path segment. Percent-encode reserved characters. An order name usually starts with `#`, which is `%23` in the path:

```bash Order name search theme={null}
curl "https://api.wonderment.com/2022-10/shipments/search/%231001" \
  -H "X-Wonderment-Access-Token: sk_live_..."
```

```bash Tracking code search theme={null}
curl "https://api.wonderment.com/2022-10/shipments/search/9400111206213767912345" \
  -H "X-Wonderment-Access-Token: sk_live_..."
```

The term is matched without regard to case.

* An order name matches with or without the leading `#`. `#1001` and `1001` find the same order.
* A tracking code matches the code on the tracked shipment.
* When the term matches an order name, the response is that order. A tracking code that happens to equal an order name does not override the order match.
* A term that ends in a period and a digit from 1 to 9 is matched without those two characters. `#1001.1` is searched as `#1001`. This accepts a fulfillment name such as `#1001.1`.
* Fulfillments with nothing to ship are excluded. Fulfillments must have at least one shippable line item to appear.
* Fulfillments that share a tracking code are returned as one shipment. Line items from each of those fulfillments are combined on that shipment.

The terms `preview`, `preview-<status>`, and `#9999` return sample tracking-page data.

You can omit the path segment when the `t` parameter includes `query`. See [Customer verification](#customer-verification).

## Customer verification

All shops require the customer's email or phone before a search returns an order. Send the customer's email or phone in the `t` query parameter. `t` is the standard Base64 encoding of a JSON object:

| Field | Required | Description |
| - | - | - |
| `query` | Required when the path has no search term | Order name or tracking code. When present, it replaces the path search term. |
| `email` | One of `email` or `phone` | Customer email. Compared without regard to case. |
| `phone` | One of `email` or `phone` | Customer phone. Must match the phone stored on the order exactly. |

If both `email` and `phone` are present, either one matching the order is enough.

```javascript Node.js theme={null}
const payload = {
  email: "customer@example.com",
  query: "#1001",
}

const t = Buffer.from(JSON.stringify(payload)).toString("base64")

const url = new URL("https://api.wonderment.com/2022-10/shipments/search")
url.searchParams.set("t", t)

const response = await fetch(url, {
  headers: { "X-Wonderment-Access-Token": process.env.TRACK_ACCESS_TOKEN },
})
```

```bash cURL theme={null}
# After producing the Base64-encoded t parameter
curl "https://api.wonderment.com/2022-10/shipments/search?t=${t}" \
  -H "X-Wonderment-Access-Token: sk_live_..."
```

The API rejects a search that does not match the customer. The response is `401`:

```json theme={null}
{ "message": "We couldn't find that order" }
```

That same message is returned when the email or phone does not match. An order that does not exist is different: it returns `200` with an empty body. See [No match](#no-match).

## Response

A found order is `200` with `Content-Type: application/json`.

```json theme={null}
{
  "name": "#1001",
  "pendingLineItems": [],
  "shipments": [
    {
      "trackingUrl": "https://tools.usps.com/go/TrackConfirmAction?tLabels=9400111206213767912345",
      "trackingCode": "9400111206213767912345",
      "carrierName": "USPS",
      "eta": "2026-04-24T00:00:00.000Z",
      "serviceLevel": {
        "name": "USPS Ground Advantage",
        "token": "usps_ground_advantage"
      },
      "order": {
        "id": "1234567890",
        "name": "#1001"
      },
      "statusDetails": {
        "trackingCode": "9400111206213767912345",
        "details": "Delivered, in/at mailbox",
        "status": "DELIVERED",
        "substatus": "delivered",
        "date": "2026-04-24T14:32:00",
        "city": "Austin",
        "state": "TX",
        "zip": "78701",
        "country": "US",
        "trackingUrl": "https://tools.usps.com/go/TrackConfirmAction?tLabels=9400111206213767912345",
        "eta": "2026-04-24 00:00:00",
        "createdAt": "2026-04-24T14:36:12Z",
        "locationDisplay": "Austin, TX, 78701, US",
        "isTimezoneProvided": false,
        "displayTimezone": "America/Chicago"
      },
      "events": [
        {
          "trackingCode": "9400111206213767912345",
          "details": "Delivered, in/at mailbox",
          "status": "DELIVERED",
          "substatus": "delivered",
          "date": "2026-04-24T14:32:00",
          "city": "Austin",
          "state": "TX",
          "zip": "78701",
          "country": "US",
          "trackingUrl": "https://tools.usps.com/go/TrackConfirmAction?tLabels=9400111206213767912345",
          "eta": "2026-04-24 00:00:00",
          "createdAt": "2026-04-24T14:36:12Z",
          "locationDisplay": "Austin, TX, 78701, US",
          "isTimezoneProvided": false,
          "displayTimezone": "America/Chicago"
        }
      ],
      "lineItems": [
        {
          "trackingCode": "9400111206213767912345",
          "lineItemId": "9876543210",
          "productImage": "https://cdn.shopify.com/s/files/example/product.jpg",
          "productName": "Wonderment T-Shirt",
          "variantName": "Medium / Black",
          "variantImage": "https://cdn.shopify.com/s/files/example/variant.jpg",
          "sku": "WM-TSHIRT-M-BLK",
          "quantity": 1
        }
      ]
    }
  ]
}
```

`statusDetails` is the latest event in `events`. Each event copies the shipment's `trackingUrl` onto the scan. The event `eta` is the estimate as stored on the shipment, which can be a different format from the ISO-8601 `eta` on the shipment itself.

### Order

| Field | Description |
| - | - |
| `name` | Order name, such as `#1001`. |
| `shipments` | Packages for the match. Empty when every package was omitted, and empty for a pickup order that has no carrier shipment. |
| `pendingLineItems` | Shippable line items that are not fully fulfilled. Present on every found order. Populated for an order-name search when the shop has pending line items enabled. Empty for a tracking-code search, a cancelled order, and a shop without that capability. |

### Shipment

| Field | Description |
| - | - |
| `trackingCode` | Carrier tracking code. Empty on the pending placeholder described below. |
| `trackingUrl` | Carrier tracking URL stored for the fulfillment. `null` on the pending placeholder. |
| `carrierName` | Carrier display name, such as `USPS`, `UPS`, or `FedEx`. |
| `eta` | Estimated delivery as an ISO-8601 timestamp. FedEx and UPS values are interpreted as UTC. Omitted when the carrier has not provided one. The pending placeholder uses the literal string `pending`. |
| `serviceLevel.name` | Service level display name. |
| `serviceLevel.token` | Service level code. |
| `order.id` | Shopify order ID, without a `gid://shopify/Order/` prefix. |
| `order.name` | Order name. |
| `statusDetails` | Latest included tracking event. Omitted when the shipment has no included events. |
| `events` | Included tracking events, oldest first. |
| `lineItems` | Shippable line items in this package. |
| `date` | Present on the pending placeholder only. ISO-8601 timestamp for when the placeholder was built. |

### Tracking events

Each event in `events`, and `statusDetails` when it is present, has these fields:

| Field | Description |
| - | - |
| `trackingCode` | Tracking code for the scan. |
| `details` | Carrier description. Text that was stored in all capitals is returned in sentence case. |
| `status` | Shipment status. Common values are `PRE_TRANSIT`, `TRANSIT`, `IN_TRANSIT`, `OUT_FOR_DELIVERY`, `DELIVERED`, `ATTEMPTED_DELIVERY`, `READY_FOR_PICKUP`, `RETURNED`, `FAILURE`, and `UNKNOWN`. |
| `substatus` | Normalized carrier detail. One of `address_issue`, `contact_carrier`, `delayed`, `delivered`, `delivery_attempted`, `delivery_rescheduled`, `delivery_scheduled`, `information_received`, `location_inaccessible`, `notice_left`, `other`, `out_for_delivery`, `package_accepted`, `package_arrived`, `package_damaged`, `package_departed`, `package_disposed`, `package_forwarded`, `package_held`, `package_lost`, `package_processed`, `package_processing`, `package_unclaimed`, `package_undeliverable`, `pickup_available`, `reschedule_delivery`, `return_to_sender`, `arrived_at_customs`, `delayed_in_customs`, `departed_from_customs`, `canceled`. |
| `date` | When the scan happened. Includes the offset when the carrier supplied a timezone. Otherwise a timestamp with no trailing `Z`. |
| `city`, `state`, `zip`, `country` | Scan location. Any of them may be empty. |
| `locationDisplay` | Location parts that are present, joined in city, state, zip, country order. The city is title case. |
| `trackingUrl` | The shipment's tracking URL, copied onto the event. |
| `eta` | The shipment ETA as stored, copied onto the event. This is often a timestamp such as `2026-04-24 00:00:00`, while the shipment's own `eta` is ISO-8601. |
| `isTimezoneProvided` | `true` when the carrier supplied a timezone for `date`. |
| `displayTimezone` | IANA timezone used to display the event, when one is known. |
| `createdAt` | When the event was stored, UTC, with a trailing `Z`. |

Events older than eight months are omitted. Carriers reuse tracking numbers, and older scans belong to a previous shipment. `statusDetails` is the newest event that remains.

### Line items

| Field | Description |
| - | - |
| `trackingCode` | Fulfillment tracking code this item was packed under. |
| `lineItemId` | Shopify line item ID, without a `gid://shopify/LineItem/` prefix. |
| `productName` | Product title. |
| `productImage` | Product image URL. May be empty. |
| `variantName` | Variant title. May be empty. |
| `variantImage` | Variant image URL. May be empty. |
| `sku` | SKU. May be empty. |
| `quantity` | Quantity fulfilled in this package when that quantity is known, otherwise the line item quantity. |

### Pending line items

Items in `pendingLineItems` use a different id field from packed line items.

| Field | Description |
| - | - |
| `lineItemID` | Shopify line item ID. |
| `productName` | Product title. |
| `productImage` | Product image URL, or `null`. |
| `variantName` | Variant title, or `null`. |
| `variantImage` | Variant image URL, or `null`. |
| `sku` | SKU, or `null`. |
| `quantity` | Ordered quantity. |
| `fulfilledQuantity` | Quantity already fulfilled. |
| `pendingQuantity` | Quantity still to fulfill. |

### Order received, no tracking yet

An order that exists, and has no tracking code yet, returns one placeholder shipment:

```json theme={null}
{
  "name": "#1002",
  "pendingLineItems": [],
  "shipments": [
    {
      "trackingCode": "",
      "trackingUrl": null,
      "carrierName": "",
      "date": "2026-04-21T09:15:00.000Z",
      "eta": "pending",
      "serviceLevel": { "name": "", "token": "" },
      "statusDetails": {
        "status": "PENDING",
        "substatus": "order_received",
        "date": "2026-04-21T09:15:00.000Z",
        "details": "Order has been received"
      },
      "lineItems": [],
      "events": [],
      "order": { "id": "1234567891", "name": "#1002" }
    }
  ]
}
```

`date` on this placeholder is the time of the response, not a carrier scan. `substatus` here is `order_received`, which is only used on this placeholder.

### Pickup orders

A pickup order with no carrier tracking code returns the pickup in place of the placeholder shipment. `shipments` is empty.

```json theme={null}
{
  "id": "1234567892",
  "name": "#1003",
  "pendingLineItems": [],
  "shipments": [],
  "isCancelled": false,
  "isPickup": true,
  "pickupStatus": "ready",
  "pickupLocation": {
    "address1": "100 Main St",
    "city": "Austin",
    "province": "TX",
    "zip": "78701",
    "countryCode": "US"
  },
  "readyAt": "2026-04-22T15:00:00.000Z",
  "pickedUpAt": null
}
```

| Field | Description |
| - | - |
| `id` | Shopify order ID. Present on this pickup response. |
| `isCancelled` | `true` when the order has been cancelled. |
| `isPickup` | `true`. |
| `pickupStatus` | `awaiting_pickup`, `ready`, or `picked_up`. |
| `pickupLocation` | Store address. Omitted when the pickup has no location. Empty address fields are omitted. |
| `readyAt` | When the order became ready for pickup, or `null`. |
| `pickedUpAt` | When it was picked up, or `null`. |

When an order has several pickups, the response describes the one that is still waiting. After every pickup is collected, the response describes the last one.

`pickupStatus` is `picked_up` when `pickedUpAt` is set, `ready` when `readyAt` is set and the order is not picked up, and `awaiting_pickup` otherwise.

### No match

A search that finds no order returns `200` with an empty body. The body is empty, so parse JSON only after checking that the body has content.

```javascript theme={null}
const response = await fetch(url, { headers })

if (response.status === 200 && (await response.clone().text()) === "") {
  // No order matched the search term.
}
```

### Side effect

A search that finds an order records a tracking page view for the shop. The view is attributed using the request `Origin` and `Referer` headers when those headers are present.

## Errors

| Status | When | Body |
| - | - | - |
| `400` | The request has no search term. The path is empty and `t` does not supply `query`. | `{ "message": "Invalid request. Must include search term." }` |
| `400` | The access token appears in the URL. | `{ "error": "API keys must not be sent in the URL. ..." }` |
| `401` | The header is missing, or the token is not valid. | `{ "message": "401: Authentication Failed" }` |
| `401` | Customer verification failed. | `{ "message": "We couldn't find that order" }` |
| `402` | The shop does not have an active paid plan. | `{ "message": "Upgrade to a Wonderment paid plan for access." }` |
| `403` | The token does not include shipment read access. | `{ "message": "Forbidden" }` |
| `404` | The path has more than one segment after `/shipments/search/`. | |
| `500` | The search failed unexpectedly. | `{ "error": "<message>" }` |

The `500` message describes the failure and is not a stable contract. Retry the request.

When the shop's subscription cannot be confirmed, the search is allowed through and returns a normal `200`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.