IP whitelisting allows you to restrict an API key so that it only authenticates requests originating from specific IP addresses or networks.
How It Works #
- Each API key has an optional
ip_whitelistfield stored as a JSON array of IP addresses and/or CIDR ranges. - When a request is made with a key that has a whitelist configured, the middleware checks the request’s originating IP against the whitelist after authentication.
- If the IP does not match any entry in the whitelist, the request is rejected with HTTP 403.
- If the whitelist is empty (not configured), requests from any IP address are accepted.
Supported Formats #
| Format | Example |
|---|---|
| IPv4 single address | 203.0.113.5 |
| IPv4 CIDR range | 192.168.1.0/24 |
| IPv6 single address | 2001:db8::1 |
| IPv6 CIDR range | 2001:db8::/32 |
Configuring a Whitelist #
- Navigate to DDLS > Developer > API Keys.
- Click Edit on the key you want to restrict.
- In the IP Whitelist field, enter one or more addresses or CIDR ranges separated by commas.
- Click Save Changes.
IP Whitelist Rejection Response #
HTTP 403 Forbidden
{
"code": "ip_not_whitelisted",
"message": "Request IP address is not permitted for this API key."
}
