1. The CLI edge command

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.

Usage and options

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:

OptionDescription
--tokenThe Experience Edge API key value.
--hashThe Experience Edge API key hash.Returns information about the API keys in JSON format.
--pageSizeThe number of API keys to return in one chunk/page.Default: 20
--pageNumberThe page number to return when the result includes more than one page.Default: 1
--all, --showAllIf provided, the list of keys includes revoked keys. Revoked API keys are marked with a [REVOKED] indicator.
--env, --environmentSpecifies the Experience Edge environment to target.Possible values: preprod, prodDefault: prod
-?, -h, --helpDisplays 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.

Subcommands

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:

OptionDescription
-l, --labelRequired.The Experience Edge API key label.
-s, --scopesThe scopes of the Experience Edge API key.Default: audience-delivery content-#everything#
-by, --createdByThe user to assign as the creator of the API keys.Default: currently logged-in user.
--env, --environmentSpecifies the Experience Edge environment to target.Possible values: preprod, prodDefault: prod
-?, -h, --helpDisplay 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:

OptionDescription
--tokenThe Experience Edge API key value.
--hashThe Experience Edge API key hash.
--env, --environmentSpecifies the Experience Edge environment to target.Possible values: preprod, prodDefault: prod
-?, -h, --helpDisplays developer help and usage information about the command.
If you have suggestions for improving this article, let us know!