careful-honey-27437
07/03/2025, 5:19 AMbrief-egg-61061
07/03/2025, 5:19 AMbrief-egg-61061
07/03/2025, 5:19 AMgotmpl <p>Origin: {{index .TransientPayload "origin"}}</p> {{- if eq (index .TransientPayload "origin") "<http://domain1.com|domain1.com>" -}} <!-- Custom content for domain1.com --> {{- else if eq (index .TransientPayload "origin") "<http://domain.net|domain.net>" -}} <!-- Custom content for domain.net --> {{- else -}} <!-- Default content --> {{- end -}}
This approach allows you to conditionally render different content in your OTC email templates based on the origin of the request, as long as you ensure the origin is included in the transient payload when starting the flow. For more details and examples, see the documentation on [transient payload in templates](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#transient-payload-in-templates). Note: The knowledge sources do not provide a built-in way to automatically detect the request origin and inject it into the transient payload; you must ensure your application logic sets this value when initiating the flow. If you need to customize templates based on other identity attributes (like language), you can also use the .Identity
object in templates, but for request-specific data like origin, the transient payload is the recommended approach [Customizing template content for specific users](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#customizing-template-content-for-specific-users). Summary: - Pass the origin as a transient payload when starting the flow. - Use {{index .TransientPayload "origin"}}
in your template to customize content. If you need more details on how to set the transient payload in your API requests, please specify your integration environment.careful-honey-27437
07/03/2025, 5:21 AMbrief-egg-61061
07/03/2025, 5:21 AMbrief-egg-61061
07/03/2025, 5:21 AMjson { "method": "code", "email": "<mailto:user@example.com|user@example.com>", "transient_payload": { "origin": "<http://domain1.com|domain1.com>" } }
- For the verification flow, the request body allows a transient_payload object, which will be available in your email templates as .TransientPayload
[Customizing template content for specific users](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#transient-payload-in-templates). - The same approach applies to other flows that support transient_payload, such as registration or recovery [Github Issue: Possibility to define complex data types in the metadata of identity](https://github.com/ory/network/issues/187). How to use in a cURL request: bash curl -X POST \ -H 'Content-Type: application/json' \ -d '{ "method": "code", "email": "<mailto:user@example.com|user@example.com>", "transient_payload": { "origin": "<http://domain1.com|domain1.com>" } }' \ "https://<your-kratos-endpoint>/self-service/verification?flow=<flow-id>"
You can then access this value in your email template using: gotmpl {{index .TransientPayload "origin"}}
This allows you to customize the email content based on the origin value you passed in the API request [Customizing template content for specific users](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#transient-payload-in-templates). > Note: The exact endpoint and required fields may vary depending on the flow (verification, recovery, etc.), but the use of transient_payload is consistent across these flows as shown in the API reference and documentation.careful-honey-27437
07/03/2025, 5:22 AMbrief-egg-61061
07/03/2025, 5:22 AMbrief-egg-61061
07/03/2025, 5:22 AMHello {{ .Identity.traits.firstName }}, Your login code is: {{ .LoginCode }}
2. Encode your template in Base64 Convert your template to Base64. You can use the command line or an online tool: bash echo "Hello {{ .Identity.traits.firstName }},\nYour login code is: {{ .LoginCode }}" | base64
3. Update your Ory Identities configuration Add the Base64-encoded template to your configuration file, making sure to prefix it with base64://
. For example, to customize the login code email: yaml courier: smtp: from_name: MyProject via Ory templates: login: valid: email: body: plaintext: "base64://<ENCODED_TEMPLATE_HERE>"
4. Upload the updated configuration Use the Ory CLI to update your project configuration: bash ory update identity-config --project <project-id> --workspace <workspace-id> --file updated_config.yaml
Important notes: - In Ory Network, only Base64-encoded templates are supported. You cannot use http://
or file://
URIs for templates; if you do, the system will fall back to the default templates [Using custom message templates](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#using-custom-message-templates). - You can version and manage your templates in your repository, but you must always encode them to Base64 before uploading [Email Templates (GitOps)](https://www.ory.sh/docs/guides/gitops#email-templates). - For more advanced customization (e.g., per-user or per-request logic), you can use variables like .Identity
and .TransientPayload
in your templates [Customizing template content for specific users](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#customizing-template-content-for-specific-users). For a detailed step-by-step guide, see the [Ory documentation on custom email templates](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#using-custom-message-templates).careful-honey-27437
07/03/2025, 5:24 AMbrief-egg-61061
07/03/2025, 5:24 AMbrief-egg-61061
07/03/2025, 5:25 AMfrom_address
) and sender name (from_name
), you must configure them statically in your project configuration, and these values apply globally to all emails sent by Ory for that project [Use a custom server to send Ory Identity messages to users](https://www.ory.sh/docs/kratos/emails-sms/sending-emails-smtp). There is no mention of support for per-request or per-origin customization of the sender fields. If you require different "From" addresses or names based on the origin, you would need to set up separate Ory projects, each with its own configuration, or handle email sending externally via webhooks or a custom integration. However, this approach is not explicitly documented in the provided sources. Summary: Ory Network does not currently support dynamic "From" name/email customization based on request origin in its documented configuration options.