# confirmStockInExternalSystem mutation


`confirmStockInExternalSystem` is a GraphQL mutation of the Chameleoon MAX API. Send it as `POST https://max-api.chameleoon.sk/api/v1/graphql` with your API key, see [Chameleoon MAX](/chameleoon-max).

Records that the external system that manages the warehouse holds these receipts, issues and
transfers up to their `stockVersion`, as of its own clock. Call it after you write a MAX
document into the external system, and before you send a snapshot that contains it.

[`syncStockLevels`](/chameleoon-max/mutation/sync-stock-levels) adds every document that the external system has not confirmed
to the snapshot's quantities, so a snapshot never undoes a document the external system did not
have yet.

#### Permissions

Requires the `stock.sync` permission.

#### Repeated calls

A repeat, or a delayed confirmation of an older version, changes nothing.

#### Errors

The call runs in one transaction: after any of these errors, nothing is confirmed.

| Code | Reason | When |
| --- | --- | --- |
| `NOT_FOUND` | | The document does not exist or is outside your API key's scope. |
| `VALIDATION` | `STOCK_VERSION_UNKNOWN` | The document never had this `stockVersion`. |
| `VALIDATION` | `DOCUMENT_HAS_EXTERNAL_ISSUE` | The document is an order's issue, and the order has an external issue in the warehouse ([`reportExternalIssue`](/chameleoon-max/mutation/report-external-issue)). The field is `documents[i].documentId`. |
| `VALIDATION` | | The document is not a receipt, an issue or a transfer, or `side` is sent for a document that is not a transfer. |
| `VALIDATION` | | No external system manages the document's warehouse. |

#### Good to know

- An order's issue whose order has an external issue in the warehouse is never confirmed. MAX
  offsets it against what the external system reported.
- A transfer with only one end in your API key's scope confirms only that end.

> An error whose path runs below this field does not mean the call failed: the documents were
> confirmed, so do not retry. See [`Mutation`](/chameleoon-max/mutations).

Costs 1 point plus 1 per document, plus its selection.

## Arguments

- `input`: [`ConfirmStockInExternalSystemInput!`](/chameleoon-max/type/confirm-stock-in-external-system-input) · required

## Returns

[`ConfirmStockInExternalSystemResult!`](/chameleoon-max/type/confirm-stock-in-external-system-result)

## Example

**Mutation**

```graphql
mutation confirmStockInExternalSystem($input: ConfirmStockInExternalSystemInput!) {
  confirmStockInExternalSystem(input: $input) {
    confirmed
  }
}
```

**Variables**

```json
{
  "input": {
    "documents": [
      {
        "documentId": "00000000-0000-4000-8000-000000000001",
        "stockVersion": "example",
        "stockEffectiveAt": "2026-01-01T00:00:00Z"
      }
    ]
  }
}
```

**Response**

```json
{
  "data": {
    "confirmStockInExternalSystem": {
      "confirmed": 1
    }
  }
}
```

Values are illustrative: replace IDs and codes with your own before you send the call.
