Skip to content
Dashboard

Guides

View as Markdown

IP and domain restrictions

Limit an API key to your own servers and to the domains it needs.

198.51.100.9203.0.113.7192.0.2.44

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 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.7
198.51.100.0/24
2001: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_RULES when it is not valid, is repeated, uses /0, or carries a zone (%).

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.

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_ALLOWED

The list of your API keys also tells you which of your organizations have an IP list turned on.