Reusable document and recurrence templates
Delete a reusable template
/a/Template_delete
Remove a reusable preset from the tenant’s template choices
When to use this endpoint
Use the trash action for an unwanted reusable preset. The handler removes the preset only; it does not delete jobs, documents or recurrence schedules that previously copied its values.
Authentication and permissions
Authenticate with signed API-key fields or a logged-in CRM session. Template_get, Template_new, Template_setObj and Templates_get require an authenticated tenant context; Template_delete and both table handlers also call the login guard. There is no handler-level administrator, page, role, creator or ownership check.
Templates are shared within the authenticated tenant, not private to created_by. There is no user, department, feature-setting or active/deleted filter. The dispatcher also applies its normal account, authentication and team-access checks; the shared table predicate adds no template-specific row restriction.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer | Yes | Presence is required (null counts as missing), then integer-converted. Unlike Template_get, zero, negative and nonnumeric scalar values are not rejected after conversion. Supply a known positive scalar template ID. |
Example request
$result = FM_api('Template_delete', ['id' => '1042']);
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"} | No non-null id parameter. |
{"error":"Unable to delete template"} | The DELETE fails or throws. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- No existence check or affected-row count is returned. Repeating a delete or supplying a nonexistent ID still returns ok.
- A failed or throwing DELETE returns an error rather than ok. There is still no type, creator or default-template dependency check.
- No direct mobile-app or m-service caller for this template family was found in the source search. The CRM2 widget’s payload is client-defined; storing it does not validate that another document endpoint will accept every field.
Side effects
- Executes a tenant templates DELETE and requests templates cache invalidation. No cascading document mutation, email, event or scheduled work is invoked.
See it in Fieldmotion
CRM1
In CRM1 Settings → Job settings, delete a recurrence template and filter requests for Template_delete. The caller reloads the recurrence-template table after the reply.
CRM2
CRM2’s widgetTemplate.js loads Templates_get with JSON-encoded id/name/obj fields, parses obj locally, and uses Template_new, Template_setObj and Template_delete from its save/trash controls. Observe these requests in a create dialog whose configured layout includes the Template widget, such as a quote or invoice. The widget is layout-dependent, not present on every screen. The recurrence editor also configures Template_delete for its template picker.
Related endpoints
- Templates_get supplies the selectable presets for one type.
- Template_get reads one stored preset without applying it.
- Template_new creates a separate preset; Template_setObj replaces an existing preset’s payload.
- Template_delete removes the reusable preset, not documents previously created from it.