> 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/edit-item-hsn-code.md).

# Edit Item HSN Code

Sets the **HSN code** (or **SAC code** for services) of one or more items in Logic ERP. You send the HSN details once and a list of items; if the HSN code is not in Logic ERP yet, it is **created** from the details you send, and then given to every item in the list. Use it when your system decides or corrects the HSN classification of items that already exist in Logic ERP.

### **Endpoint**

| Name          | Detail                                |
| ------------- | ------------------------------------- |
| Address       | `https://your-server/api/EditItemHSN` |
| 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 names are matched without regard to capitals. This endpoint shares its request layout with [Edit Item Rates](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/push/edit-item-rates.md) and [Edit Item GST Tax Group](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/push/edit-item-gst-tax-group.md); only the fields below are read. `GST_Group_Name`, `GST_Group_Short_Name`, `GST_Group_Level`, `Reason` and the rate fields in `ListItems` are ignored.

| Field                 | Type   | Required           | Default                 | Meaning                                                                                                                                                                                                                                                          |
| --------------------- | ------ | ------------------ | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `HSSerial_No`         | number | Yes                | `0`                     | The HSN or SAC number, for example `62044290`. Logic ERP finds the HSN code by this number. Must not be `0`.                                                                                                                                                     |
| `HS_Code`             | text   | No                 | the `HSSerial_No` value | The HSN code as it is to be shown (`HSN_Code` in [Get Item Master](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/pull/get-item-master.md)). Up to 20 characters. Used only when the HSN code is created. |
| `HS_Description`      | text   | For a new HSN code | –                       | Description of the HSN code. Up to 200 characters.                                                                                                                                                                                                               |
| `HS_Short_Desc`       | text   | For a new HSN code | –                       | Short description. Up to 30 characters.                                                                                                                                                                                                                          |
| `HS_Long_Desc`        | text   | For a new HSN code | –                       | Long description.                                                                                                                                                                                                                                                |
| `Unit_of_Measurement` | text   | For a new HSN code | –                       | The GST unit (UQC), written as in the list below, for example `PCS-PIECES`. Capital and small letters do not matter.                                                                                                                                             |
| `HS_Type`             | text   | No                 | `"HSN"`                 | `"SAC"` (in capitals) for a service code; anything else is saved as a goods (HSN) code.                                                                                                                                                                          |
| `SION_Number`         | text   | No                 | empty                   | SION number, if you use one. Up to 20 characters.                                                                                                                                                                                                                |
| `SION_Rate`           | number | No                 | `0`                     | SION rate.                                                                                                                                                                                                                                                       |
| `ListItems`           | list   | **Yes**            | –                       | The items to change. See below.                                                                                                                                                                                                                                  |

**`ListItems`** – one entry per item:

