> 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-sale-order.md).

# Save a Stock Transfer Out Against a Sale Order

Creates a **stock transfer out** from a **sale order** that is already in Logic ERP. Use it when a branch (or a franchise outlet set up as a branch) has placed an order on the sending branch as a sale order, and you now dispatch goods against that order. You name the order and the items and quantities you are sending; Logic ERP takes the order's lines, issues stock for them from the sending branch, saves the transfer and takes the quantities off the order's pending quantity.

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 sale order. To transfer goods that have already been packed on a delivery order or packing slip, use [Save a Stock Transfer Out Against a Delivery Order](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).

### **Endpoint**

| Name          | Detail                                     |
| ------------- | ------------------------------------------ |
| Address       | `https://your-server/api/SaveSTOAgainstSO` |
| 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 sale order, per request. Field names are matched without regard to upper/lower case; fields not listed below are ignored.

### **How the sale order is found**

* Send `Doc_Code`: Logic ERP's internal number of the sale order – the `LastSavedCode` you got from [Save a Sale Order](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/push/save-a-sale-order.md), or the order's internal number in [Get Sale Orders](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/orders/pull/get-sale-orders.md). This is the reliable way.
* Or leave `Doc_Code` at `0` and send `OrderNo`: Logic ERP then looks for a sale order of the branch in `BranchCode` (or `BranchShortName`, when `BranchCode` is `0`) whose **party order number** (the `Party_Order_No` sent with Save a Sale Order) is exactly `OrderNo`. When more than one order of the branch has that party order number, the request is refused with *More than one Sale Order found for Order No. : … in Branch Code : …..Please send the Sale Order code (Doc\_Code)..* – send `Doc_Code`.
* With `Doc_Code`, the transfer is saved in the **order's branch** – the `BranchCode` you send is replaced by it. The order's branch is the sending branch.
* The **party** is the order's customer; `PartyUserCode` is ignored. For a proper stock transfer, the sale order must be made out to 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 sale order that is waiting for approval is refused, and so is an order with nothing pending (cancelled orders and cancelled lines count as nothing pending).

### **What is transferred**

* **Items and quantities.** For each item in `LstItems`, the quantity you send is spread over that item's open lines on the order, each line taking at most its pending quantity. Lines of the same item in `LstItems` are added together. Items of the order you do not list stay pending.
* **Not more than is pending.** If you send more of an item than the order still has pending, or the sending branch cannot issue the full quantity, nothing is saved and the message names the item with both quantities (*Unable to Create Bill for Item : … with Quantity : … Order Qty : …*; "Order Qty" here is the quantity Logic ERP could take).
* **Items not on the order** are refused (*Unable to found Item Code : … and Rate : …*). When none of the items you list has anything pending on the order, the message is *No Pending Item Present against Sale Order..* instead.
* **Empty `LstItems`.** When `LstItems` is empty or left out, **everything still pending on the order** is taken. When the sending branch's stock cannot fill an item's whole pending quantity, nothing is saved and the request is refused with *Unable to Create Bill for Item Code : … Order Pending Qty : … Billing Qty : … (stock not available)..*.
* **Stock.** Stock reserved against the order line is used first, then other lots with stock at the sending branch, as on Logic ERP's sale screen when an order is pulled in.
* **Lot numbers.** `Lot_No` must exist for the item. It chooses the lot only when your API site is set to require lot numbers for this endpoint: then stock is taken only from the lots you name for that item (from the lot named on the order line, if it names one; from any lot with stock for an item sent without `Lot_No`), and if there is none with stock the request fails with a message starting *Stock not available for Item :*. Otherwise Logic ERP picks the lots itself.
* **Rates are not taken from the request.** Each line is priced as on Logic ERP's sale screen when an order is pulled in: from the series' price list, or from the order line's rate (and CD %) when the stock-transfer series is set to pick them from the sale order. `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 as on Save a Stock Transfer Out.
* Some details are carried over from the order – for example its agent, and its external order ID, which replaces `Order_Id`.

### **What happens to the sale order**

