> 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/create-or-update-a-party.md).

# Create or Update a Party

Creates a **customer** or **supplier** (a party) in Logic ERP, with its address, contact, GST, agent and account-group details. If the **party code** you send already belongs to a customer or supplier, the same call **updates** that party instead. Other kinds of account (bank, expense, sale, purchase and so on) can also be created with this endpoint, but not updated.

### **Endpoint**

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

Send one party per request. Field names are matched without regard to upper/lower case. Fields not listed below are ignored. An object or list you do not use (`Cust_Sup_Details`, `BankDetails`, `ListCustomFields` and the others) can be left out or sent as `null`.

### **Request fields**

| Field                                                         | Type   | Required | Default          | Meaning                                                                                                                                                                                                                                                                                                                                                 |
| ------------------------------------------------------------- | ------ | -------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Account_Name`                                                | text   | **Yes**  | –                | Party name, up to 100 characters (fewer when a city is given – see the rules). On an update the name is replaced by what you send.                                                                                                                                                                                                                      |
| `Account_Type`                                                | text   | **Yes**  | –                | `CU` = customer, `SU` = supplier. Other account types are listed under the rules. Upper/lower case does not matter; spaces around it are ignored.                                                                                                                                                                                                       |
| `User_Code`                                                   | text   | No       | next free number | The **party code** shown in Logic ERP (`User_Code` in [Get Party Master](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/api-documentation/masters/pull/get-party-master.md)), up to 20 characters. If a customer or supplier already has this code, that party is updated. Left empty, see "How a party is matched" below. |
| `PrintAccountName`                                            | text   | No       | empty            | Name printed on documents, up to 200 characters. Logic ERP does **not** copy `Account_Name` into it when you leave it empty.                                                                                                                                                                                                                            |
| `AddlAccountUserCode`                                         | text   | No       | empty            | An additional party code (`AddlActUserCode` in Get Party Master), up to 100 characters.                                                                                                                                                                                                                                                                 |
| `Group_Name1` … `Group_Name8`                                 | text   | No       | empty            | The party's account groups at levels 1 to 8 (`Group_Name1`…`Group_Name8` in Get Party Master). A group that does not exist yet is **created** – see the rules.                                                                                                                                                                                          |
| `Use_As_Cust_Supp_Both`                                       | number | No       | `0`              | `1` = the party is also used as the other type (a customer that is also a supplier, or the reverse). Any other value = no.                                                                                                                                                                                                                              |
| `Cust_Sup_Details`                                            | object | No       | all empty        | Address, contact, GST and trading details. See the table below.                                                                                                                                                                                                                                                                                         |
| `ListCustomFields`                                            | list   | No       | empty            | Extra fields your company has defined for parties. See the table below.                                                                                                                                                                                                                                                                                 |
| `BankDetails`                                                 | object | No       | all empty        | Only for **bank** accounts – leave it out for parties.                                                                                                                                                                                                                                                                                                  |
| `Opening_Balance`                                             | number | No       | `0`              | **Ignored** – see the known issue below.                                                                                                                                                                                                                                                                                                                |
| `Tax_Region`                                                  | text   | No       | empty            | The party's tax region, by its name in Logic ERP. Used only when the party is created; a name that is not found saves no tax region.                                                                                                                                                                                                                    |
| `Group_Name`, `BS_Grp1`, `BS_Grp2`, `New_BS_Grp`              | text   | No       | empty            | Ignored on a normal Logic ERP setup: the general and balance-sheet groups always come from the defaults set for the account type in Logic ERP. They are read only when that default balance-sheet group is missing in Logic ERP.                                                                                                                        |
| `FixedAssetDetails`, `CaptialDetails`, `AccountExciseDetails` | object | No       | empty            | For fixed-asset and capital accounts, and old excise registrations. Leave them out for parties.                                                                                                                                                                                                                                                         |
| `DisplayError`                                                | text   | No       | `"0"`            | Ignore.                                                                                                                                                                                                                                                                                                                                                 |

**`Cust_Sup_Details`**

Names you send (city, state, agent, branch, transport and so on) must already exist in Logic ERP; they are matched exactly as typed, ignoring upper/lower case only. Nothing in this object is created automatically.

| Field                                                                                                    | Type                 | Required | Default         | Meaning                                                                                                                                                                                |
| -------------------------------------------------------------------------------------------------------- | -------------------- | -------- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `First_Add1`, `First_Add2`, `First_Add3`                                                                 | text                 | No       | empty           | First (main) address lines, up to 80 characters each.                                                                                                                                  |
| `First_CityName`                                                                                         | text                 | No       | empty           | City of the first address, as in the Logic ERP city list. The party's **state and country are taken from this city**. The city is also added to the stored party name (see the rules). |
| `First_Pincode`                                                                                          | text                 | No       | empty           | PIN code of the first address, up to 6 characters.                                                                                                                                     |
| `First_Location`                                                                                         | text                 | No       | empty           | A location (area) defined under the first city in Logic ERP. Used only when `First_Pincode` is empty: Logic ERP then fills the PIN code from the location.                             |
| `First_State_Name`, `First_Country_Name`                                                                 | text                 | No       | empty           | Only **checked** – they must exist in Logic ERP – but not saved. The country is checked only when `First_CityName` is filled.                                                          |
| `Second_Add1`, `Second_Add2`, `Second_Add3`                                                              | text                 | No       | empty           | Second address lines (for example a delivery address).                                                                                                                                 |
| `Second_CityName`, `Second_PinCode`, `Second_Location`                                                   | text                 | No       | empty           | City, PIN code and location of the second address, used the same way as for the first address.                                                                                         |
| `Second_State_Name`, `Second_Country_Name`                                                               | text                 | No       | empty           | Only checked, not saved, as for the first address.                                                                                                                                     |
| `Telephone_Off`, `Telephone_Res`                                                                         | text                 | No       | empty           | Office and residence telephone numbers.                                                                                                                                                |
| `Mobile_No`                                                                                              | text                 | No       | empty           | Mobile number.                                                                                                                                                                         |
| `Fax_No`                                                                                                 | text                 | No       | empty           | Fax number.                                                                                                                                                                            |
| `Email_Address`                                                                                          | text                 | No       | empty           | E-mail address.                                                                                                                                                                        |
| `WebsiteAddress`                                                                                         | text                 | No       | empty           | Website.                                                                                                                                                                               |
| `Contact_Person`                                                                                         | text                 | No       | empty           | Contact person, up to 30 characters (`Contact_Name` in Get Party Master).                                                                                                              |
| `Designation`                                                                                            | text                 | No       | empty           | Designation of the contact person.                                                                                                                                                     |
| `GST_No`                                                                                                 | text                 | No       | empty           | The party's GSTIN. Saved as sent – Logic ERP does not check its format.                                                                                                                |
| `GST_StateCode`                                                                                          | text                 | No       | empty           | GST state code, for example `"03"`. Not checked against the GSTIN.                                                                                                                     |
| `GST_Date`                                                                                               | date                 | No       | empty           | GST registration date, `yyyy-MM-dd`.                                                                                                                                                   |
| `GST_Reg_Type`                                                                                           | number               | No       | `0`             | `0` = unregistered, `1` = registered, `2` = composite. Send `1` together with a GSTIN – the default `0` marks the party unregistered even when `GST_No` is filled.                     |
| `GST_Reverse_Charge`                                                                                     | true / false         | No       | `false`         | `true` when GST on purchases from this party is paid under reverse charge.                                                                                                             |
| `ECommGST_Party`                                                                                         | true / false         | No       | `false`         | `true` when the party is an e-commerce operator.                                                                                                                                       |
| `ECommGST_No`                                                                                            | text                 | No       | empty           | GSTIN of the e-commerce operator.                                                                                                                                                      |
| `PAN_No`                                                                                                 | text                 | No       | empty           | PAN.                                                                                                                                                                                   |
| `Aadhaar_No`                                                                                             | text                 | No       | empty           | Aadhaar number.                                                                                                                                                                        |
| `CIN_No`                                                                                                 | text                 | No       | empty           | Company identification number.                                                                                                                                                         |
| `MSME_Type`                                                                                              | text                 | No       | `"None"`        | `None`, `Micro`, `Small` or `Medium` (`Madium` is also accepted); upper/lower case does not matter. Any other value, or `null`, saves "none" and clears `MSME_No`.                     |
| `MSME_No`                                                                                                | text                 | No       | empty           | MSME (Udyam) registration number.                                                                                                                                                      |
| `FoodLicNo`                                                                                              | text                 | No       | empty           | Food licence (FSSAI) number.                                                                                                                                                           |
| `Drug_Lisc_No1`, `Drug_Lisc_No2`, `Drug_Lisc_No3`                                                        | text                 | No       | empty           | Drug licence numbers.                                                                                                                                                                  |
| `Drug_Lisc1_ExpDate`, `Drug_Lisc2_ExpDate`, `Drug_Lisc3_ExpDate`                                         | date                 | No       | empty           | Expiry dates of the drug licences, `yyyy-MM-dd`.                                                                                                                                       |
| `AgentName`                                                                                              | text                 | No       | empty           | The party's agent or broker, by name.                                                                                                                                                  |
| `BranchName`                                                                                             | text                 | No       | empty           | The branch the party is linked to, by its **full branch name** (not the short name).                                                                                                   |
| `Trans_Name`                                                                                             | text                 | No       | empty           | Default transporter, by name.                                                                                                                                                          |
| `BuyingAgent_Name`                                                                                       | text                 | No       | empty           | Buying agent (an agent set up as an export buying agent).                                                                                                                              |
| `ForwardingAgent_Name`                                                                                   | text                 | No       | empty           | Forwarding agent (an agent set up as an export forwarding agent).                                                                                                                      |
| `StockTrans`                                                                                             | true / false         | No       | `false`         | `true` = the party is a stock-transfer party. Used only when the party is created.                                                                                                     |
| `STBranchCode`                                                                                           | number               | No       | `0`             | The branch linked to this party for stock transfers, by Logic ERP's branch number. Not checked.                                                                                        |
| `STBranchName`                                                                                           | text                 | No       | empty           | The same branch by its full name; used when `STBranchCode` is `0`.                                                                                                                     |
| `StopBilling`                                                                                            | true / false         | No       | `false`         | `true` = billing to this party is blocked. Used only when the party is created.                                                                                                        |
| `ExportImportParty`                                                                                      | true / false         | No       | `false`         | `true` for an export / import party.                                                                                                                                                   |
| `Credit_Limit`                                                                                           | number               | No       | `0`             | Credit limit in ₹.                                                                                                                                                                     |
| `Credit_Limit_Variance`                                                                                  | number               | No       | `0`             | Allowed variance on the credit limit.                                                                                                                                                  |
| `Bill_Limit`                                                                                             | number               | No       | `0`             | Limit per bill in ₹.                                                                                                                                                                   |
| `OverDueDaysLimit`                                                                                       | number               | No       | `0`             | Overdue-days limit.                                                                                                                                                                    |
| `Security_Amount`                                                                                        | number               | No       | `0`             | Security deposit in ₹.                                                                                                                                                                 |
| `Bank_Guarantee_Date`                                                                                    | date                 | No       | empty           | Bank guarantee date, `yyyy-MM-dd`.                                                                                                                                                     |
| `Comm_P`                                                                                                 | number               | No       | `0`             | Commission %.                                                                                                                                                                          |
| `Add_P`                                                                                                  | number               | No       | `0`             | Additional %.                                                                                                                                                                          |
| `Octroi_P`, `Add_Octroi`                                                                                 | number, true / false | No       | `0`, `false`    | Octroi / market-fee settings.                                                                                                                                                          |
| `Allow_CD`, `Allow_Slab_CD`, `Less_Cd`, `Allow_TD`                                                       | true / false         | No       | `false`         | Cash-discount and trade-discount switches for this party.                                                                                                                              |
| `LockSchPerUnit`, `LockSchRs`, `LockAdjustItemRs`                                                        | true / false         | No       | `false`         | Locks on scheme and item-rate adjustments in documents for this party.                                                                                                                 |
| `Bank_Name`, `Bank_Add1`, `Bank_add2`                                                                    | text                 | No       | empty           | The party's bank and its address.                                                                                                                                                      |
| `Remarks_1`, `Remarks_2`, `Remarks_3`                                                                    | text                 | No       | empty           | Remarks.                                                                                                                                                                               |
| `Extra_Str_1`, `Extra_Str_2`                                                                             | text                 | No       | empty           | Two free text fields.                                                                                                                                                                  |
| `BuyerReference`, `SupplierNo`, `RegistrationNo`, `BookingFormat`, `AcdFormat`, `DaysForBooking`         | text                 | No       | empty           | Further reference fields shown on the party screen.                                                                                                                                    |
| `Cst_No`, `Cst_Date`, `Lst_No`, `Lst_Date`, `Give_CForm`, `TIN_No`, `Service_Tax_No`, `SSI_No`, `SSE_No` | –                    | No       | empty / `false` | Pre-GST registrations. Leave them out.                                                                                                                                                 |
| `Dest_Code`, `Final_Dest_Code`                                                                           | number               | No       | `0`             | Logic ERP's internal destination numbers. Leave both out unless your Logic ERP team gives you the numbers.                                                                             |
| `First_Location_Code`, `Second_Location_Code`                                                            | number               | No       | `0`             | **Ignored.**                                                                                                                                                                           |

**`ListCustomFields`** — one entry per extra field you want to fill:

| Field          | Type | Required | Default | Meaning                                                                                                                                                                                                          |
| -------------- | ---- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `FieldName`    | text | **Yes**  | –       | Name of the extra field as defined for parties in Logic ERP (`FieldName` in Get Party Master). Spaces around it are removed; upper/lower case does not matter. Each name only once – a repeated name is refused. |
| `FieldValue_1` | text | No       | empty   | The value.                                                                                                                                                                                                       |
| `FieldValue_2` | text | No       | empty   | A second value, used by some field types.                                                                                                                                                                        |

### **Rules Logic ERP applies**

**How a party is matched for an update**

* **With `User_Code`.** If a customer or supplier has this code (upper/lower case does not matter) and you send `Account_Type` `CU` or `SU`, that party is **updated**. If the code belongs to an account of another kind, or you send any other type, the request is refused with `Account User Code already exists!!`. If no account has the code, a new party is created with it.
* **Without `User_Code`.** Logic ERP looks for an account with exactly the same stored name – the name plus the first city, built as described below. If one is found, its code is used and the rule above applies (so a customer or supplier with the same name in the same city is **updated**). If none is found, a new party is created with the **next free number** as its code: one more than the highest code made only of digits.
* Logic ERP never changes the account type, the party code or the account groups chosen at creation when it updates a party – see "What an update changes".

**What is created**

* One account, with its address and GST details, and – for `ListCustomFields` – the extra-field values.
* **Account groups.** For each `Group_Name1`…`Group_Name8` you fill, Logic ERP looks for a group of that level with this name (upper/lower case does not matter), top-level groups first and then sub-groups. Only when there is none does it **create** a top-level group, with the name exactly as you typed it.
* Cities, states, countries, locations, agents, transporters and branches are **never created**. A name that does not exist stops the request (see the messages).
* The general group and the balance-sheet groups come from the defaults set for the account type in Logic ERP.
* If your company requires approval of accounts, the party is saved as **awaiting approval** and cannot be used until it is approved in Logic ERP. Depending on the approval setup, an **update** can also send the party back for approval.

**Names and duplicates**

* The stored party name includes the first city: the name is followed by spaces up to 30 characters (one space when the name is 30 characters or longer), then `-` and the first 19 characters of the city, for example `BALAJI FABRICS -AMRITSAR`. This is the name returned in `AccountName`. Without a city, the name is stored as sent. Keep `Account_Name` to about 80 characters when you send a city.
* Two parties may have the same name in **different cities**. The same name in the same city is not allowed: without `User_Code` the existing party is updated; with a different `User_Code` the request fails with a database error.
* When a new party is created, an existing account of any type whose stored name is exactly the name you sent (an account saved with **no city**) gives `Account with same name already exists!!`.
* Account codes must be unique: Logic ERP's own code check is not case-sensitive.

**What an update changes**

* Text fields you leave **empty** keep their current value, and number fields you send as `0` keep theirs. So you cannot clear a text field or set a number back to `0` through this endpoint.
* These are **always replaced** with what you send, so send their current values when you update: all true / false fields (except `StockTrans` and `StopBilling`), `Use_As_Cust_Supp_Both`, `GST_Reg_Type`, `MSME_Type`, `Final_Dest_Code` and the stock-transfer branch (`STBranchCode` / `STBranchName` – both empty removes it).
* These are **never changed** by an update: the account type, the party code, `StockTrans`, `StopBilling`, the general and balance-sheet groups.
* `Group_Name1`…`Group_Name8`, `AgentName`, `BranchName`, `Trans_Name`, `First_CityName`, `Second_CityName` and the extra fields are changed only when you fill them; empty keeps the current value. Changing `First_CityName` also changes the stored name.
* An update cannot give a party the stored name of another account: it fails with `Invalid Account Name` when that account was saved without a city, otherwise with a database error.

**Other things to know**

* Parties belong to the whole company; the request has no branch and no date.
* Party saves on your API site are processed **one at a time**.
* The whole save is all-or-nothing: if it fails, nothing is kept – including groups that would have been created.
* Extra fields (`ListCustomFields`) are saved only when extra fields for accounts are switched on in your Logic ERP setup. Otherwise they are checked but silently not saved.
* Dates: write them as `yyyy-MM-dd`. A value that is not a date is ignored, except `GST_Date`, which is then saved empty.
* **Other account types.** `Account_Type` accepts the short names of all Logic ERP account types: `AS` current assets, `BD` bad debts, `BK` bank, `CH` cash, `CT` creditors, `CU` customer, `DT` debtors, `EX` expenses, `FS` fixed assets, `IN` income, `IT` income tax, `LB` current liabilities, `MF` manufacturing, `OP` opening stock, `PL` profit & loss, `PR` capital, `PU` purchase, `SL` sale, `SU` supplier, `TD` trading. Only one `PL`, `TD` and `MF` account may exist. Accounts of these other types are only created, never updated; for them the GST fields are read from `BankDetails` (`Bank_Gst_No`, `Bank_Gst_State_Code`, `Bank_Gst_Date`), and `BankDetails` also holds a bank account's address, city, account number, IFSC and SWIFT code.

> **Known issue – `Opening_Balance` is not saved.** The opening balance is never written, whatever you send. Enter opening balances in Logic ERP.

### **Example request**

A new customer:

```json
{
  "Account_Name": "BALAJI FABRICS",
  "PrintAccountName": "Balaji Fabrics",
  "Account_Type": "CU",
  "User_Code": "C2051",
  "Group_Name1": "NORTH ZONE",
  "Group_Name2": "WHOLESALE",
  "Use_As_Cust_Supp_Both": 0,
  "Cust_Sup_Details": {
    "First_Add1": "22, Katra Jaimal Singh",
    "First_Add2": "Near Hall Bazar",
    "First_CityName": "AMRITSAR",
    "First_Pincode": "143001",
    "Mobile_No": "9876501234",
    "Email_Address": "accounts@balajifabrics.in",
    "Contact_Person": "Sunil Arora",
    "GST_No": "03AAKFB1234M1Z2",
    "GST_StateCode": "03",
    "GST_Date": "2019-07-01",
    "GST_Reg_Type": 1,
    "PAN_No": "AAKFB1234M",
    "AgentName": "MAHESH KUMAR",
    "Credit_Limit": 200000,
    "MSME_Type": "None"
  },
  "ListCustomFields": [
    { "FieldName": "Credit Days", "FieldValue_1": "30", "FieldValue_2": "" }
  ]
}
```

Updating the same customer (new mobile number; `GST_Reg_Type` and `MSME_Type` are sent again because an update replaces them):

```json
{
  "Account_Name": "BALAJI FABRICS",
  "Account_Type": "CU",
  "User_Code": "C2051",
  "Cust_Sup_Details": {
    "Mobile_No": "9876509999",
    "GST_No": "03AAKFB1234M1Z2",
    "GST_StateCode": "03",
    "GST_Date": "2019-07-01",
    "GST_Reg_Type": 1,
    "MSME_Type": "None"
  }
}
```

### **Test it**

Send a request to the Logic ERP **sandbox** (a test company) from this page: open the block below, enter the sandbox user name and password (ask your Logic ERP support team), change the request if you like, and press **Test it**. This really saves in the sandbox, so use test values like the example. The example creates (or, when sent again, updates) the sandbox's test supplier `APITESTS01`.

## Create or Update a Party

> Creates a customer or supplier (a party) in Logic ERP, with its address, contact, GST, agent and account-group details. If the party code you send already belongs to a customer or supplier, the same call updates that party instead. Other kinds of account (bank, expense, sale, purchase and so on) can also be created with this endpoint, but not updated.

```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":{"/SaveParty":{"post":{"tags":["Masters - Push"],"operationId":"SaveParty","summary":"Create or Update a Party","description":"Creates a customer or supplier (a party) in Logic ERP, with its address, contact, GST, agent and account-group details. If the party code you send already belongs to a customer or supplier, the same call updates that party instead. Other kinds of account (bank, expense, sale, purchase and so on) can also be created with this endpoint, but not updated.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"Account_Name":{"type":"string","description":"Party name, up to 100 characters (fewer when a city is given – see the rules). On an update the name is replaced by what you send."},"PrintAccountName":{"type":"string","description":"Name printed on documents, up to 200 characters. Logic ERP does not copy `Account_Name` into it when you leave it empty."},"Account_Type":{"type":"string","description":"`CU` = customer, `SU` = supplier. Other account types are listed under the rules. Upper/lower case does not matter; spaces around it are ignored."},"User_Code":{"type":"string","description":"The party code shown in Logic ERP (`User_Code` in Get Party Master), up to 20 characters. If a customer or supplier already has this code, that party is updated. Left empty, see \"How a party is matched\" below."},"Use_As_Cust_Supp_Both":{"type":"integer","description":"`1` = the party is also used as the other type (a customer that is also a supplier, or the reverse). Any other value = no."},"Cust_Sup_Details":{"type":"object","properties":{"First_Add1":{"type":"string","description":"First (main) address lines, up to 80 characters each."},"First_Pincode":{"type":"string","description":"PIN code of the first address, up to 6 characters."},"Mobile_No":{"type":"string","description":"Mobile number."},"Contact_Person":{"type":"string","description":"Contact person, up to 30 characters (`Contact_Name` in Get Party Master)."},"GST_Reg_Type":{"type":"integer","description":"`0` = unregistered, `1` = registered, `2` = composite. Send `1` together with a GSTIN – the default `0` marks the party unregistered even when `GST_No` is filled."},"MSME_Type":{"type":"string","description":"`None`, `Micro`, `Small` or `Medium` (`Madium` is also accepted); upper/lower case does not matter. Any other value, or `null`, saves \"none\" and clears `MSME_No`."}},"description":"Address, contact, GST and trading details. See the table below."}}}}}},"responses":{"200":{"description":"Always HTTP 200. Check Status and Message.","content":{"application/json":{"schema":{"type":"object","properties":{"AccountName":{"type":"string","description":"The name as stored, including the padded city part (for example `BALAJI FABRICS                -AMRITSAR`). For a party saved without a city it is the name followed by spaces up to 100 characters – trim it before you compare. With `Account with same name already exists!!` it holds the code of the existing party instead. Empty or `null` on other failures."},"AccountCode":{"type":"string","description":"The party code (`User_Code`) of the saved party – useful when Logic ERP numbered it for you. With `Account User Code already exists!!` and `Account with same name already exists!!` it repeats the code you sent (empty when you sent none)."},"Status":{"type":"boolean","description":"`true` when the party was saved."},"Message":{"type":"string","description":"`Success` when saved; otherwise the reason."},"LastSavedCode":{"type":"integer","description":"Logic ERP's internal party number (`ActCode` in Get Party Master). The same number is returned when a party is updated. `0` on failure."},"request_ID":{"type":"string","description":"As described in How Every API Call Works. `null` when the request was refused before saving started (the first five messages below)."}}}}}},"401":{"description":"No login was sent."}}}}}}
```

### **Response**

| Field           | Type         | Meaning                                                                                                                                                                                                                                                                                                                                                   |
| --------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AccountName`   | text         | The name as stored, including the padded city part (for example `BALAJI FABRICS -AMRITSAR`). For a party saved without a city it is the name followed by spaces up to 100 characters – trim it before you compare. With `Account with same name already exists!!` it holds the **code** of the existing party instead. Empty or `null` on other failures. |
| `AccountCode`   | text         | The party code (`User_Code`) of the saved party – useful when Logic ERP numbered it for you. With `Account User Code already exists!!` and `Account with same name already exists!!` it repeats the code you sent (empty when you sent none).                                                                                                             |
| `Status`        | true / false | `true` when the party was saved.                                                                                                                                                                                                                                                                                                                          |
| `Message`       | text         | `Success` when saved; otherwise the reason.                                                                                                                                                                                                                                                                                                               |
| `LastSavedCode` | number       | Logic ERP's internal party number (`ActCode` in Get Party Master). The same number is returned when a party is updated. `0` on failure.                                                                                                                                                                                                                   |
| `request_ID`    | text         | As described in How Every API Call Works. `null` when the request was refused before saving started (the first five messages below).                                                                                                                                                                                                                      |

