> 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/purchase/push/save-a-purchase-challan-return.md).

# Save a Purchase Challan Return

Creates a **purchase challan return** in Logic ERP: goods you send back to a supplier that were received on a **purchase challan** and have not been billed yet – for example damaged pieces or excess quantity found when the goods were checked. The goods **leave your branch's stock** at once. Like the challan, the return is not a purchase document: no purchase return or debit note is raised by it.

### **Endpoint**

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

The response envelope, branches, dates 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 return per request. Field names are matched without regard to upper/lower case; fields not listed below are ignored. Do not send `null` for `LstItems`.

### **How a challan return links to a challan**

* This endpoint takes **no reference to the original challan** – `Challan_Code` is ignored. The return is tied to the **supplier** and to the **lots** the goods are taken from, not to a challan.
* The goods are taken from lots of the item that **have stock** in the branch in the return's financial year. To return the goods of a particular challan, send the lot number used on that challan in `LotNo`, and – if the same lot number was used on other challans – that challan's `Bill_No` in `Lot_Bill_No` (a lot carries the bill number of the last challan or purchase that received goods into it).
* The lot's supplier is not checked: a lot received from another supplier is accepted. Send lot numbers that belong to this supplier.
* The return gets its own GRN number and internal number. Saved returns are returned by [Get Purchase Challan Returns](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/purchase/pull/get-purchase-challan-returns.md).

### **How it differs from Save a Purchase Voucher**

The request has the same fields as [Save a Purchase Voucher](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/purchase/push/save-a-purchase-voucher.md). The differences:

* Stock goes **out** instead of coming in, and **no lot is created**: every line must find stock in existing lots.
* The document is a challan return, kept with the purchase challans, not a purchase bill or purchase return.
* This endpoint always uses Logic ERP's import save routine, with its own API site settings (default series, default godown, lot filters, duplicate bill-number check).
* `LotNo` is optional and, when sent, chooses the lot instead of naming a new one.

### **Request fields**

| Field                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | Type   | Required | Default                            | Meaning                                                                                                                                                                                                                                                                                                            |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `AccountCode`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | text   | **Yes**  | –                                  | The supplier's **party code** (`User_Code` in [Get Party Master](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/pull/get-party-master.md)). Must already exist. The tax region, credit days, transporter and default discounts are taken from this account. |
| `SupplierCode`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | text   | No       | `AccountCode`                      | A different party code for the supplier, when the account is someone else. Must exist. Usually left out.                                                                                                                                                                                                           |
| `BranchCode`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | number | No       | `0`                                | The branch sending the goods back, by Logic ERP's branch number (`Branch_Code` in [Get Branch Info](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/pull/get-branch-info.md)).                                                                               |
| `BranchShortName`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | text   | No       | empty                              | The branch by its short name; used only when `BranchCode` is `0`. With neither, Logic ERP falls back to a default branch – always send one.                                                                                                                                                                        |
| `Bill_No`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | text   | No\*     | empty                              | Your return reference, for example your return note number. \*Required when your API site checks duplicate supplier bills. See the known issue – it cannot be the challan's bill number.                                                                                                                           |
| `InvoiceDate`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | date   | No       | today                              | Date of the return, `yyyy-MM-dd`. Same rules as on a challan.                                                                                                                                                                                                                                                      |
| `Bill_Date`, `PartyBillDate`                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | date   | No       | `InvoiceDate`                      | Reference dates stored on the return.                                                                                                                                                                                                                                                                              |
| `Godown_Name`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | text   | No       | none                               | Only lots in this godown are used. Must exist.                                                                                                                                                                                                                                                                     |
| `GRN_Prefix`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | text   | No       | the series' GRN prefix, else `GRN` | Prefix of the return's GRN number.                                                                                                                                                                                                                                                                                 |
| `GR_Number`, `GR_Date` (or `GRDate`), `GPN_No`, `GPN_Date`, `OrderNo`, `OrderDate`, `ChallanNo`, `ChallanDate`, `PU_Remarks_1`, `PU_Remarks_2`, `PU_Remarks_3`, `AgentName`, `TransporterName`, `CostCenter`, `CurrencyName`, `ExchangeRate`, `CreditDays`, `Freight`, `Adjustment_Rs`, `SpDiscountRs`, `TransportMode`, `VehicleNo`, `Cases`, `Weight`, `PVTMark`, `Insurance_Policy_No`, `Declaration_No`, `DeliveryAt`, `DeliveryAdd1`, `DeliveryAdd2`, `Series_Code`, `DisplayError`, `Doc_Type` | –      | No       | –                                  | As on [Save a Purchase Challan](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/purchase/push/save-a-purchase-challan.md). `Series_Code` is used only when your API site has no default series for **challan returns**.                                              |
| `CD_P`, `TD_P`, `SP_CD`, `SchemeRs`, `AdjustUnit`                                                                                                                                                                                                                                                                                                                                                                                                                                                    | –      | No       | –                                  | See the known issue on Save a Purchase Challan – the bill-level discounts do not change the amounts.                                                                                                                                                                                                               |
| `LstItems`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | list   | **Yes**  | –                                  | The goods returned. See below. `ListItems` is accepted as another name.                                                                                                                                                                                                                                            |
| `Request_ID`, `EntrySource`, `DNO_Code`, `Challan_Code`, `PO_Code`                                                                                                                                                                                                                                                                                                                                                                                                                                   | –      | No       | –                                  | **Ignored** by this endpoint.                                                                                                                                                                                                                                                                                      |

