---
title: "The edge apikey command"
slug: "the-edge-apikey-command"
abstract: "Reference for the Sitecore CLI edge apikey command for managing Experience Edge API keys."
---
# The edge apikey command

The Experience Edge plugin for Sitecore CLI provides the `edge apikey` command to help you manage API keys for Experience Edge.

<details>
<summary><h2>Usage and options</h2></summary>

You can use the `edge apikey` command as follows:

```shell
dotnet sitecore edge apikey [subcommand] [options]

```

Using the command without any subcommands or options returns the list of active API keys for the currently selected tenant. For example:

```shell
dotnet sitecore edge apikey

```

You can use the following options with the `edge apikey` command:

| Option | Description |
| --- | --- |
| `--token` | The Experience Edge API key value. |
| `--hash` | The Experience Edge API key hash.<br><br>Returns information about the API keys in JSON format. |
| `--pageSize` | The number of API keys to return in one chunk/page.<br><br>Default: 20 |
| `--pageNumber` | The page number to return when the result includes more than one page.<br><br>Default: 1 |
| `--all`, `--showAll` | If provided, the list of keys includes revoked keys. Revoked API keys are marked with a `[REVOKED]` indicator. |
| `--env`, `--environment` | Specifies the Experience Edge environment to target.<br><br>Possible values: `preprod`, `prod`<br><br>Default: `prod` |
| `-?`, `-h`, `--help` | Displays developer help and usage information about the command. |

For example, to show the second page of five API keys for the current tenant, including the revoked keys, run the following command:

```shell
dotnet sitecore edge apikey --pageSize 5 --pageNumber 2 --all

```

To get detailed information about an API key, run the following command:

```shell
dotnet sitecore edge apikey --hash <your-api-key-hash>

```

The command displays JSON-formatted information about the API key:

```json
{
  "Hash": "XXXXX",
  "IsRevoked": <false|true>,
  "Label": "<apikey-label>",
  "Scopes": [
    "audience-preview",
    "content-#everything#"
  ],
  "CreatedBy": "<user>",
  "Created": "<created-date>"
}

```

> [!note]
> Dates are displayed in local time.

</details>

<details>
<summary><h2>Subcommands</h2></summary>

You can use the following subcommands:

- `create` - creates a new Experience Edge API key.
- `revoke` - revokes an Experience Edge API key.

### The create subcommand

The `create` subcommand creates a new Experience Edge API key based on the provided options. For example:

```shell
dotnet sitecore edge apikey create -l Main

```

The command prints the newly created API key.

> [!important]
> Experience Edge does not store API keys in plain text. It is therefore vital that you copy the API key from the output and keep it safe.

You can use the following options with the `create` subcommand:

| Option | Description |
| --- | --- |
| `-l`, `--label` | Required.<br><br>The Experience Edge API key label. |
| `-s`, `--scopes` | The scopes of the Experience Edge API key.<br><br>Default: `audience-delivery content-#everything#` |
| `-by`, `--createdBy` | The user to assign as the creator of the API keys.<br><br>Default: currently logged-in user. |
| `--env`, `--environment` | Specifies the Experience Edge environment to target.<br><br>Possible values: `preprod`, `prod`<br><br>Default: `prod` |
| `-?`, `-h`, `--help` | Display developer help and usage information about the command. |

### The revoke subcommand

The `revoke` subcommand deactivates an Experience Edge API key to prevent it from being used. For example:

```shell
dotnet sitecore edge apikey revoke --hash <your-api-key-hash>

```

You can use the following options with the `revoke` subcommand:

| Option | Description |
| --- | --- |
| `--token` | The Experience Edge API key value. |
| `--hash` | The Experience Edge API key hash. |
| `--env`, `--environment` | Specifies the Experience Edge environment to target.<br><br>Possible values: `preprod`, `prod`<br><br>Default: `prod` |
| `-?`, `-h`, `--help` | Displays developer help and usage information about the command. |

</details>