Create an API Key - Cognigy Documentation
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Create an API Key
Request
POST /v2.1/users/me/apikeys
Example Request with cURL
curl --request POST \
--url https://api-trial.cognigy.ai/new/v2.1/users/me/apikeys \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"name": "Office"
}
'
Example Request with Python
import requests
url = "https://api-trial.cognigy.ai/new/v2.1/users/me/apikeys"
payload = { "name": "Office" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
Example Request with JavaScript (Fetch)
const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'Office'})
};
fetch('https://api-trial.cognigy.ai/new/v2.1/users/me/apikeys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
Response Codes
- 201 Created
- 400 Bad Request
- 401 Unauthorized
- 402 Payment Required
- 403 Forbidden
- 404 Not Found
- 405 Method Not Allowed
- 409 Conflict
- 413 Payload Too Large
- 500 Internal Server Error
- 501 Not Implemented
- 502 Bad Gateway
- 503 Service Unavailable
- 504 Gateway Timeout
Example Response
{
"name": "<string>",
"_id": "<string>",
"createdAt": 1527621049,
"apiKey": "<string>"
}
Errors
- Bad Request Error
{
"type": "Bad Request",
"title": "Bad Request Error",
"status": 400,
"detail": "Validation failed. Missing payload.",
"code": 1000
}
- Unauthorized Error
{
"type": "Unauthorized",
"title": "Unauthorized Error",
"status": 401,
"detail": "<string>",
"code": 401
}
Authorizations
API Key
| Header | Description |
|---|---|
X-API-Key |
Supply the API Key in the HTTP header. |
Headers
| Header | Type | Description |
|---|---|---|
Accept |
enum | The Accept header specifies media type. Available options: application/json, application/xml, etc. |
Body
| Parameter | Type | Description |
|---|---|---|
name |
string | The name of the ApiKey. Example: "Office" |
Response
Returns the created api-key in JSON format.