Asset tables
Create or update an Asset Table row
/a/AssetTable_setRow
Create a new Asset Table row or replace the JSON data on an existing row.
When to use this endpoint
Use AssetTable_setRow when the interactive Asset Tables editor saves one row. Send id=0 to add; send a positive row ID to update.
Authentication and permissions
The request must establish an authenticated tenant through signed API-key fields or a CRM session. The handler checks tenant context but performs no page, role, or feature-permission check.
All writes use the authenticated tenant table.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Existing row ID, or exact 0 to insert. Negative values are rejected. |
aid | Integer string | Yes | Positive asset ID. Required for both paths, but only stored on insert; the update path does not verify or change it. |
tid | Integer string | Yes | Positive table ID. Required for both paths, but only stored on insert; the update path does not verify or change it. |
row | JSON value string | Yes | Replacement data. It must decode to a truthy PHP value. Objects, including {}, nonempty arrays, nonzero numbers, and most nonempty strings are accepted; [], 0, false, null, empty strings, and string "0" are rejected. |
Example request
$result = FM_api('AssetTable_setRow', [
'id' => '0',
'aid' => '418',
'tid' => '1700000000123',
'row' => json_encode(['1' => '8.2', '2' => 'passed']),
]);
Example response
{
"ok": 92
}
ok is the inserted ID for a create or the supplied row ID for an update.
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 negative. |
{"error":"missing or invalid parameter: aid"} | aid is absent or not positive. |
{"error":"missing or invalid parameter: tid"} | tid is absent or not positive. |
{"error":"missing or invalid parameter: row"} | row is absent, malformed JSON, or decodes to a falsey value. |
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 JSON string is stored as supplied rather than normalized. Configured field IDs and types are not checked.
- Updating a missing ID still returns that ID as
ok; database affected-row counts are not inspected.
Side effects
- Inserts set both creation and edit datetimes; updates refresh only
last_edited. The Asset Table cache is invalidated, with no activity audit.
See it in Fieldmotion
CRM1
Open an asset’s Tables tab, choose Add Row or click a row, save, and inspect AssetTable_setRow.
CRM2
Open an asset table and use Add Row or Edit. Both the embedded widget and full Tables module call AssetTable_setRow.
Related endpoints
AssetTable_deleteRowremoves one row using all three IDs.AssetTable_importappends many rows.