Delete a template

Search Documentation

Search across all developer documentation

entities

Delete a template

DELETE /v1/templates/{slug}
Auth required api.templates.manage

Deletes a managed template and its version history, and removes it from the org's SES account on a best-effort basis.

A template something live still sends is refused with 409 conflict, and the dependents are named in referenced_by as {kind, key, name}: a workflow that is not archived and contains a send of this template, or a broadcast that pins it and has not gone out yet (draft, scheduled or failed). Both would otherwise fail later and somewhere else — the workflow mid-journey, one contact at a time; the broadcast at its scheduled send. Repoint or remove the dependent, then retry.

The layout that is the org's default layout cannot be deleted, so there is always one to start from: it is refused with 422 and validation_code: default_layout_not_deletable. Make another layout, or the built-in one, the default first.

Path parameters

slug string required

Template name (e.g. welcome).

Responses

Errors follow the RFC 7807 problem format — see the error reference.

204 Template deleted (no content)
401 Missing, malformed, or unknown API key application/problem+json
403 Either the credential lacks the required scope (code: invalid_scope), or it is bound to the test environment and this operation is irreversible (code: test_environment_forbidden). Branch on code: the first is fixed by granting the scope, the second only by using a live credential. See the "Live and test credentials" section of the API description. application/problem+json
404 Resource not found application/problem+json
409 The write was refused by a state rule. Three cases, told apart by the extension members on the Problem: a stale expected_content_hash carries the row's current content_hash; a delete blocked by a live dependent carries referenced_by. application/problem+json
422 A query parameter, path value or body field failed validation. The body is a validation_failed Problem. When the refusal is about a reference — a segment key, template slug, topic or attribute name the organization does not have — it additionally carries validation_code, field, line/column, missing, candidates and next_step, so a client can correct the call without a second round of guessing. See ValidationProblem. application/problem+json
429 Per-org rate limit exceeded application/problem+json
500 Unexpected server-side failure. The code is internal_error. The request_id field can be quoted to SendOps support to investigate. application/problem+json