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

# API keys

## Introduction

API keys are the main authentication mechanism of the HUB2 API. Understanding what they are and how to use them is essential.

API keys are managed on the [HUB2 Dashboard](https://dashboard.hub2.io), in the "Developer" section, as illustrated below:

![](https://mintcdn.com/hub2-83/aPkTvmVeXN9HXpuW/assets/dashboard/apikeys/01.webp?fit=max\&auto=format\&n=aPkTvmVeXN9HXpuW\&q=85\&s=32c20705e6cba62d76efad3ff8cff0bb)

The following screenshot shows the list of existing keys:

![](https://mintcdn.com/hub2-83/aPkTvmVeXN9HXpuW/assets/dashboard/apikeys/02.webp?fit=max\&auto=format\&n=aPkTvmVeXN9HXpuW\&q=85\&s=4a68e26c529005bf58804ed06fe29e9e)

## Key management

### Creating a key

> [!WARNING]
>
> For security reasons, the API key is only visible when it is created and **cannot be viewed afterwards**.

**1. Create a key**

Click the "**Create a key**" button to open the following window:

![](https://mintcdn.com/hub2-83/aPkTvmVeXN9HXpuW/assets/dashboard/apikeys/03.webp?fit=max\&auto=format\&n=aPkTvmVeXN9HXpuW\&q=85\&s=ab27f3cb57966a2af8efb7a656f104d7)

**2. Details**

* (Optional) Enter a **name** and a **description** for the new key.
* The **environment** (*sandbox* or *live*) is required. The new key is restricted to this environment. [Read more about environments.](#environment)

**3. IP Whitelist**

![](https://mintcdn.com/hub2-83/aPkTvmVeXN9HXpuW/assets/dashboard/apikeys/04.webp?fit=max\&auto=format\&n=aPkTvmVeXN9HXpuW\&q=85\&s=15ef4e3e1f26b0aecacb5273245f3951)

In this section, you can restrict which source IP addresses can use the new API key.

**4. Permissions**

![](https://mintcdn.com/hub2-83/aPkTvmVeXN9HXpuW/assets/dashboard/apikeys/05.webp?fit=max\&auto=format\&n=aPkTvmVeXN9HXpuW\&q=85\&s=1ed88258f34580fa30352e4689d201a0)

Set the permissions of the new API key here.

Permissions allow you to separate responsibilities: a merchant can use several API keys, for example one per component of its software, each with a different role.

**5. Review and validate**

![](https://mintcdn.com/hub2-83/aPkTvmVeXN9HXpuW/assets/dashboard/apikeys/06.webp?fit=max\&auto=format\&n=aPkTvmVeXN9HXpuW\&q=85\&s=13422ffa13bbc3f2fc0440fe95d5e6d3)

On the summary page, review the settings of the new API key, then click *Validate*.

> [!WARNING]
>
> The API key is only displayed once. Save it now in a secure vault: it will not be accessible later.

![](https://mintcdn.com/hub2-83/aPkTvmVeXN9HXpuW/assets/dashboard/apikeys/07.webp?fit=max\&auto=format\&n=aPkTvmVeXN9HXpuW\&q=85\&s=afbd296b2cf87279653ab57391d311d9)

### Editing a key

On each API key row, in the "Actions" column, an *Edit* button lets you change the settings of a key. Editing follows the same steps as creation, except that the key itself cannot be viewed. **Every setting can be edited**.

> [!WARNING]
>
> Changes to permissions and IP address restrictions take effect immediately. Review your changes carefully before saving them.

### Deleting a key

In the "Actions" column, a *Delete* button lets you delete a key.

> [!WARNING]
>
> Deleting a key is irreversible. Requests using the deleted key are rejected immediately after deletion.

## Using the keys

The [API reference](https://docs.hub2.io/api-reference/balance/check-merchant-balance.md) shows which endpoints require authentication. For these endpoints, set the following HTTP headers on every request to identify and authenticate the sender:

| Header | Description |
| :- | :- |
| `ApiKey` | Your API key |
| `MerchantId` | Your merchant ID, available on the HUB2 Dashboard |
| `Environment` | `sandbox` or `live`; must match the environment of the API key |

## API key configuration

### Environment

* `sandbox`: a closed environment for integration testing. No real transaction is created when the API key is set to the `sandbox` environment: HUB2 simulates provider behaviour, and `sandbox` transactions use the `sandbox` transfer and collection accounts.
* `live`: the real-world environment. A `live` key processes real traffic, and providers are contacted when the transaction endpoints are called. *Sending traffic in the `live` environment requires the GO LIVE and an integration review by HUB2.*

[More on transfer and collection accounts.](https://docs.hub2.io/integration/en/getting_started/api_operation.md#accounts)

### IP address restriction

IP address restriction is an optional feature that further secures exchanges between the merchant platform and HUB2.

When an IP address restriction is set on an API key, HUB2 checks that the IP address sending the HTTP request is authorized to use the API key it contains.

### Permissions

Permissions are configured per API key, so a merchant can create several keys with different permissions, each with its own responsibility. An API key must carry at least one API permission. A call to an endpoint whose permission the key lacks is rejected with `403` and the error code `missing_permission`.

The permissions and their descriptions are as follows. In the Dashboard, they are grouped under **Api** and listed by the part after `Api.` (for example `transfer_create`).

| Permission | Description |
| :- | :- |
| `Api.transfer_create` | Create transfers |
| `Api.transfer_read` | Read transfers |
| `Api.payment_intent_create` | Create payment intents and payment links |
| `Api.payment_intent_read` | Read payment intents and payment links |
| `Api.payment_intent_auth_create` | Authenticate a payment |
| `Api.payment_fees_read` | Read payment fees |
| `Api.provisionning_read` | Read provisioning requests |
| `Api.provisionning_create` | Create a provisioning request |
| `Api.merchant_balance_read` | Read the balances of the merchant accounts |
| `Api.terminal_payment_create` | Create payments made via a payment terminal |
| `Api.terminal_payment_read` | Read payments made via a payment terminal |
| `Api.kyb_read` | Read [KYB](https://docs.hub2.io/documentation/en/glossary.md#kyb) and [KYB transactions](https://docs.hub2.io/documentation/en/glossary.md#kyb-transaction) |
| `Api.kyb_update` | Update KYB |
| `Api.kyb_delete` | Delete KYB and KYB transactions |
| `Api.kyb_create` | Create KYB and KYB transactions |
| `Api.kyc_read` | Read KYC information |
| `Api.recipient_create` | Create recipients |
| `Api.recipient_read` | Read and list recipients |
| `Api.recipient_delete` | Delete recipients |
| `Api.refund_create` | Create refunds |
| `Api.refund_read` | Read refunds |
| `Api.deposit_create` | Create deposits |
| `Api.deposit_read` | Read deposits |
| `Api.delegated_payment_create` | Create payments using the merchant's own provider credentials |
| `Api.delegated_transfer_create` | Create transfers using the merchant's own provider credentials |
| `Api.submerchant_create` | Create submerchants |
| `Api.submerchant_list` | List submerchants |
| `Api.submerchant_update` | Update submerchants |
| `Api.submerchant_manage_status` | Manage the status of submerchants (not used by any endpoint yet) |
| `Api.subscription_intent_create` | Create card-on-file subscription enrollments |
| `Api.subscription_intent_read` | Read the status of a card-on-file enrollment |
| `Api.subscription_list` | List subscriptions |
| `Api.subscription_cancel` | Cancel a subscription |
| `Api.subscription_suspend` | Suspend a subscription |
| `Api.subscription_charge` | Charge a subscription |
| `Api.instant_payment_alias_create` | Create instant payment aliases |
| `Api.instant_payment_alias_read` | List instant payment aliases |
| `Api.instant_payment_alias_delete` | Delete instant payment aliases |

## Good practices

### API key rotation

A good security practice is to **renew API keys regularly**. If a key has been inadvertently disclosed to a third party, or stolen by a malicious one, deleting the affected keys and creating new ones limits the impact on the merchant's business.

> [!WARNING]
>
> **Disclaimer**: The merchant is responsible for storing its API keys securely on its platform. HUB2 cannot be held responsible for processing illegitimate traffic associated with a merchant API key that has been stolen or disclosed.


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