> For the complete documentation index, see [llms.txt](https://kb.logicerp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/push/save-a-stock-transfer-out-against-a-delivery-order.md).

# Save a Stock Transfer Out Against a Delivery Order

Creates a **stock transfer out** from a **delivery order** that is already in Logic ERP. A delivery order sets goods aside for a party – either assigned against a sale order, or packed on a **packing slip** (with or without a sale order). This endpoint takes the delivery order's open lines, saves them as a transfer out from the branch to the receiving branch, and marks those lines as dispatched.

The transfer itself – stock-transfer series, receiving branch, taxes, automatic stock transfer in – works as described in [Save a Stock Transfer Out](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-stock-transfer-out.md). This page describes what is **different** when the transfer is made against a delivery order. To transfer straight from a sale order, use [Save a Stock Transfer Out Against a Sale Order](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/push/save-a-stock-transfer-out-against-a-sale-order.md).

### **Endpoint**

| Name          | Detail                                     |
| ------------- | ------------------------------------------ |
| Address       | `https://your-server/api/SaveSTOAgainstDO` |
| Method        | `POST`                                     |
| Authorization | Basic Auth                                 |

The response envelope, branches, dates, queueing and the common messages are explained in [How Every API Call Works](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/how-every-api-call-works.md).

Send one transfer, against one delivery order, per request. Field names are matched without regard to upper/lower case; fields not listed below are ignored. Do not send `null` for `LogicUserCode` or `AddlItemCode`.

### **How the delivery order is found**

* Send `Doc_Code`: Logic ERP's internal number of the delivery order – the `LastSavedCode` you got when it was saved (for example from [Assign Stock to a Delivery Order](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/push/assign-stock-to-a-delivery-order.md) or [Save a Packing Slip Against a Sale Order](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/push/save-a-packing-slip-against-a-sale-order.md)), or its internal number in [Get Delivery Orders](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/pull/get-delivery-orders.md). Delivery orders assigned against a sale order, packing slips against a sale order and packing slips without one are all accepted.
* Or leave `Doc_Code` at `0` and send `OrderNo` with `BranchCode` (or `BranchShortName`): Logic ERP then looks for a delivery order **assigned against a sale order** that still has something pending, whose sale order belongs to that branch and has the party order number `OrderNo` (the `Party_Order_No` sent with Save a Sale Order). When more than one such delivery order is found, the request is refused – send `Doc_Code`. Packing slips are not found this way – see the known issue.
* The transfer is saved in the **delivery order's branch**; the `BranchCode` you send is replaced by it.
* The **party** is the delivery order's party; `PartyUserCode` is ignored. For a proper stock transfer the delivery order must be for the receiving branch's stock-transfer party (see Save a Stock Transfer Out, *How the receiving branch and party are chosen*). `STBranchCode` works as there.
* A delivery order that is waiting for approval is refused.

### **What is transferred**

* **Whole open lines.** Every line of the delivery order that still has a pending quantity is transferred **with its full pending quantity**. When you send `LstItems`, the total `Quantity` you list for each item must equal what is transferred of that item, and every item transferred must be listed – otherwise nothing is saved and the request is refused.
* **Choosing items.** `LstItems` limits the transfer to the lines of the items you list **only when the stock-transfer series used has "Allow Item Selection in SO/Chal Reterival" switched on** in its sale configuration in Logic ERP. Otherwise all open lines are transferred, so `LstItems` must list every item of the delivery order with its full pending quantity. The items you list are also checked (they must exist, and so must any `Lot_No` you send). `LstItems` may be empty: then every open line is transferred without this comparison.
* **Lots and stock** come from the delivery order: the lots and godowns it set aside are issued.
* **Rates and discounts** are worked out as on Logic ERP's sale screen when a delivery order is pulled in, according to the stock-transfer series' settings – not from the request. `Rate`, `Mrp`, `CD_P`, `TD_P`, `SPCD_P`, `Scheme_Rs`, `AdjustItem_Rs` and `ItemDescription` in `LstItems` are **ignored**. Transfer-level `CD_P`, `TD_P`, `SpCD_P`, `Freight`, `Handling`, `SpDiscountRs` and `Adjustment_Rs` still apply.

### **What happens to the delivery order**

* The transferred lines' pending quantity is reduced to nothing, so they cannot be transferred or billed again.
* For a delivery order assigned against a sale order, the sale order's pending quantity is reduced by the transferred quantity as well. (A packing slip against a sale order already reduced it when the packing slip was saved.)

### **Request fields**

The request has the same shape as [Save a Stock Transfer Out](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-stock-transfer-out.md). Fields not in this table – `Bill_Number`, `Bill_Date`, `Ext_Bill_No`, `Tax_Region`, `GST_State_Code`, `Tax_Form_Name`, `PaymentMode`, `ActEntryPartyUserCode`, `AgentName`, `TransporterName`, `CostCenter`, transport, delivery and remark fields, `CurrencyName`, `ExchangeRate`, `CreditDays`, `Godown_Name`, `Ext_NetSale_Value`, `TenderDetails`, `DisplayError` and the transfer-level discounts and charges – work exactly as described there.

| Field                                                                                                                                                                                                                         | Type   | Required                                   | Default                   | Meaning                                                                                                                                          |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ------------------------------------------ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Doc_Code`                                                                                                                                                                                                                    | number | Yes, or `OrderNo`                          | `0`                       | Logic ERP's internal number of the delivery order (see above).                                                                                   |
| `OrderNo`                                                                                                                                                                                                                     | text   | Yes, if `Doc_Code` is `0`                  | empty                     | The sale order's party order number, used to find the delivery order when `Doc_Code` is `0`. Also saved on the transfer as its order number.     |
| `BranchCode`                                                                                                                                                                                                                  | number | Yes, with `OrderNo` (or `BranchShortName`) | `0`                       | With `OrderNo`: the branch of the sale order (`BranchShortName` is used when it is `0`). Otherwise replaced by the delivery order's branch.      |
| `BillSeries`                                                                                                                                                                                                                  | text   | **Yes, in practice**                       | see rules                 | A stock-transfer series of the delivery order's branch, for example `"STO"`.                                                                     |
| `STBranchCode`                                                                                                                                                                                                                | number | No                                         | the party's linked branch | As on Save a Stock Transfer Out.                                                                                                                 |
| `LstItems`                                                                                                                                                                                                                    | list   | No                                         | empty                     | Items to transfer – they choose the lines only with the item-selection setting described above; their quantities must match what is transferred. |
| `PartyUserCode`, `BranchShortName` (when `Doc_Code` is sent), `EntrySource`, `InvoiceType`, `Doc_Type`, `Request_ID`, `RCU_…` fields, `Billing_Address1`, `Billing_Address2`, `BillingAddress`, `ShippingAddress`, `Token_No` | –      | No                                         | –                         | **Ignored** by this endpoint.                                                                                                                    |

**`LstItems`**

| Field                                                                                                                                                                                                        | Type   | Required                | Default | Meaning                                                                                                                                                                                                            |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------ | ----------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `LogicUserCode`                                                                                                                                                                                              | text   | Yes, or `AddlItemCode`  | empty   | The **item code** shown in Logic ERP (`UserCode` in [Get Item Master](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/pull/get-item-master.md)). Must exist. |
| `AddlItemCode`                                                                                                                                                                                               | text   | Yes, or `LogicUserCode` | empty   | The item's additional code / barcode, used when `LogicUserCode` is empty.                                                                                                                                          |
| `Quantity`                                                                                                                                                                                                   | number | **Yes**                 | –       | Must be above `0`. The delivery order line's pending quantity is transferred; the total per item must equal it, or the request is refused.                                                                         |
| `Lot_No`                                                                                                                                                                                                     | text   | No                      | empty   | Must exist for the item if sent; does not choose the lot.                                                                                                                                                          |
| `Rate`, `Mrp`, `CD_P`, `TD_P`, `SPCD_P`, `Scheme_Rs`, `AdjustItem_Rs`, `ItemDescription`, `SchemePerUnit`, `LabourPerUnit`, `AdjustmentPerUnit`, `AdjustmentRs`, `GodownName`, `Production_Unit`, `SaleOrSR` | –      | No                      | –       | **Ignored**.                                                                                                                                                                                                       |

### **Rules Logic ERP applies**

* **No settings of its own.** Unlike Save a Stock Transfer Out, this endpoint has no settings in your API site: there is no default series, no order-number check, no background saving or request storing, and it cannot be switched off per branch.
* **Series.** `BillSeries` is looked up among the stock-transfer series of the delivery order's branch; one that is not found is refused with *Bill Series : … Not found for Branch Code :… in API Parameter..*. If it is empty, the stock-transfer series linked to the party in Logic ERP is used; with none, the request fails with *Default Bill Series Not Set for Branch Code :…*. A series that is not a stock-transfer series is refused. Always send `BillSeries`.
* **Date and financial year.** The transfer is dated `Bill_Date` (today when left out), and `Bill_Date` decides the financial year.
* **Duplicates.** There is no duplicate check on the request. Transferred lines are no longer pending, so a repeat finds nothing to transfer and fails. Check `Status` before you resend.
* **After saving.** The automatic stock transfer in works as on Save a Stock Transfer Out. The transfer and the changes to the delivery order and sale order are saved together; if anything fails, nothing is saved.
* Your Logic ERP licence must include this endpoint.
* **Part transfers.** A delivery order cannot be transferred in part: a `Quantity` other than the open quantity is refused. To transfer only part of a delivery order, change the delivery order in Logic ERP first, or transfer from the sale order with Save a Stock Transfer Out Against a Sale Order.

> **Known issue – `LstItems` does not limit the transfer unless the series allows item selection.** Without "Allow Item Selection in SO/Chal Reterival" on the stock-transfer series, every open line of the delivery order is transferred, so a `LstItems` that leaves out an item of the delivery order is refused. With the setting on, a request whose items are not on the delivery order finds nothing to transfer and fails.

> **Known issue – `OrderNo` finds only delivery orders assigned against a sale order.** Packing slips are never found by `OrderNo`. Send `Doc_Code` whenever you can.

> **Known issue – an apostrophe in a code or name.** Codes and names you send (order number, series, lot number, tax region, godown, agent, transporter, cost centre and so on) are looked up exactly as typed. An apostrophe (`'`) in any of them makes the request fail with a database error. Leave apostrophes out of codes and names you send.

### **Example request**

```json
{
  "Doc_Code": 7716,
  "BillSeries": "STO",
  "Bill_Date": "2026-10-30",
  "TransporterName": "SHIV ROADLINES",
  "Remarks1": "Dispatch of packed cartons to Ludhiana-2",
  "LstItems": []
}
```

### **Response**

| Field           | Type         | Meaning                                                                                                                        |
| --------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| `Status`        | true / false | `true` = the transfer was saved.                                                                                               |
| `Message`       | text         | Why it failed. On success it is empty, or holds the notes and the *Saved Doc No.* text described on Save a Stock Transfer Out. |
| `LastSavedCode` | number       | Logic ERP's internal number of the transfer out.                                                                               |
| `request_ID`    | text         | The ID of this request – quote it to support.                                                                                  |
| `Invoice_No`    | text         | The transfer's number, for example `STO-62`, or your `Ext_Bill_No`.                                                            |
| `Order_No`      | text         | The delivery order's number in Logic ERP (its prefix and number), for example `PS-118`. Empty when the request fails.          |
| `PartyOrderNo`  | text         | The order number held on the transfer – normally the `OrderNo` you sent.                                                       |
| `PrintFile`     | text         | Always empty.                                                                                                                  |

### **Example response**

```json
{
  "PrintFile": "",
  "Invoice_No": "STO-62",
  "Order_No": "PS-118",
  "PartyOrderNo": "",
  "Status": true,
  "Message": "",
  "LastSavedCode": 52114,
  "request_ID": "e2b7c915-04fa-4d6e-8a31-6c9d58f0b217"
}
```

### **Messages you may see**

All with `Status: false`. Text in `…` is replaced by the value concerned. Where the reason comes from an error inside Logic ERP it may be followed by technical detail – read the first line. The messages about the series, `Bill_Number`, item codes, lot numbers, names that are not found, currency, way bill, credit limit, `Ext_NetSale_Value` and card tenders are the same as on [Save a Stock Transfer Out](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-stock-transfer-out.md).

| Message                                                                                                                                        | Meaning                                                                                                                                 | What to do                                            |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| `Unable to Retrieve Delivery Order...`                                                                                                         | `Doc_Code` is `0` and `OrderNo` is empty, or no open delivery order was found for it in the branch.                                     | Send `Doc_Code`, or check `OrderNo` and `BranchCode`. |
| `More than one Delivery Order found for Order No. : … in Branch Code : …..Please send the Delivery Order code (Doc_Code)..`                    | More than one open delivery order was found for `OrderNo`.                                                                              | Send `Doc_Code`.                                      |
| `No financial year covers the date …` (date as day/month/year)                                                                                 | `Bill_Date` lies outside every financial year set up in Logic ERP. Nothing was saved.                                                   | Send a date inside a financial year.                  |
| `Bill Series Code : … is not a Stock Transfer series. A Stock Transfer must be saved in a Stock Transfer series..Please Check API Parameter..` | The series chosen for the transfer is not a stock-transfer series.                                                                      | Send a stock-transfer series in `BillSeries`.         |
| `Doc_Code (Delivery Order Code) : … not exists..Please Check...`                                                                               | No delivery order has that internal number.                                                                                             | Check `Doc_Code`.                                     |
| `Delivery Order Is marked as Un Approved. Cannot allow Bill Creation :…`                                                                       | The delivery order is waiting for approval.                                                                                             | Have it approved in Logic ERP first.                  |
| `No Items present....`, `No Pending Item Present against Delivery Order..`                                                                     | Nothing was left to transfer – the delivery order is already fully dispatched, or (with item selection on) none of your items is on it. | Check the delivery order with Get Delivery Orders.    |
| `Unable to Create Bill for Item Code : … Quantity : … Billing Qty against Delivery Order : …..`                                                | The total `Quantity` you listed for that item differs from what is transferred of it. Nothing was saved.                                | Send the open quantity, or leave `LstItems` empty.    |
| `Item Code : … (Billing Qty : …) is on the Delivery Order but not in LstItems..`                                                               | The item is transferred from the delivery order but not listed in `LstItems`. Nothing was saved.                                        | List every item, or leave `LstItems` empty.           |
| `Unable to Retrieve Accounts...`                                                                                                               | The delivery order's party could not be read.                                                                                           | Check the delivery order in Logic ERP.                |


---

# 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://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/push/save-a-stock-transfer-out-against-a-delivery-order.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.