* The transferred quantity is taken off the pending quantity of the order lines it came from. The rest stays pending and can be transferred later with another request.
* If your API site is set to **cancel what is still pending after a transfer against an order**, the rest of the order is cancelled right after the transfer is saved, with the reason *Auto Cancel After STO from API*. If that cancellation fails, the transfer stays saved and `Message` says so: *Sale Order not cancelled after Stock Transfer : …* followed by the reason.

### **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 – `BillSeries`, `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`, `DisplayError`, `Request_ID` 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 sale order (see above).                                                                                                                                                                                         |
| `OrderNo`                                                                                                                                                                           | text   | Yes, if `Doc_Code` is `0` | empty                     | The order's party order number, used to find the order when `Doc_Code` is `0`. It is also saved on the transfer as its order number and is subject to the order-number setting described in Save a Stock Transfer Out (see the known issue below). |
| `BranchCode`                                                                                                                                                                        | number | No                        | `0`                       | Ignored when `Doc_Code` is sent (the order's branch is used). With `Doc_Code` `0`, the branch in which the order is looked up by `OrderNo`.                                                                                                        |
| `BranchShortName`                                                                                                                                                                   | text   | No                        | empty                     | Used to choose the branch when the order is found by `OrderNo` and `BranchCode` is `0`.                                                                                                                                                            |
| `BillSeries`                                                                                                                                                                        | text   | No\*                      | see rules                 | A stock-transfer series of the order's branch. \*Not used when your API site links the order's series to another series (see the rules).                                                                                                           |
| `STBranchCode`                                                                                                                                                                      | number | No                        | the party's linked branch | As on Save a Stock Transfer Out.                                                                                                                                                                                                                   |
| `LstItems`                                                                                                                                                                          | list   | No                        | empty                     | The items to transfer from the order. Empty or left out = everything still pending.                                                                                                                                                                |
| `PartyUserCode`, `EntrySource`, `TenderDetails`, `InvoiceType`, `Doc_Type`, `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 be on the order. Do not send `null`. |
| `AddlItemCode`                                                                                                                                                                                               | text   | Yes, or `LogicUserCode` | empty   | The item's additional code / barcode, used when `LogicUserCode` is empty. Do not send `null`.                                                                                                                                                    |
| `Quantity`                                                                                                                                                                                                   | number | **Yes**                 | –       | Quantity to transfer; more than `0`.                                                                                                                                                                                                             |
| `Lot_No`                                                                                                                                                                                                     | text   | No                      | empty   | Must exist for the item; chooses the lot only with the lot setting described above.                                                                                                                                                              |
| `Rate`, `Mrp`, `CD_P`, `TD_P`, `SPCD_P`, `Scheme_Rs`, `AdjustItem_Rs`, `ItemDescription`, `SchemePerUnit`, `LabourPerUnit`, `AdjustmentPerUnit`, `AdjustmentRs`, `GodownName`, `Production_Unit`, `SaleOrSR` | –      | No                      | –       | **Ignored** – rates and discounts are worked out by Logic ERP (see above).                                                                                                                                                                       |

### **Rules Logic ERP applies**

* **Series.** If your API site links the sale order's series to a sale series, that series is used and `BillSeries` is ignored. Otherwise `BillSeries` is looked up among the stock-transfer series of the order's branch; one that is not found is refused. When `BillSeries` is empty, the stock-transfer series linked to the party, then the default series of this endpoint in your API site is used. Whatever way it is chosen, the series must be a stock-transfer series, or the request is refused with *Bill Series Code : … is not a Stock Transfer series. A Stock Transfer must be saved in a Stock Transfer series..Please Check API Parameter..*.
* **Date and financial year.** The transfer is dated `Bill_Date` (today when left out), and `Bill_Date` decides the financial year.
* **Order-number setting.** When your API site's order-number setting is on for this endpoint, `OrderNo` is required and must not already be used on a sale document of the same party in the same branch and financial year. It is checked before saving and again while saving.
* **Payments.** `TenderDetails` is not used.
* **Duplicates.** There is no duplicate check on the request. A transferred quantity is no longer pending, so a repeat finds less to take: it is refused when the order has nothing left of the item, and transferred again when something is left. Check `Status` before you resend.
* **After saving.** The automatic stock transfer in, background saving and request storing work as on Save a Stock Transfer Out. The transfer, its lines and the change to the order's pending quantities are saved together; if anything fails, nothing is saved.
* Your Logic ERP licence must include this endpoint.

> **Known issue – a second transfer against the same order with the order-number setting on.** With your API site's order-number setting on, `OrderNo` must be new for the party. If you find the order by `OrderNo`, the second transfer against the same order uses the same `OrderNo` and is refused with *Order No. already exists for same Customer.Please Check*. For orders you transfer in parts, send `Doc_Code` and a new `OrderNo` each time.

> **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": 18342,
  "BillSeries": "STO",
  "Bill_Date": "2026-10-30",
  "OrderNo": "IND-4410-A",
  "TransporterName": "SHIV ROADLINES",
  "Remarks1": "Part dispatch against branch indent",
  "LstItems": [
    { "LogicUserCode": "SHRT-BLU-M", "Quantity": 24 },
    { "LogicUserCode": "KRT-WHT-L", "Quantity": 12 }
  ]
}
```

### **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-61`, or your `Ext_Bill_No`.                                                            |
| `Order_No`      | text         | The sale order's number in Logic ERP (its prefix and number), for example `SO-245`. 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-61",
  "Order_No": "SO-245",
  "PartyOrderNo": "IND-4410-A",
  "Status": true,
  "Message": "",
  "LastSavedCode": 52107,
  "request_ID": "8c41f2a0-3d7e-4b5a-9e61-2f0b7d14c3a9"
}
```

### **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, the order-number setting, names that are not found, currency, way bill, credit limit, `Ext_NetSale_Value` and request storing 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 Sale Order...`                                                                                                             | `Doc_Code` is `0` and no sale order of the branch has that party order number (or `OrderNo` is empty too).                                          | Send `Doc_Code`, or check `OrderNo` and the branch.             |
| `More than one Sale Order found for Order No. : … in Branch Code : …..Please send the Sale Order code (Doc_Code)..`                            | More than one sale order of the branch has that party order number.                                                                                 | 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.                                                                                  | Ask your Logic ERP team to link or set a stock-transfer series. |
| `Doc_Code (Sale Order Code) : … not exists..Please Check...`                                                                                   | No sale order has that internal number.                                                                                                             | Check `Doc_Code`.                                               |
| `Sale Order Is marked as Un Approved. Cannot allow Bill Creation :…`                                                                           | The order is waiting for approval.                                                                                                                  | Have the order approved in Logic ERP first.                     |
| `No Pending Item Present against Sale Order..`                                                                                                 | The order (or the items you listed) has nothing pending – fully transferred, cancelled, or the items are not on it.                                 | Check the order with Get Sale Orders.                           |
| `Unable to found Item Code : … and Rate : …` (followed by a few more words)                                                                    | An item in `LstItems` has no pending line on the order. The rate shown is not used.                                                                 | Send only items that are pending on the order.                  |
| `Unable to Create Bill for Item : … with Quantity : … Order Qty : …`                                                                           | Less than the quantity you sent could be taken – more than is pending on the order, or not enough stock.                                            | Send at most the pending quantity, or check stock.              |
| `Unable to Create Bill because stock not available Item Code : …`                                                                              | None of the item could be taken.                                                                                                                    | Check stock at the sending branch.                              |
| `Unable to Create Bill for Item Code : … Order Pending Qty : … Billing Qty : … (stock not available)..`                                        | `LstItems` is empty and the stock cannot fill the whole pending quantity of that item. Nothing was saved.                                           | Check stock, or send `LstItems` with what you can send.         |
| A message starting `Stock not available for Item :`                                                                                            | Your API site requires lot numbers for this endpoint and the lots you named have no stock.                                                          | Send lots that have stock.                                      |
| `Unable to Retrieve Accounts...`                                                                                                               | The order's customer could not be read.                                                                                                             | Check the sale order in Logic ERP.                              |
| A message containing `Request cannot be processed. API Template is marked as In-Active in the configuration.`                                  | Your Logic ERP team has switched this endpoint off for the branch. The answer is `Status: false` with this sentence in `Message`. Nothing is saved. | Ask your Logic ERP team.                                        |


---

# 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-sale-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.
