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

# Restrict API keys by IP address (per-key IP allowlist)

> Set the IP addresses (IPv4 or CIDR ranges) that can use each Public API key. Learn how to add and edit the list, which values you can enter, and what happens when a request comes from an address that isn't allowed.

## Overview

You can set the source IP addresses that can use each Public API key.
If a request uses the API key from any other address, the request is refused.

* The setting is per API key. Each API key can have a different list.
* An API key with an empty list can be used from any IP address.
* You can add IPv4 addresses and CIDR ranges. IPv6 isn't supported.
* This setting is separate from the organization's [IP restriction](https://support.i.moneyforward.com/en/it-management/settings/0xo5rmfxw8-ip-restriction.md), which restricts browser access. IP restriction doesn't apply to access with API keys.

> [!NOTE]
>
> To enter allowed IP addresses when you generate an API key, you need permission to create API keys.
> To edit the list of an existing API key, you need permission to update API keys. Login users with the Admin role have this permission.
> Roles that can only create API keys, such as the Operator role, can enter the list when generating a key. They don't see **Edit IP allowlist** for existing keys.

## Check the current lists

Open **Settings** > **API Keys**.
The **IP allowlist** column shows the list of each API key.

| Shown | Meaning |
| - | - |
| **Any address** | No addresses are added. The API key can be used from any IP address. |
| **1 address**, **2 addresses**, and so on | The number of entries. The API key can be used only from these addresses. |

