Delete an API Key - Cognigy Documentation

DELETE API Endpoint

Delete an API Key

To delete an API key for the current user, you can use the following endpoint:

DELETE /v2.0/users/me/apikeys/{apiKeyId}

Example cURL Request

curl --request DELETE \
  --url https://api-trial.cognigy.ai/new/v2.0/users/me/apikeys/{apiKeyId} \
  --header 'X-API-Key: <api-key>'

Example Using Python (requests Library)

import requests

url = "https://api-trial.cognigy.ai/new/v2.0/users/me/apikeys/{apiKeyId}"

headers = {"X-API-Key": "<api-key>"}

response = requests.delete(url, headers=headers)

print(response.text)

Example Using JavaScript (fetch API)

const options = {method: 'DELETE', headers: {'X-API-Key': '<api-key>'}};

fetch('https://api-trial.cognigy.ai/new/v2.0/users/me/apikeys/{apiKeyId}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

Example Using PHP (cURL)

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api-trial.cognigy.ai/new/v2.0/users/me/apikeys/{apiKeyId}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "DELETE",
  CURLOPT_HTTPHEADER => [
    "X-API-Key: <api-key>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Example Using Go

package main

import (
    "fmt"
    "net/http"
    "io"
)

func main() {
    url := "https://api-trial.cognigy.ai/new/v2.0/users/me/apikeys/{apiKeyId}"

req, _ := http.NewRequest("DELETE", url, nil)
    req.Header.Add("X-API-Key", "<api-key>")

res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}

Error Codes

Status Code Type Detail
400 Bad Request Validation failed. Missing payload.
401 Unauthorized
402 Payment Required Validation failed. Missing payload.
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

Response

Status 204: The API key was removed successfully.

Authorizations

Headers

Path Parameters