> 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/orders/pull/get-purchase-orders.md).

# Get Purchase Orders

Returns your **purchase orders** from Logic ERP, each with its **header** (supplier, branch, department, amounts and tax, supplier's order and quotation numbers, delivery details, cancellation) and its **item lines** (item, lot, ordered and **pending** quantity, rate, MRP and tax rates). Use it to copy new and changed purchase orders into your own system – normally by asking only for orders **added or changed** since your last call – or to fetch particular orders by Logic ERP's internal number. With `ApprovalFilter` you can follow **approved** orders only.

### **Endpoint**

| Name          | Detail                                     |
| ------------- | ------------------------------------------ |
| Address       | `https://your-server/api/GetPurchaseOrder` |
| 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).

### **Request fields**

| Field                | Type   | Required | Default | Meaning                                                                                                                                                                                                                                                                                            |
| -------------------- | ------ | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GlobalModifyCode`   | number | No       | `0`     | Your bookmark in the change log, as described in How Every API Call Works: `0` = from the start (or a period, with `DateFrom`/`DateTo`), a number = only changes after it, `-1` = Logic ERP keeps the bookmark for you.                                                                            |
| `DateFrom`, `DateTo` | date   | No       | empty   | With `GlobalModifyCode` `0`: a period of **changes** (the day an order was saved, edited or – with `ApprovalFilter` `"1"` – approved; not the order date). Leave both out (or send `null`) when you are not asking for a period; with a bookmark they are not checked. Write them as `yyyy-MM-dd`. |
| `Doc_Codes`          | text   | No       | empty   | Logic ERP's internal order numbers (`Vouch_Code` in the response), separated by commas, for example `"1869,1870"`. Returns exactly these orders; the bookmark and period are ignored. Numbers and commas only.                                                                                     |
| `ApprovalFilter`     | text   | No       | `"0"`   | `"1"` = only approved orders, followed through the **approval** change log (see the rules); `"2"` = only orders still waiting for approval; anything else = both. Applies in every kind of request.                                                                                                |
| `Branch_Codes_From`  | text   | No       | empty   | Branch codes separated by commas, for example `"2,5"`. Only orders of these branches are returned, in every kind of request. Numbers and commas only – anything else is refused.                                                                                                                   |
| `Doc_Num_Like`       | text   | No       | empty   | Only orders whose number starts with this text, written prefix-number, for example `"PO-"` or `"PO-13"`. Used with the bookmark or a period.                                                                                                                                                       |

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

### **Rules Logic ERP applies**

* **Two change logs.** Normally the change log of purchase-order **saves** is read. With `"ApprovalFilter": "1"` the change log of purchase-order **approvals** is read instead, so you receive an order when it is approved. The two logs number their lines differently: keep a separate bookmark for requests with `ApprovalFilter` `"1"`, and do not mix them. With `GlobalModifyCode` `-1`, Logic ERP keeps a separate bookmark for `ApprovalFilter` `"1"` requests (the first time, it starts from the bookmark of the plain requests), so alternating the two kinds of request loses nothing.
* With a bookmark, each call reads up to **200 change-log lines** and returns the orders they belong to. When none of them can be returned (for example deleted orders, or orders excluded by `ApprovalFilter` or `Branch_Codes_From`), you get `"No Record Found."` with `Status: true` and a **higher** `LastGlobalModifyCode` – store it and call again. You have caught up when the message is `"No Pending Purchase Order found..."` and `LastGlobalModifyCode` is the value you sent.
* **An order can come back in a later batch.** Every save of an order adds a line to the change log, so an order edited after your bookmark is returned again with its current details. Update it in your system; do not add it a second time.
* **Not split by financial year.** Purchase orders are not kept per financial year, so `Vouch_Code` identifies an order without a year, and orders of every year are returned. The change-log problem with earlier financial years that affects some other endpoints does not apply here.
* **What is returned.** Despite the "pending" in the messages, every order in the batch is returned, also when it has been fully received; check `Pending_Qty` on the lines. **Cancelled** orders are returned with `Cancel_Order: true`, cancelled lines with `Cancel_Item: true`. Orders **deleted** in Logic ERP are not returned, so a deletion does not reach you through this endpoint.
* With `Doc_Codes` and with a period request, `LastGlobalModifyCode` comes back as `0` – do not store it.
* `DateFrom` and `DateTo` only select changes for a period request; they never filter on the order date, and they are ignored when `Doc_Codes` is filled.
* Every line must find its item, and the order its supplier, agent, branch, currency, department, transporter, transfer party and delivery-address records. A line or order that cannot is left out. An order without a tax region is returned with `Tax_Region` `""`.
* Orders and their lines are not returned in any guaranteed order.
* Dates in the response are text `dd/MM/yyyy`, for example `05/10/2026`, except `Valid_Till` – see the known issue. A date that is not filled is `""`.

> **Known issue – `Valid_Till` is written in the server's short date format.** On most servers this is `dd/MM/yy`, for example `05/10/26`, unlike the other dates. Read it as day/month/two-digit year.

### **Example request**

Next batch after your stored bookmark:

```json
{
  "GlobalModifyCode": 58778,
  "DateFrom": null,
  "DateTo": null,
  "Doc_Codes": "",
  "Branch_Codes_From": ""
}
```

Approved orders only (keep this bookmark separately):

```json
{
  "GlobalModifyCode": 0,
  "DateFrom": null,
  "DateTo": null,
  "Doc_Codes": "",
  "ApprovalFilter": "1"
}
```

### **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 first batch of the change log; send the `LastGlobalModifyCode` you get back to see the next batch. Do not send `"GlobalModifyCode": -1` here – it changes what the sandbox has marked as already sent.

## Get Purchase Orders

> Returns your purchase orders from Logic ERP, each with its header (supplier, branch, department, amounts and tax, supplier's order and quotation numbers, delivery details, cancellation) and its item lines (item, lot, ordered and pending quantity, rate, MRP and tax rates). Use it to copy new and changed purchase orders into your own system – normally by asking only for orders added or changed since your last call – or to fetch particular orders by Logic ERP's internal number. With \`ApprovalFilter\` you can follow approved orders only.

```json
{"openapi":"3.0.3","info":{"title":"Logic ERP API","version":"1.0"},"tags":[{"name":"Orders - 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":{"/GetPurchaseOrder":{"post":{"tags":["Orders - Pull"],"operationId":"GetPurchaseOrder","summary":"Get Purchase Orders","description":"Returns your purchase orders from Logic ERP, each with its header (supplier, branch, department, amounts and tax, supplier's order and quotation numbers, delivery details, cancellation) and its item lines (item, lot, ordered and pending quantity, rate, MRP and tax rates). Use it to copy new and changed purchase orders into your own system – normally by asking only for orders added or changed since your last call – or to fetch particular orders by Logic ERP's internal number. With `ApprovalFilter` you can follow approved orders only.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"GlobalModifyCode":{"type":"integer","description":"Your bookmark in the change log, as described in How Every API Call Works: `0` = from the start (or a period, with `DateFrom`/`DateTo`), a number = only changes after it, `-1` = Logic ERP keeps the bookmark for you."},"DateFrom":{"type":"string","nullable":true,"description":"With `GlobalModifyCode` `0`: a period of changes (the day an order was saved, edited or – with `ApprovalFilter` `\"1\"` – approved; not the order date). Leave both out (or send `null`) when you are not asking for a period; with a bookmark they are not checked. Write them as `yyyy-MM-dd`."},"DateTo":{"type":"string","nullable":true,"description":"With `GlobalModifyCode` `0`: a period of changes (the day an order was saved, edited or – with `ApprovalFilter` `\"1\"` – approved; not the order date). Leave both out (or send `null`) when you are not asking for a period; with a bookmark they are not checked. Write them as `yyyy-MM-dd`."},"Doc_Codes":{"type":"string","description":"Logic ERP's internal order numbers (`Vouch_Code` in the response), separated by commas, for example `\"1869,1870\"`. Returns exactly these orders; the bookmark and period are ignored. Numbers and commas only."},"ApprovalFilter":{"type":"string","description":"`\"1\"` = only approved orders, followed through the approval change log (see the rules); `\"2\"` = only orders still waiting for approval; anything else = both. Applies in every kind of request."},"Branch_Codes_From":{"type":"string","description":"Branch codes separated by commas, for example `\"2,5\"`. Only orders of these branches are returned, in every kind of request. Numbers and commas only – anything else is refused."},"Doc_Num_Like":{"type":"string","description":"Only orders whose number starts with this text, written prefix-number, for example `\"PO-\"` or `\"PO-13\"`. Used with the bookmark or a period."}}}}}},"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":{"Vouch_Code":{"type":"integer","description":"Logic ERP's internal order number. Use it in `Doc_Codes`."},"Order_Prefix":{"type":"string","description":"Order prefix, for example `PO`."},"Order_Number":{"type":"integer","description":"Order number within the prefix."},"Order_Date":{"type":"string","description":"Order date, `dd/MM/yyyy`."},"Party_Name":{"type":"string","description":"Name of the supplier as kept in Logic ERP, usually with its city; there may be several spaces before the `-` and the city."},"Print_Act_Name":{"type":"string","description":"The supplier's print name."},"Party_User_Code":{"type":"string","description":"Code of the supplier as shown in Logic ERP."},"Agent_Name":{"type":"string","description":"The order's agent, or `NIL`."},"Branch_Name":{"type":"string","description":"Name and short name of the order's branch."},"Branch_Short_Name":{"type":"string","description":"Name and short name of the order's branch."},"Exchange_Rate":{"type":"number","description":"Exchange rate of the order's currency; `1` for rupees."},"Currency_Name":{"type":"string","description":"Currency, for example `INR`."},"Order_Amount":{"type":"number","description":"Order value before taxes."},"Total_Tax":{"type":"number","description":"The order's tax: its first and second tax amounts together (with GST, CGST + SGST). A further tax amount such as cess is not included."},"Net_Order_Amount":{"type":"number","description":"Order total."},"Supplier_Order_No":{"type":"string","description":"The supplier's reference number typed on the order."},"Delivery_Date":{"type":"string","description":"Delivery date, `dd/MM/yyyy`; `\"\"` when not filled."},"Quotation_No":{"type":"string","description":"Supplier's quotation number and date; empty when not filled."},"Transfer_Branch_Name":{"type":"string","description":"Name of that branch; `\"\"` when none."},"Transfer_Branch_Code":{"type":"integer","description":"The branch the goods are ordered for, when the order is placed on behalf of another branch; `0` or `-1` when none."},"Quotation_Date":{"type":"string","description":"Supplier's quotation number and date; empty when not filled."},"Action_Code":{"type":"string","description":"The order's latest save: `N` = added, `M` = modified; empty when the order has no change-log line."},"Cancel_Order":{"type":"boolean","description":"`true` when the order has been cancelled."},"Department_Name":{"type":"string","description":"Department on the order, or `(NIL)`."},"Transpoter_Name":{"type":"string","description":"Transporter (the name is spelt this way), or `(NIL)`."},"Transfer_PartyName":{"type":"string","description":"The transfer party on the order, or `(NIL)`."},"Tax_Region":{"type":"string","description":"The order's tax region, for example `CGST/SGST` or `IGST`; `\"\"` when the order has none."},"Valid_Till":{"type":"string","description":"Date the order is valid until – see the known issue."},"Delivery_At":{"type":"string","nullable":true,"description":"The delivery place of the order's delivery address; `null` when the order's delivery address has no text (also when no delivery address was chosen)."},"Delivery_Add_1":{"type":"string","nullable":true,"description":"The lines of that delivery address; `null` when the address has no such line."},"Delivery_Add_2":{"type":"string","nullable":true,"description":"The lines of that delivery address; `null` when the address has no such line."},"Delivery_Add_3":{"type":"string","nullable":true,"description":"The lines of that delivery address; `null` when the address has no such line."},"ListItems":{"type":"array","items":{"type":"object","properties":{"Txn_Code":{"type":"integer","description":"Logic ERP's internal line number."},"Logic_UserCode":{"type":"string","description":"Item code as shown in Logic ERP (`UserCode` in Get Item Master)."},"Lot_Number":{"type":"string","description":"Lot number planned for the goods, for example `PO-132`; empty when none."},"CF_Qty":{"type":"number","description":"Conversion factor of the line's quantity."},"Total_Qty":{"type":"number","description":"Quantity ordered."},"Rate":{"type":"number","description":"Purchase rate on the line."},"Pending_Qty":{"type":"number","description":"Quantity not yet received."},"PO_MRP":{"type":"number","description":"MRP on the line; `0` when not set."},"EAN_Code":{"type":"string","description":"The item's additional code, for example a barcode."},"Cancel_Item":{"type":"boolean","description":"`true` when the line has been cancelled."},"Tax_1":{"type":"number","description":"Tax rates (%) of the three tax slots of the line; with GST usually CGST in slot 1 and SGST or IGST in slot 3. `0` when the line has no tax details."},"Tax_2":{"type":"number","description":"Tax rates (%) of the three tax slots of the line; with GST usually CGST in slot 1 and SGST or IGST in slot 3. `0` when the line has no tax details."},"Tax_3":{"type":"number","description":"Tax rates (%) of the three tax slots of the line; with GST usually CGST in slot 1 and SGST or IGST in slot 3. `0` when the line has no tax details."}}},"description":"The item lines. See below."}}},"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 purchase order:

| Field                                                | Type         | Meaning                                                                                                                                              |
| ---------------------------------------------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Vouch_Code`                                         | number       | Logic ERP's internal order number. Use it in `Doc_Codes`.                                                                                            |
| `Order_Prefix`                                       | text         | Order prefix, for example `PO`.                                                                                                                      |
| `Order_Number`                                       | number       | Order number within the prefix.                                                                                                                      |
| `Order_Date`                                         | date         | Order date, `dd/MM/yyyy`.                                                                                                                            |
| `Party_Name`                                         | text         | Name of the supplier as kept in Logic ERP, usually with its city; there may be several spaces before the `-` and the city.                           |
| `Print_Act_Name`                                     | text         | The supplier's print name.                                                                                                                           |
| `Party_User_Code`                                    | text         | Code of the supplier as shown in Logic ERP.                                                                                                          |
| `Agent_Name`                                         | text         | The order's agent, or `NIL`.                                                                                                                         |
| `Branch_Name`, `Branch_Short_Name`                   | text         | Name and short name of the order's branch.                                                                                                           |
| `Exchange_Rate`                                      | number       | Exchange rate of the order's currency; `1` for rupees.                                                                                               |
| `Currency_Name`                                      | text         | Currency, for example `INR`.                                                                                                                         |
| `Order_Amount`                                       | number       | Order value before taxes.                                                                                                                            |
| `Total_Tax`                                          | number       | The order's tax: its first and second tax amounts together (with GST, CGST + SGST). A further tax amount such as cess is not included.               |
| `Net_Order_Amount`                                   | number       | Order total.                                                                                                                                         |
| `Supplier_Order_No`                                  | text         | The supplier's reference number typed on the order.                                                                                                  |
| `Delivery_Date`                                      | date         | Delivery date, `dd/MM/yyyy`; `""` when not filled.                                                                                                   |
| `Quotation_No`, `Quotation_Date`                     | text, date   | Supplier's quotation number and date; empty when not filled.                                                                                         |
| `Transfer_Branch_Code`                               | number       | The branch the goods are ordered for, when the order is placed on behalf of another branch; `0` or `-1` when none.                                   |
| `Transfer_Branch_Name`                               | text         | Name of that branch; `""` when none.                                                                                                                 |
| `Transfer_PartyName`                                 | text         | The transfer party on the order, or `(NIL)`.                                                                                                         |
| `Action_Code`                                        | text         | The order's latest save: `N` = added, `M` = modified; empty when the order has no change-log line.                                                   |
| `Cancel_Order`                                       | true / false | `true` when the order has been cancelled.                                                                                                            |
| `Department_Name`                                    | text         | Department on the order, or `(NIL)`.                                                                                                                 |
| `Transpoter_Name`                                    | text         | Transporter (the name is spelt this way), or `(NIL)`.                                                                                                |
| `Tax_Region`                                         | text         | The order's tax region, for example `CGST/SGST` or `IGST`; `""` when the order has none.                                                             |
| `Valid_Till`                                         | text         | Date the order is valid until – see the known issue.                                                                                                 |
| `Delivery_At`                                        | text         | The delivery place of the order's delivery address; `null` when the order's delivery address has no text (also when no delivery address was chosen). |
| `Delivery_Add_1`, `Delivery_Add_2`, `Delivery_Add_3` | text         | The lines of that delivery address; `null` when the address has no such line.                                                                        |
| `ListItems`                                          | list         | The item lines. See below.                                                                                                                           |

**`ListItems`** — one entry per order line:

| Field                     | Type         | Meaning                                                                                                                                                                                           |
| ------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Txn_Code`                | number       | Logic ERP's internal line number.                                                                                                                                                                 |
| `Logic_UserCode`          | text         | Item code 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)). |
| `EAN_Code`                | text         | The item's additional code, for example a barcode.                                                                                                                                                |
| `Lot_Number`              | text         | Lot number planned for the goods, for example `PO-132`; empty when none.                                                                                                                          |
| `CF_Qty`                  | number       | Conversion factor of the line's quantity.                                                                                                                                                         |
| `Total_Qty`               | number       | Quantity ordered.                                                                                                                                                                                 |
| `Pending_Qty`             | number       | Quantity not yet received.                                                                                                                                                                        |
| `Rate`                    | number       | Purchase rate on the line.                                                                                                                                                                        |
| `PO_MRP`                  | number       | MRP on the line; `0` when not set.                                                                                                                                                                |
| `Cancel_Item`             | true / false | `true` when the line has been cancelled.                                                                                                                                                          |
| `Tax_1`, `Tax_2`, `Tax_3` | number       | Tax rates (%) of the three tax slots of the line; with GST usually CGST in slot 1 and SGST or IGST in slot 3. `0` when the line has no tax details.                                               |

### **Example response**

```json
{
  "GetData": [
    {
      "Vouch_Code": 1869,
      "Order_Prefix": "PO",
      "Order_Number": 132,
      "Order_Date": "05/10/2026",
      "Party_Name": "JAIPUR HANDLOOM HOUSE -JAIPUR",
      "Print_Act_Name": "JAIPUR HANDLOOM HOUSE",
      "Party_User_Code": "S2001",
      "Agent_Name": "NIL",
      "Branch_Name": "LUDHIANA MAIN",
      "Branch_Short_Name": "LDH",
      "Exchange_Rate": 1.0,
      "Currency_Name": "INR",
      "Order_Amount": 75000.0,
      "Total_Tax": 1875.0,
      "Net_Order_Amount": 78750.0,
      "Supplier_Order_No": "JHH-52",
      "Delivery_Date": "20/10/2026",
      "Quotation_No": "",
      "Transfer_Branch_Name": "",
      "Transfer_Branch_Code": -1,
      "Quotation_Date": "",
      "Action_Code": "N",
      "Cancel_Order": false,
      "Department_Name": "PROCUREMENT",
      "Transpoter_Name": "(NIL)",
      "Transfer_PartyName": "(NIL)",
      "Tax_Region": "CGST/SGST",
      "Valid_Till": "04/11/26",
      "Delivery_At": null,
      "Delivery_Add_1": null,
      "Delivery_Add_2": null,
      "Delivery_Add_3": null,
      "ListItems": [
        {
          "Txn_Code": 13830,
          "Logic_UserCode": "KUR-1001-M",
          "Lot_Number": "PO-132",
          "CF_Qty": 1.0,
          "Total_Qty": 100.0,
          "Rate": 750.0,
          "Pending_Qty": 100.0,
          "PO_MRP": 1499.0,
          "EAN_Code": "8901234567012",
          "Cancel_Item": false,
          "Tax_1": 2.5,
          "Tax_2": 0.0,
          "Tax_3": 2.5
        }
      ]
    }
  ],
  "Status": true,
  "Message": "",
  "LastGlobalModifyCode": 142299,
  "resultSize": "2 KB"
}
```

### **Messages you may see**

| Message                                                                             | Meaning                                                                                                                                                                                                                       | What to do                                                                                            |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| *No Pending Purchase Order found...* (with `Status: true`)                          | Nothing has been added to the change log after your bookmark.                                                                                                                                                                 | You are up to date. Call again later with the same bookmark.                                          |
| *No Record Found.* (with `Status: true`)                                            | Change-log lines were found but no order could be returned (deleted orders, orders excluded by `ApprovalFilter` or by `Branch_Codes_From`), or no order was changed in the period, or the `Doc_Codes` you sent found nothing. | With a bookmark: store the new `LastGlobalModifyCode` and call again. Otherwise: check what you sent. |
| `Invalid code in list: '…'. Only numeric codes are allowed.` (with `Status: false`) | `Doc_Codes` or `Branch_Codes_From` contains something other than numbers and commas.                                                                                                                                          | Send them as numbers separated by commas.                                                             |


---

# 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/orders/pull/get-purchase-orders.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.
