Templates define the content of your notifications. Each template belongs to a service and can include personalized fields that are filled in when you send a notification.
# From app/models.py - Template modelclass Template: id: UUID # Unique identifier name: str # Template name (for reference) template_type: str # "email", "sms", or "letter" content: str # Message body subject: str # Email/letter subject (required for email & letter) service_id: UUID # Parent service created_by_id: UUID # Creator version: int # Version number (starts at 0) archived: bool # Soft deleted? hidden: bool # Hidden from UI?
Email Template
SMS Template
Letter Template
{ "name": "Password reset", "template_type": "email", "subject": "Reset your password", "content": "Hi ((name)),\n\nClick this link to reset: ((reset_url))", "has_unsubscribe_link": false}
{ "name": "Appointment reminder", "template_type": "sms", "content": "Hi ((name)), your appointment is on ((date)) at ((time))." # SMS templates don't have a subject}
{ "name": "Tax reminder letter", "template_type": "letter", "subject": "Tax Payment Due", "content": "Dear ((title)) ((surname)),\n\nYour tax payment of £((amount)) is due.", "postage": "second", "letter_languages": "english" # or "welsh_then_english"}
Notify doesn’t support conditional logic in templates. Handle conditions in your application:
# Instead of conditionals in template, use different templatesif user.premium: template_id = PREMIUM_WELCOME_TEMPLATEelse: template_id = STANDARD_WELCOME_TEMPLATE
Templates are versioned - every change creates a new version:
1
Initial Creation
Template created with version = 0
2
Updates
Each edit increments version: 0 → 1 → 2 → 3…
3
Notifications Reference Version
Each notification stores the template version used, ensuring content doesn’t change retroactively
# From app/models.py - TemplateHistory tracks all versionsclass TemplateHistory: id: UUID # Same as original template version: int # Increments with each edit content: str # Content at this version subject: str updated_at: datetime created_by_id: UUID # Who made this version
You cannot delete a version once created. Notifications reference specific versions to maintain audit trail.
# From app/models.py - TemplateEmailFileclass TemplateEmailFile: filename: str # File name link_text: str # Optional link text retention_period: int # Weeks to retain (default: 1) validate_users_email: bool # Verify recipient email before download template_id: UUID template_version: int
Attachments are uploaded separately and linked to template versions.
# From app/constants.pyPOSTAGE_TYPES = [ "first", # First class (1-2 days) "second", # Second class (2-3 days) "economy", # Economy (3-5 days) "europe", # European international "rest-of-world" # Worldwide international]
# From app/models.pyclass TemplateFolder: id: UUID service_id: UUID name: str parent_id: UUID # For nested folders # Folders can have permissions users_with_permission: List[UUID] # User IDs who can access