# Stock Reservation Release

When the order is created, the Omnitron starts to hold reservations on stock. This reservation is used to synchronize the stock between the ERP system and the Omnitron. If the order has been successfully registered in the ERP, a request must be sent to Omnitron with the order line created in the ERP to release the reservation.

Due to the information sent to the endpoint below, Omnitron both keeps the information of the order line created in the ERP and removes the reservation for the order.

<table data-header-hidden><thead><tr><th width="166.625"></th><th width="103.125"></th><th width="90.71875"></th><th width="116.0546875"></th><th></th></tr></thead><tbody><tr><td><strong>Parameter</strong></td><td><strong>Data Type</strong></td><td><strong>In</strong></td><td><strong>Reqiured</strong></td><td><strong>Description</strong></td></tr><tr><td><code>api_token</code></td><td>string</td><td>header</td><td>mandatory</td><td><a href="../../getting-started">The API key of the customer’s account</a></td></tr><tr><td><code>update_stock</code></td><td>boolean</td><td>data</td><td>optional</td><td>If it is <code>True</code>, the stock reservation is released. Default is <code>True</code>.</td></tr><tr><td><code>code</code></td><td>string</td><td>data</td><td>mandatory</td><td>Unique ID of the order line on the ERP side.</td></tr><tr><td><code>{order_item_id}</code></td><td>string</td><td>query</td><td>mandatory</td><td>Order item ID.</td></tr></tbody></table>

## <mark style="color:red;">`POST`</mark> <mark style="color:red;"></mark><mark style="color:red;">Release Stock Reservation</mark>

**Path:** `/api/i1/order_items/{order_item_id}/create_mapping/`

Sample HTTP request to create mapping and release a stock.

* `content_type` header represents the response type.
* `Authorization` header is a required header for authentication. You can retrieve api\_token with login.

**Example Request**

```python
import requests
import json

url = "https://{customer_api_url}/api/v1/order_items/{order_item_id}/create_mapping/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
   'content-type': 'application/json',
   'Authorization': 'Token {}'.format(api_token)

data = {
 "update_stock": True,
 "code": "{erp_orderitem_code}"
}

response = requests.post(url, headers=headers , data=json.dumps(data))
print(response.text)
```

**Example Response**

Returns Integration Mapping object data.

`object_id` is the ID of the `order_item`, code is the given code, `content_type` shows the data table (ex: Product, Order etc.) in the Omnitron system. Users can get all table ContentType information via HTTP GET request to `/api/v1/content_types/` endpoint.

```json
{
 "pk": 4183,
 "content_type": 66,
 "object_id": 46761,
 "integration_type": "external_company",
 "code": "<erp_orderitem_code>"
}
 
```
