createStockMovement
Requires permission inventory:stock_movement:create.
Records one stock movement and changes stock by its quantity. An issue must be negative and a receipt positive, and a movement of the wrong sign is refused; transfers, adjustments, returns and cycle counts carry their own sign. Which warehouse is affected depends on the type, and the movement needs one. A quantity entered in a pack unit is converted to base units. Needs the stock movement create permission.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
mutation CreateStockMovement($input: CreateStockMovementInput!) {
createStockMovement(input: $input) {
id
batchNumber
movementNumber
serialNumber
status
type
fromWarehouse {
id
code
taxRegistrationNumber
name
status
type
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation CreateStockMovement($input: CreateStockMovementInput!) {\n createStockMovement(input: $input) {\n id\n batchNumber\n movementNumber\n serialNumber\n status\n type\n fromWarehouse {\n id\n code\n taxRegistrationNumber\n name\n status\n type\n }\n }\n}",
"variables": {
"input": {
"productId": "id",
"quantity": 0,
"type": "ADJUSTMENT",
"variantId": "id"
}
}
}
EOF
Variables:
{
"input": {
"productId": "id",
"quantity": 0,
"type": "ADJUSTMENT",
"variantId": "id"
}
}
Response:
{
"data": {
"createStockMovement": {
"id": "id",
"batchNumber": "string",
"movementNumber": "string",
"serialNumber": "string",
"status": "CANCELLED",
"type": "ADJUSTMENT",
"fromWarehouse": {
"id": "id",
"code": "string",
"taxRegistrationNumber": "string",
"name": "string",
"status": "ACTIVE",
"type": "string"
}
}
}
}
Record a stock adjustment:
- GraphQL
- cURL
mutation CreateStockMovement($input: CreateStockMovementInput!) {
createStockMovement(input: $input) {
id
movementNumber
status
balanceQuantity
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation CreateStockMovement($input: CreateStockMovementInput!) {\n createStockMovement(input: $input) {\n id\n movementNumber\n status\n balanceQuantity\n }\n}",
"variables": {
"input": {
"productId": "PRODUCT_ID",
"variantId": "VARIANT_ID",
"type": "ADJUSTMENT",
"quantity": 5
}
}
}
EOF
Variables:
{
"input": {
"productId": "PRODUCT_ID",
"variantId": "VARIANT_ID",
"type": "ADJUSTMENT",
"quantity": 5
}
}
Response:
{
"data": {
"createStockMovement": {
"id": "STOCK_MOVEMENT_ID",
"movementNumber": "MOVEMENT_NUMBER",
"status": "COMPLETED",
"balanceQuantity": 5
}
}
}
createStockMovement(
input: CreateStockMovementInput!
): StockMovement!
Arguments
createStockMovement.input ● CreateStockMovementInput! non-null input
The movement type, warehouses, product, variant, quantity and optional batch, serial number, reference, reason, notes and unit.
Type
StockMovement object
A movement of stock: a receipt, issue, transfer or adjustment.