> ## Documentation Index
> Fetch the complete documentation index at: https://razorpay.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage IP Whitelist for API Keys

> Limit which servers can use your API keys. Add, remove and review the IP whitelist for your Test and Live keys on the Razorpay Dashboard.

Available in
🇮🇳 India

> [!NOTE]
>
> **Feature Availability**
>
> The IP whitelist is being rolled out to merchants in phases, so it may not be available for your account yet. If the **IP Whitelist** section is not visible on the **API Keys** page, the feature is not turned on for your account yet.

An IP whitelist limits where your API keys can be used. When your IP whitelist has at least one IP, Razorpay accepts API calls made with your key ID and secret only from the IPs on it. Razorpay blocks calls from any other IP, even if they use the right key ID and secret.

This protects you if your key secret leaks. Someone who has the secret still cannot create orders, refunds or linked accounts from their own servers.

The Dashboard asks for your server IPs when you generate or regenerate a key. Add or remove IPs later from the **IP whitelist** section of the API keys page.

## How the IP Whitelist Works

The IP whitelist works as follows:

* **Test and Live mode have separate IP whitelists.** The Live IP whitelist checks calls made with your Live keys. The Test IP whitelist checks calls made with your Test keys. Switch the mode on the Dashboard to see the other list.
* **Only server-side calls are checked.** The IP whitelist applies to every API call authenticated with your key ID and secret, such as creating orders, payments, refunds and Route linked accounts. Checkout runs in your customers' browsers and apps with only your key ID, so your customers can still pay from anywhere.
* **Add all your servers.** Once the IP whitelist has one IP, Razorpay blocks calls from every other IP. If your servers make calls from more than one public IP, for example through several Network Address Translation (NAT) gateways or regions, add all of them.
* **All keys in a mode share one IP whitelist.** Regenerating a key keeps the IP whitelist, unless you choose **Regenerate without IP whitelist**.

## Before You Start

The table below lists the rules for the IP whitelist:

| Rule | Detail |
| - | - |
| Who can make changes | Users with the Owner, Pseudo Owner or Admin role. The View-Only (Auditor) role can see the IP whitelist but cannot change it. Users with other roles do not see the **IP whitelist** section. |
| What you can add | Single public IPv4 addresses, for example `203.0.113.10`. |
| What you cannot add | IP ranges such as `203.0.113.0/24`, IPv6 addresses, private or reserved addresses such as `10.0.0.5`, `192.168.1.20` or `127.0.0.1`, and addresses with a port such as `203.0.113.10:443`. |
| How many | Up to 15 IPs in Live mode and 15 IPs in Test mode. |
| Verification | Every change in Live mode needs a one-time password (OTP). Changes in Test mode do not. |

