Template Docs Commerce APIs Webhooks Tools
Get Started
Get Started

Adjust stock quantities

POST https://api.squarespace.com/{api-version}/commerce/inventory/adjustments

Adjusts stock quantities for product variants. Stock quantities can be added or subtracted, set with a given number, or marked as "unlimited". All quantity information is stored in InventoryItems.

Read the Overview to learn more about InventoryItems.

Parameters

{api-version} string
required

See the Inventory API Overview page for the current API version.

Request example

Read the Making requests guide to learn why specific headers are necessary, and why some are omitted. Every request should also abide by Squarespace rate limits.

curl "https://api.squarespace.com/1.0/commerce/inventory/adjustments" \
  -i \
  -H "Authorization: Bearer YOUR_API_KEY_OR_OAUTH_TOKEN" \
  -H "User-Agent: YOUR_CUSTOM_APP_DESCRIPTION" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: YOUR_IDEMPOTENCY_KEY" \
  -X POST \
  -d '{' \
    # Optional; array of objects. Increments stock quantity for InventoryItems.
    '"incrementOperations": [{' \
      # Unique id for the InventoryItem.
      '"variantId": "185db2da-c3cf-47f3-8aff-0485082792a5",' \
      # Amount to add to the current stock quantity; must be greater than or equal to 1.
      '"quantity": 1' \
    '}],' \
    # Optional; array of objects. Subtracts stock quantity for InventoryItems.
    '"decrementOperations": [{' \
      # Unique id for the InventoryItem.
      '"variantId": "7eb25f50-4a0a-4e86-ac7c-cc1d49347bb4",' \
      # Amount to subtract from the current stock quantity; must be greater than or equal to 1.
      '"quantity": 1' \
    '}],' \
    # Optional; array of objects. Sets the exact stock quantity for InventoryItems.
    '"setFiniteOperations": [{' \
      # Unique id for the InventoryItem.
      '"variantId": "cdf29b1e-01c2-4931-a3f9-7c0568daff23",' \
      # New quantity for the InventoryItem.
      '"quantity": 40' \
    '}],' \
    # Optional; array of InventoryItem ids. Marks stock quantity
    # as "unlimited" for the given InventoryItems.
    '"setUnlimitedOperations": [' \
      '"3afec275-5c9e-4167-93a7-17c01bba1ae2",' \
      '"f4334e47-b517-4291-8bcc-1e11dfc51a4f"' \
    ']' \
  '}'

Precautions

Don't forget the Idempotency-Key header; it's required. Read the idempotency key guide to learn more.

Don't send a request without a valid stock adjustment.
Although all four operation arrays are optional, at least one must be provided with valid values (i.e. an array that isn't empty).

Response example

A response to a successful request will not contain any data.

Status codes and error conditions

204 NO CONTENT

The request was successful. The message body does not contain any data. If this is a request with a previously used Idempotency-Key, the previous operation was successful and no new changes were made.


400 BAD REQUEST

Type: INVALID_REQUEST_ERROR

Subtype: null

  • The request body is missing a required field, or a field is an incorrect type.
  • No operations were specified.
  • Greater than 50 operations were specified.
  • One or more InventoryItems were not found.
  • The same InventoryItem was referenced in more than one operation.
  • A specified quantity is invalid.
  • The Idempotency-Key header is missing or invalid. Refer to the idempotency key guide for requirements.
  • The provided Idempotency-Key has already been used by another request bearing a different body.

409 CONFLICT

Type: CONFLICT

Subtype: CONCURRENT_MODIFICATION

  • A request using the provided Idempotency-Key is already in progress. If the request should be attempted independently of the other request, specify a new Idempotency-Key and try again.
  • A request modifying one or more of the specified InventoryItems could not be completed due to an overlapping request. You may retry your request.

Subtype: INSUFFICIENT_STOCK
A decrement operation cannot be completed because the referenced InventoryItem does not have sufficient stock.

Subtype: STOCK_EXCEEDS_MAX
An increment operation cannot be completed because the referenced InventoryItem will exceed the maximum allowed stock.

Subtype: STOCK_NOT_TRACKED
An increment or decrement operation cannot be completed because the referenced InventoryItem has unlimited inventory.