# SKUs

SKUs describe specific product variations that are being sold. A unique `code` identifies each SKU, which can be either the [EAN](https://en.wikipedia.org/wiki/International_Article_Number) code, the [UPC](https://en.wikipedia.org/wiki/Universal_Product_Code), or any other code format.

{% hint style="warning" %}
The SKU `name`, `description`, and `image_url` are best suited for internal usage (Commerce Layer is not a CMS).
{% endhint %}

By marking an SKU with the `do_not_ship` and `do_not_track` combinable flags, is possible to manage different scenarios, such as intangible products which generate no shipments, or products with a virtually infinite stock.

When creating an SKU you need to specify its [shipping category](https://docs.commercelayer.io/core-api-reference/shipping_categories), unless the SKU is marked as `do_not_ship`, in which case the relationship with the shipping category is optional.

### Inventory information

{% hint style="info" %}
For performance reasons the `inventory` attribute is returned when retrieving a single SKU only.
{% endhint %}

The related aggregated information about the SKU's inventory considers the [active markets](https://docs.commercelayer.io/core-api-reference/markets#disabling-markets) in scope only.

| Field                   | Type      | Description                                                                                                                                                                                                                                                                     |
| ----------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| inventory.**available** | `boolean` | The SKU availability, based on the [stock items](https://docs.commercelayer.io/core-api-reference/stock_items) associated with the stock location in scope — `true` if the sum of all the stock item quantities is greater than zero or if the SKU is marked as `do_not_track`. |
| inventory.**quantity**  | `integer` | The sum of the SKU's stock item quantities in the stock locations in scope (net of the related reserved stock quantities).                                                                                                                                                      |
| inventory.**levels**    | `array`   | Aggregated information by stock location, including stock item quantity and available [delivery lead times](https://docs.commercelayer.io/core-api-reference/delivery_lead_times) (ordered by shipping method cost, ascending).                                                 |

#### Checking real-time stock availability

You can fetch via API a list of SKUs and [include](https://app.gitbook.com/s/-LgByaSP8eKjad-MIuHE/including-associations#using-relationship-paths) the `stock_items.reserved_stock` relationships, but in order to get the real-time stock availability you need to perform some additional computation on your side, based on the response payload:

1. Cycle the `included` payload for each SKU to get the sums of `stock_items` and `reserved_stocks` quantities.
2. Subtract the latter from the former to get the *cross-stock* availability for each SKU (you can also do distinct subtractions to get the *per-stock* SKU availability).

<details>

<summary>Data model</summary>

Check the related [ER diagram](https://commercelayer.io/docs/data-model/skus) and explore the flowchart that illustrates how the SKU resource relates to the other API entities.

</details>
