---
title: "Set the inventory quantity"
description: >
  Set the available inventory quantity for a specified inventory item at a specified location. The provided quantity replaces the existing available inventory quantity.
doc_type: openapi
doc_category: openapi
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/docs/admin-rest-api/product/inventory/set-item-inventory'
  md: 'https://developer.shopline.com/docs/admin-rest-api/product/inventory/set-item-inventory.md'
---
# Set the inventory quantity

Set the available inventory quantity for a specified inventory item at a specified location. The provided quantity replaces the existing available inventory quantity.

- **Base URL:** `https://{handle}.myshopline.com/admin/openapi`
- **Required Scopes:** `write_inventory`
- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** RESTful

## Endpoint

```http
POST /inventory_levels/set.json
```

## Base URL

* `https://{handle}.myshopline.com/admin/openapi`

  * `{handle}`: `handle` : The store's unique identifier, which is the prefix of the store's domain name. For example, if a store's domain name is `open001.myshopline.com` , the store handle is `open001` .

## Required Permissions

* `write_inventory`

## Request

### Request Headers

* `Content-Type`

  string (required)

  The field must be set to the fixed value `application/json; charset=utf-8`.

* `Authorization`

  string (required)

   The access token for the API resource. Refer to [App authorization](https://developer.shopline.com/docs/apps/api-instructions-for-use/app-authorization.md?lang=en) to obtain the access token, and then pass the obtained token in the Bearer format. 

### Request Body

* `available`

  long

  The available inventory quantity to set. This value replaces the existing available inventory quantity at the specified location.

* `inventory_item_id`

  string

  The unique identifier for the inventory item.<br/>
  Maximum length: 64

* `location_id`

  string

  The unique identifier for the inventory location.<br/>
  Maximum length: 64

## Response

### Status Codes

* `200`

  For the complete list of codes and messages, see [Http status code](https://developer.shopline.com/docs/apps/api-instructions-for-use/http-status-code.md?lang=en).

* `401`

  

* `429`

  

### Response Headers

* `traceId`

  A globally unique identifier for the request. It is used to track the request flow throughout the system, allowing for easy location and debugging when issues arise.

### Response Body

#### 200

* `inventory_level`

  object

  Inventory information for the specified inventory item at the specified location.

  * `available`

    long

    The available inventory quantity.

  * `created_at`

    string

    The date and time when the inventory information was created. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).

  * `inventory_item_id`

    string

    The unique identifier for the inventory item.

  * `location_id`

    string

    The unique identifier for the inventory location.

  * `updated_at`

    string

    The date and time when the inventory information was updated. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).

  * `variant_id`

    string

    The unique identifier for the product variant.


#### 401

* `errors`

  string

  Error message. 


#### 429

* `errors`

  string

  Error message. 


## OpenAPI Definition

