# The stock model

Source: https://developers.swell.is/backend-api/stock/the-stock-model

## Fields

- `id` (objectId): Unique identifier for the stock adjustment.
- `date_created` (date, auto): Date and time the stock adjustment was created.
- `date_updated` (date, auto): Date and time the stock adjustment was last updated.
- `description` (string): A brief description of the stock entry.
- `level` (int): New stock level after the adjustment is applied.
- `location` (string): Location associated to the stock entry, if applicable.
- `transfer_location` (string): Second location used in a transfer operation.
- `referenced_transfer_id` (objectId): ID of the referenced transfer operation that removed stock.
- `cancelation_group_id` (string): Identifier used to restore all archived stock entries as a group.
- `number` (string, auto): Auto-incremented stock adjustment number.
- `order` (Order): Expandable link to an order, if applicable to the stock adjustment.
- `order_id` (objectId): ID of an order when the stock adjustment was either reduced by the sale of a product, or increased by cancelling an order. Adjustments from orders are created automatically when stock tracking is enabled.
- `parent` (Product): Expandable link to the parent product.
- `parent_id` (objectId, required): ID of the parent product.
- `prev` (Stock): Link to the previous stock adjustment.
- `prev_id` (objectId): ID of the previous stock adjustment.
- `quantity` (int, required): Quantity of the adjustment. A positive number means stock was increased, and a negative number means stock was decreased.
- `reason` (enum): Enumerated reason for the stock adjustment. Can be `received`, `returned`, `canceled`, `sold`, `missing`, `damaged`, `transfer_remove`, or `transfer_add`. Possible values: `received`, `returned`, `canceled`, `sold`, `missing`, `damaged`, `transfer_remove`, `transfer_add`.
- `reason_message` (string): A brief description of the reason for the stock adjustment. Default: `{"$formula":"description"}`.
- `variant` (Product variant): Expandable link to the parent variant, if applicable.
- `variant_id` (objectId): ID of the parent variant, if applicable. Default: `null`.

## Example response

```json
{
  "id": "60f199509111e7000000005f",
  "parent_id": "60f199509111e70000000062",
  "date_created": "2021-07-16T14:36:00.321Z",
  "date_updated": "2021-07-16T14:36:00.321Z",
  "level": 20,
  "number": 1029376,
  "reason": "received",
  "reason_message": "Restock - PO #47362",
  "variant_id": "60f199509111e70000000061"
}
```