**`LstItems`**

| Field                                                                                  | Type   | Required                 | Default     | Meaning                                                                                                                                                                                                |
| -------------------------------------------------------------------------------------- | ------ | ------------------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `LogicUser_Code`                                                                       | 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)). |
| `AddlItemCode`                                                                         | text   | Yes, or `LogicUser_Code` | empty       | The item's additional code / barcode; used when `LogicUser_Code` is empty or not found.                                                                                                                |
| `ScannedQty`                                                                           | number | **Yes**                  | –           | Quantity returned; more than `0`. There must be at least this much stock in the matching lots.                                                                                                         |
| `LotNo`                                                                                | text   | No                       | any lot     | Lot number to take the goods from. Empty = any lot of the item with stock. Upper and lower case and spaces at the end do not matter.                                                                   |
| `Lot_Bill_No`                                                                          | text   | No\*                     | empty       | Only lots with this bill number are used (for a lot received on a challan, the challan's `Bill_No`). \*Required when your API site filters return lots by lot bill number.                             |
| `Production_Unit`                                                                      | text   | No                       | empty       | Only lots of this production unit are used.                                                                                                                                                            |
| `BasicRate`                                                                            | number | No                       | `0`         | Rate per unit in ₹ for the line amount. Send the rate of the goods returned.                                                                                                                           |
| `ItemDescription`                                                                      | text   | No                       | empty       | Description for the line.                                                                                                                                                                              |
| `PurRate`, `SaleRate`, `Lot_Mrp`, `SP_Rate_1` … `SP_Rate_5`, `Expiry_Date`, `MFG_Date` | –      | No                       | `0` / empty | Optional line values; the goods come from an existing lot.                                                                                                                                             |
| `LotCode`, `Godown_Code`, `Org_Production_Unit`                                        | –      | No                       | –           | **Ignored** by this endpoint; the lot and its godown are found by Logic ERP.                                                                                                                           |

### **Rules Logic ERP applies**

**Supplier, branch, series and dates**

* As on Save a Purchase Challan: the supplier is found by its party code and must be a customer, supplier or cash account, the series is your API site's default series for **purchase challan returns** (else `Series_Code`), the return is saved in the financial year `InvoiceDate` falls in, and the tax region comes only from the supplier.

**Choosing the lots**

* For each line Logic ERP looks for lots of the item with stock **above 0** in the branch in the return's financial year, and keeps only those that match what you sent: `LotNo`, `Lot_Bill_No`, `Production_Unit`, and the godown of `Godown_Name` – or, when no `Godown_Name` is sent, your API site's default godown for this endpoint if one is set.
* The quantity is taken from the **oldest lot first** (by purchase date). If one lot does not have enough, the rest is taken from the next one, and the line becomes one return line per lot. All lines share each lot's stock, so together they never take more than a lot holds.
* If the matching lots together hold less than the quantity, the request fails with *Insufficient Stock for Item Code : …*. Nothing is returned from stock that is not there, even if your Logic ERP set-up allows negative stock.
* While saving, Logic ERP checks the chosen lot again: it must be in one of the series' default godowns (when the series has any), and, if your API site filters return lots by lot bill number or production unit, `Lot_Bill_No` must be sent and the lot must have a production unit.

**Duplicates**

* The same checks as a challan: your API site's duplicate supplier-bill check, and Logic ERP's own refusal of a `Bill_No` already used on a purchase challan or purchase challan return of the same supplier in the same branch. Challans and challan returns are checked **together**.

**Saving**

* The return is saved in one step; on any failure nothing is saved.

> **Known issue – the return's `Bill_No` cannot be the challan's.** Purchase challans and purchase challan returns share one bill-number check, so a return sent with the bill number of the challan it returns is refused with *Bill No:… already exists for this supplier... Cannot Continue.* Give the return its own number (for example your return note number) and put the challan's bill number in `Lot_Bill_No` or `ChallanNo`.

> **Known issue – no API route raises the purchase return for a challan return.** The route meant for a purchase return against a purchase challan return ([Save a Purchase Return Against a Purchase Challan Return](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/purchase/push/save-a-purchase-return-against-a-purchase-challan-return.md)) refuses a request that names the challan return, and without it saves a new **purchase challan** (goods coming in) instead. Do not use it until it is fixed; raise the purchase return in Logic ERP.

> **Apostrophes in codes and names.** Party codes, item codes, lot number, lot bill number, production unit, godown, agent, transporter, cost centre and currency names may contain an apostrophe (`'`). Leave apostrophes out of `Bill_No` and `GRN_Prefix`: Logic ERP's own purchase routine also uses them.

### **Example request**

```json
{
  "BranchCode": 2,
  "AccountCode": "S0142",
  "Bill_No": "RTN-0311",
  "InvoiceDate": "2026-10-31",
  "Godown_Name": "MAIN",
  "ChallanNo": "DC-5521",
  "PU_Remarks_2": "Damaged pieces returned",
  "LstItems": [
    { "LogicUser_Code": "SHRT-BLU-M", "ScannedQty": 3, "BasicRate": 450.00, "LotNo": "DC5521-01", "Lot_Bill_No": "DC-5521" }
  ]
}
```

### **Test it**

Send a request to the Logic ERP **sandbox** (a test company) from this page: open the block below, enter the sandbox user name and password (ask your Logic ERP support team), change the request if you like, and press **Test it**. This really saves in the sandbox, so use test values like the example. The example returns one pair of the test item `APITEST0001`; each send creates one more test challan return.

## Save a Purchase Challan Return

> Creates a purchase challan return in Logic ERP: goods you send back to a supplier that were received on a purchase challan and have not been billed yet – for example damaged pieces or excess quantity found when the goods were checked. The goods leave your branch's stock at once. Like the challan, the return is not a purchase document: no purchase return or debit note is raised by it.

```json
{"openapi":"3.0.3","info":{"title":"Logic ERP API","version":"1.0"},"tags":[{"name":"Purchase - Push"}],"servers":[{"url":"https://demo.logicerp.com/api","description":"Logic ERP sandbox (test company)"}],"security":[{"basicAuth":[]}],"components":{"securitySchemes":{"basicAuth":{"type":"http","scheme":"basic","description":"The user name and password of your API site."}}},"paths":{"/SavePurchaseChallanReturn":{"post":{"tags":["Purchase - Push"],"operationId":"SavePurchaseChallanReturn","summary":"Save a Purchase Challan Return","description":"Creates a purchase challan return in Logic ERP: goods you send back to a supplier that were received on a purchase challan and have not been billed yet – for example damaged pieces or excess quantity found when the goods were checked. The goods leave your branch's stock at once. Like the challan, the return is not a purchase document: no purchase return or debit note is raised by it.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"BranchCode":{"type":"integer","description":"The branch sending the goods back, by Logic ERP's branch number (`Branch_Code` in Get Branch Info)."},"AccountCode":{"type":"string","description":"The supplier's party code (`User_Code` in Get Party Master). Must already exist. The tax region, credit days, transporter and default discounts are taken from this account."},"Bill_No":{"type":"string","description":"Your return reference, for example your return note number. *Required when your API site checks duplicate supplier bills. See the known issue – it cannot be the challan's bill number."},"Bill_Date":{"type":"string","description":"Reference dates stored on the return."},"PartyBillDate":{"type":"string","description":"Reference dates stored on the return."},"InvoiceDate":{"type":"string","description":"Date of the return, `yyyy-MM-dd`. Same rules as on a challan."},"Godown_Name":{"type":"string","description":"Only lots in this godown are used. Must exist."},"ChallanNo":{"type":"string","description":"As on Save a Purchase Challan. `Series_Code` is used only when your API site has no default series for challan returns."},"PU_Remarks_2":{"type":"string","description":"As on Save a Purchase Challan. `Series_Code` is used only when your API site has no default series for challan returns."},"LstItems":{"type":"array","items":{"type":"object","properties":{"LogicUser_Code":{"type":"string","description":"The item code shown in Logic ERP (`UserCode` in Get Item Master)."},"ScannedQty":{"type":"integer","description":"Quantity returned; more than `0`. There must be at least this much stock in the matching lots."},"BasicRate":{"type":"integer","description":"Rate per unit in ₹ for the line amount. Send the rate of the goods returned."},"LotNo":{"type":"string","description":"Lot number to take the goods from. Empty = any lot of the item with stock. Upper and lower case and spaces at the end do not matter."},"Lot_Bill_No":{"type":"string","description":"Only lots with this bill number are used (for a lot received on a challan, the challan's `Bill_No`). *Required when your API site filters return lots by lot bill number."},"ItemDescription":{"type":"string","description":"Description for the line."}}},"description":"The goods returned. See below. `ListItems` is accepted as another name."}}}}}},"responses":{"200":{"description":"Always HTTP 200. Check Status and Message.","content":{"application/json":{"schema":{"type":"object","properties":{"LastSavedDocNo":{"type":"string","description":"The return's GRN number, GRN prefix and number joined by `-`, for example `RGRN-311`. `null` when nothing was saved."},"Status":{"type":"boolean","description":"`true` = the return was saved."},"Message":{"type":"string","description":"Why it failed; empty on success."},"LastSavedCode":{"type":"integer","description":"Logic ERP's internal number of the challan return. Use it in `Doc_Codes` to read it back."},"request_ID":{"type":"string","description":"The ID of this request – quote it to support."}}}}}},"401":{"description":"No login was sent."}}}}}}
```

### **Response**

| Field            | Type         | Meaning                                                                                                              |
| ---------------- | ------------ | -------------------------------------------------------------------------------------------------------------------- |
| `Status`         | true / false | `true` = the return was saved.                                                                                       |
| `Message`        | text         | Why it failed; empty on success.                                                                                     |
| `LastSavedCode`  | number       | Logic ERP's internal number of the challan return. Use it in `Doc_Codes` to read it back.                            |
| `LastSavedDocNo` | text         | The return's GRN number, GRN prefix and number joined by `-`, for example `RGRN-311`. `null` when nothing was saved. |
| `request_ID`     | text         | The ID of this request – quote it to support.                                                                        |

### **Example response**

```json
{
  "LastSavedDocNo": "RGRN-311",
  "Status": true,
  "Message": "",
  "LastSavedCode": 1424,
  "request_ID": "b7e41f02-6c3d-4a9e-8d15-2f0a9c6e7b48"
}
```

### **Messages you may see**

All with `Status: false`. Text in `…` is replaced by the value concerned. Messages marked † come with technical text before and after the reason – look for the sentence. With `"DisplayError": "1"` every message carries technical detail – read the first line.

**Specific to returns**

| Message                                          | Meaning                                                                          | What to do                                                                                               |
| ------------------------------------------------ | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `Insufficient Stock for Item Code : … Lot_No: …` | The matching lots hold less than the quantity, or no lot matched.                | Check the stock with Get Stock In Hand, the lot number, `Lot_Bill_No`, `Production_Unit` and the godown. |
| `Lot not found for this item : …` †              | The chosen lot is not in one of the series' default godowns.                     | Return the goods from a godown the series allows, or ask your Logic ERP team.                            |
| `Invalid Bill No. Please Check..` †              | Your API site filters return lots by lot bill number and `Lot_Bill_No` is empty. | Send `Lot_Bill_No`.                                                                                      |
| `Invalid Production Unit for Item : …` †         | Your API site filters return lots by production unit and the lot has none.       | Ask your Logic ERP team.                                                                                 |
| `Unable to Retrive Item Details...`              | The item could not be read while looking for stock.                              | Contact support with the `request_ID`.                                                                   |

**Same as on a challan**

`Default Configuration Not Defined in API Template`, `Account Code Not Defined...`, `Invalid Account User Code...`, `Invalid Supplier Code Defined...`, `Account Code : … is not a Customer / Supplier / Cash account..Please Check...`, the date messages (including `No financial year covers the date …`), `Bill No can't be blank...`, the `Bill No:… already exists…` messages, `Item Details Not Defined...`, `Logic User Code/Additional Item Code Not Defined for Item No : …`, `Invalid LogicUserCode / EANCode : …`, `Quantity Not Defined For : '…' Item No : …`, `Unable to Find Items for Import...` †, `Invalid Godown Name […]. Please Check...`, `Default Tax Region not Set.Please Check....`, the GST messages †, the name-not-found messages and `Error while saving voucher` † – see [Save a Purchase Challan](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/purchase/push/save-a-purchase-challan.md) for their meaning.


---

# 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/purchase/push/save-a-purchase-challan-return.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.