### **Example response**

```json
{
  "AccountName": "BALAJI FABRICS                -AMRITSAR",
  "AccountCode": "C2051",
  "Status": true,
  "Message": "Success",
  "LastSavedCode": 1187,
  "request_ID": "3b9e0c47-58a2-4d7e-9f1a-6c2e8d41b0f5"
}
```

### **Messages you may see**

All with `Status: false`. Nothing is saved.

| Message                                                                                                                                                                                                                                                                                                                                                                                       | Meaning                                                                                                                                                   | What to do                                                                                                    |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `Account Name is Missing!!`                                                                                                                                                                                                                                                                                                                                                                   | `Account_Name` is empty or missing.                                                                                                                       | Send the party name.                                                                                          |
| `Account Type is Missing!!`                                                                                                                                                                                                                                                                                                                                                                   | `Account_Type` is empty or missing.                                                                                                                       | Send `CU` or `SU`.                                                                                            |
| `Invalid Account Type Selected!!`                                                                                                                                                                                                                                                                                                                                                             | `Account_Type` is not a Logic ERP account type.                                                                                                           | Send `CU` or `SU` (or another type from the list above).                                                      |
| `Account User Code already exists!!`                                                                                                                                                                                                                                                                                                                                                          | The code is already used by an account that is not a customer or supplier, or you sent an `Account_Type` other than `CU` / `SU`, so it cannot be updated. | For a party, send `CU` or `SU` with a customer's or supplier's code. For a new account, use a different code. |
| `Account with same name already exists!!`                                                                                                                                                                                                                                                                                                                                                     | A new party was asked for, but an account with this name and no city exists. `AccountName` holds that account's code.                                     | Update that party by sending its code, or use a different name.                                               |
| A message containing `Invalid First City Name`, `Invalid Second City Name`, `Invalid First State Name`, `Invalid Second State Name`, `Invalid First Country Name`, `Invalid Second Country Name`, `Invalid Agent Name`, `Invalid Branch Name`, `Invalid Buying Agent Name`, `Invalid Forwarding Agent Name`, `Invalid ST Branch Name`, `Invalid Transport Name` or `Invalid Bank City Name..` | The name you sent does not exist in Logic ERP.                                                                                                            | Correct the name, or ask your Logic ERP team to add it.                                                       |
| A message containing `Unable to found First Location Name...` or `Unable to found Second Location Name...`                                                                                                                                                                                                                                                                                    | The location does not exist under that city.                                                                                                              | Send the PIN code instead, or correct the location.                                                           |
| A message containing `Invalid Custom Field Name : …` (the name you sent) or `Invalid Custom Field Name..`                                                                                                                                                                                                                                                                                     | An extra field with this name does not exist for parties, or `FieldName` is empty.                                                                        | Use the names returned in `ListCustomFields` by Get Party Master.                                             |
| `Duplicate Custom Field Name : …` (the name you sent)                                                                                                                                                                                                                                                                                                                                         | The same extra field appears twice in `ListCustomFields`.                                                                                                 | Send each field once.                                                                                         |
| A message containing `Invalid Account Name`                                                                                                                                                                                                                                                                                                                                                   | An update would give the party the name of another account.                                                                                               | Use a different name.                                                                                         |
| A message containing `New Balance Sheet Group not found....`                                                                                                                                                                                                                                                                                                                                  | The default balance-sheet group for the account type is missing in Logic ERP.                                                                             | Ask your Logic ERP team.                                                                                      |
| A message containing `Multiple accounts of … cannot exist.` (the type)                                                                                                                                                                                                                                                                                                                        | A second profit & loss, trading or manufacturing account was asked for.                                                                                   | Do not create it.                                                                                             |
| A database error                                                                                                                                                                                                                                                                                                                                                                              | The name and city already belong to another party, or a text value is longer than Logic ERP allows.                                                       | Correct the request and send it again.                                                                        |
| `Unable to save Account. Please Check...`                                                                                                                                                                                                                                                                                                                                                     | Logic ERP stopped the save internally. Nothing was saved.                                                                                                 | Check the party in Logic ERP, or ask your Logic ERP 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/masters/push/create-or-update-a-party.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.
