When to use this endpoint

Use this from an invoice-template settings UI after an administrator chooses the layout type.

Authentication and permissions

The request must authenticate with signed API-key fields or a logged-in CRM session and is scoped to that tenant.

The authenticated user must satisfy Core_isClientAdmin().

Parameters

ParameterTypeRequiredDescription
typeInteger-compatibleYesStored as an integer without range validation.

Example request

$result = FM_api('Invoices_templateTypeSet', ['type' => '0']);

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 parameter: type"}Type is absent; present blank or nonnumeric values are accepted as zero.
{"error":"you are not an admin"}Caller is not a tenant administrator.

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

Behaviour and edge cases

  • Only parameter presence is validated, then PHP integer coercion is used.
  • The response does not echo the stored type.

Side effects

  • Replaces the tenant setting invoice-type.

See it in Fieldmotion

CRM1

The invoice Word-template settings page writes this selection.

CRM2

No direct CRM2 caller was found.

Related endpoints