Contracts
Soft-delete multiple contracts
/a/Contracts_delete
Soft-delete a submitted batch of contracts through the single-contract deletion path.
When to use this endpoint
Use Contracts_delete only for a legacy bulk-delete client that already has the exact contract IDs and needs the permissions-bit guard.
CRM2 currently performs bulk deletion as a sequence of Contract_delete calls instead.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session.
After authentication, bit 1 must be present in userdata.permissions. The endpoint performs no separate page-permission check.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ids | JSON array string | Yes | Nonempty array of contract IDs. A flat array of positive integers is the supported form; individual values are not validated by the wrapper before dispatch. |
Example request
$result = FM_api('Contracts_delete', [
'ids' => json_encode([720, 721]),
]);
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 parameter: ids"} | The key is missing or false-like, including an empty string. |
{"error":"invalid parameter: ids"} | The value does not decode to a nonempty array. |
{"error":"You do not have the correct permissions to delete a contract.","permissions":...} | Permission bit 1 is not set; the response also exposes the caller’s numeric permission mask. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Each array item is passed to the single-delete route independently. There is no transaction, deduplication, ordering guarantee, or maximum batch size.
- A nested array is not a supported ID shape; PHP integer conversion can turn a nonempty array into
1, so always send a flat numeric list. - Related jobs, files, links, and orders are not deleted.
Side effects
- Every valid item receives the single-delete side effects: soft-delete flags, type-104 expiry-worker cancellation, delete-poll record, and audit entry.
See it in Fieldmotion
CRM1
CRM1’s import/history tooling can call Contracts_delete for selected rows; the normal Contracts page uses one Contract_delete request.
CRM2
The CRM2 Contracts module currently loops over selected IDs and calls Contract_delete for each, so this bulk wrapper is not visible in its Network panel.
Related endpoints
Contract_deletedefines the actual per-item behavior.Contract_restorerestores one deleted contract through Admin.