# Create and manage an API key

Self-managed FIX sessions are authenticated with an API key created in the [Revolut X web app](https://exchange.revolut.com/account/api-keys). The key carries your **Comp ID**, your Ed25519 public key and the FIX permissions granted to the session.

:::note
FIX access requires a non-primary sub-account. API keys created for the primary account cannot use the FIX permissions.
:::

## Before you begin

Before you start, make sure you have:

- A Revolut X account with at least one [sub-account](https://exchange.revolut.com/account/sub-accounts) that is not the primary account.
- An Ed25519 key pair, generated locally as described below.

## Generate an Ed25519 key pair

The FIX API key is bound to an **Ed25519 key pair**.
The **private key** is kept secret and used to sign the [**`A` (Logon)**](/docs/guides/exchange-fix-api/trading-fix-api/supported-fix-messages/fix-session-level-messages/message-A-logon) message, while the **public key** is registered on the API key so Revolut can verify the signature.

You can generate this pair using `openssl`.

### 1. Generate the private key

Run the following command in your terminal:

```sh
openssl genpkey -algorithm ed25519 -out private.pem
```

This command generates a file named `private.pem`, which contains your private key.
It has the following structure:

```
-----BEGIN PRIVATE KEY-----
{YOUR BASE64-ENCODED PRIVATE KEY}
-----END PRIVATE KEY-----
```

:::danger[IMPORTANT: Secure your private key]
This is your **private** key, and it will be used for signing your FIX logons.
**Your private key is a secret.**
Never share it with anyone and never send it as a part of any message.
:::

### 2. Generate the public key

Next, generate the public key from your private key:

```sh
openssl pkey -in private.pem -pubout -out public.pem
```

This command generates a file named `public.pem` with your public key.
It has the following structure:

```
-----BEGIN PUBLIC KEY-----
{YOUR BASE64-ENCODED PUBLIC KEY}
-----END PUBLIC KEY-----
```

:::info[About your public key]
This is your **public** key.
It is not secret, and it is safe to share.
You will provide this key to Revolut X so we can verify the Logon messages signed with your matching private key.

When you provide it, make sure that you copy all of it, including the `-----BEGIN PUBLIC KEY-----` and `-----END PUBLIC KEY-----` lines.
:::

## Create the API key

Once you have your **public key** (the content of `public.pem`), you are ready to create your API key.

1. Go to the [**API keys**](https://exchange.revolut.com/account/api-keys) page in the Revolut X web app and select **New**.
2. In **Account**, select a non-primary sub-account.
3. Enter an **API key name**.
4. Paste the content of `public.pem` into **Public key**.
5. Enable the FIX permissions you need:
    - **FIX order entry trade**: required for the Trading FIX API session.
    - **FIX market data read**: required for the Market Data FIX API session.
6. Optionally, in **IP whitelist**, enter the public egress IPv4 addresses you will connect from, separated by commas, for example `203.0.113.10,198.51.100.20`.
    Individual addresses only. CIDR ranges are not supported.
7. Optionally, set an **Expiration date** for the key. Once set, the expiration date cannot be changed.
8. Select **Save**.

:::warning
Save the full API key when it is first shown.
Only a masked value is displayed afterwards, and the masked value cannot be used to log on.
:::

## Comp ID

Every API key has a **Comp ID**, shown in the key details.
Use this value as <code><b>49</b> SenderCompID</code> in the FIX message header of all your messages.

Keys created for the same owner and the same sub-account share one Comp ID, including replacement keys.

## Rotate a key

To rotate an API key, create a replacement key for the same sub-account with the same permissions, reconnect with the new key, then disable or delete the old key.
Existing keys can be edited, disabled or deleted at any time.