Move stock between states
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/inventory/levels/move';const options = { method: 'POST', headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'}, body: '{"note":"example","idempotency_key":"example","items":[{"variant_id":1,"from":"available","to":"available","quantity":1}],"reason":"correction"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://apibase.ecomweb.app/api/v1/stores/example/inventory/levels/move \ --header 'Content-Type: application/json' \ --header 'x-api-key: <x-api-key>' \ --data '{ "note": "example", "idempotency_key": "example", "items": [ { "variant_id": 1, "from": "available", "to": "available", "quantity": 1 } ], "reason": "correction" }'Moves a quantity of a variant’s stock from one state to another, for example from available to damaged, for up to 250 items in one request. from and to must differ. The request is refused with 409 when the source state does not hold enough: INSUFFICIENT_INVENTORY for available on a variant that does not allow overselling, INVENTORY_STATE_NEGATIVE for an unavailable state. reason defaults to correction. Sending the same idempotency_key again writes nothing and answers with replayed true.
Required scopes: write:inventory
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The store’s ref, as returned by GET /stores.
Request Bodyrequired
Section titled “Request Bodyrequired”object
A note recorded with the change in the variants’ history.
Repeating a key makes the request a no-op.
The moves, 1 to 250.
object
ID of the variant.
The state the stock leaves.
The state the stock enters. It must differ from from.
How many units to move, at least 1.
Why the stock is being moved. Defaults to correction.
Responses
Section titled “Responses”object
The levels that were written, as they are now.
object
What happens when stock runs out: deny stops sales, continue keeps selling.
Variant ID.
ID of the product the variant belongs to.
Product name.
Product image URL, or null.
The variant’s option values joined with /, or null for a product without options.
Stock keeping unit, or null.
ID of the location that holds the stock.
Whether stock is tracked for the variant.
Units that can be sold now.
Units reserved by orders that are not yet fulfilled.
Units set aside as damaged.
Units set aside for quality control.
Units held back as safety stock.
Units set aside for another reason.
Total of damaged, quality control, safety stock and other.
Units physically held: available, committed and unavailable together.
Units expected from open purchase orders.
When the level last changed, as an ISO 8601 timestamp.
True when the idempotency_key was used before: nothing was written and applied is empty.
Example
{ "applied": [ { "inventory_policy": "deny" } ]}The request is malformed or failed validation.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key is missing, invalid, revoked or expired.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The resource does not exist in this store.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The request conflicts with the resource’s current state.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}