Invite tokens must be per-user and time-limited
A generic invite link in a template is a security risk. The token must be generated before the email is sent and included in the payload.
Team invite, organisation invite, role-specific access grant — each fires a domain event. else.events picks the right template, injects the invite token and delivers.
A generic invite link in a template is a security risk. The token must be generated before the email is sent and included in the payload.
Inviting a viewer differs from inviting an admin. The email copy and permissions context should reflect the assigned role.
Users need to know when the invite expires. This means the expiry timestamp must be in the event payload and rendered in the template.
A resent invite may need different subject line copy ("Your invite was resent") and a new token without changing the email template structure.
Generate the token in your backend, include it in the event payload data. The template renders it as the CTA link — no generic links.
Admin invite and viewer invite can use different templates with role-appropriate copy. Rules route by role from the payload.
Include expires_at in the payload. The template renders it directly — no hardcoded expiry text.
Fire the same team.invited event with a new token. Rules or a re-invite flag can select slightly different template copy.
// invitation event with token
{
"type": "team.invited",
"user": { "email": "newmember@example.com", "name": "Jordan" },
"data": {
"invited_by": "Alex",
"role": "admin",
"team_name": "Acme Engineering",
"invite_url": "https://app.example.com/invite/accept?token=xyz789",
"expires_at": "2026-06-01T23:59:00Z"
}
} else.events matches the rule for type = team.invited and role = admin, renders the admin invite template with the personalised invite_url and expires_at, then delivers through your provider.
Fire team.invited. else.events delivers the right invite to the right person.