# Create stock adjustments

Source: https://developers.swell.is/backend-api/stock/create-stock-adjustments

Create a new stock adjustment. Normally, stock adjustments are automatically created when stock tracking is enabled and orders are placed or canceled.

## Arguments

- `parent_id` (objectId, required): The id of the parent product.
- `quantity` (int, required): Quantity of the adjustment. A positive number means the stock was increased, and a negative number means the stock was decreased.
- `reason` (string): Enumerated reason for the stock adjustment. Can be `received`, `returned`, `canceled`, `sold`, `missing`, or `damaged`.
- `reason_message` (string): A brief description of the reason for the stock adjustment.
- `order_id` (objectId): The id of an order when the stock adjustment was either reduced by the sale of a product or increased by canceling an order. Adjustments from orders are created automatically when stock tracking is enabled.
- `variant_id` (objectId): The id of the parent variant, if applicable.

## Example request

`POST /products:stock`

**cURL**

```bash
$ curl https://api.swell.store/products:stock \
  -u store-id:secret-key \
  -d parent_id=5ca24abb9c077817e5fe2b3b
  -d quantity=10
  -d reason=received
  -d reason_message="Restock - PO #47362"
```

**Node**

```javascript
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');

await swell.post('/products:stock', {
  parent_id: '5ca24abb9c077817e5fe2b3b',
  quantity: 10,
  reason: 'received',
  reason_message: 'Restock - PO #47362',
});
```

**PHP**

```php
<?php $swell = new \Swell\Client('store-id', 'secret-key');

$swell->post('/products:stock', [
  'parent_id' => '5ca24abb9c077817e5fe2b3b',
  'quantity' => 10,
  'reason_message' => 'Restock - PO #47362'
]);
```

## Example response

```json
{
  "id": "5ca24abb9c077817e5fe2b3b",
  "parent_id": "5ca7d6c68f749692da37c985",
  "quantity": 10,
  "level": 10,
  "number": "100184",
  "reason": "received"
  "reason_message": "Restock - PO #47362",
  "date_created": "2019-04-01T00:00:00.000Z"
}
```
