MATIH Platform is in active MVP development. Documentation reflects current implementation status.
8. Platform Services
Templates

Templates

The Template system provides reusable notification templates with variable substitution, HTML support, and localization. The TemplateController at /api/v1/templates manages template CRUD operations and live preview rendering.


Create a Template

Endpoint: POST /api/v1/templates

curl -X POST http://localhost:8085/api/v1/templates \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -d '{
    "tenantId": "550e8400-e29b-41d4-a716-446655440000",
    "templateKey": "welcome-email",
    "name": "Welcome Email",
    "channel": "EMAIL",
    "subject": "Welcome to MATIH, {{userName}}!",
    "bodyTemplate": "Hi {{userName}},\n\nWelcome to the MATIH platform. Your dashboard is ready at {{dashboardUrl}}.\n\nYou have {{trialDays}} days remaining in your trial.",
    "htmlTemplate": "<h1>Welcome, {{userName}}!</h1><p>Your dashboard is ready at <a href=\"{{dashboardUrl}}\">{{dashboardUrl}}</a>.</p><p>You have <strong>{{trialDays}}</strong> days remaining.</p>",
    "variables": ["userName", "dashboardUrl", "trialDays"],
    "locale": "en",
    "active": true
  }'

Get Templates

By ID: GET /api/v1/templates/{id}

By key: GET /api/v1/templates/tenant/{tenantId}/key/{templateKey}

All for tenant: GET /api/v1/templates/tenant/{tenantId}

By channel: GET /api/v1/templates/tenant/{tenantId}/channel/{channel}


Preview a Template

Render a template with sample variables to see the output.

Endpoint: POST /api/v1/templates/tenant/{tenantId}/key/{templateKey}/preview

curl -X POST http://localhost:8085/api/v1/templates/tenant/550e8400-e29b-41d4-a716-446655440000/key/welcome-email/preview \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -d '{
    "userName": "Alice",
    "dashboardUrl": "https://acme.matih.ai/dashboard",
    "trialDays": 14
  }'

Response:

{
  "subject": "Welcome to MATIH, Alice!",
  "body": "Hi Alice,\n\nWelcome to the MATIH platform. Your dashboard is ready at https://acme.matih.ai/dashboard.\n\nYou have 14 days remaining in your trial.",
  "htmlBody": "<h1>Welcome, Alice!</h1><p>Your dashboard is ready at <a href=\"https://acme.matih.ai/dashboard\">https://acme.matih.ai/dashboard</a>.</p><p>You have <strong>14</strong> days remaining.</p>"
}

Update a Template

Endpoint: PUT /api/v1/templates/{id}


Delete a Template

Endpoint: DELETE /api/v1/templates/{id}