API keys
To use the Preview or Delivery API, 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, if you have the necessary permissions.
An API key is only valid for a specific tenant (app) within an organization. For a list of endpoints, see 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.
Only lowercase API key type names are valid (that is, delivery and preview).
curl --location '<Base_URL>/api/content/v1/apikeys' \
--header 'Content-Type: application/json' \
--header 'Authorization: <BEARER_TOKEN>' \
--data '{
"name": "preview_key",
"type": "preview"
}'
{
apiKey: "AaBaCcDdEdFfGg=="
}
List the API keys
Use this method to list all the API keys.
curl --location '<Base_URL>/api/content/v1/apikeys' \
--header 'Authorization: <BEARER_TOKEN>' \
--data ''
{
"totalCount": 2,
"pageSize": 20,
"pageNumber": 1,
"data": [
{
"name": "jlo-preview",
"type": "preview",
"hash": "f1a0ceb8e8d3aa21077b241ee67cc",
"createdBy": {
"type": "Link",
"relatedType": "User",
"id": "[email protected]",
"uri": "<Base_URL>/api/content/v1/users/[email protected]"
},
"createdAt": "2023-10-04T18:36:54.7338696+00:00"
},
{
"name": "jlo-delivery",
"type": "delivery",
"hash": "907417c99ce963b6463a7c05680da6a83",
"createdBy": {
"type": "Link",
"relatedType": "User",
"id": "[email protected]",
"uri": "<Base_URL>/api/content/v1/users/[email protected]"
},
"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 --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 --location --request DELETE '<Base_URL>/api/content/v1/apikeys/<hash>' \
--header 'Authorization: <BEARER_TOKEN>' \
--data ''