Company logo from an email domain: BIMI explained

BIMI lets a company publish its official logo in DNS. Here's how the record works, how to read it, and how to use it to show a logo for any work email.

You have jane@stripe.com and want to show Stripe's logo next to her name. The best source for that logo is one most developers have never heard of: BIMI.

What BIMI is

BIMI (Brand Indicators for Message Identification) is a standard that lets a domain publish its official logo so email clients can show it next to messages. The logo lives in a DNS TXT record:

default._bimi.example.com.  TXT  "v=BIMI1; l=https://example.com/logo.svg; a=https://example.com/vmc.pem"

Those requirements are why BIMI logos are good: a company that publishes one has gone to the trouble of setting up email authentication, and often of certifying its trademark. The logo is square, vector, and official.

Reading it yourself

  1. Look up the TXT record at default._bimi.<domain>. In a Worker or browser, a DNS-over-HTTPS endpoint works: https://cloudflare-dns.com/dns-query?name=default._bimi.stripe.com&type=TXT with accept: application/dns-json.
  2. Parse l= out of the record.
  3. Fetch the SVG, check it really is an image, and serve or cache it.

Most domains do not publish BIMI, so you also need a fallback for the rest.

One URL that does it, with fallbacks

<img src="https://avatarsapi.com/domain/stripe.com?size=64" alt="">

/domain/:domain walks a Ladder: BIMI first, then DuckDuckGo and Google favicons if there is no BIMI record. Whatever it finds is fetched and validated as a real image before it is served. If nothing usable exists, you get a 404 with "code": "ENOTFOUND".

For a work email, /email/:address goes one step further. It checks the person first (Gravatar and GitHub, raced), and only then falls back to the domain's BIMI logo:

<img src="https://avatarsapi.com/email/jane@stripe.com?size=64" alt="">

That gives you a face when the person has one and a company logo when they do not, from a single src.

Related

Try it: put https://avatarsapi.com/github/torvalds in an <img src>. No key, no signup. Read the docs or create a Project.