Accounts and tax types
Synchronize all tax types
/a/AccountCategory_updateData
Synchronize the tenant’s complete tax-type list to a CRM2 Finance-page snapshot.
When to use this endpoint
Use AccountCategory_updateData only after loading and submitting every Tax Type shown by CRM2. Missing existing IDs are permanently deleted.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler calls the normal login guard but performs no additional Finance-page, client-admin, role, create, edit, or delete permission check.
All reads and writes use the authenticated tenant. CRM1 and CRM2 decide whether to show finance controls, but these handlers do not repeat those client-side checks.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
taxTypes | Nonempty native array of objects | Yes | Authoritative complete category list. |
taxTypes[].taxTypeID | Integer-compatible | Yes | Existing positive ID to retain/update, or 0 to insert a new category. |
taxTypes[].taxTypeName | String | No | Trimmed name, maximum 64 characters. Omission becomes an empty name. |
taxTypes[].taxTypeRate | Numeric-compatible | No | Converted with floatval(); omission becomes 0. |
taxTypes[].taxTypeGroup | Integer-compatible | No | Group ID, defaulting to 0. Group existence is not validated. |
Example request
$result = FM_api('AccountCategory_updateData', [
'taxTypes' => [
[
'taxTypeID' => 271006,
'taxTypeName' => 'Standard VAT',
'taxTypeRate' => '20',
'taxTypeGroup' => 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: tax types"} | The outer value is absent, not a native array, empty, or contains a non-object/non-array element. |
{"error":"parameter too long: taxTypeName. max length 64 characters"} | Any submitted name exceeds 64 characters; this validation occurs before deletion. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Deletions occur before creates and updates. Each submitted ID
0inserts; each positive ID is overwritten without checking that it exists. - Duplicate names and invalid group IDs are accepted.
- The response contains no created IDs, counts, or per-row warnings.
Side effects
- Deletes account/category links for removed tax types and advances
last_editedon the affected accounts. - Writes app-sync deletion rows under the legacy key
tax_ratefor removed IDs. - Creates or updates category rows with current
last_editedtimestamps, but does not repair category IDs stored in invoices, quotes, customers, or other objects.
See it in Fieldmotion
CRM1
CRM1 does not call this snapshot route; it saves and deletes category rows individually.
CRM2
Open Settings → Finance. CRM2 loads the three finance tables and saves them as complete snapshots; filter browser developer tools for the exact function name. Save sends every nonblank Tax Type row here after the account snapshot succeeds.
Related endpoints
Accounts_getCategoriessupplies the initial complete list.AccountCategoryGroup_updateDatasaves the following Tax Group snapshot.