# dkim.fyi for agents

dkim.fyi validates DKIM records, finds the selectors a domain uses, analyses `DKIM-Signature` headers and, with a throwaway address, reads the real selectors from a test email. This guide describes the public JSON API at `https://dkim.fyi/api/v1`; the machine-readable description is [openapi.json](https://dkim.fyi/openapi.json).

There is no authentication, no account and no API key. Nothing is stored about callers.

Pages have Markdown copies: send `Accept: text/markdown`, or append `.md` to the path (home: `/index.md`).

## Recipes

### 1. Validate a record (domain and selector known)

```bash
curl -s 'https://dkim.fyi/api/v1/validate?domain=github.com&selector=selector1'
curl -s -X POST 'https://dkim.fyi/api/v1/validate' \
  -H 'content-type: application/json' \
  -d '{"domain":"github.com","selector":"selector1"}'
```

Read `verdict`, `record.raw`, `key.type`, `key.bits`, `key.strength`, `dns.cnameChain`, `findings[]` (each has `code`, `severity`, `message`), `wildcard.detected` and `providers[]`. `domain` also accepts a hostname, an email address or a URL. A lookup that cannot be completed at all returns `502 upstream_error`.

### 2. Find selectors without an email

DNS cannot list selectors, so this guesses from a curated dataset, ordered by hints from the domain's MX, SPF and DMARC records.

```bash
curl -s 'https://dkim.fyi/api/v1/enumerate/plan?domain=github.com'
curl -s -X POST 'https://dkim.fyi/api/v1/enumerate/check' \
  -H 'content-type: application/json' \
  -d '{"domain":"github.com","selectors":["google","selector1","selector2","k1"]}'
```

The plan returns `candidates[]` (each has `selector`, `providers`, `hinted`), `chunkSize`, `hints[]` and `wildcard.detected`. Send `candidates[].selector` to `/enumerate/check` in slices of at most `chunkSize`. The plan's `chunkSize` is authoritative: it is 40 on dkim.fyi and the server never allows more than 45; a longer list gets `400 too_many_selectors` with `details.max`. Each check costs one DNS fetch per selector.

In the check response, `results[]` has one entry per selector with `status` of `found`, `testing`, `revoked`, `invalid`, `not_found` or `error`. Only `not_found` has no `result`; the others carry a full validate result in `result`, and `error` carries `error`. `notFound` counts the misses in the chunk. If `wildcard.detected` is true in the plan, treat every hit as suspect.

### 3. Analyse pasted headers

```bash
jq -Rn --rawfile raw headers.txt '{raw: $raw}' |
  curl -s -X POST 'https://dkim.fyi/api/v1/message' \
    -H 'content-type: application/json' --data-binary @-
```

The body is `{"raw": "<headers, or the whole message>"}`, up to 1 MiB. Read `signatures[]` (`header.domain`, `header.selector`, `key`, `verification.status`, `findings[]`), `alignment[]`, `fromDomain` and `hasBody`. `verification.status` is `pass`, `fail`, `neutral`, `permerror`, `temperror` or `not_attempted` (headers only: the key and header signature were checked, not the body hash).

### 4. The dataset

```bash
curl -s 'https://dkim.fyi/api/v1/dataset'
curl -s 'https://dkim.fyi/api/v1/health'
```

`/health` returns the service `version`, the dataset counts in `dataset` and the DNS `resolver` in use. The dataset call returns `info` (counts and version), `providers[]` (`slug`, `company_name`, `selectors`, `selector_patterns`, `status`, `confidence`, `source_urls`, `last_verified`), `generic[]`, `limitations[]`, `cnameSignatures[]` and `hintRules`. `slug` names the product (`mailgun`); `last_verified` is a date or null. `cnameSignatures[]` maps DKIM CNAME target suffixes to a `company` and `product`; `hintRules` holds the rules that order the plan. The response is cacheable for an hour. The dataset licence has not been published yet; until it is, please link to https://dkim.fyi/selectors when you cite it.

### 5. The throwaway address (finds selectors no list contains)

Random, per-tenant and rotating selectors cannot be guessed. A real message carries the selector in its `s=` tag, so this method reads it.

```bash
curl -s -X POST 'https://dkim.fyi/api/v1/inbox'
curl -s -i "https://dkim.fyi/api/v1/inbox/$TOKEN"
curl -s -i -H "If-None-Match: $ETAG" "https://dkim.fyi/api/v1/inbox/$TOKEN"
curl -s -i -X DELETE "https://dkim.fyi/api/v1/inbox/$TOKEN"
```

The first call answers `201` with `address`, `token`, `expiresAt`, `pollIntervalSeconds` (4) and `maxMessages` (20). Send one email from the system under test to `address`. Then poll `GET /inbox/{token}`: each `200` carries an `ETag`; send it back as `If-None-Match` and an unchanged inbox answers `304` with no body. Do not poll faster than `pollIntervalSeconds`, slow down as the address stays quiet, and stop after about 30 minutes without a new message. Every poll is a billed request.

`messages[]` is oldest first. Each has `fromDomain`, `signatures[]` (`header.domain`, `header.selector`, `key`, `verification.signatureValid`), `alignment[]` and `receiver` (the receiving server's `dkim`, `spf`, `dmarc`, `arc` result tokens, or null). The address accepts up to `maxMessages` messages and expires at `expiresAt`, 24 hours after creation; `expired` turns true then and a deleted or purged token answers `404 not_found`. `DELETE` answers `204`. Only the header block is read, so the body hash is never checked: `verification.status` is always `not_attempted` and `signatureValid` is the result over the signed headers. The receiving server may reject mail that fails the sender's own DMARC policy before it arrives.

If a deployment turns on its browser check (off by default), `POST /inbox` answers `403 turnstile_required` and only a browser that passes the check gets an address; send the user to the email page instead.

## MCP server

The same operations are MCP tools at `https://dkim.fyi/mcp` (Streamable HTTP, stateless, read-only, no key). Tools: `validate_dkim_record`, `plan_selector_discovery`, `check_selectors`, `analyze_message_headers` and `list_providers`. Each returns the matching endpoint's JSON. `check_selectors` takes one chunk of at most `chunkSize` selectors per call; page through the plan. Calls share the rate limit below. Cross-site browser requests get `403`. Setup for common clients: https://dkim.fyi/mcp-server.

## Reading results

- `verdict` is `valid`, `testing` (`t=y`), `revoked` (empty `p=`), `invalid` (record found, unusable), `not_found` or `error`. In `/enumerate/check`, `valid` appears as `found`.
- `not_found` means no DKIM TXT record at that name. A miss is not proof that DKIM is absent: the domain may use a selector that was not tried.
- Wildcards: if `wildcard.detected` is true, every name under `_domainkey` answers, so a hit proves little.
- `dns.cnameChain` lists the CNAME hops followed.
- Key size follows RFC 8301: RSA of 2048 bits or more is `strong`, 1024 to 2047 is `acceptable`, smaller is `weak`; above 4096 bits verifiers need not support the key, and RSA keys above 8192 bits are not accepted. Ed25519 reports 256 bits.
- `providers[]` is attribution, not proof: a selector name alone is a hint, a CNAME into the provider's zone is strong. `dnsRecordTypes` gives TXT or CNAME.
- Limits: a name `selector._domainkey.domain` may be at most 253 characters (otherwise `400 invalid_selector`). `/message` verifies the first 50 signatures and looks up at most 10 distinct keys (later ones report `temperror`); the inbox reports at most 20 signatures per message.

## Etiquette and limits

- Rate limit: 120 requests per minute per client for all of `/api/*` and `/mcp`, and 5 per minute for `POST /inbox`. A client is the IPv4 address or the IPv6 /64. Excess requests get `429 rate_limited` with `Retry-After: 60`. Counts are approximate.
- Request bodies: 256 KiB for JSON, 1 MiB for `/message`; larger gets `413`.
- Errors have the shape `{"error":{"code":"...","message":"..."}}`; branch on the HTTP status.
- Browsers: POST and DELETE requests marked cross-site by the browser get `403`. Calls from curl or a server (no `Origin` header) are fine.
- CORS-open (`Access-Control-Allow-Origin: *`): `GET /health`, `GET /dataset`, `GET /validate`, `GET /enumerate/plan`. Every other endpoint is same-origin only.
- Please do not bulk-scan domains you have no reason to check; where you can, use the dataset locally instead of probing every domain.

## Privacy

No accounts or cookies; web pages use cookie-free Cloudflare Web Analytics. Lookups store nothing beyond DNS caching of a few minutes, and pasted messages are not retained. The email check reads only the header block, keeps a minimal analysis (signing domains, selectors, key results, the From domain, the receiver's result tokens) for 24 hours or until deleted, and never stores addresses, subjects, raw headers or the body. The service does not log addresses or tokens. DNS questions go to Cloudflare's public resolver, with Google's as fallback.

## Caveats

- Answers are what a public DNS-over-HTTPS resolver returned at that moment, not necessarily what a mail server sees; changes, split-horizon DNS and caches can differ.
- `dns.dnssec` only reports whether the resolver flagged the answer as validated. dkim.fyi does not validate DNSSEC itself.
- It is not a deliverability or spam test; a valid key says nothing about reputation or inbox placement.
