> 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-gift-voucher.md).

# Save a Gift Voucher

Creates one **gift voucher** in Logic ERP – a prefix and number, a ₹ value, the account it is booked to and, if you like, an expiry date, a barcode, a **gift voucher group** and the retail customer it was issued to – so that the tills can accept it. The voucher is created as already issued. If a voucher with the same prefix and number already exists, its expiry date and group are updated instead. Use it when gift vouchers are sold or given away from your own system (a website, an app, a corporate order).

### **Endpoint**

| Name          | Detail                                    |
| ------------- | ----------------------------------------- |
| Address       | `https://your-server/api/SaveGiftVoucher` |
| 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 **one voucher** (a JSON object, not a list). Field names are matched without regard to upper or lower case.

| Field                      | Type   | Required                                      | Default        | Meaning                                                                                                                                                                                                                                                                                                                                       |
| -------------------------- | ------ | --------------------------------------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Gift_Voucher_Prefix`      | text   | Yes                                           | `""`           | Prefix of the voucher number, for example `"GV"`. Up to 20 characters.                                                                                                                                                                                                                                                                        |
| `Gift_Voucher_Number`      | number | Yes                                           | `0`            | The voucher's number within the prefix, for example `10045`. `0` is refused. The full voucher number the shopper quotes is the prefix followed by this number, for example `GV10045`.                                                                                                                                                         |
| `Amount`                   | number | Yes                                           | `0`            | Value of the voucher in ₹. Must be more than `0`.                                                                                                                                                                                                                                                                                             |
| `Gift_Voucher_AccountCode` | text   | Yes, unless `Gift_Voucher_Account` is sent    | `""`           | The code, as shown in Logic ERP, of the account the voucher is booked to. It must be a current-assets or current-liabilities account.                                                                                                                                                                                                         |
| `Gift_Voucher_Account`     | text   | Only when `Gift_Voucher_AccountCode` is empty | `""`           | The **name** of that account, used only when `Gift_Voucher_AccountCode` is empty. Same account types.                                                                                                                                                                                                                                         |
| `Creation_Branch_Code`     | number | No (see the rules)                            | `0`            | Logic ERP's code of the branch that issued the voucher (`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)). Must be a branch that exists.                                                                                     |
| `Expiry_Date`              | date   | No                                            | empty          | Last day the voucher may be used, `yyyy-MM-dd`. Today or later. Empty saves the voucher without an expiry date, and the till then does not check expiry.                                                                                                                                                                                      |
| `Gift_Voucher_Barcode`     | text   | No                                            | `""`           | Barcode printed on the voucher. Up to 25 characters. Must not already be used by another voucher.                                                                                                                                                                                                                                             |
| `RCU_Mobile_No`            | text   | No                                            | `""`           | Mobile number of the **retail customer** the voucher is issued to. The customer must already exist in Logic ERP (see [Get Retail Customers](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/pull/get-retail-customers.md)); the voucher is linked to that customer's membership number. |
| `Gift_Voucher_Group`       | text   | No                                            | `""`           | Name of the gift voucher group, for example `"DIWALI GV"`. If no group of that name exists, Logic ERP creates it from the four `GVG_` fields below.                                                                                                                                                                                           |
| `GVG_ShortName`            | text   | No                                            | the group name | Short name of a **new** group.                                                                                                                                                                                                                                                                                                                |
| `GVG_AccountCode`          | text   | Yes, when the group is new                    | `""`           | Code, as shown in Logic ERP, of the account of a **new** group. Current-assets or current-liabilities account.                                                                                                                                                                                                                                |
| `GVG_Commission_On`        | text   | No                                            | `""`           | How the commission of a **new** group is worked out: `VALUE BASED`, `PERCENTAGE` or `PER RUPEE`, written exactly so, in capitals. Anything else means no commission.                                                                                                                                                                          |
| `GVG_Commission_Value`     | number | No                                            | `0`            | The commission of a **new** group. With `PERCENTAGE`, at most `100`. Ignored (set to `0`) when `GVG_Commission_On` is not one of the three values.                                                                                                                                                                                            |

The four `GVG_` fields are used only when Logic ERP creates the group; for a group that already exists they are ignored and the group is not changed.

### **Rules Logic ERP applies**

