Communications
Set an email-template form ID
/a/EmailTemplate_setFormId
Set the form ID stored in an email template’s metadata.
When to use this endpoint
Use EmailTemplate_setFormId when only the template-to-form metadata association must change without replacing the body or other editor fields.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler requires login and performs no additional page or role-permission check.
The read or write is limited to the authenticated tenant. Notice endpoints that say “current user” use the authenticated session user ID within that tenant.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer-compatible | Yes | Template ID. It must convert to an integer of at least 1. |
form_id | Integer-compatible | No | Form ID stored at meta.form_id. Missing, blank, or nonnumeric input becomes 0; the referenced form is not validated. |
Example request
$result = FM_api('EmailTemplate_setFormId', [
'id' => '152004',
'form_id' => '81',
]);
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: id"} | id is absent or converts below 1. This validation occurs before the handler login check. |
{"error":"email template does not exist"} | No template has the numeric ID. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Other metadata keys are preserved. If the integer-converted form ID is unchanged, no database update is issued and success is still returned.
- The endpoint does not require template
type=7, check archive state, or verify that the form exists. - Legacy blank or missing metadata is treated as an empty structure before the form key is assigned.
Side effects
- Updates only template metadata. It does not write generic history or explicitly invalidate cache.
See it in Fieldmotion
CRM1
No direct CRM1 production caller was found; CRM1’s full editor sends form_id to EmailTemplate_save.
CRM2
No direct CRM2 production caller was found; CRM2’s full editor also uses EmailTemplate_save.
Related endpoints
EmailTemplate_savestores a form ID only when template type is7and replaces the metadata object.EmailTemplate_updateFieldexposes the same nested key asmetaFormID.