Know more about [standard user roles and permissions](https://razorpay.com/docs/payments/dashboard/account-settings/manage-team.md#standard-user-roles).

## Add IPs When You Generate or Regenerate a Key

When you generate your first key or regenerate a key, the Dashboard asks for your server IPs first. If you already have an IP whitelist in that mode, the Dashboard fills in the saved IPs for you to check.

### Live Mode

To add IPs while you generate or regenerate a Live key:

1. Log in to the [Razorpay Dashboard](https://dashboard.razorpay.com) and select **Live** mode.
2. Navigate to **Account & Settings** → **API keys** (under **Website and app settings**) and click **Generate Key** (or **Regenerate Key**).
3. In the **Add your server IPs** pop-up page, enter the public IPv4 address of every server that calls Razorpay's APIs in the **Server IP addresses** text box. Separate the addresses with commas. Click **Continue**.

   ![Add your server IPs pop-up page for Live mode, Step 1 of 3, with two IPs in the Server IP addresses text box](https://mintcdn.com/razorpay-881012b3/vvOO1YMETthd9A-D/static/docs-home/assets/api-key-ip-whitelist-live-add-ips.jpg?fit=max\&auto=format\&n=vvOO1YMETthd9A-D\&q=85\&s=298bceb62c08ea7c67c8ef672018d2a7)
4. Check the IPs in the **Confirm** pop-up page and click **Confirm**. Click **Back** to change them.
5. Enter the OTP. This one OTP saves your IPs and creates your key.
6. Copy your key ID and key secret and store them safely.

### Test Mode

To add IPs while you generate or regenerate a Test key:

1. Log in to the Dashboard and select **Test** mode.
2. Navigate to **Account & Settings** → **API keys** (under **Website and app settings**) and click **Generate Key** (or **Regenerate Key**).
3. In the **Add your server IPs** pop-up page, enter your server IPs in the **Server IP addresses** text box and click **Continue**. Razorpay does not ask for an OTP in Test mode.

   ![Add your server IPs pop-up page for Test mode, Step 1 of 2, with an empty text box](https://mintcdn.com/razorpay-881012b3/vvOO1YMETthd9A-D/static/docs-home/assets/api-key-ip-whitelist-test-add-ips.jpg?fit=max\&auto=format\&n=vvOO1YMETthd9A-D\&q=85\&s=a8716626d166d3dfbf279223f1cee18a)

### Generate a Key Without an IP Whitelist

If you cannot add IPs yet, for example because your servers do not have a fixed public IP, generate the key without an IP whitelist.

To generate a key without an IP whitelist:

1. In the **Add your server IPs** pop-up page, clear the **Server IP addresses** text box. The button in the next step stays unavailable while the text box has IPs.
2. Click **Generate without IP whitelist** (or **Regenerate without IP whitelist**).
3. In Live mode, the **Continue without an IP whitelist?** pop-up page opens with a high-risk warning. Select the **I accept the risk and the terms. My business is responsible for all activity on this key.** check box.

   ![Continue without an IP whitelist pop-up page with a High risk warning and an unselected check box](https://mintcdn.com/razorpay-881012b3/vvOO1YMETthd9A-D/static/docs-home/assets/api-key-ip-whitelist-risk-warning.jpg?fit=max\&auto=format\&n=vvOO1YMETthd9A-D\&q=85\&s=14f5fe79615f6e449006673174fec7be)
4. Click **Continue without IP whitelist** and enter the OTP.

In Test mode, Razorpay creates the key straight away and shows no warning.

> [!WARNING]
>
> **Watch Out!**
>
> Your key works from any server. Anyone with your key ID and secret can use them from anywhere. This option also removes any IPs already saved for that mode. The **IP whitelist** section shows **Your Live keys work from any server** until you add IPs.

## Add or Remove IPs Later

Log in to the Dashboard, select the mode (**Test** or **Live**) and navigate to **Account & Settings** → **API keys** (under **Website and app settings**). The **IP whitelist** section shows whether the IP whitelist is **On** or **Off**, how many IPs are saved out of 15, and who added each IP and when.

Razorpay saves each add and each remove straight away. In Live mode, each one needs an OTP.

![IP whitelist section in Live mode with 2 of 15 IPs saved, an Add IP addresses text box and a table of the saved IPs](https://mintcdn.com/razorpay-881012b3/vvOO1YMETthd9A-D/static/docs-home/assets/api-key-ip-whitelist-section-with-ips.jpg?fit=max\&auto=format\&n=vvOO1YMETthd9A-D\&q=85\&s=bc78d1ccbfd9539042117203ccc0d844)

### Add IPs

To add IPs to your IP whitelist:

1. In the **Add IP addresses** text box, enter one or more public IPv4 addresses. Separate them with commas.
2. Click **Add**.
3. In Live mode, enter the OTP.

### Remove an IP

To remove an IP from your IP whitelist:

1. Click the remove icon in the row of the IP.
2. In Live mode, enter the OTP.

Razorpay blocks API calls from a removed IP. If you remove the last IP, the IP whitelist turns off and your keys in that mode work from any server again.

IPs that Razorpay Support added before self-serve show a dash under **Added by** and **Added on**.

## Find the Public IP of Your Server

Add the public IP that your server's API calls come from, which is its outbound IP. This is often not the IP your website runs on and not the private IP your server sees for itself.

### Check from the Server

Run this command on each server or container that calls Razorpay's APIs. The address it prints is the one Razorpay sees.

```bash theme={null}
curl -4 https://checkip.amazonaws.com
```

Run it a few times, and on every server, region and instance. If you get different addresses, your servers use more than one outbound IP and you must add all of them. If the address changes each time you restart or redeploy, your server has no fixed outbound IP. See [If Your Server Has No Fixed IP](#if-your-server-has-no-fixed-ip).

### Find the IP on a Cloud Provider

The table below lists the IP to add for each setup:

| Where Your Server Runs | The IP to Add |
| - | - |
| AWS EC2 instance with a public IP | Its Elastic IP. AWS assigns a plain public IP when the instance starts and releases it when the instance stops, so attach an Elastic IP first. List your Elastic IPs with `aws ec2 describe-addresses --query "Addresses[].PublicIp"`. |
| AWS resources in a private subnet, for example EC2, ECS, EKS or Lambda in a Virtual Private Cloud (VPC) | The Elastic IP of each NAT gateway the subnet routes through. List them with `aws ec2 describe-nat-gateways --query "NatGateways[].NatGatewayAddresses[].PublicIp"`. |
| Google Cloud VM | Its static external IP. List reserved addresses with `gcloud compute addresses list`. |
| Google Cloud with Cloud NAT, for example GKE, Cloud Run with VPC egress or private VMs | The static IPs assigned to Cloud NAT. Set Cloud NAT to manual IP allocation so the addresses do not change. |
| Azure VM or Azure NAT gateway | The static public IP of the VM, or the public IPs of the NAT gateway. List them with `az network public-ip list --query "[].ipAddress"`. |
| Kubernetes on any cloud | The outbound IPs of the cluster's NAT or egress gateway, not the node or pod IPs. |
| Your own data centre or office | The public IP of your firewall or internet gateway. Ask your network team for every outbound IP. |
| Shared hosting or a managed platform | The fixed outbound IP of your server. Ask your hosting provider, because many shared hosts use outbound IPs that change or that other customers share. |

### If Your Server Has No Fixed IP

Serverless functions, such as AWS Lambda outside a VPC, and many managed platforms usually send requests from addresses that can change. Other customers of the provider can share these addresses, so you cannot whitelist them reliably.

Do one of the following:

* Route outbound traffic through a NAT gateway with a fixed IP. For AWS Lambda, run the function in a VPC with a NAT gateway and an Elastic IP.
* Use your platform's static outbound IP option.
* [Generate your key without an IP whitelist](#generate-a-key-without-an-ip-whitelist) until you have a fixed IP, then add the IPs.

### IPs You Should Not Add

Do not add the following:

* Your laptop or office IP for Live keys, unless your Live servers really call from there. Use Test mode for development.
* Your website's IP, if it is not the server that calls Razorpay's APIs.
* Private addresses such as `10.0.0.5` or `192.168.1.20`. Razorpay never sees these.

## Messages You Might See

The table below lists the messages the Dashboard shows and what to do about each:

| Message | What to Do |
| - | - |
| `<IP> is a private address. Use your server's public outbound IP.` or `<IP> is a reserved address. Use your server's public outbound IP.` | Run the check in [Find the Public IP of Your Server](#find-the-public-ip-of-your-server) and add that address. |
| `<IP> isn't a valid IPv4 address.` | Check for typos, extra characters, a port such as `:443` or a leading zero such as `010.1.1.1`. |
| `<IP> is IPv6, which isn't supported yet.` | Add the IPv4 address of the server. |
| `<IP> is a range. Single IPs only for now.` | Add each IP separately. |
| `<IP> is already on the list.` or `<IP> is entered twice.` | Remove the repeated address. |
| `Only N more IPs fit. You can whitelist up to 15 IPs in Live mode. Remove an IP to add more.` | Remove IPs you no longer use, then add the new ones. |
| `You've reached 15 IPs. Remove an IP to add more.` | Remove an IP you no longer use. |
| `These IPs don't fit. Remove an IP or use shorter addresses.` | The list has reached its storage limit before 15 IPs. Remove an IP you no longer use. |
| `You can't change the IP whitelist. Ask an owner or admin to make this change.` | Only users with the Owner, Pseudo Owner or Admin role can make changes. |
| `Couldn't save. Nothing changed. Try again.` | Try the change again. |
| `Couldn't save. Reload the page to see the current list.` | Reload the page, check the list and make the change again. |
| `Couldn't confirm the save. The saved IPs were refreshed. Check them and try again.` | Check the IPs shown. If your change is missing, make it again. |

Errors in the key generation step appear under the **Server IP addresses** text box after you leave it. Errors in the **IP whitelist** section appear when you click **Add**.

![Add your server IPs pop-up page showing the error that 10.0.0.5 is a private address](https://mintcdn.com/razorpay-881012b3/vvOO1YMETthd9A-D/static/docs-home/assets/api-key-ip-whitelist-error-key-step.jpg?fit=max\&auto=format\&n=vvOO1YMETthd9A-D\&q=85\&s=712fcdb70dcae373df0169cb178acb05)

![IP whitelist section showing the error that 192.168.1.0 is a private address](https://mintcdn.com/razorpay-881012b3/vvOO1YMETthd9A-D/static/docs-home/assets/api-key-ip-whitelist-error-section.jpg?fit=max\&auto=format\&n=vvOO1YMETthd9A-D\&q=85\&s=62dde782bd2dcf669c1bc9f093186f50)

## If Your API Calls Are Blocked

A call from an IP that is not on the IP whitelist fails with an error. To fix it:

1. Run the check in [Find the Public IP of Your Server](#find-the-public-ip-of-your-server) on the server that made the call.
2. Log in to the Dashboard and add that IP to the IP whitelist. The IP whitelist does not affect the Dashboard.
3. Retry the call.

## Best Practices

Follow these practices to get the most from the IP whitelist:

* **Turn on the IP whitelist for your Live keys.** Generate a key without an IP whitelist only if your servers have no fixed public IP yet. Add IPs as soon as you have one.
* **Use fixed outbound IPs.** Send API calls from addresses that do not change on restart or redeploy, such as an Elastic IP or a NAT gateway with static IPs. See [Find the Public IP of Your Server](#find-the-public-ip-of-your-server).
* **Add every server that calls Razorpay's APIs.** Include each region, NAT gateway, standby or failover server and scheduled jobs such as refund or reconciliation scripts. Razorpay blocks calls from a server you leave out.
* **Keep Test and Live separate.** Add your development machines and office IPs to the Test IP whitelist only. The Live IP whitelist must hold only the servers that make Live API calls.
* **Add the new IP before you remove the old one.** When you move servers or change an IP, add the new address first. Check that API calls from it work, then remove the old address.
* **Review the IP whitelist regularly.** Remove IPs you no longer use. Check that IPs with a dash under **Added by**, which Razorpay Support added before self-serve, are still yours.
* **Regenerate keys with care.** Regenerating a key keeps your IP whitelist. **Regenerate without IP whitelist** removes every IP in that mode, so choose it only if that is what you want.
* **Keep your key secret on your servers.** Never put it in website code, mobile apps or public code repositories. Store it in a secrets manager or in environment variables. An IP whitelist limits where the secret works, but it does not replace keeping the secret safe.
* **Limit who can make changes.** Only users with the Owner, Pseudo Owner or Admin role can change the IP whitelist. Give those roles only to people who need them.

## Frequently Asked Questions

> [accordion] Does the IP whitelist affect my customers' payments on Checkout?
>
> No. Checkout uses only your key ID from your customers' browsers and apps, and Razorpay does not check those calls. Razorpay checks only calls made with your key ID and secret.

> [accordion] Does the IP whitelist affect webhooks?
>
> No. Webhooks are calls from Razorpay to your server. The IP whitelist checks calls from your server to Razorpay.

> [accordion] Is the IP whitelist the same as whitelisting my website?
>
> No. Website whitelisting controls which websites and apps can accept payments. The IP whitelist controls which servers can call Razorpay's APIs with your key secret. Know more about [business website details](https://razorpay.com/docs/payments/dashboard/account-settings/business-website-details.md).

> [accordion] Is the IP whitelist the same as the RazorpayX IP allowlist?
>
> No. RazorpayX payouts have their own IP allowlist, managed in RazorpayX. Know more about [Allowlist IPs](https://razorpay.com/docs/x/dashboard/allowlist-ip.md). The IP whitelist on this page covers payment APIs.

### Related Information

* [API Keys](https://razorpay.com/docs/payments/dashboard/account-settings/api-keys.md)
* [Manage API Key Secrets](https://razorpay.com/docs/payments/dashboard/account-settings/api-key-secrets.md)
* [API Best Practices](https://razorpay.com/docs/api/best-practices.md)