* **Matching.** Account codes, account names and group names are matched without regard to upper or lower case, but otherwise exactly. The mobile number must match the customer's mobile number exactly.
* **A new voucher** is created as **issued** and not yet redeemed, with today's date (on the server) as its creation date. The response gives its number in Logic ERP in `LastSavedCode`.
* **A voucher that already exists** – same `Gift_Voucher_Prefix` and `Gift_Voucher_Number` – is updated, not created again. Only these change:

  * the expiry date, when you send one (an empty `Expiry_Date` keeps the old date);
  * the group, when you send `Gift_Voucher_Group` (an empty `Gift_Voucher_Group` keeps the old group).

  The amount, accounts, barcode, branch and customer of an existing voucher are **not** changed and **not** checked, and there is no message saying so. This also happens to a voucher that has already been redeemed. `LastSavedCode` is the existing voucher's number in Logic ERP.
* The first five checks (prefix, number, amount, expiry date, and a new group's account and commission) apply to existing vouchers too, so a past `Expiry_Date` is refused even when you only want to change the group.
* **The branch.** `Creation_Branch_Code` must be a branch that exists in Logic ERP. Leaving it out (`0`) is normally **accepted**, because Logic ERP keeps a built-in "no branch" entry with code `0`; the voucher is then not linked to any branch. Send the issuing branch.
* **Full voucher numbers must be unique.** The full number is the prefix followed by the number, so prefix `GV` with number `11` and prefix `GV1` with number `1` both give `GV11`; the second is refused with `Gift Voucher No. … already exists under another Prefix / Number...(local)`. Use prefixes that do not begin with one another.
* **A new group** is created together with the voucher: if saving the voucher fails, the group is not kept either.
* **The customer.** When `RCU_Mobile_No` is sent, the customer is looked up even for an existing voucher, and the request is refused if none is found – but only a new voucher is linked to the customer. If several customers share the mobile number, one of them is used.
* The voucher is saved in the company your API site is connected to; the branch and financial year of the request play no part.

### **Example request**

A new ₹1,000 voucher in a group that does not exist yet:

```json
{
  "Gift_Voucher_Prefix": "DGV",
  "Gift_Voucher_Number": 10045,
  "Amount": 1000,
  "Gift_Voucher_AccountCode": "GV01",
  "Creation_Branch_Code": 4,
  "Expiry_Date": "2027-03-31",
  "Gift_Voucher_Barcode": "DGV26010045",
  "RCU_Mobile_No": "9876501234",
  "Gift_Voucher_Group": "DIWALI GV",
  "GVG_ShortName": "DGV",
  "GVG_AccountCode": "GV01",
  "GVG_Commission_On": "PERCENTAGE",
  "GVG_Commission_Value": 2.5
}
```

### **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 creates (or, when sent again, updates) the sandbox's test voucher `APTGV1001`.

## Save a Gift Voucher

> Creates one gift voucher in Logic ERP – a prefix and number, a ₹ value, the account it is booked to and, if you like, an expiry date, a barcode, a gift voucher group and the retail customer it was issued to – so that the tills can accept it. The voucher is created as already issued. If a voucher with the same prefix and number already exists, its expiry date and group are updated instead. Use it when gift vouchers are sold or given away from your own system (a website, an app, a corporate order).

```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":{"/SaveGiftVoucher":{"post":{"tags":["Sale - Push"],"operationId":"SaveGiftVoucher","summary":"Save a Gift Voucher","description":"Creates one gift voucher in Logic ERP – a prefix and number, a ₹ value, the account it is booked to and, if you like, an expiry date, a barcode, a gift voucher group and the retail customer it was issued to – so that the tills can accept it. The voucher is created as already issued. If a voucher with the same prefix and number already exists, its expiry date and group are updated instead. Use it when gift vouchers are sold or given away from your own system (a website, an app, a corporate order).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"Gift_Voucher_Prefix":{"type":"string","description":"Prefix of the voucher number, for example `\"GV\"`. Up to 20 characters."},"Gift_Voucher_Number":{"type":"integer","description":"The voucher's number within the prefix, for example `10045`. `0` is refused. The full voucher number the shopper quotes is the prefix followed by this number, for example `GV10045`."},"Amount":{"type":"integer","description":"Value of the voucher in ₹. Must be more than `0`."},"Gift_Voucher_AccountCode":{"type":"string","description":"The code, as shown in Logic ERP, of the account the voucher is booked to. It must be a current-assets or current-liabilities account."},"Creation_Branch_Code":{"type":"integer","description":"Logic ERP's code of the branch that issued the voucher (`Branch_Code` in Get Branch Info). Must be a branch that exists."},"Expiry_Date":{"type":"string","description":"Last day the voucher may be used, `yyyy-MM-dd`. Today or later. Empty saves the voucher without an expiry date, and the till then does not check expiry."},"Gift_Voucher_Barcode":{"type":"string","description":"Barcode printed on the voucher. Up to 25 characters. Must not already be used by another voucher."},"RCU_Mobile_No":{"type":"string","description":"Mobile number of the retail customer the voucher is issued to. The customer must already exist in Logic ERP (see Get Retail Customers); the voucher is linked to that customer's membership number."},"Gift_Voucher_Group":{"type":"string","description":"Name of the gift voucher group, for example `\"DIWALI GV\"`. If no group of that name exists, Logic ERP creates it from the four `GVG_` fields below."}}}}}},"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 voucher was created or updated.
* `Message` – `Success` when saved; otherwise the reason (see below).
* `LastSavedCode` – Logic ERP's number of the voucher created or updated. `0` when nothing was saved.
* `request_ID` – the ID of this request, as described in How Every API Call Works. `null` when the request was refused before saving began: by one of the checks whose message ends in `(local)`, or by a database error during those checks.

