Adjust stock quantities
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/inventory/levels/adjust';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,"state":"available","delta":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/adjust \ --header 'Content-Type: application/json' \ --header 'x-api-key: <x-api-key>' \ --data '{ "note": "example", "idempotency_key": "example", "items": [ { "variant_id": 1, "state": "available", "delta": 1 } ], "reason": "correction" }'Changes available or one of the unavailable states (damaged, quality_control, safety_stock, other) by a positive or negative delta, for up to 250 items in one request. available may be adjusted below zero, but an unavailable state may not: that request is refused with 409 INVENTORY_STATE_NEGATIVE. The change is recorded in each variant’s history with the reason. 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 changes, 1 to 250. A variant may repeat with different states.
object
ID of the variant.
The state to change.
Never zero.
Why the stock is being adjusted.
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"}