![API key list. The IP allowlist column shows Any address and 2 addresses](https://mintcdn.com/moneyforwardi/Ws9Q0ykhHXEX2RQt/images/en/it-management/bulpw3cqk0/api-key-list.png?fit=max\&auto=format\&n=Ws9Q0ykhHXEX2RQt\&q=85\&s=d74a71bcde03d59cba5147de2baaf90a)

## Add addresses when you generate an API key

1. Open **Settings** > **API Keys** and click **Generate a new API key**.

2. In the "Generate a new API key" dialog, enter **API Key Name**, **Expires in**, and **Access level**.

3. Under **Allowed IP addresses**, click **Add IP address**. Enter an IP address or CIDR range and an optional description (see [Values you can enter](#allowed-values)).
   To add more entries, click **Add IP address** again.

   ![The Generate a new API key dialog. 203.0.113.0/24 and Tokyo office are entered under Allowed IP addresses](https://mintcdn.com/moneyforwardi/Ws9Q0ykhHXEX2RQt/images/en/it-management/bulpw3cqk0/generate-dialog.png?fit=max\&auto=format\&n=Ws9Q0ykhHXEX2RQt\&q=85\&s=1d7a3dd3e95d144b6405f1989a0b470d)

4. Click **Generate**.

5. Copy the API key and store it in a safe place.

> [!NOTE]
>
> To generate an API key that can be used from any IP address, leave **Allowed IP addresses** empty and click **Generate**.
> If your organization already has 20 API keys, you can't enter allowed IP addresses until you delete an existing API key.
> Expired API keys count toward the 20 keys until you delete them.

## Edit the list of an existing API key

1. Open **Settings** > **API Keys**.

2. Hover over the ︙ at the right end of the API key's row and click **Edit IP allowlist** in the menu that appears.

   ![Edit IP allowlist and Delete shown at the right end of an API key row](https://mintcdn.com/moneyforwardi/Ws9Q0ykhHXEX2RQt/images/en/it-management/bulpw3cqk0/edit-action.png?fit=max\&auto=format\&n=Ws9Q0ykhHXEX2RQt\&q=85\&s=fc9faad5645d3a856350d85c600a2d58)

3. In the "Edit IP allowlist" dialog, add or change IP addresses or CIDR ranges and their optional descriptions.
   To remove a row, click the trash icon on the right of the row.
   This dialog has no "Allowed IP addresses" heading. The same fields as **Allowed IP addresses** in the generate dialog appear below the API key name.

   ![The Edit IP allowlist dialog with 203.0.113.0/24 and 198.51.100.7/32](https://mintcdn.com/moneyforwardi/Ws9Q0ykhHXEX2RQt/images/en/it-management/bulpw3cqk0/edit-dialog.png?fit=max\&auto=format\&n=Ws9Q0ykhHXEX2RQt\&q=85\&s=4de94ac8014716945984745fdcf885c2)

4. Click **Save**.

Saved changes apply to API requests right away.
If you remove all rows and save, the API key can be used from any IP address.

> [!NOTE]
>
> Saving replaces the API key's list with what is shown in the dialog.
> If another person changes the same API key's list while you're editing, the dialog shows "This key's IP allowlist was changed elsewhere while you were editing. Saving will overwrite those changes."
> If you save anyway, the other person's changes are overwritten.

## Values you can enter

| Item | Details |
| - | - |
| IP address | An IPv4 address (for example, `198.51.100.7`) or a CIDR range (for example, `203.0.113.0/24`) |
| Prefix length | `/8` to `/32` |
| Number of entries | Up to 100 per API key |
| Description | Optional. Up to 255 characters |

* An IP address without a prefix length is added as `/32` (a single address).
* You can't add the same range twice. `198.51.100.7` and `198.51.100.7/32` are treated as the same range.
* You can't add a range that includes an address the service uses internally.

![The Generate a new API key dialog. 203.0.113.0/4 is entered and "The prefix length must be between /8 and /32." is shown](https://mintcdn.com/moneyforwardi/Ws9Q0ykhHXEX2RQt/images/en/it-management/bulpw3cqk0/generate-dialog-error.png?fit=max\&auto=format\&n=Ws9Q0ykhHXEX2RQt\&q=85\&s=113aa307dbe2c631fa45d34bd7c721af)

## Requests from addresses that aren't allowed

If an API key has at least one entry, the request's source IPv4 address must be in one of the ranges.
Requests from other addresses are refused with HTTP status `403`.
Requests whose source address can't be determined are refused too.

```json theme={null}
{
  "statusCode": 403,
  "errorId": "api_key_ip_restricted",
  "errorDetails": {
    "message": "Access from this network is not allowed for this API key",
    "ip": "192.0.2.10"
  },
  "path": "/api/v1/organizations/<ORGANIZATION_ID>",
  "requestId": "<REQUEST_ID>"
}
```

`errorDetails.ip` is the source address that Admina checked.
It's `null` when the address couldn't be determined.

Changes to the list and refused requests are recorded in the [audit log](https://support.i.moneyforward.com/en/it-management/faq/3kr059fq2z-auditlog.md).

## Check the setting

1. In **API Keys**, check that the **IP allowlist** column shows the number of entries you added.
2. Call the API from an allowed address, for example `GET /api/v1/organizations/<ORGANIZATION_ID>`.
   Check that it returns HTTP status `200`.
3. Call the API with the same key from an address that isn't on the list. Check that it returns HTTP status `403` (`api_key_ip_restricted`).

## FAQ and troubleshooting

### Troubleshooting

| Symptom or message | Cause | Solution |
| - | - | - |
| The API returns `403` with `api_key_ip_restricted` | The source address isn't on the API key's list. Requests over IPv6 and requests whose source address can't be determined are refused too. | Check `errorDetails.ip` in the response. Add the source IPv4 address or CIDR range from **Edit IP allowlist**. |
| "Enter a valid IPv4 address or CIDR range, for example 203.0.113.0/24." | The IP address or CIDR range isn't in a valid format. | Enter a value such as `198.51.100.7` or `203.0.113.0/24`. |
| "IPv6 addresses are not supported." | You entered an IPv6 address. | Enter an IPv4 address or an IPv4 CIDR range. |
| "The prefix length must be between /8 and /32." | The prefix length is outside `/8` to `/32`. | Change the prefix length to a value from `/8` to `/32`. |
| "This range is already in the list." | You entered the same range twice. | Delete or change the duplicate row. |
| "You can add up to 100 entries." | You tried to add more than 100 entries to one API key. | Combine addresses into CIDR ranges. |
| "The description must be 255 characters or fewer." | The description is longer than 255 characters. | Shorten the description to 255 characters or fewer. |
| "This range includes an address the service uses internally, so it cannot be added. Remove it or enter a range that leaves that address out." | The range includes an address that Admina uses internally. | Narrow or split the range so that it doesn't include that address. |
| "IP allowlists for API keys aren't available for this organization right now. Reload the page and try again." | Per-key IP allowlists aren't available for this organization. | Reload the page. If the problem continues, contact Admina support. |
| **Edit IP allowlist** isn't shown | You don't have permission to update API keys. Login users without the Admin role, such as the Operator role, don't see it. | Ask a login user with the Admin role to edit the list. |

### FAQ

**Q. If I turn on IP restriction for the organization, is access with API keys restricted too?**

A. No.
The organization's [IP restriction](https://support.i.moneyforward.com/en/it-management/settings/0xo5rmfxw8-ip-restriction.md) applies only to browser access.
To restrict access with an API key, add allowed IP addresses to the API key as described on this page.

**Q. Do I need to regenerate the API key after changing its list?**

A. No.
The API key stays the same, and the new list applies as soon as you save it.

**Q. If my current IP address isn't on the list, will I be locked out of the web app?**

A. No.
Per-key IP allowlists apply only to API requests that use the API key.
They don't affect signing in to the web app.

**Q. Are Admina Extension and Admina Tracker restricted too?**

A. No.
Per-key IP allowlists apply only to API keys created in **API Keys**.

## Related pages

* [IT Management API authentication](https://support.i.moneyforward.com/en/api-reference/it-management/authentication.md)
* [Use the Public API](https://support.i.moneyforward.com/en/it-management/faq/cw1ivgng0g-admina-api.md)
* [Restrict access by IP address (IP restriction)](https://support.i.moneyforward.com/en/it-management/settings/0xo5rmfxw8-ip-restriction.md)
* [Required IP addresses, URLs, and ports](https://support.i.moneyforward.com/en/it-management/faq/nmglgrm1ik-restrict-ip.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.