Inventory

Inventory represents the quantity of stock that a specific seller has for a multi-store advert variant. For instance, a parent seller might have an advert with two variants: “Blue / Small” and “Red / Large”; Seller A might hold 2 of the “Blue / Small” variant while Seller B holds 3 of the “Red / Large” variant. This would be represented by 2 inventory items:

  • Seller A, “Blue / Small”, 2 on hand
  • Seller B, “Red / Large”, 3 on hand

You can retrieve the seller IDs related to the multi-store using multi_store_memberships.

This endpoint only deals with multi-store adverts. For single seller adverts, stock levels are set diretly on the variant.

List a variant’s inventory items

Request

GET /api/v2/client/variants/1/inventories

Response

Status: 200 OK
{
  "data": [
    {
      "id": 1,
      "type": "inventories",
      "attributes": {
        "count_on_hand": 10,
        "seller_id": 1
      }
    }
  ]
}

Updating a variant’s inventory

Request

PUT /api/v2/client/variant/1/inventories

Example

If you do not send a record for a seller who already has stock in the system, that seller's stock will remain unchanged. To set a seller as having no stock, you must explicitly send a 0 value.
{
  "data": [
    {
      "type": "inventories",
      "attributes": {
        "count_on_hand": 10,
        "seller_id": 1
      }
    },
    {
      "type": "inventories",
      "attributes": {
        "count_on_hand": 15,
        "seller_id": 2
      }
    }
  ]
}

Response

Status: 200 OK
{
  "data": [
    {
      "id": 1,
      "type": "inventories",
      "attributes": {
        "count_on_hand": 10,
        "seller_id": 1
      }
    },
    {
      "id": 2,
      "type": "inventories",
      "attributes": {
        "count_on_hand": 15,
        "seller_id": 2
      }
    }
  ]
}

Deleting an inventory record

An inventory record with a 0 count_on_hand value is handled differently to a non-existent inventory record. The 0 value will show the seller in the store selector but disabled; a non-existent record means the seller won't be shown at all in the store selector.

Request

DELETE /api/v2/client/variant/1/inventories/1

Reponse

Status: 204 No Content