Guides
IP and domain restrictions
Limit an API key to your own servers and to the domains it needs.
A request made with an API key passes up to three checks. Each one answers 403 with its own error code, so you can tell which check stopped you.
| Check | Set by | Error when it fails |
|---|---|---|
| Is the caller’s IP on the key’s list? | You, on the key | API_KEY_IP_NOT_ALLOWED |
| May the key act on this domain? | You, on the key | API_KEY_ACCESS_DENIED |
| Is the caller’s IP on the organization’s list? | The organization that owns the domain | SECURITY_IP_NOT_ALLOWED |
A check that is not configured always passes.
Allowed IPs on a key
Section titled “Allowed IPs on a key”allowed_ips is a list of up to 16 entries. Each entry is an IPv4 or IPv6 address, either exact or as a CIDR network:
203.0.113.7198.51.100.0/242001:db8::/48- With no list, or an empty one, the key accepts requests from any IP.
- The API normalizes each entry, so what you read back may be written differently from what you sent.
- An entry is rejected with
400 API_KEY_INVALID_IP_RULESwhen it is not valid, is repeated, uses/0, or carries a zone (%).
Allowed domains on a key
Section titled “Allowed domains on a key”A key can be limited to a set of domains. A restricted key only sees and acts on those domains, and GET /public-api/domains/ only lists them.
- On partner accounts, and on keys that are already restricted, the domain list is required. Leaving it empty answers
400 API_KEY_DOMAINS_REQUIRED. - Repeated domains, or domains the key cannot be given, answer
400 API_KEY_INVALID_DOMAINS. - Using the key on any other domain answers
403 API_KEY_ACCESS_DENIED.
Organization IP lists
Section titled “Organization IP lists”An organization can turn on its own IP list. When it does, every request for that organization’s domains must come from an IP on that list, and this applies to API keys too.
So for a domain in such an organization, the caller’s IP must be on both lists: the key’s and the organization’s.
When the organization check fails, the error names the organization (public_id and name) so you know whose list to update:
403 SECURITY_IP_NOT_ALLOWEDThe list of your API keys also tells you which of your organizations have an IP list turned on.