When to use this endpoint

Use this when correcting the document date; historical customer names and addresses are recalculated as of the new date.

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

ParameterTypeRequiredDescription
idPositive integerYesActive invoice ID.
valStringYesValue written to cdate. The handler does not validate a date format.

Example request

$result = FM_api('Invoice_setDate', ['id' => 981, 'val' => '2026-10-02']);

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":"invoice does not exist"}The invoice is absent or deleted.
{"error":"cannot edit invoices that are marked Paid"}The located invoice is Paid.

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

Behaviour and edge cases

  • Changing the invoice date does not automatically recalculate its due date.

Side effects

  • Updates cdate, last_edited, and edited_uuid, refreshes the historical target snapshot, and fires Invoice_edit.

See it in Fieldmotion

CRM1

The main invoice editor calls this route when the invoice date changes.

CRM2

No direct production CRM2 caller was found for this route.

Related endpoints