# Shipments

List your shipping labels, view one, and void a label for a refund. To buy a
label, see [Rates & Labels](rates-and-labels.md).

`GET` endpoints need the `read:shipments` scope, and voiding needs
`write:shipments`. See [Authentication](authentication.md). A shipment that
belongs to another account returns `404 NOT_FOUND`, the same as one that does
not exist.

## List Shipments

```
GET /api/v1/shipments
```

Returns a paginated list of shipments for your account, newest first.

### Query Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `page` | integer | `1` | Page number |
| `limit` | integer | `50` | Items per page (max 100) |
| `status` | string | — | Filter by label status (see below) |
| `carrier` | string | — | Filter by carrier name, e.g. `usps` (case-insensitive) |
| `dateFrom` | string | — | Shipments created on or after this time (ISO 8601) |
| `dateTo` | string | — | Shipments created on or before this time (ISO 8601) |

A date without a time (`2026-02-18`) covers that whole UTC day, so
`dateFrom=2026-02-18&dateTo=2026-02-18` returns every label created on
February 18 (UTC).

Label `status` values:

| Status | Meaning |
|--------|---------|
| `created` | Rated but no label bought |
| `rate_selected` | A rate was chosen but no label bought |
| `purchased` | Label bought |
| `shipped` | The carrier has the package |
| `delivered` | Delivered |
| `voided` | Label voided; see `refundStatus` |
| `void_failed` | The carrier refused the void. The label is still active, and you can try again |

Carrier tracking progress is in `trackingStatus`, separate from `status`.

### Example

```bash
curl "https://shipwave.app/api/v1/shipments?carrier=usps&limit=25" \
  -H "Authorization: Bearer sw_live_abc123..."
```

```typescript
const res = await fetch(
  "https://shipwave.app/api/v1/shipments?carrier=usps&limit=25",
  { headers: { Authorization: "Bearer sw_live_abc123..." } }
);
const { data, meta } = await res.json();
```

### Response

```json
{
  "data": [
    {
      "id": "clx2ship1",
      "easypostId": "shp_abc123",
      "trackingCode": "9400111899223100012345",
      "status": "purchased",
      "carrierCode": "usps",
      "labelUrl": "https://easypost-files.s3.amazonaws.com/label.png",
      "customsFormUrl": null,
      "trackingStatus": "in_transit",
      "estimatedDeliveryDate": "2026-02-20T00:00:00.000Z",
      "deliveredAt": null,
      "isReturn": false,
      "insurance": 0,
      "signature": false,
      "refundStatus": null,
      "voidedAt": null,
      "createdAt": "2026-02-18T16:00:00.000Z",
      "updatedAt": "2026-02-19T09:15:00.000Z",
      "selectedRate": {
        "carrier": "USPS",
        "service": "Priority",
        "rate": "12.50",
        "currency": "USD",
        "deliveryDays": 2,
        "deliveryDate": null,
        "deliveryGuaranteed": false
      },
      "toAddress": {
        "name": "Jane Smith",
        "street1": "123 Main St",
        "street2": "Apt 4B",
        "city": "Austin",
        "state": "TX",
        "zip": "78701",
        "country": "US",
        "phone": null
      },
      "fromAddress": {
        "name": "Main Warehouse",
        "street1": "500 Commerce Dr",
        "street2": null,
        "city": "Portland",
        "state": "OR",
        "zip": "97201",
        "country": "US",
        "phone": "5035550100"
      },
      "parcel": {
        "weight": 32.5,
        "length": 12,
        "width": 8,
        "height": 6,
        "predefinedPackage": null
      },
      "returnRequest": null,
      "orderShipments": [
        {
          "orderId": "clx1abc2d3efg",
          "order": {
            "orderNumber": "1042",
            "customerName": "Jane Smith"
          }
        }
      ]
    }
  ],
  "meta": {
    "page": 1,
    "limit": 25,
    "total": 142,
    "totalPages": 6
  }
}
```

---

## Get Shipment

```
GET /api/v1/shipments/:id
```

Returns a single shipment in the same shape as one item from the list response.

### Example

```bash
curl https://shipwave.app/api/v1/shipments/clx2ship1 \
  -H "Authorization: Bearer sw_live_abc123..."
```

### Response

```json
{
  "data": {
    "id": "clx2ship2",
    "easypostId": "shp_def456",
    "trackingCode": "1Z999AA10123456784",
    "status": "purchased",
    "carrierCode": "ups",
    "labelUrl": "https://easypost-files.s3.amazonaws.com/return-label.png",
    "customsFormUrl": null,
    "trackingStatus": "delivered",
    "estimatedDeliveryDate": "2026-02-24T00:00:00.000Z",
    "deliveredAt": "2026-02-24T15:42:00.000Z",
    "isReturn": true,
    "insurance": 0,
    "signature": false,
    "refundStatus": null,
    "voidedAt": null,
    "createdAt": "2026-02-20T11:00:00.000Z",
    "updatedAt": "2026-02-24T15:45:00.000Z",
    "selectedRate": {
      "carrier": "UPS",
      "service": "Ground",
      "rate": "14.25",
      "currency": "USD",
      "deliveryDays": 3,
      "deliveryDate": null,
      "deliveryGuaranteed": false
    },
    "toAddress": {
      "name": "Main Warehouse",
      "street1": "500 Commerce Dr",
      "street2": null,
      "city": "Portland",
      "state": "OR",
      "zip": "97201",
      "country": "US",
      "phone": "5035550100"
    },
    "fromAddress": {
      "name": "Jane Smith",
      "street1": "123 Main St",
      "street2": "Apt 4B",
      "city": "Austin",
      "state": "TX",
      "zip": "78701",
      "country": "US",
      "phone": null
    },
    "parcel": {
      "weight": 32.5,
      "length": 12,
      "width": 8,
      "height": 6,
      "predefinedPackage": null
    },
    "returnRequest": {
      "id": "clx3ret1",
      "reason": "defective",
      "reasonDetail": "Will not power on"
    },
    "orderShipments": [
      {
        "orderId": "clx1abc2d3efg",
        "order": {
          "orderNumber": "1042",
          "customerName": "Jane Smith"
        }
      }
    ]
  }
}
```

