Communications
Create a mapped email template
/a/EmailTemplate_createData
Insert an email template through the generic camelCase field-map pipeline.
When to use this endpoint
Use EmailTemplate_createData only when a mapped CRM2-style workflow needs to create several stored fields in one call. The settings UI uses EmailTemplate_new, which supplies a body token, checks duplicate names, and applies the tenant default sender.
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 |
|---|---|---|---|
name | String | No | Stored template name. The generic map does not require a name, trim it, or check for duplicates. |
body | String | No | Stored HTML/text body. It is not sanitized and inline data images are not uploaded by this route. |
archived, isDefault, type | Integer-compatible | No | Stored state/category fields. No allowed range or single-default invariant is enforced. |
fromEmail, subject | String | No | Mapped sender and subject. Sender syntax and the schema’s subject length are not prevalidated by the endpoint. |
meta | String | No | Raw metadata text. Prefer metaFormID for the mapped form key rather than replacing all metadata. |
metaFormID | String | No | Writes meta.form_id in JSON while preserving any metadata supplied in the same conversion pass. The value remains text. |
Example request
$template = FM_api('EmailTemplate_createData', [
'name' => 'Service completion email',
'body' => '{{BODY}}',
'fromEmail' => 'service@example.test',
'subject' => 'Your service report',
'type' => '1',
]);
Example response
{
"ok": 1,
"id": 152004
}
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 parameters."} | No recognized mapped field produces a value for the insert. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
idis in the field map but is ignored on create. Unknown request keys are ignored.- Omitted fields use database defaults or nulls; the generic map defines no required fields or application defaults.
- There is no pagination and no tenant setting is consulted.
Side effects
- Inserts one template row, invalidates the email-template cache, and writes generic Core history for supplied mapped fields.
See it in Fieldmotion
CRM1
No direct CRM1 production caller was found.
CRM2
No direct CRM2 production caller was found; the settings screen uses dedicated create/copy/save calls.
Related endpoints
EmailTemplate_newis the settings-oriented draft creator.EmailTemplate_updateDataapplies the same map to an existing row.