---
title: "API keys"
slug: "api-keys"
abstract: "How to use the Content Management API to create, list, rename, and delete API keys for the GraphQL Preview and Delivery APIs."
---
# API keys

To use the [Preview or Delivery API](https://doc.sitecore.com/ch-one/en/developers/content-hub-one/content-management-api/preview-and-delivery-apis.md "Preview and Delivery APIs"), you must have a valid API key, which you enter on the **HEADERS** tab in the GraphQL IDE. You can create, rename, or delete API keys using either the API or the [Content Hub ONE app](https://doc.sitecore.com/ch-one/en/developers/content-hub-one/content-management-api/manage-api-keys-using-the-app.md "Manage API keys using the app"), if you have the necessary permissions.

> [!note]
> An API key is only valid for a specific tenant (app) within an organization. For a list of endpoints, see [Content Management API](https://doc.sitecore.com/ch-one/en/developers/content-hub-one/content-management-api.html "Content Management API").

## Create an API key

Use this method to create an API key. The following example includes two parameters:

- *name* is the name you define for the key.
- *type* is the type of key. There are two types: *delivery* when you are generating an API key for a production environment or *preview* when you are generating a key for a staging or testing environment.

> [!note]
> Only lowercase API key type names are valid (that is, *delivery* and *preview*).

```curl
curl --location '<Base_URL>/api/content/v1/apikeys' \
--header 'Content-Type: application/json' \
--header 'Authorization: <BEARER_TOKEN>' \
--data '{
  "name": "preview_key",
  "type": "preview"
}'
```

```json
{
 apiKey: "AaBaCcDdEdFfGg=="
}
```

## List the API keys

Use this method to list all the API keys.

```curl
curl --location '<Base_URL>/api/content/v1/apikeys' \
--header 'Authorization: <BEARER_TOKEN>' \
--data ''
```

```json
{
    "totalCount": 2,
    "pageSize": 20,
    "pageNumber": 1,
    "data": [
        {
            "name": "jlo-preview",
            "type": "preview",
            "hash": "f1a0ceb8e8d3aa21077b241ee67cc",
            "createdBy": {
                "type": "Link",
                "relatedType": "User",
                "id": "jlo@sitecore.com",
                "uri": "<Base_URL>/api/content/v1/users/jlo@sitecore.com"
            },
            "createdAt": "2023-10-04T18:`36:54`.7338696+`00:00`"
        },
        {
            "name": "jlo-delivery",
            "type": "delivery",
            "hash": "907417c99ce963b6463a7c05680da6a83",
            "createdBy": {
                "type": "Link",
                "relatedType": "User",
                "id": "jlo@sitecore.com",
                "uri": "<Base_URL>/api/content/v1/users/jlo@sitecore.com"
            },
            "createdAt": "2023-10-04T18:`25:02`.7325993+`00:00`"
        }
    ]
}
```

## Rename an API key

Use this method to rename an API key. To do this, you need the hash. You can fetch the hash by retrieving a list of API keys. This request includes the following parameter:

- *hash* is the hash code.

```curl
curl --location --request PUT '<Base_URL>/api/content/v1/apikeys/<hash>' \
--header 'Content-Type: application/json' \
--header 'Authorization: <BEARER_TOKEN>'
--data '{
  "name": "new_preview_key_name"
}'
```

## Delete an API key

Use this method to delete a specific API key. To do this, you need the hash. You can fetch the hash by retrieving a list of API keys. This request includes the following parameter:

- *hash* is the hash code.

```curl
curl --location --request DELETE '<Base_URL>/api/content/v1/apikeys/<hash>' \
--header 'Authorization: <BEARER_TOKEN>' \
--data ''
```