> 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/masters/push/create-discount-coupons.md).

# Create Discount Coupons

Creates **discount coupons** in Logic ERP – a fixed ₹ discount or a percentage discount, with a minimum bill amount, a start date and an expiry date – so that the tills can accept them. Send one or many coupons in one call. Use it when coupons are issued from your own system (a campaign tool, an app, a loyalty programme).

### **Endpoint**

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

The response and the messages every endpoint can return 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**

The body is a **list** (a JSON array) of coupons, even for one coupon; a single coupon sent without the `[ ]` is answered with the "no body" message (``Payload Request Can`t be null. Please Check...``). Each coupon:

| Field                     | Type   | Required         | Default | Meaning                                                                                                                                                                                                                                                                              |
| ------------------------- | ------ | ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Discount_Coupon_PreFix`  | text   | Yes              | `""`    | Prefix of the coupon number, for example `"DW"`. Logic ERP numbers the coupons of each prefix itself (see the rules). Sending `null` gives a technical error.                                                                                                                        |
| `Discount_Coupon_Number`  | number | Yes, in practice | `0`     | **Not used as the coupon's number** – Logic ERP gives its own (see the rules). It is only used to tell the coupons of one request apart: give every coupon with the same prefix a **different** number, for example `1`, `2`, `3` … See the known issues below.                      |
| `CD_Rs`                   | number | No               | `0`     | Fixed discount in ₹.                                                                                                                                                                                                                                                                 |
| `CD_P`                    | number | No               | `0`     | Discount as a percentage of the bill.                                                                                                                                                                                                                                                |
| `Max_Amount_For_CD_P`     | number | No               | `0`     | The most a percentage discount may come to, in ₹.                                                                                                                                                                                                                                    |
| `Minimum_Amount`          | number | No               | `0`     | Minimum bill amount, in ₹, for the coupon to apply.                                                                                                                                                                                                                                  |
| `Start_Date`              | date   | No               | empty   | First day the coupon may be used, `yyyy-MM-dd`.                                                                                                                                                                                                                                      |
| `Expiry_Date`             | date   | No               | empty   | Last day the coupon may be used, `yyyy-MM-dd`. Send it: a coupon without an expiry date is not listed by [Get Pending Discount Coupons](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/pull/get-pending-discount-coupons.md). |
| `Create_Date`             | date   | No               | today   | The coupon's creation date, `yyyy-MM-dd`. Also stored as its last-changed date.                                                                                                                                                                                                      |
| `Creation_Branch_Code`    | number | No               | `0`     | Logic ERP's code of the branch that issued the coupon (`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)). Not checked.                                              |
| `Discount_Coupon_Barcode` | text   | No               | empty   | Barcode printed on the coupon. Not checked for duplicates.                                                                                                                                                                                                                           |

**Ignored** although they exist: `Discount_Coupon_Num` (Logic ERP builds the full number itself) and `Sale_Fin_Year` (Logic ERP uses the financial year it is working in for your API site).

### **Rules Logic ERP applies**

* **Numbering.** Each coupon gets the **next free number for its prefix**: the highest number already used with that prefix, plus one. The full coupon number the shopper quotes is the prefix followed by that number, for example `DW1026`. Several coupons with the same prefix in one request get consecutive numbers. The numbers given are listed in `Message`, for example `Discount Coupon(s) saved : DW1026, DW1027`.
* **All or nothing.** The coupons are saved together: if one fails while saving, none are kept.
* The coupons are not linked to a customer, a coupon group, an item group or a branch group, and are single-use.
* Nothing checks the amounts: a coupon can carry both `CD_Rs` and `CD_P`, or neither. A start date after the expiry date is not refused.
* A date that cannot be read is ignored without a message (for `Create_Date`, today is used).
* **Prefixes that begin with another prefix** (for example `DW` and `DW1`) can produce the same full coupon number (`DW` + `11` and `DW1` + `1` are both `DW11`). The request then fails with a database error and nothing is saved. Use prefixes that do not begin with one another.
* If your Logic ERP team has set your company to keep discount coupons in a **separate central coupon database**, the coupons are saved there instead of in the company. Such coupons are not listed by Get Pending Discount Coupons.

> **Known issue – the number you send is not the coupon's number.** Logic ERP always gives the next free number for the prefix, whatever `Discount_Coupon_Number` you send, and `LastSavedCode` is `0`. Read the numbers given from `Message`.

> **Known issue – the "already exists" check does not stop duplicates.** The check compares the prefix and the number **you send** (not the number Logic ERP will give), and when coupons are kept in the company it looks in a separate list meant for central-database coupons, not among the company's own coupons, so it normally finds nothing. Sending the same coupons twice therefore normally creates them twice, with new numbers. Do not re-send a request that answered `Status: true`. When the check does find a coupon, that coupon is **left out without a message** and the rest are saved; only when every coupon is left out does the call answer `Discount Coupons Already Exist in database...`.

**Each coupon of a prefix needs its own number in the request.** Two coupons with the same prefix and `Discount_Coupon_Number` – also when `Discount_Coupon_Number` is left out for several coupons of one prefix (they all count as `0`) – make the whole request refused with `Duplicate Discount Coupon(s) with the same Prefix + Number in the request: …. Each coupon must have a distinct Discount_Coupon_Number.` (the prefix and number shown as `DW|1`). Nothing is saved.

### **Example request**

```json
[
  {
    "Discount_Coupon_PreFix": "DW",
    "Discount_Coupon_Number": 1,
    "CD_Rs": 250,
    "Minimum_Amount": 1999,
    "Start_Date": "2026-11-01",
    "Expiry_Date": "2026-11-15",
    "Creation_Branch_Code": 4,
    "Discount_Coupon_Barcode": "DW26-000481"
  },
  {
    "Discount_Coupon_PreFix": "DW",
    "Discount_Coupon_Number": 2,
    "CD_P": 10,
    "Max_Amount_For_CD_P": 500,
    "Minimum_Amount": 2999,
    "Start_Date": "2026-11-01",
    "Expiry_Date": "2026-11-15",
    "Creation_Branch_Code": 4,
    "Discount_Coupon_Barcode": "DW26-000482"
  }
]
```

### **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. Each send creates one more test coupon with the prefix `APT`.

## Create Discount Coupons

> Creates discount coupons in Logic ERP – a fixed ₹ discount or a percentage discount, with a minimum bill amount, a start date and an expiry date – so that the tills can accept them. Send one or many coupons in one call. Use it when coupons are issued from your own system (a campaign tool, an app, a loyalty programme).

```json
{"openapi":"3.0.3","info":{"title":"Logic ERP API","version":"1.0"},"tags":[{"name":"Masters - 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":{"/SaveDiscountCoupon":{"post":{"tags":["Masters - Push"],"operationId":"SaveDiscountCoupon","summary":"Create Discount Coupons","description":"Creates discount coupons in Logic ERP – a fixed ₹ discount or a percentage discount, with a minimum bill amount, a start date and an expiry date – so that the tills can accept them. Send one or many coupons in one call. Use it when coupons are issued from your own system (a campaign tool, an app, a loyalty programme).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"Discount_Coupon_PreFix":{"type":"string","description":"Prefix of the coupon number, for example `\"DW\"`. Logic ERP numbers the coupons of each prefix itself (see the rules). Sending `null` gives a technical error."},"Discount_Coupon_Number":{"type":"integer","description":"Not used as the coupon's number – Logic ERP gives its own (see the rules). It is only used to tell the coupons of one request apart: give every coupon with the same prefix a different number, for example `1`, `2`, `3` … See the known issues below."},"CD_Rs":{"type":"integer","description":"Fixed discount in ₹."},"Minimum_Amount":{"type":"integer","description":"Minimum bill amount, in ₹, for the coupon to apply."},"Start_Date":{"type":"string","description":"First day the coupon may be used, `yyyy-MM-dd`."},"Expiry_Date":{"type":"string","description":"Last day the coupon may be used, `yyyy-MM-dd`. Send it: a coupon without an expiry date is not listed by Get Pending Discount Coupons."},"Creation_Branch_Code":{"type":"integer","description":"Logic ERP's code of the branch that issued the coupon (`Branch_Code` in Get Branch Info). Not checked."},"Discount_Coupon_Barcode":{"type":"string","description":"Barcode printed on the coupon. Not checked for duplicates."}}}}}}},"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**

