Customers
Set a customer account number
/a/Customer_setAccountNumber
Replace or clear one customer account number without applying uniqueness or format rules.
When to use this endpoint
Use Customer_setAccountNumber for a focused change after an accounting or customer-management workflow has identified the Fieldmotion customer ID.
This is not an account-number lookup or upsert. Use Customer_getByAccountNumber to resolve an existing number before deciding which record to change.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler performs no additional page or role-permission check.
The lookup and any write use the authenticated tenant; an ID from another tenant cannot be addressed through this call.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Customer to update. It must convert to an integer of at least 1. |
val | String | Yes | New account number. It is trimmed; a present blank value clears the field. The handler imposes no length, format, or uniqueness check. |
Example request
$result = FM_api('Customer_setAccountNumber', [
'id' => '1088',
'val' => 'NW-1088',
]);
Example response
{
"ok": 1
}
The same response is returned when the requested value already matches, but that path performs no write or other side effect.
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"} | id is absent or does not convert to a positive integer. |
{"error":"missing or invalid parameter: val"} | val was omitted; a present blank value is valid. |
{"error":"customer does not exist"} | No customer row with that ID exists in the authenticated tenant. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- The lookup does not filter by
deletedor active state, so inactive and soft-deleted customer rows can be changed. - Comparison and storage use the trimmed value. Two customers can therefore be assigned the same account number.
- A no-change request returns before timestamps, cache, audit logging, or events are touched.
- This is a single-record mutation; it provides no list filtering or pagination.
Side effects
- A real change updates
account_number,last_edited, andedited_uuid, and invalidates the customer cache. - It writes a customer audit-log entry and fires
Customer_edit. It does not contact an accounting system.
See it in Fieldmotion
CRM1
Open a customer in the legacy edit popup, change Account Number, and filter Network requests for Customer_setAccountNumber. The field saves immediately.
CRM2
No direct production CRM2 caller was found. CRM2 saves customer fields through its layout-driven update contract rather than this focused setter.
Related endpoints
Customer_getByAccountNumberresolves a non-deleted customer from an exact account number.Customer_getretrieves the record after the change.