### Shipment Fields

| Field | Description |
|-------|-------------|
| `status` | Label status (see [List Shipments](#list-shipments)) |
| `trackingStatus` | Latest carrier tracking status, e.g. `pre_transit`, `in_transit`, `delivered` |
| `selectedRate.rate` | The price of the label to you, as a decimal string |
| `insurance` | Declared insurance amount in dollars (`0` when none) |
| `isReturn` | `true` for return labels; `returnRequest` links the return |
| `refundStatus` | Carrier refund status after a void, otherwise `null` |
| `orderShipments` | Orders this label fulfills |

### Errors

| Status | Code | Cause |
|--------|------|-------|
| 404 | `NOT_FOUND` | The shipment does not exist or belongs to another account |

---

## Void / Refund Label

```
POST /api/v1/shipments/:id/void
```

Voids a label with the carrier and requests a refund. Requires
`write:shipments`.

A label the carrier has already scanned cannot be voided. ShipWave checks its
own tracking record and then asks the carrier before it voids anything.

### Example

```bash
curl -X POST https://shipwave.app/api/v1/shipments/clx2ship1/void \
  -H "Authorization: Bearer sw_live_abc123..."
```

```typescript
const res = await fetch(
  "https://shipwave.app/api/v1/shipments/clx2ship1/void",
  {
    method: "POST",
    headers: { Authorization: "Bearer sw_live_abc123..." },
  }
);
const { data } = await res.json();
```

### Response

```json
{
  "data": {
    "shipmentId": "clx2ship1",
    "refundStatus": "submitted",
    "trackingCode": "9400111899223100012345",
    "balanceRefundedCents": 0,
    "balanceRefundStatus": "pending_carrier",
    "balanceRefundHeldUntil": null,
    "balanceRefundMessage": "The carrier refund is pending. $12.50 returns to your shipping balance after the carrier confirms it (USPS usually takes 15 to 30 days) and no sooner than 7 days after the void, if the label was never scanned.",
    "balanceSettlementError": null,
    "orderStatus": "pending",
    "shopifyReconciliation": {
      "status": "cancelled",
      "fulfillmentIds": [5123456789]
    }
  }
}
```

| Field | Description |
|-------|-------------|
| `refundStatus` | The carrier's answer: `submitted` (refund requested) or `refunded` (refund completed) |
| `balanceRefundStatus` | For labels paid from a ShipWave shipping balance: `credited`, `held`, `pending_carrier` or `not_credited`. `none` for labels not paid from a balance |
| `balanceRefundedCents` | Amount credited back to your balance by this call |
| `balanceRefundHeldUntil` | When a `held` credit is released (ISO 8601), otherwise `null` |
| `balanceRefundMessage` | A sentence describing the balance credit, or `null` |
| `balanceSettlementError` | Set when the balance credit could not be recorded yet. The void still succeeded |
| `orderStatus` | The linked order's status after the void. Present when the label belongs to an order |
| `shopifyReconciliation` | What happened to the Shopify fulfillment for this label: `status` is `cancelled`, `tracking_updated`, `not_applicable`, `not_found`, `failed` or `skipped_unconfirmed_void`. Present when the label belongs to an order |

**Balance credits.** A refund for a label paid from your shipping balance is
credited only after the carrier confirms the refund, and no sooner than 7 days
after the void. If the carrier scans the label during those 7 days, the credit
is not made.

### Side Effects

- The shipment's `status` becomes `voided` and `voidedAt` is set.
- The linked order's status is recalculated from the items its remaining active
  labels cover: `pending` when none are covered, `partially_shipped` when some
  are, and `shipped` when all are. The new status is returned as `orderStatus`.
- The Shopify fulfillment for this label is cancelled or updated (see
  `shopifyReconciliation`).
- A `shipment.voided` [webhook](webhooks.md) is sent.

### Retries

If a void succeeded but you never got the response, retrying returns
`409 CONFLICT` with `Label already voided`. Treat that as success, and read the
shipment with [Get Shipment](#get-shipment) for its `refundStatus`.

### Errors

| Status | Code | Cause |
|--------|------|-------|
| 400 | `VALIDATION_ERROR` | The shipment has no carrier label to void |
| 400 | `INTERNAL_ERROR` | The carrier refused the void. The shipment's `status` becomes `void_failed` and the label stays active; you can retry |
| 404 | `NOT_FOUND` | The shipment does not exist or belongs to another account |
| 409 | `CONFLICT` | The label is already voided (see [Retries](#retries)), or the carrier has scanned it (`details.reason` is `carrier_scanned`) |
| 502 | `INTERNAL_ERROR` | The carrier could not be reached (`details.reason` is `carrier_unavailable`). Nothing changed; retry later |
