Stock items and catalogue maintenance
Delete a stock ID interval
/a/Stock_deleteByIDs
Soft-delete catalogue items within an inclusive numeric ID interval.
When to use this endpoint
Supply the literal start-end string; this is not a JSON list of selected IDs. It is restricted to the main account user.
Authentication and permissions
Authenticate with a signed API key or a logged-in CRM session on the account’s routed host. API keys act as their owner; session calls require dispatcher CSRF protection where configured. IDs address the authenticated tenant.
Requires tenant database context and equality of logged-in user ID and tenant account ID; no CRM2 role replaces this owner check.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ids | String | Yes | Exactly digits-dash-digits, for example 18-25. No spaces, JSON list, explicit positivity or start<=end validation. |
Example request
$result = FM_api('Stock_deleteByIDs', ['ids'=>'18-25']);
Example response
{
"ok": 1,
"deleted": 8
}
Application errors can use HTTP 200. Inspect error/warning fields; database numeric values can be strings unless this handler explicitly converts them.
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":"only the main account user can delete by IDs"} | Actor differs from the tenant account owner. |
{"error":"IDs not in 123-456 format"} | The literal range format is invalid. |
{"error":"no stock in the database has IDs in that range"} | The inclusive interval has no saved rows. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Counts and logs all rows in the inclusive range, including already-deleted items; the UPDATE changes only currently undeleted rows. deleted therefore can exceed the number newly deleted.
- Does not require items to be archived and does not clear the per-item accounting mappings/upload queue like Stock_delete. Reversed intervals simply have no matches.
- Writes deleted=1,ddate=Unix now,last_edited=SQL now, with deletion-log records before the bulk UPDATE. No transaction/check of these writes is present.
Side effects
- Stock tombstones, deletion log and stock-cache invalidation.
See it in Fieldmotion
CRM1
In CRM1 Stock, main-account users can open Delete by IDs and submit a range such as 18-25.
CRM2
Source search found no direct CRM2 interval-deletion caller. The Stocks module deletes selected archived items individually.
Related endpoints
Stock_deleteByDate— Soft-delete the tenant’s undeleted stock rows whose creation datetime begins with a date.Stock_delete— Soft-delete one catalogue item and record its tenant deletion event.Stock_restore— Restore one stock tombstone through an Admin-console authenticated session.