Mail templates, translations and sending email with Core.
The MailTemplate model
Every mail sent by the system is defined by a global mail template. The template has an id and a system name, along with a default subject and body in a defined language.
The mail template can either be used as is to send email, or a translation can be provided for a given language. During mail sending, if no translation exists for the required language, the default implementation from the template will be used.
Properties
- Name
id- Type
- UUID
- Description
The id of the mail template
- Name
name- Type
- string
- Description
The system name of the template
- Name
subject- Type
- string
- Description
The default subject for the template
- Name
body- Type
- string
- Description
The default body for the template
- Name
language- Type
- string
- Description
The language code of the language used in the default subject and body
The MailTemplateTranslation model
A MailTemplate can be translated into multiple languages. This will be used in place of the default subject/body from the mail template when sending an email in the requested language.
Properties
- Name
id- Type
- UUID
- Description
The id of the mail translation
- Name
template- Type
- UUID
- Description
The template id for this translation
- Name
subject- Type
- string
- Description
The default subject for the translation
- Name
body- Type
- string
- Description
The default body for the translation
- Name
language- Type
- string
- Description
The language code of the language used in the subject and body
List all templates
List all global mail templates
Required privileges
- MailTemplateRead
Request
curl -G https://core-api.syse.no/v2/brands/${brand}/mail/templates \
-H "Authorization: Bearer ${token}"
Response
[
{
"id": "cbb19cbb-60b4-4797-b9d2-a32cc94fc78d",
"name": "migration-executed",
"subject": "Domenet ditt {{ .Domain }} er ...",
"body": "y",
"language": "no"
},
{
"id": "59b80b98-cf55-44d2-a066-f9bc43215f58",
"name": "migration-failed",
"subject": "x",
"body": "y",
"language": "no"
},
{
"id": "efbb27e1-c2c4-4008-981d-7dd909b4b2ff",
"name": "migration-scheduled",
"subject": "Nu er det straks tid for migrering",
"body": "Men ikke før {{ .notBefore }} !",
"language": "no"
}
]
Create translation
Create a translation in a given language for the given template
Required privileges
- MailTemplateWrite
Request
curl -X POST https://core-api.syse.no/v2/brands/${brand}/mail/templates/${templateId}/translations \
-H "Authorization: Bearer ${token}" \
-d \
'
{
"language": "no",
"subject": "My subject",
"body": "My body"
}
'
Response
{
"id": "e63e54cd-5647-4541-979a-ca58c1084275",
"template": "cbb19cbb-60b4-4797-b9d2-a32cc94fc78d",
"language":"no",
"subject":"My subject",
"body":"My body"
}
List translations
List all translations for the given template
Required privileges
- MailTemplateRead
Request
curl -G https://core-api.syse.no/v2/brands/${brand}/mail/templates/${templateId}/translations \
-H "Authorization: Bearer ${token}"
Response
{
"id": "e63e54cd-5647-4541-979a-ca58c1084275",
"template": "cbb19cbb-60b4-4797-b9d2-a32cc94fc78d",
"language":"no",
"subject":"My new subject",
"body":"My new body"
}
Update translation
Update a translation for the given template. You can only modify the subject and body of an existing translation. To change language you need to delete and create a new one with the same content.
Required privileges
- MailTemplateWrite
Request
curl -X PUT https://core-api.syse.no/v2/brands/${brand}/mail/templates/${templateId}/translations/${translationId} \
-H "Authorization: Bearer ${token}" \
-d \
'
{
"subject": "My new subject",
"body": "My new body"
}
'
Response
{
"id": "e63e54cd-5647-4541-979a-ca58c1084275",
"template": "cbb19cbb-60b4-4797-b9d2-a32cc94fc78d",
"language":"no",
"subject":"My new subject",
"body":"My new body"
}
Delete translation
Delete a translation for the given template
Required privileges
- MailTemplateWrite
Request
curl -X DELETE https://core-api.syse.no/v2/brands/${brand}/mail/templates/${templateId}/translations/${translationId} \
-H "Authorization: Bearer ${token}" \
'
Response
