> 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/how-every-api-call-works.md).

# How Every API Call Works

This page explains what is **the same for every endpoint**: how to read a response, how branches and dates are handled, how to fetch only new or changed records, and the messages any endpoint can return. The endpoint pages only describe what is particular to each endpoint.

### **The response to a Push**

Every Push endpoint answers with at least these fields:

| Field           | Type         | Meaning                                                                                                                                                                                                                  |
| --------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Status`        | true / false | `true` when the request was accepted. `false` when nothing was saved – read `Message`.                                                                                                                                   |
| `Message`       | text         | Why the request failed, or extra information. Usually empty when the record was saved.                                                                                                                                   |
| `LastSavedCode` | number       | Logic ERP's internal number of the document or master just saved. Keep it if you want to fetch or refer to that record later.                                                                                            |
| `request_ID`    | text         | A unique ID Logic ERP gives this request. Quote it when you contact support about a request. It is empty when the request failed before saving started – then nothing was saved and you can send the same request again. |

Some endpoints add more fields, such as the document number that was given (`LastSavedDocNo`, `Invoice_No`) or a print file. The endpoint page lists them.

> **Example — a saved sale invoice**
>
> ```json
> {
>   "Status": true,
>   "Message": "",
>   "LastSavedCode": 10452,
>   "request_ID": "6f1c2a9e-3b7d-4c55-9a0e-2d8f61b0c7aa"
> }
> ```

Business errors (a missing item, a wrong field value) still come back as a normal answer with `Status: false` and the reason in `Message`. **Always check `Status`**, not only whether the call went through. Some error messages include technical detail after the reason; the reason is the first line.

**Endpoint switched off for your branch:** if your support team has switched an endpoint off for your branch, nothing is saved and `Message` contains *"Request cannot be processed. API Template is marked as In-Active in the configuration"*. Depending on the endpoint, `Status` can be `true` or `false`, and the sentence can be surrounded by technical detail – so look for the sentence and treat the request as **not saved**. Not every endpoint can be switched off per branch; each endpoint page says how it behaves.

### **The response to a Pull**

Every Pull endpoint answers with these fields:

| Field     | Type         | Meaning                                                                                                                                                                             |
| --------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GetData` | list         | The records found. Each endpoint page describes the fields of one record.                                                                                                           |
| `Status`  | true / false | `true` when the request was valid. `false` when it was not – read `Message`. **Exception:** the date checks below answer with `Status: true`, no data and the problem in `Message`. |
| `Message` | text         | Why the request failed, or – with `Status: true` – a note such as *"No Pending Sale Bill found..."* when nothing new was found.                                                     |

So for a Pull, treat the call as successful only when `Status` is `true` **and** `GetData` holds records; when `GetData` is empty or `null`, read `Message`. | `LastGlobalModifyCode` | number | A bookmark. Send it back in your next request to get only what changed after this one (see below). | | `resultSize` | text | The size of the answer, for example `"12 KB"`. |

### **Branches**

Most Push requests say which **branch** the document belongs to – by branch code or by branch short name, depending on the endpoint. If a branch short name is given that does not exist, the request fails with a message containing *"Branch\_Short\_Name : … not exists."* (the name you sent in place of …).

### **Dates**

* For most documents you push, **the date of the document** decides which financial year it is saved in. A few endpoints save into the financial year of the day the request arrives; their pages say so. If no financial year in Logic ERP covers the date you send, nothing is saved: the answer has `Status: false` and `Message` contains *"No financial year covers the date dd/MM/yyyy."* (with your date).
* Dates in Pull responses are text written day/month/year in the server's short date format – for example `19/04/2026`, or `19/04/26` on some servers and endpoints. Read both forms. A few fields also carry a time, for example the sale invoice time `19/04/2026 06:49 PM`.
* In requests, write dates as `yyyy-MM-dd` (for example `2026-04-19`). This form is always read correctly; a form like `04/05/2026` can be read as 4 May or 5 April depending on the server.

### **Fetching only new or changed records (Pull)**

Logic ERP keeps a **change log**: when a document is saved or edited, a line is added with a running number. Most Pull endpoints use that number so you never have to download everything again. These request fields are common to them – each endpoint page says whether it uses them:

