# Ship and deliver a shipment

Operation ID: `commitShipment`

Group: Inventory › Shipments

[Open in the interactive reference](https://lensing.ai/api-docs/lensing/v1/endpoints/commitShipment)

`POST /inventory/shipments/{id}/commit`

Not retry-safe: A write that does not run in its own transaction, so it cannot offer replay; it refuses Idempotency-Key with 400. Retry only on a natural key the endpoint rejects duplicates on.

Ships and delivers a shipment in one request. Moves a draft or packed shipment to 'DELIVERED': the stock leaves the warehouse and the cost of sale is recorded in a journal entry. The response gives the new status and, when a journal entry was created, its id in journalEntryId.

Every line must leave from the same warehouse. The check runs before any stock leaves or any journal entry is created, and a shipment with lines in more than one warehouse fails the request with MIXED_LOCATIONS.

A delivered shipment can't be changed or deleted, and no endpoint cancels it.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Api-Version` | header | string · v1 | yes | The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version `v1`. |
| `id` | path | string | yes | The unique identifier of the shipment you want to commit. |

## Request body

Required, `application/json`: commitShipmentInput.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `cogsChoice` | string | no | Whether the cost of sale is amortized. AMORTIZED requests COGS amortization schedules, which are created only for service lines, so on a shipment of goods it changes nothing. Defaults to NON_AMORTIZED. One of: `"NON_AMORTIZED"`, `"AMORTIZED"`. |

```json
{}
```

## Response

`200` Success

Under `data` (commitShipmentOutput):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | The unique identifier for the shipment. Example: `"2f7c9b31-8a05-4d16-b47e-903c5f1a86d2"`. |
| `documentStatus` | string | yes | The status the shipment is now in, read back from the document. Possible values: 'DRAFT', 'PACKED', 'PARTIALLY_SHIPPED', 'SHIPPED', 'COMMITTED', 'DELIVERED', 'COMPLETED', 'CANCELLED', 'INVOICED', 'PARTIALLY_INVOICED', 'RETURNED', 'PARTIALLY_RETURNED'. Example: `"DELIVERED"`. |
| `journalEntryId` | string | no | The unique identifier for the journal entry this step posted, when it posted one. See id on GET accounting/journal-entries/:id. Example: `"6b2d90f1-4c37-4e85-a019-8d3f5c72b6e4"`. |
| `warnings` | array<string> | yes | Non-fatal advisories from the step. An empty array on a clean run. The step succeeded regardless of what is listed here. Example: `[]`. |

```json
{
  "data": {
    "id": "2f7c9b31-8a05-4d16-b47e-903c5f1a86d2",
    "documentStatus": "DELIVERED",
    "journalEntryId": "6b2d90f1-4c37-4e85-a019-8d3f5c72b6e4",
    "warnings": []
  },
  "diagnostics": [
    {
      "code": "<code>",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": "<details>"
    }
  ]
}
```

## Errors

| Code | Status |
| --- | --- |
| `NOT_FOUND` | 400 |
| `WRONG_STATUS` | 400 |
| `NO_LINES` | 400 |
| `SOURCE_LINE_NOT_PROJECTED` | 400 |
| `MIXED_LOCATIONS` | 400 |
| `POSTING_REJECTED` | 400 |
| `IDEMPOTENCY_NOT_SUPPORTED` | 400 |

## Statuses

- `400` — Invalid request or business failure. Codes: NOT_FOUND, WRONG_STATUS, NO_LINES, SOURCE_LINE_NOT_PROJECTED, MIXED_LOCATIONS, POSTING_REJECTED. Sending an Idempotency-Key is answered with `IDEMPOTENCY_NOT_SUPPORTED`: this action does not run in its own transaction, so the replay guarantee cannot be offered and the header is refused rather than ignored.
- `401` — The request carries no valid access token.
- `403` — Not authorized
- `404` — Not found
- `429` — Too many requests from this client address. The response has no body and no `Retry-After` header.
- `500` — Internal server error