| Field      | Type | Required       | Default | Meaning                                                                                                                                                  |
| ---------- | ---- | -------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ItemCode` | text | One of the two | `""`    | The item code as shown in Logic ERP (`UserCode` in Get Item Master). When filled, `EANCode` is not used.                                                 |
| `EANCode`  | text | One of the two | `""`    | The item's barcode (`AddlItemCode` in Get Item Master). Used only when `ItemCode` is empty. Other barcodes of the item (`ListEANCode`) are not searched. |

Both codes are matched without regard to capitals; spaces at the end are ignored.

**Units accepted in `Unit_of_Measurement`:** `PCS-PIECES`, `BAG-BAGS`, `BGS-BAGS`, `BKL-BUCKLES`, `BOU-BOU`, `BOU-BILLIONS OF UNITS`, `BOX-BOX`, `BTL-BOTTLES`, `BUN-BUNCHES`, `CBM-CUBIC METER`, `CCM-CUBIC CENTIMETER`, `CIN-CUBIC INCHES`, `CMS-CENTIMETER`, `CQM-CUBIC METERS`, `CTN-CARTONS`, `DOZ-DOZEN`, `DRM-DRUM`, `FTS-FEET`, `GGR-GREAT GROSS`, `GMS-GRAMS`, `GRS-GROSS`, `GYD-GROSS YARDS`, `HKS-HANKS`, `INC-INCHES`, `KGS-KILOGRAMS`, `KLR-KILOLITER`, `KME-KILOMETRE`, `LBS-POUNDS`, `LOT-LOTS`, `LTR-LITERS`, `MGS-MILLI GRAMS`, `MTR-METERS`, `MTS-METRIC TON`, `NOS-NUMBERS`, `ODD-ODDS`, `PAC-PACKS`, `PRS-PAIRS`, `QTL-QUINTAL`, `ROL-ROLLS`, `SDM-DECAMETER SQUARE`, `SET-SETS`, `SHT-SHEETS`, `SQF-SQUARE FEET`, `SQI-SQUARE INCHES`, `SQM-SQUARE METERS`, `SQY-SQUARE YARDS`, `TBS-TABLETS`, `THD-THOUSANDS`, `TOL-TOLA`, `TON-GREAT BRITAIN TON`, `TON-TONNES`, `TUB-TUBES`, `UGS-US GALLONS`, `UNT-UNITS`, `VLS-VIALS`, `YDS-YARDS`, `OTH-OTHERS`, `BAL-BALE`, `BDL-BUNDLES`, `CAN-CANS`, `MLT-MILILITRE`, `TGM-TEN GROSS`. The spelling must match exactly; capital and small letters do not matter.

### **Rules Logic ERP applies**

* **Existing HSN code:** if an HSN code with this `HSSerial_No` is already in Logic ERP, it is used **as it is** – its code, descriptions, unit, type and SION details are **not changed**. The description fields and the unit are then not needed in the request.
* **New HSN code:** otherwise a new HSN code is created from the fields you send.
* **The whole item changes.** The HSN code belongs to the item (item and shade), so the change applies to **every item code** of each item in the list – all its sizes and packs.
* All items are checked before anything is saved. If any one of them is not found, **nothing** is saved – not even the new HSN code.
* Everything is saved in one go: if anything fails, nothing is saved.
* An empty or missing `ListItems` is refused with `EAN Codes not defined...`.
* Every item code of each item gets today's date as its modified date, and the change is recorded in Logic ERP's change log, so the items come back in Get Item Master – by bookmark, or for a period that includes today.
* This endpoint is covered by the same licence as creating items through the API.

### **Example request**

Gives HSN 62044290 to two items, creating it if needed:

```json
{
  "HSSerial_No": 62044290,
  "HS_Code": "62044290",
  "HS_Description": "Women's dresses of cotton",
  "HS_Short_Desc": "LADIES DRESS COTTON",
  "HS_Long_Desc": "Women's or girls' dresses of cotton, not knitted or crocheted",
  "Unit_of_Measurement": "PCS-PIECES",
  "HS_Type": "HSN",
  "ListItems": [
    { "ItemCode": "KR1045-M", "EANCode": "" },
    { "ItemCode": "", "EANCode": "8901234567892" }
  ]
}
```

### **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 gives the test item `APITEST0001` an HSN code that already exists in the sandbox.

## Edit Item HSN Code

> Sets the HSN code (or SAC code for services) of one or more items in Logic ERP. You send the HSN details once and a list of items; if the HSN code is not in Logic ERP yet, it is created from the details you send, and then given to every item in the list. Use it when your system decides or corrects the HSN classification of items that already exist in Logic ERP.

```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":{"/EditItemHSN":{"post":{"tags":["Masters - Push"],"operationId":"EditItemHSN","summary":"Edit Item HSN Code","description":"Sets the HSN code (or SAC code for services) of one or more items in Logic ERP. You send the HSN details once and a list of items; if the HSN code is not in Logic ERP yet, it is created from the details you send, and then given to every item in the list. Use it when your system decides or corrects the HSN classification of items that already exist in Logic ERP.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"HSSerial_No":{"type":"integer","description":"The HSN or SAC number, for example `62044290`. Logic ERP finds the HSN code by this number. Must not be `0`."},"HS_Code":{"type":"string","description":"The HSN code as it is to be shown (`HSN_Code` in Get Item Master). Up to 20 characters. Used only when the HSN code is created."},"HS_Description":{"type":"string","description":"Description of the HSN code. Up to 200 characters."},"HS_Short_Desc":{"type":"string","description":"Short description. Up to 30 characters."},"HS_Long_Desc":{"type":"string","description":"Long description."},"Unit_of_Measurement":{"type":"string","description":"The GST unit (UQC), written as in the list below, for example `PCS-PIECES`. Capital and small letters do not matter."},"HS_Type":{"type":"string","description":"`\"SAC\"` (in capitals) for a service code; anything else is saved as a goods (HSN) code."},"ListItems":{"type":"array","items":{"type":"object","properties":{"ItemCode":{"type":"string","description":"The item code as shown in Logic ERP (`UserCode` in Get Item Master). When filled, `EANCode` is not used."},"EANCode":{"type":"string","description":"The item's barcode (`AddlItemCode` in Get Item Master). Used only when `ItemCode` is empty. Other barcodes of the item (`ListEANCode`) are not searched."}}},"description":"The items to change. See below."}}}}}},"responses":{"200":{"description":"Always HTTP 200. Check Status and Message.","content":{"application/json":{"schema":{"type":"object","properties":{"Status":{"type":"boolean","description":"`true` when the items were saved."},"Message":{"type":"string","description":"`HSN allocated successfully.` when saved; otherwise the reason."},"LastSavedCode":{"type":"integer","description":"Logic ERP's internal number of the HSN code that was given to the items."},"request_ID":{"type":"string","description":"The ID of this request. `null` when the request was refused by one of the checks below before anything was saved."}}}}}},"401":{"description":"No login was sent."}}}}}}
```

### **Response**

| Field           | What it holds for this endpoint                                                                                   |
| --------------- | ----------------------------------------------------------------------------------------------------------------- |
| `Status`        | `true` when the items were saved.                                                                                 |
| `Message`       | `HSN allocated successfully.` when saved; otherwise the reason.                                                   |
| `LastSavedCode` | Logic ERP's internal number of the HSN code that was given to the items.                                          |
| `request_ID`    | The ID of this request. `null` when the request was refused by one of the checks below before anything was saved. |

### **Example response**

```json
{
  "Status": true,
  "Message": "HSN allocated successfully.",
  "LastSavedCode": 625,
  "request_ID": "c2f9a6d1-7e4b-4a30-8d5f-91b0e3c4a7d2"
}
```

### **Messages you may see**

| Message                                                                                                       | Meaning                                                                                                                                                                                                               | What to do                          |
| ------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| `Invalid HSSerial_No : 0`                                                                                     | `HSSerial_No` was `0` or left out.                                                                                                                                                                                    | Send the HSN number.                |
| `Invalid HS_Description : . Do not allow entry without HS Description.`                                       | `HS_Description` was empty or left out for a new HSN code.                                                                                                                                                            | Fill it in.                         |
| `Invalid HS_Short_Desc : . Do not allow entry without HS_Short_Desc.`                                         | `HS_Short_Desc` was empty or left out for a new HSN code.                                                                                                                                                             | Fill it in.                         |
| `Invalid HS_Long_Desc : . Do not allow entry without HS_Long_Desc.`                                           | `HS_Long_Desc` was empty or left out for a new HSN code.                                                                                                                                                              | Fill it in.                         |
| `Invalid Unit_of_Measurement not defined. Do not allow entry without Unit_of_Measurement.`                    | `Unit_of_Measurement` was empty or left out for a new HSN code.                                                                                                                                                       | Send a unit from the list.          |
| `Invalid Unit_of_Measurement : …. Do not allow entry without Unit_of_Measurement.` (your value in place of …) | The unit is not in the list (new HSN code only).                                                                                                                                                                      | Use a unit from the list.           |
| `Invalid EAN Code : …`                                                                                        | An item in `ListItems` was not found, or an entry has neither `ItemCode` nor `EANCode`. The barcode you sent is shown in place of …; when you sent an `ItemCode` the message ends after the colon. Nothing was saved. | Check the item codes and barcodes.  |
| `EAN Codes not defined...`                                                                                    | `ListItems` was empty or left out.                                                                                                                                                                                    | Send at least one item.             |
| A database error (with `Status: false`)                                                                       | A text was longer than the limits above. Nothing was saved.                                                                                                                                                           | Correct the request and send 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/edit-item-hsn-code.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.