| Field                | Type   | Meaning                                                                                                                                                                                                                                                                                                                                                                                                                     |
| -------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GlobalModifyCode`   | number | Where to start in the change log. See the three ways below.                                                                                                                                                                                                                                                                                                                                                                 |
| `DateFrom`, `DateTo` | date   | A period of the change log, used when `GlobalModifyCode` is `0`. Send them as `null`, or leave them out, when you are not asking for a period.                                                                                                                                                                                                                                                                              |
| `Branch_Codes_From`  | text   | Branch codes separated by commas, for example `"2,5"`. Only documents of these branches are returned. Leave empty for all branches.                                                                                                                                                                                                                                                                                         |
| `Doc_Num_Like`       | text   | Only documents whose number starts with this text, for example `"WSL"`.                                                                                                                                                                                                                                                                                                                                                     |
| `Doc_Codes`          | text   | Logic ERP's internal numbers of particular records, separated by commas, for example `"10452,10453"` – such as the `LastSavedCode` a Push returned. When this is filled (and `GlobalModifyCode` is not `-1` – for retail customers also with `-1`, see below), these records are returned and the bookmark and period fields are ignored. Whether `Branch_Codes_From` still applies depends on the endpoint – see its page. |

There are three ways to fetch changes:

**1. Keep your own bookmark** – recommended.

* The first time, send `"GlobalModifyCode": 0` with `"DateFrom": null` and `"DateTo": null`. You get the first batch from the start of the change log.
* Store the `LastGlobalModifyCode` from the response.
* Next time, send that number as `GlobalModifyCode`. You get the next batch. A batch covers up to **200 change-log lines** on most endpoints; a document saved and then edited takes two lines but is returned once. A document that is still being saved at the moment you call is not skipped – it comes in a later batch.
* Repeat until `GetData` is empty and `Message` says nothing was found. Then wait and call again later.

**2. Let Logic ERP keep the bookmark.** Send `"GlobalModifyCode": -1`. Logic ERP remembers, for your API site, what it has already sent you, and each call returns the next batch. Records are marked as sent only when the call succeeds. Records that your Logic ERP team has marked to be sent again are returned first, on their own and with `LastGlobalModifyCode` `0`; the next `-1` call carries on with the change log.

* The account-entries pull keeps a separate `-1` bookmark for each `Doc_Type`, and Get Purchase Orders with `ApprovalFilter` `"1"` keeps its own bookmark, apart from the plain call. A bookmark that has not been used yet starts where the shared one stood.
* For sale invoices, sale returns, stock transfers out, stock transfers in, purchase vouchers, purchase returns, production receipts, blank piece receipts and account entries, the very first `-1` call of your API site (no bookmark yet) starts at the first change of the current financial year. After that, `-1` returns the changes of every financial year.
* A `-1` call that asks for particular records – a party by `PartyUserCode`, retail customers by `Mobile_No` or `Doc_Codes`, or sale invoices, sale returns or stock transfers out by `SaleBillNo`, `SaleOrderNo`, `PartyOrderNo`, `Mobile_No` or `Challan_No` – returns only those records, with `LastGlobalModifyCode` `0`. It does not return the records marked to be sent again, and your bookmark does not move.

**3. Ask for a period.** Send `"GlobalModifyCode": 0` with both `DateFrom` and `DateTo`. You get every record **saved or changed** in that period, with no batch limit. The period is the date of the change, not the document date: an invoice dated in March that was edited in April is found by an April period. A period request returns `LastGlobalModifyCode` as `0` – do not store it as your bookmark.

> **Example — a shop that reads new sale invoices every 15 minutes**
>
> At 10:00 the shop sends `"GlobalModifyCode": 0, "DateFrom": null, "DateTo": null`. It gets the first batch and `"LastGlobalModifyCode": 8812`. It stores 8812 and calls again at once with `"GlobalModifyCode": 8812`, gets the rest and `"LastGlobalModifyCode": 8901`. A third call with 8901 returns no invoices and *"No Pending Sale Bill found..."*, with `LastGlobalModifyCode` still 8901.
>
> At 10:15 it calls with 8901 and gets only the invoices saved or edited since 10:00.

A record that is **edited again** after you fetched it appears again in a later batch, so update your copy rather than adding a second one.

When the request asks for a period, these checks answer with `Status: true` and no data – check `Message`:

* `DateFrom` with `DateTo` sent as `null` or left out of the request gives *"If Date From exists then Date To cannot be null..Please Check.."*
* `DateFrom` later than `DateTo` gives *"Date From cannot be greater than Date To...Please Check.."*
* A value that is not a date gives *"Invalid Date From.."* or *"Invalid Date To."*

### **Saves of the same kind run one at a time**

When your support team switches on **request queueing** for your API site, Push requests to the same endpoint for the same branch are saved one after another, in the order they arrive, instead of at the same moment. Each request still gets its own answer; it may simply take a little longer at busy times.

### **Messages any endpoint can return**

| Message                                                                                                                                            | What it means                                                                                                                      | What to do                                                                           |
| -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| *Validating License error...* (Push), or a licence message such as *License for product is not available.* (Pull)                                  | The endpoint is not covered by your licence.                                                                                       | Ask your Logic ERP support team.                                                     |
| *Your data meters balance for the product \[ … ] has been fully utilized. Kindly recharge your balance promptly to avoid any interruption.* (Pull) | Your Pull data allowance is used up.                                                                                               | Recharge the balance.                                                                |
| *Unable to Get Meters Balance...* (Pull)                                                                                                           | Logic ERP could not check your data allowance.                                                                                     | Try again later; if it continues, ask support.                                       |
| *Payload Request Can\`t be null. Please Check...*, or an error                                                                                     | The Push request had no body.                                                                                                      | Send the request JSON.                                                               |
| *You have already refreshed … Seconds ago. Refreshing of … is allowed only at minimum interval of … Seconds.* (Pull)                               | Your API site allows this endpoint only once in a set number of seconds. The limit counts calls from everyone using your API site. | Wait and call again.                                                                 |
| A message containing *API Template … is Marked as In-Active...*, *API Template … not found. Please Check...* or *Logic User Not Linked*            | Your API site's setup in Logic ERP is switched off, missing or incomplete.                                                         | Ask your Logic ERP support team.                                                     |
| A message containing *API settings for this route are not configured for the API template.* (Pull)                                                 | The settings of this endpoint have not been saved for your API site in Logic ERP.                                                  | Ask your Logic ERP support team.                                                     |
| A technical error such as *Object reference not set to an instance of an object.*, with an empty `request_ID` (Push)                               | The request failed before Logic ERP started to save it; nothing was saved.                                                         | Send the same request again. If it keeps happening, 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/how-every-api-call-works.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.
