> 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/inventory/pull/get-stock-in-hand.md).

# Get Stock In Hand

Returns the **stock in hand** of your items in Logic ERP: for each item and branch (and, depending on your setup, each godown, lot or bin) the **quantity in stock right now**, with the item's rates and lot details. Use it to show stock in your web store or app, to check particular items by item code or barcode, or to take a full copy of a branch's stock. To fetch only the items whose stock may have changed since your last call, use [Get Delta Stock In Hand](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/inventory/pull/get-delta-stock-in-hand.md), which uses the same address.

### **Endpoint**

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

The response and the common request fields 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). This endpoint does **not** use the change-log fields (`GlobalModifyCode`, `DateFrom`, `DateTo`, `Doc_Codes`, `Branch_Codes_From`, `Doc_Num_Like`); they are ignored, and `LastGlobalModifyCode` is always `0`.

### **Request fields**

| Field                  | Type | Required                                                                                                  | Default | Meaning                                                                                                                                                                                                                                                                                                                   |
| ---------------------- | ---- | --------------------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Branch_Codes`         | text | Yes, unless you send `BranchShortNames` or your Logic ERP team has set default branches for this endpoint | empty   | Branch codes separated by commas, for example `"2"` or `"2,5"`. Only stock of these branches is returned. A plain number such as `2` is also accepted. Numbers and commas only (spaces around each code are removed); anything else is refused.                                                                           |
| `BranchShortNames`     | text | No                                                                                                        | empty   | Branch short names separated by commas, for example `"WH"` (spaces around each name are removed). Used only when `Branch_Codes` is empty, in its place.                                                                                                                                                                   |
| `LogicUserCode`        | text | No                                                                                                        | empty   | Item codes as 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)), separated by commas, for example `"KUR-1001-M,KUR-1001-L"`. Only these items are returned. `null` is treated as empty. |
| `AddlItemCode`         | text | No                                                                                                        | empty   | The items' additional codes (usually the barcode), separated by commas, for example `"8901234567012"`. Only these items are returned. `null` is treated as empty.                                                                                                                                                         |
| `Godown_Name`          | text | No                                                                                                        | empty   | Godown names separated by commas, for example `"MAIN,SHOWROOM"`. Only stock in these godowns is returned. A name that is not a godown in Logic ERP refuses the request.                                                                                                                                                   |
| `DisplayZeroStockAlso` | text | No                                                                                                        | empty   | `"1"` = also return lots whose stock is zero or below zero (shown as `0`). Anything else = only stock above zero.                                                                                                                                                                                                         |
| `UseBinStock`          | text | No                                                                                                        | `"0"`   | `"1"` = read the stock kept by **warehouse bin** instead of the normal stock (for warehouses that keep stock by bin).                                                                                                                                                                                                     |
| `StockType`            | text | No                                                                                                        | empty   | Leave empty for this endpoint. `"DELTA"` (exactly, in capitals) turns the call into [Get Delta Stock In Hand](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/inventory/pull/get-delta-stock-in-hand.md); any other value is treated as empty.                              |
| `DisplayError`         | text | No                                                                                                        | `"0"`   | `"1"` = when the request fails, `Message` carries full technical detail, and the query used is written to the server's log. For troubleshooting only.                                                                                                                                                                     |
| `RequestDate`          | date | No                                                                                                        | empty   | Ignored by this endpoint (it is used only by Get Delta Stock In Hand).                                                                                                                                                                                                                                                    |

Field names are matched without regard to upper or lower case. Other fields in the request are ignored.

### **Rules Logic ERP applies**

* **Which stock.** The quantity is Logic ERP's running stock balance at the moment of the call, for the **financial year that contains today's date** on the server. There is no "as on" date: `RequestDate` is ignored. If the financial year for today has not been created in Logic ERP, no stock is found.
* **Which quantity.** Your Logic ERP team chooses whether the quantity is the closing stock less net issues (the usual setting) or the plain closing stock, and whether bin stock and carton stock are added to it. Quantities are never negative: a negative result is shown as `0`.
* **Which branches.** Both `Branch_Codes` (or the branches named in `BranchShortNames`) and the default branches your Logic ERP team may have set for this endpoint apply: stock is returned only for branches that are in both. When none of them is given, the request is refused.
* **Which godowns.** All godowns of the branch, unless you send `Godown_Name` or your Logic ERP team has set default godowns. Godown names must match exactly (upper or lower case does not matter; spaces around each name are removed). When a name you send is not found, the request is refused with `Godown not found : …`, naming the unknown names – even when the other names are found. See the known issue: names you send are **added to** the default godowns rather than narrowing them.
* **Which items.** `LogicUserCode` and `AddlItemCode` must match exactly (upper or lower case does not matter; spaces around each code are removed). When you send both, an item must match **both** lists. When you send neither, **every item** with stock in the branch is returned. Your Logic ERP team can also limit the endpoint to certain item groups.
* **One record per …** item and branch, split further by godown, lot number, lot (with its rates and dates), lot MRP, lot special rate or bin only when your Logic ERP team has switched these on for your API site. When godowns are not switched on, the stock of all godowns is added together and `Godown_Name` is empty; when lots are not switched on, the stock of all lots of the item is added together.
* **Only stock above zero**, unless `DisplayZeroStockAlso` is `"1"`. The test is made on the record's quantity: the balances of all the godowns and lots that make up the record are added together first (with carton stock, when your Logic ERP team has it added), so a record is left out only when that total is zero or below. Your Logic ERP team can also set a minimum: items whose stock is not above it are left out, or shown as `0`.
* **Pending orders can be deducted.** When your Logic ERP team has switched this on, the quantity still pending on sale orders (all orders, or only those of the order prefixes they chose) is deducted from the stock of that item and branch. They can also have the quantity pending on delivery orders made against sale orders of chosen prefixes deducted.
* **No batches.** Every matching record is returned in one answer – a request with no item codes can return thousands of records and several MB. Ask for particular items where you can.
* Records are in no guaranteed order; when lot details are switched on they are ordered by the lot's purchase date.
* **Your Logic ERP team can choose which fields are returned.** A field that is not chosen is left out of the response altogether. When no choice has been made – the usual case – every field below is returned.
* **Minimum interval between calls.** Your Logic ERP team can set a minimum number of minutes between stock calls for your API site. The limit is shared by everyone using your API site and by Get Delta Stock In Hand: a call made sooner after the last stock call of either kind that got past this check (even one that then failed for another reason) is refused with `You have already refreshed Stock … minutes ago. Refreshing of stock is allowed only at minimum interval of … minutes.` When no interval is set (the usual case), there is no limit. The general limit in seconds described in How Every API Call Works does not apply to this endpoint.

> **Known issue – godown names add to the default godowns.** When your Logic ERP team has set default godowns for this endpoint, the godowns you name in `Godown_Name` are returned **as well as** the default ones, not instead of them. Check `Godown_Name` in each record.

### **Example request**

Stock of two items, by barcode, in branch 2:

```json
{
  "Branch_Codes": "2",
  "BranchShortNames": "",
  "LogicUserCode": "",
  "AddlItemCode": "8901234567012,8901234567029",
  "Godown_Name": "",
  "DisplayZeroStockAlso": "0"
}
```

### **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**. The example asks for the stock of the sandbox's test item `APITEST0001` in branch `2`. Leaving out the item codes returns every item in one answer, which can run to several MB.

## Get Stock In Hand

> Returns the stock in hand of your items in Logic ERP: for each item and branch (and, depending on your setup, each godown, lot or bin) the quantity in stock right now, with the item's rates and lot details. Use it to show stock in your web store or app, to check particular items by item code or barcode, or to take a full copy of a branch's stock. To fetch only the items whose stock may have changed since your last call, use Get Delta Stock In Hand, which uses the same address.

```json
{"openapi":"3.0.3","info":{"title":"Logic ERP API","version":"1.0"},"tags":[{"name":"Inventory - Pull"}],"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":{"/GetStockInHand":{"post":{"tags":["Inventory - Pull"],"operationId":"GetStockInHand","summary":"Get Stock In Hand","description":"Returns the stock in hand of your items in Logic ERP: for each item and branch (and, depending on your setup, each godown, lot or bin) the quantity in stock right now, with the item's rates and lot details. Use it to show stock in your web store or app, to check particular items by item code or barcode, or to take a full copy of a branch's stock. To fetch only the items whose stock may have changed since your last call, use Get Delta Stock In Hand, which uses the same address.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"Branch_Codes":{"type":"string","description":"Branch codes separated by commas, for example `\"2\"` or `\"2,5\"`. Only stock of these branches is returned. A plain number such as `2` is also accepted. Numbers and commas only (spaces around each code are removed); anything else is refused."},"BranchShortNames":{"type":"string","description":"Branch short names separated by commas, for example `\"WH\"` (spaces around each name are removed). Used only when `Branch_Codes` is empty, in its place."},"LogicUserCode":{"type":"string","description":"Item codes as shown in Logic ERP (`UserCode` in Get Item Master), separated by commas, for example `\"KUR-1001-M,KUR-1001-L\"`. Only these items are returned. `null` is treated as empty."},"AddlItemCode":{"type":"string","description":"The items' additional codes (usually the barcode), separated by commas, for example `\"8901234567012\"`. Only these items are returned. `null` is treated as empty."},"Godown_Name":{"type":"string","description":"Godown names separated by commas, for example `\"MAIN,SHOWROOM\"`. Only stock in these godowns is returned. A name that is not a godown in Logic ERP refuses the request."},"DisplayZeroStockAlso":{"type":"string","description":"`\"1\"` = also return lots whose stock is zero or below zero (shown as `0`). Anything else = only stock above zero."},"UseBinStock":{"type":"string","description":"`\"1\"` = read the stock kept by warehouse bin instead of the normal stock (for warehouses that keep stock by bin)."},"StockType":{"type":"string","description":"Leave empty for this endpoint. `\"DELTA\"` (exactly, in capitals) turns the call into Get Delta Stock In Hand; any other value is treated as empty."},"DisplayError":{"type":"string","description":"`\"1\"` = when the request fails, `Message` carries full technical detail, and the query used is written to the server's log. For troubleshooting only."},"RequestDate":{"type":"string","description":"Ignored by this endpoint (it is used only by Get Delta Stock In Hand)."}}}}}},"responses":{"200":{"description":"Always HTTP 200. Check Status, Message and GetData.","content":{"application/json":{"schema":{"type":"object","properties":{"GetData":{"type":"array","items":{"type":"object","properties":{"Branch_Code":{"type":"integer","description":"Code of the branch."},"Branch_Name":{"type":"string","description":"Name of the branch."},"BranchShortName":{"type":"string","description":"Short name of the branch."},"Godown_Name":{"type":"string","description":"Godown, when godowns are switched on for your API site; otherwise empty."},"LogicUserCode":{"type":"string","description":"Item code as shown in Logic ERP."},"AddlItemCode":{"type":"string","description":"The item's additional code (usually the barcode)."},"Item_Name":{"type":"string","description":"Item name."},"Shade_Name":{"type":"string","description":"Colour (shade) of the item, or `(NIL)`."},"Pack_Name":{"type":"string","description":"Pack (size) of the item."},"Lot_Number":{"type":"string","description":"Lot number, when lot numbers are switched on; otherwise empty."},"Lot_Code":{"type":"integer","description":"Logic ERP's internal lot number, when lot details are switched on; otherwise `0`."},"Packing":{"type":"string","description":"Packing description from the item master."},"Stock_Qty":{"type":"number","description":"Quantity in stock (never negative). See the rules."},"Lot_Sale_Rate":{"type":"number","description":"Sale rate of the lot, when lot details are switched on; otherwise `0`."},"Lot_Basic_Rate":{"type":"number","description":"Basic rate of the lot, when lot details are switched on; otherwise `0`."},"Lot_MRP":{"type":"number","description":"MRP of the lot, when lot details or lot MRP are switched on; otherwise `0`."},"Lot_SPRate1":{"type":"number","description":"Special rates 1–4 of the lot, when switched on; otherwise `0`."},"Lot_SPRate2":{"type":"number","description":"Special rates 1–4 of the lot, when switched on; otherwise `0`."},"Lot_SPRate3":{"type":"number","description":"Special rates 1–4 of the lot, when switched on; otherwise `0`."},"Lot_SPRate4":{"type":"number","description":"Special rates 1–4 of the lot, when switched on; otherwise `0`."},"Item_Sale_Rate":{"type":"number","description":"Sale rate in the item master."},"Item_MRP":{"type":"number","description":"MRP in the item master."},"Carton_Stock":{"type":"number","description":"Quantity held in cartons for this record; `0` when none."},"Godown_Code":{"type":"integer","description":"Code of the godown, when godowns are switched on for your API site; otherwise `0`."},"Item_Cf_1":{"type":"integer","description":"The item's conversion factors, as whole numbers."},"Item_Cf_2":{"type":"integer","description":"The item's conversion factors, as whole numbers."},"Item_Cf_3":{"type":"integer","description":"The item's conversion factors, as whole numbers."},"Lot_Pur_Date":{"type":"string","nullable":true,"description":"Purchase date of the lot, `dd/MM/yyyy`, when lot details are switched on; otherwise `null`."},"Lot_Expiry_Date":{"type":"string","nullable":true,"description":"Expiry and manufacturing date of the lot, `dd/MM/yyyy`, when lot details are switched on and the date is filled; otherwise `null`."},"Lot_Mfg_Date":{"type":"string","nullable":true,"description":"Expiry and manufacturing date of the lot, `dd/MM/yyyy`, when lot details are switched on and the date is filled; otherwise `null`."},"Bin_Code":{"type":"integer","description":"Warehouse bin, when bin details are switched on; otherwise `0` and empty."},"Bin_Name":{"type":"string","description":"Warehouse bin, when bin details are switched on; otherwise `0` and empty."}}},"nullable":true,"description":"The records found; null when the call failed or nothing was found - read Message."},"Status":{"type":"boolean","description":"See the Status rules on this page and on How Every API Call Works."},"Message":{"type":"string","description":"Why the call failed, or a note. The reason may be followed by technical detail - read the first line."},"LastGlobalModifyCode":{"type":"integer","description":"The change-log bookmark (see How Every API Call Works)."},"resultSize":{"type":"string","description":"Size of the answer, for example \"2 KB\"."}}}}}},"401":{"description":"No login was sent."}}}}}}
```

### **Response fields**

Each item in `GetData` is one stock record:

| Field                                 | Type         | Meaning                                                                                                                            |
| ------------------------------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------- |
| `Branch_Code`                         | number       | Code of the branch.                                                                                                                |
| `Branch_Name`                         | text         | Name of the branch.                                                                                                                |
| `BranchShortName`                     | text         | Short name of the branch.                                                                                                          |
| `Godown_Name`                         | text         | Godown, when godowns are switched on for your API site; otherwise empty.                                                           |
| `Godown_Code`                         | number       | Code of the godown, when godowns are switched on for your API site; otherwise `0`.                                                 |
| `LogicUserCode`                       | text         | Item code as shown in Logic ERP.                                                                                                   |
| `AddlItemCode`                        | text         | The item's additional code (usually the barcode).                                                                                  |
| `Item_Name`                           | text         | Item name.                                                                                                                         |
| `Shade_Name`                          | text         | Colour (shade) of the item, or `(NIL)`.                                                                                            |
| `Pack_Name`                           | text         | Pack (size) of the item.                                                                                                           |
| `Packing`                             | text         | Packing description from the item master.                                                                                          |
| `Lot_Number`                          | text         | Lot number, when lot numbers are switched on; otherwise empty.                                                                     |
| `Lot_Code`                            | number       | Logic ERP's internal lot number, when lot details are switched on; otherwise `0`.                                                  |
| `Stock_Qty`                           | number       | Quantity in stock (never negative). See the rules.                                                                                 |
| `Carton_Stock`                        | number       | Quantity held in cartons for this record; `0` when none.                                                                           |
| `Lot_Sale_Rate`                       | number       | Sale rate of the lot, when lot details are switched on; otherwise `0`.                                                             |
| `Lot_Basic_Rate`                      | number       | Basic rate of the lot, when lot details are switched on; otherwise `0`.                                                            |
| `Lot_MRP`                             | number       | MRP of the lot, when lot details or lot MRP are switched on; otherwise `0`.                                                        |
| `Lot_SPRate1` … `Lot_SPRate4`         | number       | Special rates 1–4 of the lot, when switched on; otherwise `0`.                                                                     |
| `Item_Sale_Rate`                      | number       | Sale rate in the item master.                                                                                                      |
| `Item_MRP`                            | number       | MRP in the item master.                                                                                                            |
| `Item_Cf_1`, `Item_Cf_2`, `Item_Cf_3` | number       | The item's conversion factors, as whole numbers.                                                                                   |
| `Lot_Pur_Date`                        | date         | Purchase date of the lot, `dd/MM/yyyy`, when lot details are switched on; otherwise `null`.                                        |
| `Lot_Expiry_Date`, `Lot_Mfg_Date`     | date         | Expiry and manufacturing date of the lot, `dd/MM/yyyy`, when lot details are switched on and the date is filled; otherwise `null`. |
| `Bin_Code`, `Bin_Name`                | number, text | Warehouse bin, when bin details are switched on; otherwise `0` and empty.                                                          |

### **Example response**

```json
{
  "GetData": [
    {
      "Branch_Code": 2,
      "Branch_Name": "LUDHIANA MAIN",
      "BranchShortName": "LDH",
      "Godown_Name": "",
      "LogicUserCode": "KUR-1001-M",
      "AddlItemCode": "8901234567012",
      "Item_Name": "COTTON KURTA BLUE",
      "Shade_Name": "BLUE",
      "Pack_Name": "M",
      "Lot_Number": "L-2604",
      "Lot_Code": 0,
      "Packing": "PCS",
      "Stock_Qty": 18.0,
      "Lot_Sale_Rate": 0.0,
      "Lot_Basic_Rate": 0.0,
      "Lot_MRP": 1499.0,
      "Lot_SPRate1": 0.0,
      "Lot_SPRate2": 0.0,
      "Lot_SPRate3": 0.0,
      "Lot_SPRate4": 0.0,
      "Item_Sale_Rate": 1200.0,
      "Item_MRP": 1499.0,
      "Carton_Stock": 0.0,
      "Godown_Code": 0,
      "Item_Cf_1": 1,
      "Item_Cf_2": 1,
      "Item_Cf_3": 1,
      "Lot_Pur_Date": null,
      "Lot_Expiry_Date": null,
      "Lot_Mfg_Date": null,
      "Bin_Code": 0,
      "Bin_Name": ""
    }
  ],
  "Status": true,
  "Message": "",
  "LastGlobalModifyCode": 0,
  "resultSize": "1 KB"
}
```

### **Messages you may see**

| Message                                                                                                                                        | Meaning                                                                                                                 | What to do                                                                                          |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| `Stock Not Found...` (with `Status: true`, `GetData` `null`)                                                                                   | No stock record matched: the items have no stock above zero in these branches and godowns, or the codes were not found. | Check the item codes and branches; send `"DisplayZeroStockAlso": "1"` to see items with zero stock. |
| `Branch not defined for Get Stock Hand..Please Check..(…)` (with `Status: false`; a number in place of …)                                      | Neither `Branch_Codes`, `BranchShortNames` nor default branches were given.                                             | Send `Branch_Codes`.                                                                                |
| `Unable to found Branch Short Name : …` (with `Status: false`; the name in place of …)                                                         | A name in `BranchShortNames` does not exist.                                                                            | Send existing short names, separated by commas.                                                     |
| `Godown not found : …` (with `Status: false`; the unknown names in place of …)                                                                 | A name in `Godown_Name` is not a godown in Logic ERP.                                                                   | Send godown names exactly as in Logic ERP.                                                          |
| `Invalid code in list: '…'. Only numeric codes are allowed.` (with `Status: false`; your entry in place of …)                                  | An entry in `Branch_Codes` is not a number.                                                                             | Send branch codes as numbers separated by commas.                                                   |
| `No valid numeric code supplied.` (with `Status: false`)                                                                                       | `Branch_Codes` holds only spaces or commas.                                                                             | Send branch codes, or leave the field out.                                                          |
| `You have already refreshed Stock … minutes ago. Refreshing of stock is allowed only at minimum interval of … minutes.` (with `Status: false`) | A stock call (of either kind) was accepted for your API site less than the set interval ago.                            | Wait and call again.                                                                                |
| `Request cannot be processed. API Template is marked as In-Active in the configuration.` (with `Status: false`)                                | This endpoint is switched off for your API site.                                                                        | Ask your Logic ERP support team.                                                                    |


---

# 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/inventory/pull/get-stock-in-hand.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.
