Accounts and tax types
Create or overwrite a tax type
/a/AccountCategory_save
Create or overwrite one tax type through CRM1’s Finance table.
When to use this endpoint
Use AccountCategory_save for CRM1’s legacy row save: ID 0 inserts, while a positive ID updates.
Authentication and permissions
The request must establish an authenticated tenant context with signed API credentials or a logged-in CRM session. This legacy handler checks for the tenant database prefix rather than calling the normal login guard.
It performs no additional Finance-page, client-admin, role, create, edit, or delete permission check.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer-compatible | Yes | 0 creates a row; a positive value updates that ID. Negative values are rejected. |
name | String | Yes | Stored without trimming. Presence is required, but an empty string is accepted and no 64-character application limit is checked. |
tax_rate | Numeric-compatible | Yes | Converted with floatval(). |
group_id | Integer-compatible | Yes | Converted to an integer; group existence is not checked. |
Example request
$result = FM_api('AccountCategory_save', [
'id' => 271006,
'name' => 'Standard VAT',
'tax_rate' => '20',
'group_id' => 151003,
]);
Example response
{"ok":1}
Errors and unusual responses
| Response | Condition |
|---|---|
{"error":"not logged in"} | No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs. |
{"error":"missing or invalid parameter: id"} | The ID is absent or negative. |
{"error":"missing or invalid parameter: name"} | The name parameter is absent. |
{"error":"missing or invalid parameter: tax_rate"} | The tax-rate parameter is absent. |
{"error":"missing or invalid parameter: group_id"} | The group parameter is absent. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Create mode returns no new ID, only
{"ok":1}. - Update mode overwrites all three editable columns. An unknown positive ID is a silent no-op that returns success.
- Duplicate names are allowed and the referenced group is not validated.
Side effects
- Create mode sets
cdateandlast_edited; update mode advanceslast_edited. Both clear the category cache.
See it in Fieldmotion
CRM1
Open Settings → Finance. CRM1 loads and edits the Chart of Accounts, Tax Types, and Tax Groups from this endpoint family; filter browser developer tools for the exact function name. Editing an existing Tax Type row, or completing the blank row, calls AccountCategory_save.
CRM2
CRM2 does not call this route; it uses the create modal and the full-list AccountCategory_updateData save.
Related endpoints
AccountCategory_newvalidates a nonblank name and returns the new ID.AccountCategory_deletepermanently removes a category.