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

# Order Create

This tutorial explains how the **Order Create** process works for the **N11** integration in the Marketplace Dashboard: which orders are picked up, which requests are made to N11 and Omnitron (with example data), how the end-to-end process works, and how to read the error codes it produces.

{% hint style="info" %}
For channel-level setup (Feature Flags, Order Start Date, Cargo Company Mapping, Use Neighborhood, Send Shipping Info, etc.), see [N11 Marketplace Setup Configurations](https://docs.akinon.com/technical-guides/marketplace-dashboard/n11-marketplace-setup-configurations.md) tutorial.
{% endhint %}

## <mark style="color:red;">What is Order Create?</mark>

**Order Create** pulls orders from **N11** into **Omnitron** that fall within a specified **start date** and **end date** range and match a given **order status**. On the **Logs** screen, this process appears under the flow name **Order Create**.

## <mark style="color:red;">When Does It Run?</mark>

* Controlled by the **`get_orders`** feature flag in the channel settings. When active, it runs automatically:
  * Every **5 minutes**, requesting orders in the **`Picking`** status only, within a rolling **last 12 hours** window (bounded below by the channel's **Order Start Date**, which mainly matters for the very first run).
  * Every night at **03:00**, an additional catch-up run requests the **`Picking`** status again, but with the date window widened to the **last 15 days**, to pick up anything the 5-minute runs might have missed.
* Users can also **manually trigger** this flow from the Dashboard — either for one of three statuses (**`Picking`**, **`Shipped`**, or **`Delivered`**), or by targeting a **specific order** directly via its **order number** or **package number**, bypassing status/date filtering entirely.
* Before activating this flag, **`Order Start Date`**, **`Use Neighborhood`**, **`Send Shipping Info`**, **`Use Channel ID In Address Mapping`**, **`Get Discount Amount`**, **`Order Number Format`**, **`OMS Enabled`**, **`ERP Code`** and **`Cargo Company Mapping`** must be configured — see [N11 Marketplace Setup Configurations](https://docs.akinon.com/technical-guides/marketplace-dashboard/n11-marketplace-setup-configurations.md).

## <mark style="color:red;">Which Orders Are Eligible?</mark>

An order is picked up only if it:

* Has a **status** matching the run — `Picking` on both the 5‑minute schedule and the nightly catch-up run, or `Picking` / `Shipped` / `Delivered` when a user triggers the flow manually by status.
* Falls within the **date window**: the **last 12 hours** on the regular 5-minute schedule, or the **last 15 days** on the nightly catch-up run — both bounded below by the channel's **Order Start Date**.
* **Unless** the manual trigger targets a specific **order number** or **package number** — in that case the order is fetched directly, regardless of its status or date.
* **Has not already been imported into Omnitron** — the flow checks this before doing any other work (see [Skipping Already-Imported Orders](#skipping-already-imported-orders)) and simply skips the package if it has.

When an order is imported, its order and order item are created in Omnitron directly with **status `400`** (`approved`).

## <mark style="color:red;">Fetching Orders from N11</mark>

Orders (called **shipment packages** on N11's side) are fetched with:

```
GET {mp_host}/rest/delivery/v1/shipmentPackages
    ?startDate={startDate}
    &endDate={endDate}
    &status={Picking|Shipped|Delivered}
    &orderByField=true
    &size=100
    &page={page}
```

When a manual trigger targets a specific order instead, `startDate` / `endDate` / `status` are replaced with a single filter:

```
GET {mp_host}/rest/delivery/v1/shipmentPackages?orderNumber={orderNumber}&orderByField=true&size=100&page={page}
```

```
GET {mp_host}/rest/delivery/v1/shipmentPackages?packageIds={packageNumber}&orderByField=true&size=100&page={page}
```

{% hint style="info" %}
The automatic runs (both the 5-minute run and the nightly catch-up run) always send `status=Picking` explicitly; a manual trigger from the Dashboard sends whichever of `Picking`, `Shipped`, or `Delivered` the user selected — or, if the trigger targets a specific order, the **order number** or **package number** query above instead (order number takes priority if both are given). If none of these is supplied at all, the flow falls back to `status=Picking` internally.
{% endhint %}

The response is paginated (`totalPages` / `totalOrderCount`); the flow keeps requesting the next `page` until every page for that run has been retrieved and merged into a single list.

```json
{
  "pageCount": 1,
  "totalPages": 1,
  "page": 0,
  "size": 100,
  "content": [
    {
      "billingAddress": {
        "address": "Reşitpaşa Mah İstanbul Teknik Üniversitesi Teknokent Arı 3 4/a-3 D:8-9, 34485 Sarıyer/İstanbul",
        "city": "İstanbul",
        "district": "Sarıyer",
        "neighborhood": "Reşitpaşa",
        "fullName": "N11 müşteri",
        "gsm": "5xxxxxxxxx",
        "tcId": "11111111111",
        "postalCode": "34000",
        "taxId": null,
        "taxHouse": null,
        "invoiceType": 1,
        "countryCode": "null"
      },
      "shippingAddress": {
        "address": "Reşitpaşa Mah İstanbul Teknik Üniversitesi Teknokent Arı 3 4/a-3 D:8-9, 34485 Sarıyer/İstanbul",
        "city": "İstanbul",
        "district": "Sarıyer",
        "neighborhood": "Reşitpaşa",
        "fullName": "N11 müşteri",
        "gsm": "5xxxxxxxxx ",
        "tcId": "11111111111",
        "postalCode": "34000"
      },
      "orderNumber": "203872347637",
      "id": "112999455244259",
      "customerEmail": "n11@n11.com",
      "customerfullName": "N11 müşteri",
      "customerId": 12345678,
      "taxId": null,
      "taxOffice": null,
      "tcIdentityNumber": "11111111111",
      "cargoSenderNumber": null,
      "cargoTrackingNumber": "112999455244259",
      "cargoTrackingLink": "",
      "shipmentCompanyId": 342,
      "cargoProviderName": "MNG Kargo",
      "shipmentMethod": 1,
      "installmentChargeWithVATprice": 0.00,
      "lines": [
        {
          "quantity": 2,
          "productId": 1,
          "productName": "Erkek Spor Ayakkabı Bordo 45",
          "stockCode": "20242024",
          "variantAttributes": [
            {
              "name": "Numara",
              "value": "45"
            },
            {
              "name": "Renk",
              "value": "Bordo"
            }
          ],
          "customTextOptionValues": [],
          "price": 292.8,
          "dueAmount": 536.20,
          "installmentChargeWithVAT": 0,
          "sellerCouponDiscount": 0,
          "sellerCampaignCommissionDiscount": 0,
          "sellerDiscount": 2.9,
          "mallDiscount": 43.60,
          "sellerInvoiceAmount": 579.8,
          "totalMallDiscountPrice": 43.60,
          "orderLineId": 415490391,
          "orderItemLineItemStatusName": "Picking",
          "totalSellerDiscountPrice": 5.8,
          "vatRate": 10,
          "commissionRate": 9,
          "sellerCampaignCommissionRate": 0,
          "taxDeductionRate": 1,
          "totalLaborCostExcludingVAT": 0,
          "netMarketingFeeRate": 1.2,
          "netMarketplaceFeeRate": 0.8,
          "barcode": null,
          "deliveryFeeType": 3,
          "totalLaborCostExcludingVAT": 0,
          "sellerDiscountedPrice": 289.90,
          "sender": "SELLER",
          "productOrigin": null
        }
      ],
      "lastModifiedDate": 1724323386203,
      "agreedDeliveryDate": 1725310828346,
      "totalAmount": 1479.79,
      "totalDiscountAmount": 62.3,
      "packageHistories": [
        {
          "createdDate": 1724274054460,
          "status": "Created"
        },
        {
          "createdDate": 1724274255751,
          "status": "Picking"
        },
        {
          "createdDate": 1724274492082,
          "status": " Shipped"
        },
        {
          "createdDate": 1724396400000,
          "status": " Delivered"
        }
      ],
      "shipmentPackageStatus": "Delivered",
      "sellerId": 1,
      "micro": false
    }
  ]
}
```

{% hint style="warning" %}
The field names above (`orderNumber`, `stockCode`, `shipmentCompanyId`, etc.) are taken directly from the flow's own field references. The values themselves are illustrative, not a captured production response.
{% endhint %}

## <mark style="color:red;">Skipping Already-Imported Orders</mark>

For every package, the flow first makes sure it hasn't been imported before:

```
GET {omnitron_url}/api/v1/channel/{channel_id}/orders/?number__exact={orderNumber}
```

If no order is found by number, it also checks by the remote package ID, in case the order exists under a different number:

```
GET {omnitron_url}/api/v1/channel/{channel_id}/integration_actions/?content_type_name=order&remote_id__exact={packageId}&channel={channel_id}
```

If either call finds a match, the package is skipped entirely — nothing else in this tutorial runs for it.

{% hint style="info" %}
The remote-package-ID check is what keeps this safe even if **Order Number Format** is changed later: the constructed `number` for a previously imported order would no longer match under the new format, but the package ID lookup still finds it, so the order is not re-imported as a duplicate.
{% endhint %}

## <mark style="color:red;">Checking for Existing Cancellation/Refund Plans</mark>

Before going any further, the flow re-checks the package's current state directly on N11 (`GET {mp_host}/rest/delivery/v1/shipmentPackages?orderNumber={orderNumber}`) together with Omnitron's own `cancellation_plans` for that order — internally, this step is called **CancelRefundControl**. It guards against creating (or re-processing) an order that already has a cancellation or refund plan in progress, which is otherwise handled by the separate **Cancel/Refund Orders** flow.

{% hint style="warning" %}
This also affects **Split Packages**: if a package was split and the cancellation of one of the resulting split packages hasn't completed yet, the new split package cannot be pulled in by this flow until that cancellation finishes.
{% endhint %}

## <mark style="color:red;">Resolving the Customer</mark>

The buyer is matched (or created) in Omnitron using N11's `customerId` as the **channel code**:

```
GET {omnitron_url}/api/v1/channel/{channel_id}/customers/?channel_code={customerId}&channel={channel_id}
```

If no customer is found, one is created:

```
POST {omnitron_url}/api/v1/channel/{channel_id}/customers/
```

```json
{
  "channel_code": "122222",
  "email": "akinonuser@akinon.com",
  "first_name": "Akinon",
  "last_name": "Shop"
}
```

`first_name` / `last_name` are split off the first full name available, in this order of preference: N11's own `customerfullName` field, then `shippingAddress.fullName`, then `billingAddress.fullName`.

## <mark style="color:red;">Resolving Shipping & Billing Addresses</mark>

Each address's `city`, `township`, `district`, and `neighborhood` — plus `countryCode` on the billing side — are matched against Omnitron's own country / city / township / district records (using each record's marketplace mapping first, then falling back to a name match). If a value can't be matched, an error report is created in Omnitron for that model (`CreateErrorReport`) and the order stops with the corresponding error code (see below).

Once resolved, the address is created in Omnitron — or reused if an identical one (matched by a hash of its contents, `hash_data`) already exists:

```
GET {omnitron_url}/api/v1/channel/{channel_id}/addresses/?hash_data__exact={hash_data}
POST {omnitron_url}/api/v1/channel/{channel_id}/addresses/
```

A few behaviors worth noting:

* **Neighborhood is only sent if `Use Neighborhood` is active** in the channel settings; otherwise the `district` (mahalle) field is left empty on the Omnitron address.
* **Billing address for a corporate invoice** (N11's `invoiceType = "2"`): `company_name`, `tax_office`, and `tax_no` are filled from N11's `customerfullName` / `taxOffice` / `taxId`, and `e_bill_taxpayer` is set to `true`.
* **Micro-export orders** (`micro: true`): the billing address is created without `district` / `township`, regardless of the `Use Neighborhood` setting.

## <mark style="color:red;">Resolving the Cargo Company</mark>

N11's numeric `shipmentCompanyId` (e.g. `344`) is translated to an internal carrier slug (e.g. `yurtici`) using a fixed built-in table (`mng`, `aras`, `ups`, `surat`, `horoz`, `ptt`, etc.), and that slug is then looked up in the channel's own **Cargo Company Mapping** setting to get the Omnitron `cargo_company` ID:

```
GET {omnitron_url}/api/v1/channel/{channel_id}/cargos/{cargo_company_id}/
```

If N11's `shipmentCompanyId` doesn't resolve to a known slug, or the slug isn't present in **Cargo Company Mapping**, the mapping's mandatory `"default"` entry is used instead.

## <mark style="color:red;">Enriching Order Items from Omnitron</mark>

For every order line, the product is resolved in two steps:

1. Omnitron is first queried for an existing **Integration Action** linking N11's `stockCode` to a product, using it as the remote ID:

```
GET {omnitron_url}/api/v1/channel/{channel_id}/integration_actions/?remote_id__exact={stockCode}&content_type_name=product&channel={channel_id}
```

2. If no such Integration Action is found yet, the product itself is looked up using the **RemoteId Schema** mapped attribute (or its `sku` if no mapping is configured), and a new Integration Action is created linking it to this `stockCode` so future orders skip straight to step 1:

```
GET {omnitron_url}/api/v1/channel/{channel_id}/products/?sku__exact={stockCode}
OR
GET {omnitron_url}/api/v1/channel/{channel_id}/products/?attributes__key__exact={stockCode}
```

Then, for the matched product, its **stock** and **price** records are fetched:

```
GET {omnitron_url}/api/v1/channel/{channel_id}/product_stocks/?product={product_id}&stock_list={stock_list_id}
GET {omnitron_url}/api/v1/channel/{channel_id}/product_prices/?product={product_id}&price_list={price_list_id}
```

If the product, its stock, or its price can't be found, the order stops with error code `2018` (see below), and the specific missing remote IDs are included in the log message.

If the line's `stockCode` matches **more than one** product (so the product can't be identified unambiguously), the order stops with error code `1040` instead, and the log message lists the conflicting products: `Some products has multiple identification. Please check errors; {details}.`

## <mark style="color:red;">Building & Sending the Order to Omnitron</mark>

Once the customer, addresses, cargo company, and every order item have been resolved, the order is assembled and sent as a single request:

```
POST {omnitron_url}/api/v1/channel/{channel_id}/create_orders/
```

```json
{
  "order": {
    "number": "410232156-112999455244259",
    "channel": 1,
    "date_placed": "2024-05-29T10:00:00Z",
    "customer": 1,
    "shipping_address": 1,
    "billing_address": 1,
    "currency": "try",
    "amount": 299.80,
    "shipping_amount": 0,
    "cargo_company": 1,
    "status": "400",
    "delivery_type": null,
    "client_type": "default",
    "discount_amount": 0,
    "extra_field": {
      "id": 112999455244259,
      "tracking_number": "112999455244259",
      "orderNumber": "203872347637",
      "micro": false
    }
  },
  "order_item": [
    {
      "product": 1,
      "status": "400",
      "price_currency": "try",
      "price": 289.90,
      "retail_price": 289.90,
      "price_list": 1,
      "stock_list": 1,
      "tax_rate": "10.00",
      "extra_field": {
        "price_extra_field": {},
        "stock_extra_field": {},
        "id": 415490391,
        "campaign_number": "112999455244259",
        "status": "Picking",
        "tracking_number": "112999455244259"
      }
    },
    {
      "product": 1,
      "status": "400",
      "price_currency": "try",
      "price": 289.90,
      "retail_price": 289.90,
      "price_list": 1,
      "stock_list": 1,
      "tax_rate": "10.00",
      "extra_field": {
        "price_extra_field": {},
        "stock_extra_field": {},
        "id": 415490391,
        "campaign_number": "112999455244259",
        "status": "Picking",
        "tracking_number": "112999455244259"
      }
    }
  ]
}
```

{% hint style="info" %}
If **`Get Discount Amount`** is active in the channel settings, `discount_amount` is also populated on the order and each order item from N11's `totalSellerDiscountPrice`. If **`OMS Enabled`** is active and **`Send Shipping Info`** is not, `tracking_number` is populated on the order (and, when applicable, on each item) from N11's `cargoTrackingNumber` — otherwise the tracking number is left for the brand's own shipping process to set. For **micro-export** orders, `extra_field` on the order additionally includes `etgbNo`, `etgbDate`, and `hsCode` from N11.
{% endhint %}

### Order and Order Item `extra_field` Mapping

| Omnitron field                                               | Source                                        | Notes                                                                                          |
| ------------------------------------------------------------ | --------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| `order.extra_field.id`                                       | N11 `id`                                      | The N11 shipment package ID — also used later as the order's `remote_id` for duplicate checks. |
| `order.extra_field.tracking_number`                          | N11 `cargoTrackingNumber`                     |                                                                                                |
| `order.extra_field.orderNumber`                              | N11 `orderNumber`                             |                                                                                                |
| `order.extra_field.micro`                                    | N11 `micro`                                   |                                                                                                |
| `order.extra_field.etgbNo` / `etgbDate` / `hsCode`           | N11 `etgbNo` / `etgbDate` / `hsCode`          | Only present when `micro` is `true`.                                                           |
| `order_item.extra_field.id`                                  | N11 `orderLineId`                             |                                                                                                |
| `order_item.extra_field.status`                              | N11 `orderItemLineItemStatusName`             |                                                                                                |
| `order_item.extra_field.campaign_number` / `tracking_number` | N11 `cargoTrackingNumber`                     | Same tracking number, kept under both keys.                                                    |
| `order_item.extra_field.price_extra_field`                   | Omnitron product price record's `extra_field` | Copied through as-is, not derived from N11.                                                    |
| `order_item.extra_field.stock_extra_field`                   | Omnitron product stock record's `extra_field` | Copied through as-is, not derived from N11.                                                    |

{% hint style="warning" %}
To use the **micro-export** order feature, the **`get_updated_order_items`** feature flag must also be enabled. At the time Order Create picks up a micro-export order, it hasn't cleared customs yet, so N11 hasn't filled in `etgbNo` / `etgbDate` / `hsCode` yet — these are only populated once the **Get Updated Orders** flow re-fetches the order after customs clearance.
{% endhint %}

## <mark style="color:red;">How the Process Works — Summary</mark>

1. Orders matching the run's status (`Picking` on the automatic runs, or `Picking` / `Shipped` / `Delivered` on a manual trigger) and the configured date window are fetched from N11, page by page — or, when a manual trigger targets a specific **order number** or **package number** instead, that single order is fetched directly.
2. Each package is checked against Omnitron by order number and by remote ID — if it already exists, it's skipped.
3. Any existing cancellation/refund plan for the package is checked.
4. The customer is resolved (matched by `customerId`, or created).
5. The shipping and billing addresses are resolved — country, city, township, and district are matched or reported as errors — and created or reused in Omnitron.
6. The cargo company is resolved via the built-in N11 carrier table and the channel's Cargo Company Mapping.
7. Each order item's product, stock, and price are fetched from Omnitron, and a missing Integration Action is created for the product if needed.
8. The order and its items are assembled — including all `extra_field` values — and sent to Omnitron in a single request.
9. The outcome is written back and becomes visible on the **Logs** screen.

## <mark style="color:red;">Monitoring</mark>

1. From the left menu, go to **Sales Channels > N11 > Marketplace Operations > Logs**.
2. Filter by flow name **Order Create**.
3. Use the **Order Number** or **Execution ID** filters to locate a specific order.

## <mark style="color:red;">Flow Trigger</mark>

Manual runs described in [When Does It Run?](#when-does-it-run) are started from the **Trigger** screen (**Sales Channels > N11 > Marketplace Operations > Trigger**), by clicking **Run** next to the **Order Create** flow. In the popup form, select a **status** (`Picking`, `Shipped`, or `Delivered`), or fill in an **order number** / **package number** to fetch that single order directly instead.

See the [Flow Trigger](https://docs.akinon.com/technical-guides/marketplace-dashboard/marketplace-dashboard-flow-trigger.md) tutorial for the general trigger screen walkthrough (single trigger vs. CSV trigger).

## <mark style="color:red;">Error Codes and Explanations</mark>

| Code   | Meaning                                                                                                                                                                                                           |
| ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `1001` | The order's basic info (order number, package ID, micro flag) could not be extracted from N11's response.                                                                                                         |
| `1002` | An error occurred while resolving (matching or creating) the customer in Omnitron.                                                                                                                                |
| `1003` | The order's **city** could not be resolved in Omnitron.                                                                                                                                                           |
| `1004` | The order's **township** (ilçe) could not be resolved in Omnitron.                                                                                                                                                |
| `1005` | An error occurred while resolving or creating the **shipping address**.                                                                                                                                           |
| `1006` | An error occurred while resolving or creating the **billing address**.                                                                                                                                            |
| `1007` | An error occurred while resolving the **cargo company**.                                                                                                                                                          |
| `1008` | The order was rejected by Omnitron's `create_orders` endpoint.                                                                                                                                                    |
| `1021` | The order's **district** (mahalle) could not be resolved in Omnitron.                                                                                                                                             |
| `1026` | The order's **country** could not be resolved in Omnitron.                                                                                                                                                        |
| `1028` | An error occurred while checking whether the order already exists in Omnitron.                                                                                                                                    |
| `1030` | An error occurred while checking the package's cancellation/refund state.                                                                                                                                         |
| `1040` | A product could not be identified uniquely — more than one product matches the order line. The log message starts with `Some products has multiple identification. Please check errors;` followed by the details. |
| `2018` | One or more order items could not be enriched — the product, its stock, or its price was not found in Omnitron for the given `stockCode`. The log message lists the specific remote IDs that were not found.      |

{% hint style="info" %}
Address-resolution failures (`1003`, `1004`, `1021`, `1026`) also create an entry under the corresponding model in Omnitron's mapping error reports, so the missing country/city/township/district mapping can be added without waiting for the next retry.

These entries can be reviewed from Omnitron's left menu under **Integration > Mapping Error Logs**, where the failed address mappings can be inspected and, if applicable, resolved directly with the **Resolve** action to create the missing mapping automatically. The mapping can also be created manually ahead of time from **Integration > Address Mapping**.
{% endhint %}

## <mark style="color:red;">Related Settings</mark>

* **`get_orders`** feature flag — enables/disables the automatic 5-minute `Picking` run and the nightly 03:00 `Picking` catch-up run (15 days back).
* **Order Start Date** — the earliest date this flow will fetch orders from.
* **Cargo Company Mapping** — required; its `"default"` entry is used whenever N11's carrier can't be mapped to a more specific one.
* **Use Neighborhood** — whether the neighborhood is included when creating addresses.
* **Use Channel ID In Address Mapping** — scopes address mapping/search to this channel.
* **Get Discount Amount** — whether `discount_amount` is populated from N11 on the order and its items.
* **Order Number Format** — customizes the Omnitron order number; defaults to `{orderNumber}-{id}`.
* **OMS Enabled** / **Send Shipping Info** — control whether the tracking number is populated by this flow or left to the brand's own shipping process.
* **ERP Code** — not used by this flow directly; it can be used to distinguish the relevant sales channel in ERP integration.

See [N11 Marketplace Setup Configurations](https://docs.akinon.com/technical-guides/marketplace-dashboard/n11-marketplace-setup-configurations.md) for how to configure all of the above.


---

# 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://docs.akinon.com/tutorials/marketplace-dashboard/n11/order-create.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.
