Custom domain in email not working

Problem statement

On our dev tenant, we have custom domains disabled and blocked by default (free plan), but the {{ url }} variable in our email templates still returns the custom domain in the URLs, such as, in our email verification links.

Symptoms

  • Receiving 403 responses
  • Unable to make web or API calls

Steps to reproduce

  1. Create a custom domain
  2. Enable the switch to use the custom domain in emails
  3. Delete the custom domain, and you will lose the ability to change the toggle to avoid the use of the custom domain in emails

Cause

  • There is a tenant flag "enable_custom_domain_in_emails" that changes to “true” or “false” with this toggle.

Solution

Since you can not use the toggle anymore because of the lack of a custom domain, you will need to patch your tenant settings.

You can change the flag using the Management API Update tenant settings endpoint to PATCH your tenant with the following body:

{
  "flags": {
    "enable_custom_domain_in_emails": false
  }
}