# DeleteNotificationTemplate

## Permission Scope

template

## Overview

deleteNotificationTemplate hard-deletes a NotificationTemplate row identified by its `(eventType, channelId, locale)` triple (or by id). After deletion, subsequent dispatcher renders for that triple fall back to the configured default-locale row when one exists; if the deleted row **was** the default-locale row, the dispatcher fails with `TEMPLATE_NOT_FOUND` for the affected `(recipient, channel)` pairs. Already-persisted Notifications are unaffected because rendered content is not stored on this row. Hard deletion is intentional — there is no soft-delete or archival, since template rows are operator-edited copy and the audit story for content authoring lives at the application/admin layer.

## Business Rules

- `templateId` (or the `(eventType, channelId, locale)` triple) is required
- A NotificationTemplate row must exist for the supplied identifier
- Deletion is hard; no soft-delete or tombstone is written
- Already-persisted Notification rows are not affected

## Process Flow

```mermaid
flowchart TD
    A[Receive delete template request] --> B{NotificationTemplate exists?}
    B -->|No| C[Return TEMPLATE_NOT_FOUND]
    B -->|Yes| D[Hard-delete the row]
    D --> E[Return deletion confirmation]
    E --> F[Subsequent renders for that triple fall back to default-locale row, or fail TEMPLATE_NOT_FOUND if absent]
```

## External Dependencies

- None (operates on module-owned NotificationTemplate only)

## Error Scenarios

- **TEMPLATE_NOT_FOUND**: No NotificationTemplate row matches the supplied identifier

## Test Cases

- hard-deletes the NotificationTemplate row identified by id
- returns TEMPLATE_NOT_FOUND when the identifier does not match any row
- after deletion, a render for the same triple falls back to the default-locale row when one exists
- after deletion of the default-locale row, a render for the triple fails with TEMPLATE_NOT_FOUND
- already-persisted Notifications retain their rendered content and are not affected by the deletion
