Communications
Create an email-template draft
/a/EmailTemplate_new
Create a minimally initialized email template for subsequent editing.
When to use this endpoint
Use EmailTemplate_new when the settings screen creates a named draft and then opens it in the full editor. Use EmailTemplate_createData only for the lower-level mapped insert contract.
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 | Yes | Template name after trimming. It must be nonblank and not match another stored template name under the tenant database collation. Archived templates participate in the duplicate check. |
Example request
$template = FM_api('EmailTemplate_new', [
'name' => 'Service completion email',
]);
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 parameter: name"} | name is absent. This check occurs before the handler’s login check. |
{"error":"no name parameter"} | The supplied name is blank after trimming. |
{"error":"an email template of that name already exists"} | Any active or archived template has the same name under the database collation. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- The body starts as the literal token
{{BODY}};archived,is_default,subject, andtypeuse their database defaults. - If tenant setting
default-from-emailcontains a nonblank value, it becomesfrom_email. Otherwise that column remains null. - The route does not validate the tenant’s default sender address.
Side effects
- Inserts one template row. It does not write generic field history and explicitly bypasses normal cache/count options in the database helper.
See it in Fieldmotion
CRM1
Open Settings → Email Templates in CRM1 and filter browser developer tools for the endpoint name. Choose Create, enter the name, and observe EmailTemplate_new before the new editor opens.
CRM2
No direct production CRM2 caller was found; its current template screen loads existing templates and offers copy/edit/delete actions.
Related endpoints
EmailTemplate_savecompletes the new draft.EmailTemplate_copystarts from an existing body and metadata.