# Custom lists

> Your own blocklists of emails, domains, IP addresses and ranges, checked on every call.

A custom list is a named set of entries that you want to block: the customer who charged back, a competitor's domain, a network that keeps abusing your trial. Every check made with one of your account's keys is compared against all of your lists, and a hit comes back in `custom.matched`.

## Create a list

Lists are managed in the [dashboard](https://heimdal.codebrewerz.com) under **Custom lists**. Create a list, give it a name, and add entries one at a time or paste many at once, one per line.

There is no public API for managing lists. The check endpoint only reads them.

## Entry kinds

You do not choose a kind. Heimdal works it out from what you enter:

| Kind     | Example           | Recognised by             | Matches                                              |
| -------- | ----------------- | ------------------------- | ---------------------------------------------------- |
| `email`  | `bad@example.com` | Contains an `@`           | That one mailbox.                                    |
| `cidr`   | `198.51.100.0/24` | Contains a `/`            | Every address in the range. IPv4 and IPv6 both work. |
| `ip`     | `203.0.113.7`     | Is an IP address          | That one address.                                    |
| `domain` | `evil.example`    | Any other name with a dot | Every email at that domain and at its subdomains.    |

Entries are trimmed and lowercased when you add them, and internationalised domains are stored in their ASCII form.

These are refused, because they could never match:

- Wildcards such as `*.example.com`. A `domain` entry already covers its subdomains.
- Names without a dot, such as `localhost`.
- Anything with a space in it.
- A range with an impossible prefix, such as `1.2.3.4/99`.

## How matching works

### Emails

An `email` entry matches the same mailbox, compared without regard to case. `Bad@Example.com` and `bad@example.com` are one mailbox.

Plus tags and dots are not folded. An entry for `bad@example.com` does not match `bad+1@example.com`.

### Domains

A `domain` entry matches the email's domain and every subdomain of the entry. An entry for `evil.example` matches `x@evil.example` and `x@mail.evil.example`.

Matching walks up from the email's domain and stops at its registrable domain. An entry for a public suffix such as `co.uk` therefore does not match the domains registered under it.

Domain entries apply to emails only. They are never compared with an IP address.

### IP addresses and ranges

An `ip` entry matches that exact address. A `cidr` entry matches every address in its range.

IPv4 and IPv4-mapped IPv6 are the same address here: an entry for `198.51.100.0/24` matches a check for `::ffff:198.51.100.200`.

## In the response

Each matching entry is listed with the name of its list, its kind and its value. Any match adds `custom_list` to `reasons` and sets `block` to `true`.

```json
{
  "block": true,
  "reasons": ["custom_list"],
  "email": {
    "address": "x@mail.evil.example",
    "domain": "mail.evil.example",
    "disposable": false
  },
  "ip": null,
  "custom": {
    "matched": [{ "list": "Banned", "kind": "domain", "value": "evil.example" }]
  }
}
```

One check can hit several entries, in one list or in several. All of them are returned.

## Timing

- A change to a list applies to the next check.
- A new subscription takes up to 60 seconds to reach the API. Until then every call answers `402`.

## Limits

| Limit   | Value                                                 |
| ------- | ----------------------------------------------------- |
| Lists   | 20 per account                            |
| Entries | 50,000 per account, counted across all lists |

## If the lists cannot be read

A check does not fail because your lists are unavailable. Heimdal answers `200` with every other signal, leaves `custom.matched` empty, and adds the header `Heimdal-Degraded: custom_lists`. See [Degraded answers](https://heimdal.codebrewerz.com/docs/reference/errors/#degraded-answers).

## Lists only block

There are no allowlists. A custom list can add a reason to block; it cannot remove one. To let a known customer through despite a signal, make that exception in your own code.
