Create a message template

Write an email template your organization can send from. **One per kind of message.** A template covers one kind of message, in one language, on one channel. If you already have one for that combination, a second comes back as `409` — edit the first instead. **Leaving blanks.** Write `{{.first_name}}` anywhere in the subject or the body and it is filled in from the `values` you supply when you send. We check the template before saving it, so a mistake is caught now rather than during a live delivery later. Anything you put in `values` here acts as a fallback, used when the same name is missing at send time. Requires the `notifications.templates.create` permission.

POST
/messages/templates
AuthorizationBearer <token>

The access token returned after a successful sign-in, sent as Authorization: Bearer <access_token>.

It identifies the person and the organization they are working in, and it lasts about fifteen minutes. When it runs out, use their refresh token at POST /auth/refresh-token instead of asking them to sign in again.

In: header

Request Body

application/json

The template to create.

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://api.dual.network/messages/templates" \  -H "Content-Type: application/json" \  -d '{    "name": "Ticket ready",    "action_type": "custom",    "system": "email",    "language": "en",    "title": "Your ticket {{.ticket}} is ready",    "content": "<p>Hello {{.first_name}},</p><p>Your ticket <b>{{.ticket}}</b> is ready. <a href=\"{{.url}}\">Open it</a>.</p>",    "content_type": "html"  }'
{
  "id": "665f1c2d4b1a2c3d4e5f6a7b"
}
{
  "code": 3,
  "message": "Key: 'limit' Error:Field validation for 'limit' failed on the 'lte' tag"
}

{
  "code": 16,
  "message": "no auth provided"
}

{
  "code": 7,
  "message": "forbidden"
}
{
  "code": 10,
  "message": "conflict"
}
{
  "code": 8,
  "message": "too many requests"
}
{
  "code": 13,
  "message": "internal error"
}