### **Example response**

```json
{
  "Status": true,
  "Message": "Success",
  "LastSavedCode": 1187,
  "request_ID": "3b9d7e21-6c4a-4f08-9e15-a27c0d84f6b3"
}
```

### **Messages you may see**

Nothing is saved when `Status` is `false`.

| Message                                                                               | Meaning                                                                                                                         | What to do                                                          |
| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `Gift Voucher Prefix is missing...(local)`                                            | `Gift_Voucher_Prefix` was empty or left out.                                                                                    | Send a prefix.                                                      |
| `Gift Voucher Number is not defined...(local)`                                        | `Gift_Voucher_Number` was `0` or left out.                                                                                      | Send the voucher's number.                                          |
| `Invalid Gift Voucher Amount...(local)`                                               | `Amount` was `0`, negative or left out.                                                                                         | Send the value in ₹.                                                |
| `Invalid Gift Voucher Expiry Date...(local)`                                          | `Expiry_Date` could not be read as a date.                                                                                      | Send it as `yyyy-MM-dd`, or leave it empty.                         |
| `Gift Voucher Expiry Date Cannot be less than Current Date...(local)`                 | `Expiry_Date` is before today.                                                                                                  | Send today or a later date.                                         |
| `Invalid Gift Voucher Group Account Code...(…)(local)`                                | The group is new and `GVG_AccountCode` (shown in the brackets) is empty or not a current-assets or current-liabilities account. | Send the code of such an account, or the name of an existing group. |
| `Gift Voucher Group Commission Percentage Cannot be more than 100...(local)`          | The group is new, `GVG_Commission_On` is `PERCENTAGE` and `GVG_Commission_Value` is more than `100`.                            | Send a percentage of `100` or less.                                 |
| `Invalid Gift Voucher Account Code...(local)`                                         | `Gift_Voucher_AccountCode` is not the code of a current-assets or current-liabilities account.                                  | Correct the code.                                                   |
| `Gift Voucher Account is not defined...(local)`                                       | Both `Gift_Voucher_AccountCode` and `Gift_Voucher_Account` were empty.                                                          | Send the account code.                                              |
| `Invalid Gift Voucher Account Selected...(local)`                                     | No current-assets or current-liabilities account has the name in `Gift_Voucher_Account`.                                        | Correct the name, or send the code instead.                         |
| `Same Gift Voucher Barcode Already Exists...(local)`                                  | Another voucher already has this barcode.                                                                                       | Send a different barcode.                                           |
| `Invalid Creation Branch Code defined...(local)`                                      | No branch has the code in `Creation_Branch_Code`.                                                                               | Send a branch code from Get Branch Info.                            |
| `Gift Voucher No. … already exists under another Prefix / Number...(local)`           | A new voucher's full number (prefix followed by number) is already used by another voucher with a different prefix and number.  | Use a prefix that does not begin with another prefix.               |
| `Unable to found Retail Customer againts Mobile_No. : …` (the mobile number you sent) | No retail customer has this mobile number.                                                                                      | Create the customer first, or leave `RCU_Mobile_No` out.            |
| A database error (with `Status: false`)                                               | Saving failed – for example a text field was too long.                                                                          | 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/sale/push/save-a-gift-voucher.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.
