Invoices
Unlink a job from an invoice
POST
/a/Invoice_unlinkJob
Delete one direct or ancillary invoice-to-job relation and decrement the invoice link-count metadata.
When to use this endpoint
Use this from a linked-jobs table after the user confirms removing the relationship. It does not delete either object.
Authentication and permissions
The request must use a logged-in CRM session or valid signed API credentials and is scoped to that tenant.
Users whose legacy crm_access mask contains bit 64 receive {"error":"no permission to access api"}. No record-owner check is made.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Positive integer | Yes | Active invoice ID. |
job_id | Positive integer | Yes | Active job ID whose relation is removed. |
type_num | Integer | Yes | Must be 3 for a direct link or 4 for an ancillary link. |
Example request
$result = FM_api('Invoice_unlinkJob', ['id' => 981, 'job_id' => 2204, 'type_num' => 4]);
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":"invalid or missing parameter: type_num"} | The relation type is not 3 or 4. |
{"error":"invoice does not exist"} | The invoice is absent or deleted. |
{"error":"job does not exist"} | The job is absent or deleted. |
{"error":"invoice job link does not exist"} | The exact invoice, job, and relation-type link is absent. |
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 exact relation is deleted, then only the supplied invoice’s corresponding link-count metadata is recalculated. The misspelled
jobs_linked_ancilliarykey is the stored compatibility name.
Side effects
- Deletes the selected
manymanyrow, refreshes invoice link-count metadata, advances invoice edit metadata, and firesInvoice_edit.
See it in Fieldmotion
CRM1
No direct production CRM1 caller was found.
CRM2
The linked-job invoice widget calls this route for direct and ancillary unlink actions.
Related endpoints
Invoices_getDataTablesupplies paginated CRM2 invoice rows and IDs.Invoices_getDTis the CRM1 invoice-list counterpart.