```json
{
  "tags": [
    "Set the inventory quantity"
  ],
  "description": "Set the available inventory quantity for a specified inventory item at a specified location. The provided quantity replaces the existing available inventory quantity.",
  "externalDocs": {
    "description": "Permission point used by the interface is `write_inventory` , For more information about the use of permission points, see",
    "url": "ec20/3cv5d7wpfgr6a8z5/xabczf5442284vkq?lang=en",
    "errorTableDescription": "| Error Code | HTTP Status Code | Error Description |\n|------------|------------------|-------------------|\n| DATA_NOT_EXIST | 404 | The requested data does not exist. |\n| INVALID_PARAMETER | 400 | The provided parameter is invalid. |\n| SUCCESS | 200 | request success |\n| SYSTEM_ERROR | 500 | system error |\n"
  },
  "operationId": "SSpgCuDk",
  "parameters": [
    {
      "name": "Content-Type",
      "in": "header",
      "description": "The field must be set to the fixed value `application/json; charset=utf-8`.",
      "required": true,
      "schema": {
        "name": "Content-Type",
        "type": "string",
        "example": "application/json; charset=utf-8"
      }
    },
    {
      "name": "Authorization",
      "in": "header",
      "description": " The access token for the API resource. Refer to [App authorization](https://developer.shopline.com/docs/apps/api-instructions-for-use/app-authorization.md?lang=en) to obtain the access token, and then pass the obtained token in the Bearer format. ",
      "required": true,
      "style": "string",
      "schema": {
        "name": "Authorization",
        "description": " The access token for the API resource. Refer to [App authorization](https://developer.shopline.com/docs/apps/api-instructions-for-use/app-authorization.md?lang=en) to obtain the access token, and then pass the obtained token in the Bearer format. ",
        "type": "string",
        "example": "Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MCwiYXBwS2V5IjoiNzU2ZjI1NWE2NjdlZTcwNTk1MzM0ZjVjYzk4NzU5MzBmN2E3NGZjMSIsImV4cCI6MTg3OTQ4MjA3NiwiaXNzIjoieXNvdWwiLCJzZWxsZXJJZCI6IjIwMDAyMzQ4ODAiLCJzdG9yZUlkIjoiMTY3MjM2OTcyOTYwNiIsInRpbWVzdGFtcCI6MTc4NDc4NzY3NjY2MSwidmVyc2lvbiI6IlYyIn0.3ZzbGAH4cLU1QR2VPEvMOQInUDvus-C4amkINSQIPuNVlXsFKj0sAt1c0KnUy9MWUOFV9cHlkf7J90r2y1FzpA"
      },
      "example": "Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MCwiYXBwS2V5IjoiNzU2ZjI1NWE2NjdlZTcwNTk1MzM0ZjVjYzk4NzU5MzBmN2E3NGZjMSIsImV4cCI6MTg3OTQ4MjA3NiwiaXNzIjoieXNvdWwiLCJzZWxsZXJJZCI6IjIwMDAyMzQ4ODAiLCJzdG9yZUlkIjoiMTY3MjM2OTcyOTYwNiIsInRpbWVzdGFtcCI6MTc4NDc4NzY3NjY2MSwidmVyc2lvbiI6IlYyIn0.3ZzbGAH4cLU1QR2VPEvMOQInUDvus-C4amkINSQIPuNVlXsFKj0sAt1c0KnUy9MWUOFV9cHlkf7J90r2y1FzpA"
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "name": "body",
          "description": "body position parameter",
          "type": "object",
          "properties": {
            "available": {
              "name": "available",
              "description": "The available inventory quantity to set. This value replaces the existing available inventory quantity at the specified location.",
              "type": "long",
              "example": 10
            },
            "inventory_item_id": {
              "name": "inventory_item_id",
              "description": "The unique identifier for the inventory item.<br/>\nMaximum length: 64",
              "type": "string",
              "example": "5703943240925324252"
            },
            "location_id": {
              "name": "location_id",
              "description": "The unique identifier for the inventory location.<br/>\nMaximum length: 64",
              "type": "string",
              "example": "5421703880295066100"
            }
          },
          "required": [
            "inventory_item_id",
            "location_id",
            "available"
          ],
          "example": {
            "available": 10,
            "inventory_item_id": "5703943240925324252",
            "location_id": "5421703880295066100"
          }
        },
        "examples": {
          "Set the inventory quantity": {
            "description": "Set the available inventory quantity for the specified inventory item at the specified location to 10, replacing the existing quantity.",
            "value": {
              "available": 10,
              "inventory_item_id": "5703943240925324252",
              "location_id": "5421703880295066100"
            }
          }
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "description": "For the complete list of codes and messages, see [Http status code](https://developer.shopline.com/docs/apps/api-instructions-for-use/http-status-code.md?lang=en).",
      "headers": {
        "traceId": {
          "description": "A globally unique identifier for the request. It is used to track the request flow throughout the system, allowing for easy location and debugging when issues arise."
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "name": "body",
            "type": "object",
            "properties": {
              "inventory_level": {
                "name": "inventory_level",
                "description": "Inventory information for the specified inventory item at the specified location.",
                "type": "object",
                "properties": {
                  "available": {
                    "name": "available",
                    "description": "The available inventory quantity.",
                    "type": "long",
                    "example": 10
                  },
                  "created_at": {
                    "name": "created_at",
                    "description": "The date and time when the inventory information was created. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).",
                    "type": "string",
                    "example": "2022-12-06T20:23:06+08:00"
                  },
                  "inventory_item_id": {
                    "name": "inventory_item_id",
                    "description": "The unique identifier for the inventory item.",
                    "type": "string",
                    "example": "5703943240925324252"
                  },
                  "location_id": {
                    "name": "location_id",
                    "description": "The unique identifier for the inventory location.",
                    "type": "string",
                    "example": "5421703880295066100"
                  },
                  "updated_at": {
                    "name": "updated_at",
                    "description": "The date and time when the inventory information was updated. Format: [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html).",
                    "type": "string",
                    "example": "2022-12-06T20:25:55+08:00"
                  },
                  "variant_id": {
                    "name": "variant_id",
                    "description": "The unique identifier for the product variant.",
                    "type": "string",
                    "example": "18057039432358082693350282"
                  }
                },
                "example": {
                  "available": 10,
                  "created_at": "2022-12-06T20:23:06+08:00",
                  "inventory_item_id": "5703943240925324252",
                  "location_id": "5421703880295066100",
                  "updated_at": "2022-12-06T20:25:55+08:00",
                  "variant_id": "18057039432358082693350282"
                }
              }
            },
            "example": {
              "inventory_level": {
                "available": 10,
                "created_at": "2022-12-06T20:23:06+08:00",
                "inventory_item_id": "5703943240925324252",
                "location_id": "5421703880295066100",
                "updated_at": "2022-12-06T20:25:55+08:00",
                "variant_id": "18057039432358082693350282"
              }
            }
          },
          "examples": {
            "Set the inventory quantity": {
              "description": "Set the available inventory quantity for the specified inventory item at the specified location to 10, replacing the existing quantity.",
              "value": {
                "inventory_level": {
                  "available": 10,
                  "created_at": "2022-12-06T20:23:06+08:00",
                  "inventory_item_id": "5703943240925324252",
                  "location_id": "5421703880295066100",
                  "updated_at": "2022-12-06T20:25:55+08:00",
                  "variant_id": "18057039432358082693350282"
                }
              }
            }
          }
        }
      }
    },
    "401": {
      "headers": {
        "traceId": {
          "description": "A globally unique identifier for the request. It is used to track the request flow throughout the system, allowing for easy location and debugging when issues arise."
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "errors": {
                "description": "Error message. ",
                "type": "string"
              }
            },
            "required": [
              "errors"
            ]
          }
        }
      }
    },
    "429": {
      "headers": {
        "traceId": {
          "description": "A globally unique identifier for the request. It is used to track the request flow throughout the system, allowing for easy location and debugging when issues arise."
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "errors": {
                "description": "Error message. ",
                "type": "string"
              }
            },
            "required": [
              "errors"
            ]
          }
        }
      }
    }
  },
  "security": [
    {
      "oauth2": []
    }
  ],
  "method": "post",
  "path": "/inventory_levels/set.json",
  "servers": [
    {
      "url": "https://{handle}.myshopline.com/admin/openapi",
      "variables": {
        "handle": {
          "default": "openapiceshidianpu",
          "description": "`handle` : The store's unique identifier, which is the prefix of the store's domain name. For example, if a store's domain name is `open001.myshopline.com` , the store handle is `open001` ."
        }
      }
    }
  ],
  "info": {
    "title": "Set the inventory quantity",
    "version": "v20270301"
  },
  "authIndexes": [
    "write_inventory"
  ]
}
```