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

Endpoint:

POST /v2.0/users/me/apikeys

Example cURL Request:

curl --request POST \
  --url https://api-trial.cognigy.ai/new/v2.0/users/me/apikeys \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "name": "Office"
}
'

Example Python Request:

import requests

url = "https://api-trial.cognigy.ai/new/v2.0/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 JavaScript Fetch API Request:

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.0/users/me/apikeys', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

Response Codes:

Example Response:

{
  "name": "<string>",
  "_id": "<string>",
  "createdAt": 1527621049,
  "apiKey": "<string>"
}

Error Response Example:

{
  "type": "Bad Request",
  "title": "Bad Request Error",
  "status": 400,
  "detail": "Validation failed. Missing payload.",
  "instance": "/v2.0/flows/5ce7c2d833ea1e04d7e6c432",
  "code": 1000,
  "traceId": "api--f84324f4-98eb-4f02-abdd-375a2e6c3c1f",
  "details": {}
}

Authorization

X-API-Key - Supply the API Key in the HTTP header.

Request Headers

Request Body