syncStockLevels mutation
syncStockLevels 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.
Sets the stock of an externally managed warehouse to the quantities that the external system that manages the warehouse reports. Call it when you send that system's stock of one or more product variants as a snapshot.
Each item states all of one variant's stock in the warehouse, in physical units:
- A stock position that the item omits is 0.
- An empty
positionslist means the variant has no stock in the warehouse. - MAX writes only the difference, as one stock-sync document that no list shows, dated now.
- Receipts, issues and transfers written in MAX that the external system had not recorded at
asOfare kept. The external system reports which ones it holds withconfirmStockInExternalSystem.
Permissions
Requires the stock.sync and integration.read permissions.
Repeated calls
A repeat with the same requestId and the same input changes nothing and returns what the
first call returned.
Items
MAX applies an item whole or refuses it whole, and goes on with the other items. Read each
result's status.
- A later call can write a refused item.
- An item is
DEFERREDwhen the call has already written 500 movements. Send the item again with a newrequestId. asOfcomes from the external system's clock. It must be newer than theasOflast judged for the variant in the warehouse (an item that wasAPPLIEDorUNCHANGED), otherwise the item is refused withSTALE_SNAPSHOT.
Errors
| Code | Reason | When |
|---|---|---|
NOT_FOUND | The warehouse does not exist or is outside your API key's scope. | |
CONFLICT | STOCK_NOT_MASTERED | No external system manages the warehouse. |
CONFLICT | SOURCE_ARCHIVED | The external system that manages the warehouse is archived. |
CONFLICT | REQUEST_ID_REUSED | The requestId was sent before with other input. |
VALIDATION | asOf is more than 15 minutes ahead of the MAX clock. | |
VALIDATION | More than 100 items or 2000 positions, a negative quantity, a blank externalId, or the same item or position twice. | |
INTERNAL | The call lost a race with another write. Retry with the same requestId. |
An error whose path runs below this field does not mean the call failed: the snapshot was applied, so do not retry. See
Mutation.
Costs 1 point plus 1 per item and 1 per position, plus its selection.
Arguments
input:SyncStockLevelsInput!· required
Returns
Example
Mutation
Code
Variables
Code
Response
Code
Values are illustrative: replace IDs and codes with your own before you send the call.