The Biteship API key IP whitelist allows you to restrict an API key so it can only be used from your server's IP addresses. If the API key is exposed, for example, accidentally committed to GitHub, recorded in logs, or still held by a former vendor, it cannot be used from another IP address.
This feature is optional and configured per API key, for both testing and live keys. Keys that do not have an IP whitelist continue to accept requests from any IP address as before.
This article will help you understand:
- What an IP whitelist, IP address, and CIDR range are
- How to find your server's IP address
- How to add, remove, and disable an IP whitelist in the dashboard
- What a 403 error with code
40301005means
1. What Is the Biteship API Key IP Whitelist?
An IP whitelist is a list of IP addresses that are allowed to use an API key. Once the list is populated, Biteship only accepts requests using that key if the requests originate from an IP address on the list. Requests from other IP addresses are rejected immediately.
- Empty list: the key accepts requests from any IP address. This is the initial state for all keys.
- Populated list: the key only accepts requests from the IP addresses or IP ranges on the list.
- Effective immediately: changes take effect immediately after you click Save.
Current limitation: API keys with an IP whitelist cannot currently be used for the Maps API and other services that verify keys through a separate service. If your integration uses the Maps API, use a separate API key without an IP whitelist for that purpose.
What Is an IP Address?
An IP address is the "address" of a device or server on the internet. There are two formats:
-
IPv4, for example
203.0.113.10 -
IPv6, for example
2001:db8::1
You need to enter the public IP of the server that calls the Biteship API, not a local or private IP such as 192.168.x.x or 10.x.x.x. If your server is behind a load balancer or NAT gateway (common with cloud services), use the egress IP of the NAT gateway.
What Is a CIDR Range?
A CIDR range is a way to write a set of consecutive IP addresses at once using the address/number format. The number after the / indicates how narrow the range is: the larger the number, the fewer IP addresses are covered.
| Entry | Coverage |
|---|---|
203.0.113.10 or 203.0.113.10/32
|
1 address |
203.0.113.0/28 |
16 addresses, from 203.0.113.0 to 203.0.113.15 |
203.0.113.0/24 |
256 addresses, from 203.0.113.0 to 203.0.113.255 |
2001:db8::/64 |
One IPv6 network block |
Use a CIDR range if your server has multiple consecutive IP addresses or its IP can change within a single block. Always choose the narrowest range possible.
2. How to Find Your Server's IP Address
Run the following command from the server that calls the Biteship API, not from your laptop:
curl https://api.biteship.com/cdn-cgi/trace
Look for the line that starts with ip=. This is your server's IP address as seen by Biteship. If the result is an IPv6 address, enter that IPv6 address. If your server can use both IPv4 and IPv6, enter both.
3. How to Configure the Biteship API Key IP Whitelist in the Dashboard
The IP whitelist is configured after the API key is created. If you do not have a key yet, create one first using the Add API Key button.
Adding an IP to the Whitelist
- Log in to the Biteship Dashboard, then open Integrations > API.
-
On the API Keys tab, find the key you want to restrict. In the Actions column, click IP Whitelist.
- The IP Whitelist window will appear. Enter an IP address or CIDR range in the input field, such as
203.0.113.10or203.0.113.0/24. -
Click Add or press Enter. The entry will appear below the input field.
- Repeat steps 3 and 4 for each other IP address you want to allow.
- Click Save. The message IP whitelist saved. will appear, and the whitelist will take effect immediately.
If you close the window using the Back button, your changes will not be saved.
Removing an IP from the Whitelist
- Reopen the IP Whitelist window for the same key.
- Click the × button on the entry you want to remove.
- Click Save.
Disabling the IP Whitelist
Remove all entries using the × button, then click Save. The key will once again accept requests from any IP address.
IP Whitelist Entry Rules
If an entry does not comply with the rules, an error message will appear below the input field:
- The entry must be a valid IPv4 address, IPv6 address, or CIDR range. Otherwise, the message Enter a valid IPv4/IPv6 address or CIDR range. will appear.
- The CIDR prefix must be between 1 and 32 for IPv4, or between 1 and 128 for IPv6. Otherwise, the message CIDR prefix must be between 1 and [limit]. will appear.
- The
/0prefix is not accepted because it means all IP addresses. The message This range allows all IP addresses. Remove all entries if you want to allow all IP addresses. will appear. - The same entry cannot be entered twice. The message This entry already exists in the list. will appear.
- Each key can have a maximum of 20 entries. The message Maximum of 20 entries. will appear.
4. API Response When an IP Is Not on the Whitelist
The IP whitelist can only be changed from the dashboard. On the API side, you need to handle the response when a request is rejected. If a request is sent from an IP address that is not on the whitelist, Biteship responds with the HTTP status 403 Forbidden:
{
"success": false,
"error": "Request IP 198.51.100.1 is not whitelisted for this API key",
"code": 40301005
}-
success: is set to
falsebecause the request was rejected. - error: identifies the rejected IP address. Use this IP to check whether your server is using a different IP from the one registered.
-
code:
40301005, the specific code for rejection by the IP whitelist.
This code is different from 40301004, which appears if the endpoint being called is not part of the public API. See the article Biteship API Key Whitelist: Accessible Endpoints for an explanation.
5. Tips for Configuring an IP Whitelist
- Add the new IP before switching servers: Add the new server's IP to the whitelist before moving to or adding the server, so no requests are rejected during the transition.
- Separate testing and live keys: Use a testing key with the staging server's IP, and a live key with the production server's IP.
- Use a static IP: Make sure your server or NAT gateway uses a static public IP so the whitelist does not need to be changed frequently.
-
Choose the narrowest range possible: Avoid large ranges such as
/8or/16because they reduce the security benefits of the whitelist.
6. FAQ About the Biteship API Key IP Whitelist
Is configuring an IP whitelist required?
No. An IP whitelist is optional, but it is highly recommended for live keys used from servers with static IP addresses.
Why was my request rejected with code 40301005?
The IP address of the server sending the request is not on the key's whitelist. Check the IP address in the error message, then add it to the whitelist through Integrations > API > IP Whitelist if it is your server's IP address.
My server's IP address changes. How can I restrict API key access by IP?
Use a NAT gateway or a service with a static egress IP, then enter that IP address. If your server provider uses a specific IP block, you can also enter the CIDR range for that block.
Are older API keys restricted automatically?
No. Older and newer keys continue to accept requests from any IP address until you populate their IP whitelist.
How do I disable the IP whitelist?
Open the IP Whitelist window, remove all entries using the × button, then click Save.
Can the IP whitelist be configured through the API?
No. The IP whitelist can only be configured from the Biteship Dashboard while you are logged in, so a leaked API key cannot be used to change its own whitelist.
Can an API key with an IP whitelist be used for the Maps API?
Not currently. Keys with an IP whitelist will be rejected by the Maps API and other services that verify keys through a separate service. Use a separate API key without an IP whitelist for the Maps API.
What is the difference between a 403 error and a 401 error?
A 401 error means the API key is invalid or has expired. Check your key again on the API Keys tab and make sure the Authorization: Bearer <api_key> header is correct. A 403 error with code 40301005 means the key is valid, but the sender's IP address is not allowed.
7. Conclusion
The Biteship API key IP whitelist is an additional security layer that ensures an API key can only be used from your own servers. Simply check your server's IP address, enter it in the IP Whitelist window under Integrations > API, then click Save.
If your request is still rejected after the IP address is added, please contact the Biteship support team at support@biteship.com and include the complete error message and the Request ID from the Logs tab.