> 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/sale/push/save-a-sale-document-by-type.md).

# Save a Sale Document by Type

One address for four kinds of sale document: you say in **`Doc_Type`** whether the request is a **sale invoice**, a **sale return**, a **sale challan** or a **sale challan return**, and Logic ERP passes it on to the matching endpoint. Use it if your system sends all sale documents to one place; otherwise call the specific endpoints directly. The request, the rules and the answer are exactly those of the endpoint chosen.

### **Endpoint**

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

The response 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).

### **Request fields**

| Field            | Type | Required | Default | Meaning                                                                                      |
| ---------------- | ---- | -------- | ------- | -------------------------------------------------------------------------------------------- |
| `Doc_Type`       | text | Yes      | –       | Which document to save – see the table below. Must be written exactly as shown, in capitals. |
| all other fields |      |          |         | As described on the page of the document chosen.                                             |

| `Doc_Type` | Saves                 | Same as                                                                                                                                                             |
| ---------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `"SL"`     | a sale invoice        | [Save a Sale Invoice](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-sale-invoice.md)               |
| `"SR"`     | a sale return         | [Save a Sale Return](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-sale-return.md)                 |
| `"CH"`     | a sale challan        | [Save a Sale Challan](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-sale-challan.md)               |
| `"CHR"`    | a sale challan return | [Save a Sale Challan Return](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/sale/push/save-a-sale-challan-return.md) |

### **Rules Logic ERP applies**

* The request is handled exactly as if you had sent it to the endpoint in the table: the same fields, checks, defaults, messages and response. Read that page for the details.
* `Doc_Type` is compared exactly: `"sl"`, `" SL"` or `"SALE"` are not recognised and nothing is saved.
* Sale invoices against a sale order or delivery order, and other sale documents, cannot be sent through this address; use their own endpoints.
* A request with no body (or JSON that cannot be read) is answered with a server error, not with the usual answer.

### **Example request**

A sale invoice, trimmed to the essentials (see Save a Sale Invoice for all fields):

```json
{
  "Doc_Type": "SL",
  "BranchCode": 2,
  "PartyUserCode": "C1045",
  "Bill_Date": "2026-10-28",
  "BillSeries": "WSL",
  "OrderNo": "WEB-100246",
  "LstItems": [
    {
      "LogicUserCode": "SH-1021-BLK-9",
      "Quantity": 1,
      "Rate": 2499
    }
  ],
  "TenderDetails": []
}
```

### **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 uses `Doc_Type` `SL` and creates one more test sale invoice of the item `APITEST0001` on each send.

## Save a Sale Document by Type

> One address for four kinds of sale document: you say in \`Doc\_Type\` whether the request is a sale invoice, a sale return, a sale challan or a sale challan return, and Logic ERP passes it on to the matching endpoint. Use it if your system sends all sale documents to one place; otherwise call the specific endpoints directly. The request, the rules and the answer are exactly those of the endpoint chosen.

```json
{"openapi":"3.0.3","info":{"title":"Logic ERP API","version":"1.0"},"tags":[{"name":"Sale - 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":{"/SaveInvoice":{"post":{"tags":["Sale - Push"],"operationId":"SaveInvoice","summary":"Save a Sale Document by Type","description":"One address for four kinds of sale document: you say in `Doc_Type` whether the request is a sale invoice, a sale return, a sale challan or a sale challan return, and Logic ERP passes it on to the matching endpoint. Use it if your system sends all sale documents to one place; otherwise call the specific endpoints directly. The request, the rules and the answer are exactly those of the endpoint chosen.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"Doc_Type":{"type":"string","description":"Which document to save – see the table below. Must be written exactly as shown, in capitals."},"BranchCode":{"type":"integer","description":"Logic ERP branch codes, separated by commas, for example `\"2\"` or `\"2,5,7\"`. Numbers only — there is no \"all branches\" value. Code `0` returns Logic ERP's placeholder branch named `(NIL)`; do not ask for it."},"PartyUserCode":{"type":"string","description":"One party code as shown in Logic ERP (`User_Code` in the response), for example `\"C1045\"`. Returns that party whether or not it changed recently; the bookmark and period are ignored."},"Bill_Date":{"type":"string","description":"Date of the return, `yyyy-MM-dd`; it also decides the financial year. A value that is not a date is ignored (today is used)."},"BillSeries":{"type":"string","description":"The series of the return as shown in Logic ERP. It must be a challan return series of the branch – a normal challan series is not accepted here. Use it with `Bill_No`."},"OrderNo":{"type":"string","description":"Your order or bill number for this discount, for example `\"WEB-10452\"`."},"Remarks1":{"type":"string","description":"Remarks."},"LstItems":{"type":"array","items":{"type":"object","properties":{"LogicUserCode":{"type":"string","description":"The item code as users see and type it in Logic ERP (`UserCode` in Get Item Master), for example `\"UW260041\"`."},"Quantity":{"type":"integer","description":"Quantity returned; more than `0`."},"Rate":{"type":"integer","description":"Rate per unit in ₹; used when more than `0`. Send a `Rate` on every line or on none – a request that mixes them is refused (see the rules)."}}}},"TenderDetails":{"type":"array","items":{"type":"object"}}}}}}},"responses":{"200":{"description":"Always HTTP 200. Check Status and Message.","content":{"application/json":{"schema":{"type":"object","properties":{"Status":{"type":"boolean","description":"See the Status rules on this page."},"Message":{"type":"string","description":"Why the call failed, or a note. The reason may be followed by technical detail - read the first line."},"LastSavedCode":{"type":"integer","description":"See this page."},"request_ID":{"type":"string","description":"Logic ERP request number of this call."}}}}}},"401":{"description":"No login was sent."}}}}}}
```

### **Response**

The answer of the endpoint chosen, with the same fields – for a sale invoice: `Status`, `Message`, `LastSavedCode`, `Invoice_No`, `PartyOrderNo`, `Order_No`, `PrintFile` and `request_ID`, as described on Save a Sale Invoice.

When `Doc_Type` is not one of the four values, the answer is `"Status": false` with the message below; `LastSavedCode` is `0` and `request_ID` is empty.

### **Example response**

```json
{
  "Status": false,
  "Message": "Document Type not set in SaveInvoice Request....Please Check..",
  "LastSavedCode": 0,
  "request_ID": ""
}
```

### **Messages you may see**

| Message                                                          | Meaning                                                                | What to do                                |
| ---------------------------------------------------------------- | ---------------------------------------------------------------------- | ----------------------------------------- |
| `Document Type not set in SaveInvoice Request....Please Check..` | `Doc_Type` is missing, empty or not exactly `SL`, `SR`, `CH` or `CHR`. | Send one of the four values, in capitals. |
| Any other message                                                | It comes from the endpoint chosen.                                     | See the messages on that endpoint's page. |


---

# 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/sale/push/save-a-sale-document-by-type.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.
