# POST /partner/dispatch/shipments/{shipment_id}/units/release

Take units out of a B2B order that is still open, with a reason. Requires the dispatch:write scope.

Source: https://docs.sealtrust.io/en/reference/post-partner-dispatch-shipments-id-units-release/

---

You take units out of an order that is still open, for instance a damaged
unit or one put in the box by mistake. The row is not erased: it is closed,
with the date, the author and the reason. The whole flow is in the guide [Tie each unit to its order](/en/expedition-b2b/).

## Authorization

API key in the `Authorization` header, `Bearer` format, with the
`dispatch:write` scope. A key without it gets a 403 whose message names the
missing scope. The plan of the key's brand must include API access, and the
shipment's brand must be on the Compliance + Identity offer.

```http
Authorization: Bearer votre_clef
```

## Rate limit

The same as the other partner routes: one counter per key and one for the sum
of your brand's keys, 120 calls per 60-second window by default. Every call that
writes takes 1 unit of the key's daily quota, whatever the number of units it
carries.

## Request body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `units` | `array` of `string` | yes | 1 to 1000 units, in the same forms as for adding. |
| `reason` | `string` | yes | The reason, 1 to 200 characters. |

## Example request

```bash
curl -i -X POST "https://api.sealtrust.io/v1/partner/dispatch/shipments/318/units/release" \
  -H "Authorization: Bearer st_live_0000000000000000000000000000000000000000000000" \
  -H "Content-Type: application/json" \
  -d '{"units": ["K2M8Q0R4T6V1"], "reason": "damaged box"}'
```

## Example response

HTTP 200, the same shape as adding. Each unit answers `released`,
`not_in_shipment` (it is not in this order), `unknown_unit` or `unreadable`.

## Errors

| Code | Condition | What to do |
| --- | --- | --- |
| 401 | Key missing, malformed or unknown. | Send `Authorization: Bearer <your key>` with the whole key. |
| 403 | The key lacks the `dispatch:write` scope. Message `Missing required scopes: dispatch:write`. | Create a key that carries this scope. |
| 403 | The brand is on the Compliance offer. `detail.code` is `OFFER_EXCLUDES_IDENTITY` and `detail.feature` is `dispatch`. Nothing is recorded. | Move to the Compliance + Identity offer. Retrying changes nothing. |
| 429 | Rate limit or daily quota reached. | Wait the number of seconds in `Retry-After`, or midnight UTC for the quota. |
| 404 | No shipment of your brand has this id. A shipment of another brand gets exactly the same answer. | Check the `id` returned at creation. |
| 409 | The shipment is closed or cancelled. `detail.code` is `shipment_not_open`. | A closed shipment no longer changes. Create a new order. |
