Purchase orders
Save the legacy template type setting
/a/PurchaseOrders_templateTypeSet
Store an integer-converted po-type account setting.
When to use this endpoint
Use only for an integration that still relies on the legacy po-type setting. It does not select or modify the modern order header’s form_id.
Authentication and permissions
Authenticate with signed API-key fields or a logged-in CRM session. Session requests use dispatcher CSRF protection when configured. API keys use their owner’s identity.
Requires client-administrator access. Non-administrators receive "you are not an admin"; this is an account-wide setting, not a user/order preference.
The dispatcher also requires Purchase Order View and Edit. The setting write is checked and audited in the tenant transaction.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
type | Integer-compatible | Yes | Presence is required; intval is stored, with no allowlist or range check. Nonnumeric text becomes 0; the handler does not define labels for the resulting codes. |
Example request
$result = FM_api('PurchaseOrders_templateTypeSet', ['type'=>'0']);
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 or invalid parameter: type"} | type is absent/null. |
{"error": "you are not an admin"} | The authenticated user is not a client 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
- Requires client administrator plus Purchase Order View/Edit. Writes are checked under the tenant-owner transaction, with audit history, Unix cdate and cache invalidation after commit. A failed write returns an error; an unchanged value returns ok without a new audit.
Side effects
- Replaces the tenant template setting atomically with audit history and cache invalidation. Does not modify orders, render a document or send email.
See it in Fieldmotion
CRM1
No direct CRM1 literal caller was found in the searched client source.
CRM2
No direct CRM2 literal caller was found in the searched client source.
Related endpoints
PurchaseOrder_getPdf— Render the current order document from its selected form.PurchaseOrder_setForm— Select the modern type-5 order form.