> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/omnitron/integration/order/stock-reservation-release.md). Agents can also search and read this documentation through its [MCP server](https://apidocs.akinon.com/~gitbook/mcp).

# 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="https://apidocs.akinon.com/omnitron/getting-started.md">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;">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>"
}
 
```

#### <mark style="color:red;">Why This Mapping Matters</mark>

The purpose of this mapping is to make the ERP's own order-item code a queryable, retrievable key in Omnitron going forward. Once a mapping is created, the related stock reservation is automatically released.

This unlocks two things in practice:

**Reverse lookup by the ERP's own code**\
Once the mapping row exists, the ERP can query Omnitron later using its own identifier instead of Omnitron's internal ID:

```bash
GET /api/i1/order_items/?mapping__code__exact={erp_orderitem_code}
```

This is useful when the ERP's system of record keys everything off its own codes and doesn't want to persist Omnitron's primary keys everywhere.

**It is echoed back on re-fetch**\
The integration-facing detail payload includes a `mapping` field. So when the ERP later re-fetches an order or order item via the integration API, Omnitron returns the ERP's own code alongside its data — useful for reconciliation or logging without a second lookup.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://apidocs.akinon.com/omnitron/integration/order/stock-reservation-release.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
