Appearance
Emails
The Treezor API sends emails to your end users on your behalf during their onboarding and password reset.
Signing (SPF & DKIM)
When Treezor sends emails on behalf of your domain names, two technologies must be configured to ensure proper delivery: SPF and DKIM.
Best practice – Make sure you configure emails properly
Otherwise, emails Treezor sends on your behalf are likely to be considered as spam or to display warning messages.
SPF
The Sender Policy Framework is declared in the DNS zone of your domain name.
It enumerates the servers explicitly allowed to send emails on your behalf (aka sending emails ending in @your-domain-name.tld
)
Information – Add Treezor IP addresses to your DNS zone SPF record
Treezor provides you with IP addresses you must add to the SPF record of your DNS zone. They allow Treezor to send email on your behalf.
SPF record example
dns
company-name.tld. 3599 IN TXT "v=spf1 mx include:company-name.spf.treezor.co -all"
1
DKIM
The DomainKeys Identified Mail is a private/public key pair technology, the public key lives in the DNS zone of your domain name.
This technology allows Treezor to sign outgoing emails, and empowers the recipient into checking the signature of a received email against the public key.
Information – Add the DKIM key in a TXT record of your DNS zone
Your Treezor Account Manager provided you with Treezor public DKIM key. You must add to your DNS zone, allowing Treezor to send emails on your behalf.
DKIM record example
dns
treezor._domainkey.company-name.tld. 3599 IN TXT "k=rsa; p=QsABSUqGDCh7GOBexnj+apFT[...]NlVDzn3c4aPMoPJROgyd7v1rI2"
1
Templates
Reading – More information on Templates is available
- API Basics Templates article.
- Twig's official documentation.
Currently, only the confirmation email can be templated.
Create your templates
We expect two formats, an HTML template and a TXT template.
The second one is used as a fallback for email clients that don't support HTML, and for screen readers. Although not mandatory, it is strongly recommended to also upload a TXT template.
To retrieve the list of available variables within the confirmation email template, you can use the following endpoints:
GET /customization/templates/email.user.onboarding_confirmation_{html|text}
GET /customization/templates/email.user.password_change{html|text}
Best practice – Keep the confirmation link variable
The confirmation_link
variable must always be present. It is the URL a user is asked to visit to activate their account.
HTML example
twig
<html>
<body>
<h1>
Welcome
</h1>
<p>
Please click <a href="{{ confirmation_link }}">on this link</a> to validate your account.
</p>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
Like other files, your templates must be Base64 encoded.
text
PGh0bWw+Cgk8Ym9keT4KCQk8aDE+CgkJCVdlbGNvbWUKCQk8L2gxPgoJCTxwPgoJCQlQbGVhc2Ug
Y2xpY2sgPGEgaHJlZj0ie3sgY29uZmlybWF0aW9uX2xpbmsgfX0iPm9uIHRoaXMgbGluazwvYT4g
dG8gdmFsaWRhdGUgeW91ciBhY2NvdW50LgoJCTwvcD4KCTwvYm9keT4KPC9odG1sPg==
1
2
3
2
3
TXT example
twig
Welcome
Please click the following URL to validate your accont
{{ confirmation_link }}
1
2
3
4
5
2
3
4
5
Like other files, your templates must be Base64 encoded.
text
V2VsY29tZQoKUGxlYXNlIGNsaWNrIHRoZSBmb2xsb3dpbmcgVVJMIHRvIHZhbGlkYXRlIHlvdXIg
YWNjb250Cgp7eyBjb25maXJtYXRpb25fbGluayB9fQ==
1
2
2
Upload your templates
Your templates must be uploaded to the following endpoint: /customization/templates/email.user.onboarding_confirmation_{html|text}
Example
Note that both HTML and TXT templates are uploaded at the same time.
bash
curl -X PUT {baseUrl}/customization/templates/email.user.onboarding_confirmation_{html|text}/template \
-H 'Authorization: Bearer {accessToken}' \
-H 'Content-Type: application/json' \
-d '{
"template": "{base64EncodedTemplate}"
}'
1
2
3
4
5
6
2
3
4
5
6
Caution – Replacing a Template
- Takes effect immediately.
- Cannot be undone.
Retrieve your template
To retrieve the template you already uploaded, you can use the following endpoint: /customization/templates/email.user.onboarding_confirmation_{html|text}
Example
bash
curl -X GET {baseUrl}/customization/templates/email.user.onboarding_confirmation_{html|text} \
-H 'Authorization: Bearer {accessToken}' \
-H 'Content-Type: application/json'
1
2
3
2
3
Testing your template
To test your template with dummy values you can use the GET /customization/templates/email.user.onboarding_confirmation_{html|text}/demo
endpoint.
Example
bash
curl -X GET {baseUrl}/customization/templates/email.user.onboarding_confirmation_{html|text}/example \
-H 'Authorization: Bearer {accessToken}' \
-H 'Content-Type: application/json'
1
2
3
2
3
Errors
Check out possible errors here