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

ParameterTypeRequiredDescription
nameStringYesTemplate 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

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 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, and type use their database defaults.
  • If tenant setting default-from-email contains a nonblank value, it becomes from_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