Manage API keys using the API
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.
Create an API key
Use this method to create an API key.
POST {Base URL}/content/v1/apikeys
Request
Only lowercase API key type names are valid (that is, delivery and preview).
POST {Base URL}/content/v1/apikeys
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.
Response
{
apiKey: "AaBaCcDdEdFfGg=="
}
List the API keys
Use this method to list all the API keys.
GET api/content/v1/apikeys
Request
GET {Base URL}/content/v1/apikeys
A request to list API keys includes the following parameters:
- pageNumber is the page number to return. The default is 1.
- pageSize is the number of results to return per page. The default is 20. The maximum is 100.
Response
{
"totalCount": 2,
"pageSize": 20,
"pageNumber": 1,
"data": [
{
"name": "My Delivery Key",
"type": "delivery",
"hash": "R4ZkQ4emoyMzR5aEx3c0dCcTJnZEplcnVlbDV",
"createdBy": "Administrator",
"createdAt": "2022-04-25T12:11:32"
},
{
"name": "My Preview Key",
"type": "preview",
"hash": "Ex3c0dCcTJnZEplcnVlbDVRbz18bXRzdC1kLTA",
"createdBy": "John Johnson",
"createdAt": "2022-03-29T02:11:02"
}
]
}
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.
PUT {Base URL}/content/v1/apikeys/{hash}
Request
PUT {Base URL}/content/v1/apikeys/{hash}
Parameters:
- hash is the hash code.
Delete an API key
Use this method to delete a specific API key.
DELETE {Base URL}/content/v1/apikeys
Parameters:
- pageNumber is the page number to return. The default is 1.
- pageSize is the number of results to return per page. The default is 20. The maximum is 100.
Request
DELETE {Base URL}/content/v1/apikeys