Ankorstore Catalog API
ℹ️ This section describes the API endpoints that you can use to manage your catalog resources, such as products, product variants etc. ## 💡 Working with Products Here you will find information about the product resource and its sub-resources. If you need further information please refer to the API specification. ### Including Product Variants When retrieving the individual product via the API, you may pass an `?include=productVariants` query parameter that will return associated product variants inside the `included` root level object. ### Important Fields within Product Resource If the field contains no data, it will be `null`. ## 💡 Stock Management This API allows you to manage your product variants stock for the marketplace in both single- and bulk-operation mode. There are 2 opposite options available for the stock update requests - set an explicit product quantity or mark the corresponding product as "always in stock". ### Stock statuses Stock for the marketplace can be in one of two states. It can be `available` to order on the marketplace, or `reserved` for an order that has been submitted, but not yet shipped. Added together, these quantities make up the `onHand` state, which reflects the total quantity of the product variant "on hand" at your storage location(s). > ⚠️ **Unless specified otherwise, `stockQuantity` used in the following APIs refers to `onHand` quantity** See also [Stock State](#tag/folderName_Stock-Concepts/Stock-state) for more general information about stock states used in the Stock Tracking APIs. #### Example * 100 units of the product variant X are stock at your location (`onHand`). * 30 units of product variant X are `reserved` for Ankorstore orders that have not yet been shipped. * Then 70 units of product variant X are `available` to order on the marketplace. Now consider you produce 50 more units of product variant X, and sell 27 units on another marketplace. Your input for the stock update API would be: ``` // 100 + 50 - 27 = 133 "stockQuantity": 123 ``` ### Set product variant stock explicit quantity To set an explicit quantity for the particular product variant, you should specify the amount in the payload. In case if the target product variant was previously marked as "always in stock", this option will be disabled and the stock will be set to given value. Example of the payload to set a product variant stock to the given value (single-operation mode): `PATCH /api/v1/product-variants/1ed18988-6651-610e-8223-aa5cd9844f96/stock` ```json { "data": { "attributes": { "stockQuantity": 123 } } } ``` More details can be found in the endpoint specification ### Set product variant as "always in stock" To mark a particular product variant as "always in stock" and do not care about the stock amounts, you should include a flag `isAlwaysInStock` into the request payload. In case if the target product variant had explicit stock amount set previously, it will be reset. Example of the payload to set a product variant stock to the given value (single-operation mode): `PATCH /api/v1/product-variants/1ed18988-6651-610e-8223-aa5cd9844f96/stock` ```json { "data": { "attributes": { "isAlwaysInStock": true } } } ``` More details can be found in the endpoint specification ### Update stocks of multiple product variants in single request (bulk-operation mode) This API allows to update stocks of multiple product variants in single request. There is a specific endpoint which accepts up to 50 operations per request. Validation, business rules and payload of each operation is identical to the single-operation mode, described above. Example of the payload to update stocks of multiple product variants in single request: `POST /api/v1/operations` ```json { "atomic:operations": [ { "op": "update", "data": { "type": "productVariants", "id": "1ed18988-3253-610e-8223-aa5cd9844001", "attributes": { "isAlwaysInStock": true } } }, { "op": "update", "data": { "type": "productVariants", "id": "1ed18988-6651-610e-8223-aa5cd9844f96", "attributes": { "stockQuantity": 123 } } } ] } ``` More details can be found in the endpoint specification