When to use this endpoint

CRM2 bulk deletion calls this endpoint one header at a time. It is not the guarded CRM1 receipt-and-lines deletion workflow.

Authentication and permissions

Authenticate with signed API-key fields or a logged-in CRM session. Session CSRF, account-active and IP restrictions still apply. These handlers add no receipt-specific page, finance, department or record-owner permission check.

Records are scoped to the authenticated tenant. CRM1 displays Goods Received with employer feature bit 262144; CRM2 checks features2.goodsReceivedNotes. Those screen gates are not enforced by these handlers. Mobile receipt routes run separately through the mobile intermediary and have different permission and ownership checks.

Mapped handlers require both a logged-in user and a tenant context before loading the tenant field map.

Parameters

ParameterTypeRequiredDescription
idInteger/native arrayOne mapped filter requiredScalar integer equality or native IN list. Empty numeric arrays match nothing; omitted id is permitted when another physical mapped filter selects rows.
supplierID, poID, createdBy, targetID, targetType, jobIDInteger/native arrayNoPhysical mapped numeric filters, ANDed with other supplied filters. Does not validate related record existence.
cDate, lastEdited, notes, suppInvoice, suppDNN, purchaseOrders, customValuesScalar/native arrayNoExact quoted equality/IN filters, not the substring or lowercase detail-query contract. Composite target has no physical id and is skipped; use targetID/targetType.

Example request

FM_api('GoodReceived_delete', ['id'=>'531']);

Example response

{"ok":1}

Errors and unusual responses

ResponseCondition
{"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 filter"}No recognized physical mapped filter.
{"error":"Could not read records for deletion. Please retry."}Pre-delete read failed.
{"error":"Could not delete records. Please retry."}Primary deletion failed.
{"error":"Could not record deletion audit."}Header deletion already happened, but audit persistence failed.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • Shared mapped filters use equality/IN; numeric scalar filters use intval and quoted filters preserve exact input rather than detail-reader lowercase matching. At least one filter is required, but a broad filter can delete multiple headers.
  • The read, physical delete and subsequent deletion/history audit are not one transaction. No match returns ok. There is no deleted/ddate marker on retained rows because headers are not retained.

Side effects

  • Physically deletes matched purchases_in rows, invalidates that table cache, writes deletion snapshots through apiDeleteLogMany and a grouped Core_log history entry. Leaves receipt lines, inventory and returns untouched.

See it in Fieldmotion

CRM1

No direct CRM1 caller was found. CRM1 uses the legacy GoodsReceived_newNote, GoodsReceivedEntries_get and GoodsReceivedNote_* workflow instead.

CRM2

In CRM2 Goods Received select receipts and use bulk Delete; inspect GoodReceived_delete requests. The caller sends each selected id separately.

Related endpoints