> ## Documentation Index
> Fetch the complete documentation index at: https://apidocs.noyax.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Waybills

> Fields, numbering, Lot/serial number and linked-order rules of inbound and outbound waybills.

A waybill has a header and one or more lines. Inbound waybills (`WaybillType` 2, a goods receipt) and outbound waybills (`WaybillType` -2, a dispatch) use the same endpoints. Waybills create stock movements, so a line may also carry Lot or serial number entries depending on the product's stock tracking method.

| Operation      | Endpoint                                                 |
| -------------- | -------------------------------------------------------- |
| List           | [`GET /waybills`](/en/v1/waybills/list)                  |
| Get            | [`GET /waybills/{waybillId}`](/en/v1/waybills/get)       |
| Create         | [`POST /waybills`](/en/v1/waybills/create)               |
| Update         | [`PUT /waybills/{waybillId}`](/en/v1/waybills/update)    |
| Partial update | [`PATCH /waybills/{waybillId}`](/en/v1/waybills/patch)   |
| Delete         | [`DELETE /waybills/{waybillId}`](/en/v1/waybills/delete) |

<Warning>
  **The API does not calculate amounts and does not check that they are consistent.** Line amounts, discount amounts, VAT, additional taxes, withholding, waybill totals and the weighted average exchange rate are stored exactly as you send them (the same fields as [order lines](/en/v1/orders/overview)). The only exceptions the API does calculate: the line's [main unit quantity](#main-unit-quantity), and it requires the sum of a line's Lot/serial number entries to equal the line's `Quantity`.
</Warning>

## Required fields

* `WaybillType`: `2` inbound (goods receipt), `-2` outbound (dispatch). Cannot be changed after the waybill is created.
* `WaybillNumber`: unique within the company for the same `WaybillType`, at most 20 characters. Send `"Next"` on create to generate it automatically: **ALİRSNO** series for inbound waybills; for outbound waybills, the **SATİRSNO** series, or, when the company uses e-Waybill, the company's e-Waybill numbering (a fixed prefix, the year and a 9-digit sequence, for example `EDD2026000000014`). `"Next"` cannot be sent on update.
* `Date`: the waybill date. If you send a time it is stored as the waybill time, otherwise the current time is used.
* `CustomerCode`: a customer the user can see.
* `CurrencyCode`: the waybill currency.
* `Lines`: at least one line.

`DueDays` (payment term in days) is stored with the waybill. `ShipmentDefinitionCode` (optional) comes from [shipment definitions](/en/v1/definitions/shipment-definitions/list).

## Customer snapshot

The waybill's address, title, tax number and tax office are **not accepted in the request**. They are copied from the customer at the moment the waybill is saved (the invoice address when the customer has one, otherwise the first address) and stay fixed afterward even if the customer changes later — this is why they only appear in responses (`Address`, `CustomerTitle`, `TaxNumber`, `TaxOffice`). On update, they are only recomputed when `CustomerCode` changes; otherwise the existing values are kept.

## Lines

* `ProductCode` and `UnitCode` are required. The unit must be one of the product's own units (its main unit, or its second/third unit).
* `Quantity` must be greater than 0; `UnitPrice` cannot be negative.
* If a line has no `CurrencyCode`, the waybill currency is used; `ExchangeRate` is the rate of the line currency.
* `Discounts` is the list of the line's discount rates, applied one after another in list order.
* `LineGroupName` is optional, from [line groups](/en/v1/definitions/line-groups/list).
* `WarehouseName` is **required** and must be one of the company's [warehouses](/en/v1/stock/warehouses/list).

### Main unit quantity

`Quantity` is in the line's unit. `MainUnitQuantity` in responses is the same quantity expressed in the product's main unit, calculated by the API exactly as for [order lines](/en/v1/orders/overview#main-unit-quantity): the quantity itself when `UnitCode` is the main unit, otherwise divided by the unit's multiplier. On an outbound waybill the stored value is negative, on an inbound waybill it is positive; `MainUnitQuantity` in responses is always positive.

## Line identity on update

Unlike orders, a waybill line's Lot movements, serial number entries and linked-order record all reference the line's own ID, so a blind "replace all lines" would break those references. Instead, **the order in which you send lines determines their identity on update**: the line at position `i` in the request is treated as the same line as the one currently at position `i`. Its Lot/serial number entries and linked-order record move with it (matched or reconciled, not deleted and recreated). Sending fewer lines than before removes the trailing ones; sending more adds new ones at the end. Always send lines in the same order you received them from [Get waybill](/en/v1/waybills/get) if you only mean to change individual fields.

## Lot and serial number tracking

Whether a line needs `Lots` or `SerialNumbers` depends on the product's stock type (from the product's `StockType`, read via [Get product](/en/v1/products/get)):

| StockType                             | Tracking      | Field used      |
| ------------------------------------- | ------------- | --------------- |
| 1, 2                                  | None          | Neither         |
| 3 (Lot), 4 (FIFO), 6 (LIFO), 7 (FEFO) | Lot           | `Lots`          |
| 5                                     | Serial number | `SerialNumbers` |

**Lots** (`LotNo`, `Quantity`, `UnitCode`, and, on an inbound waybill only, `SupplierLotNo`/`ExpiryDate`/`Description`):

* **Inbound**, for all four Lot-tracked stock types: each entry creates a new lot (`LotNo` is always provided by you, unique within the company) and a matching inbound movement.
* **Outbound, StockType 3 (Lot)**: you specify `LotNo` and `Quantity` for each lot to consume from.
* **Outbound, StockType 4/6/7 (FIFO/LIFO/FEFO)**: leave `Lots` empty — the API selects the lots automatically (oldest first for FIFO, nearest expiry first for FEFO, newest first for LIFO), consuming from one lot after another until the quantity is covered.
* A lot that has already been consumed by an outbound transaction cannot be removed or reduced below the consumed quantity; the operation is cancelled instead.

**Serial numbers** (`SerialNumbers`, a plain list of strings, one per unit): on an inbound waybill each entry registers a new serial number (rejected if that serial number is already registered and has not been dispatched yet); on an outbound waybill each entry must be an existing, not-yet-dispatched serial number, which is marked as dispatched. A serial number that has already been dispatched by this waybill cannot be removed from the line.

## Linked orders

A waybill line that was created from an order line in the Noyax application carries a link to it. The API never creates this link itself, but when a line you send corresponds (by position) to an existing linked line, it checks that the line's quantity, together with what other waybills have already drawn from the same order line, does not exceed the order line's quantity.

## Sharing

`SharingCode` limits who can see the waybill: empty means visible to everyone, otherwise it must be one of the user's [sharing codes](/en/v1/guides/sharing-codes). Waybills the user cannot see return 404.