* `Status` – `true` when the coupons were saved.
* `Message` – when saved, `Discount Coupon(s) saved :` followed by the coupon numbers given; otherwise the reason (see below).
* `LastSavedCode` – always `0`.
* `request_ID` – the ID of this request, as described in How Every API Call Works.

### **Example response**

```json
{
  "Status": true,
  "Message": "Discount Coupon(s) saved : DW1026, DW1027",
  "LastSavedCode": 0,
  "request_ID": "7c2e9b41-5d08-4a6f-b3e7-1f9a0c6d2e85"
}
```

### **Messages you may see**

| Message                                                                                                                                  | Meaning                                                                                                                                                                    | What to do                                                         |
| ---------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| `Data Not Found!!`                                                                                                                       | The list was empty.                                                                                                                                                        | Send at least one coupon.                                          |
| `Discount Coupons Already Exist in database...`                                                                                          | Every coupon in the request was left out by the "already exists" check. Nothing was saved.                                                                                 | See the second known issue.                                        |
| `Duplicate Discount Coupon(s) with the same Prefix + Number in the request: …. Each coupon must have a distinct Discount_Coupon_Number.` | The same prefix and number appeared more than once in the request. Nothing was saved.                                                                                      | Give each coupon of a prefix a different `Discount_Coupon_Number`. |
| `Object reference not set to an instance of an object.`                                                                                  | `Discount_Coupon_PreFix` was sent as `null`. Nothing was saved.                                                                                                            | Send a prefix.                                                     |
| A database error (with `Status: false`)                                                                                                  | Saving failed, for example two prefixes produced the same full coupon number, or another request created coupons of the same prefix at the same moment. Nothing was saved. | Correct the request and send it again.                             |


---

# 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/masters/push/create-discount-coupons.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.
