How to Restrict an API Key to Specific IPs
Allow requests only from chosen addresses or networks
Written by Erick Horn
June 27, 2026
Updated October 16, 2026
How to restrict an API key to specific IPs
Set Allowed IP Addresses on a key to choose where it can be used. Requests from other addresses return 403 ER0601. An empty list allows requests from any IP address and is the default.
You can combine IP restrictions with endpoint scopes and an expiry date to limit where, how, and for how long a key works.
Where do you set a key’s allowed IP addresses?
Open API Keys, select a key, and find API Key Restrictions. Enter one address or range per line in Allowed IP Addresses, up to 50 entries, then click Save Restrictions.
The same field is available when creating a key. Clear it to remove the IP restriction. These settings are managed in the dashboard, rather than through a News API request.

You can enter:
- An IPv4 address, such as
203.0.113.20. - An IPv6 address.
- A CIDR range, which represents a block of addresses, such as
10.0.0.0/24. IPv4 supports/0–/32; IPv6 supports/0–/128. - A wildcard prefix such as
10.0.*, matching addresses that start with10.0.. *, allowing every address, like an empty list.
Invalid entries, such as 10.0.0.999, prevent saving and return 422 Invalid entries: ….
What happens when a request comes from a blocked IP?
The API recognizes the key but rejects the request with HTTP 403 and code ER0601:
{
"status": "not_ok",
"request_id": "…",
"errors": [
{
"status": 403,
"code": "ER0601",
"message": "Access denied: your IP address is not allowed for this API key.",
"links": { "about": "https://docs.apitube.io/platform/news-api/http-response-codes" },
"timestamp": "…"
}
]
}
The same request succeeds from an allowed address:
curl "https://api.apitube.io/v1/news/everything?title=apple" \
-H "X-API-Key: YOUR_API_KEY"
IP restrictions apply whether you send the key in the X-API-Key header or api_key parameter. A 401 instead indicates an authentication problem. See why a request is blocked by IP or scope.
How are IP restrictions different from scopes and expiry?
Each setting controls a different part of access:
- IP restrictions: where a request can come from (
ER0601). - Endpoint scopes: which endpoints the key can call (
ER0603). - Expiry: when the key stops working (
ER0230).
A request must meet every restriction set on the key.
Common Questions
Can I restrict a key to a whole network with CIDR?
Yes. For example, 10.0.0.0/24 covers 256 addresses, and 203.0.113.0/28 covers a smaller block. You can mix IPv4, IPv6, CIDR ranges, and wildcard prefixes within the 50-entry limit. A malformed CIDR entry does not match any address.
Does the API see the real client IP behind a proxy?
The IP restriction uses the original client address forwarded by the proxy. Add the public outbound IP used by your server or office gateway, rather than a private local address.
IPv4-mapped IPv6 addresses such as ::ffff:203.0.113.20 can match the IPv4 entry 203.0.113.20.
Who can change a key’s IP restrictions?
Workspace owners, admins, and members can change them. Viewers cannot. See how to create, rename and revoke API keys.
What if I lock myself out?
Open the key’s detail page in the dashboard and add the correct outbound IP, or clear Allowed IP Addresses to remove the restriction. The next API request uses the updated settings.