Authentication

AI Defense uses API keys to authenticate and secure communication between your applications and its services. Generate API keys in the AI Defense UI.

Generating an API Key

To use the AI Defense Management API, you must generate an API key through the AI Defense Dashboard, follow these steps:

  1. In AI Defense, click Administration.
  2. In the Administration page, click API Keys and click Create an API key.
  3. Specify a Name for the key.
  4. Specify the Expire on date or set it to Never Expire.
  5. Click Create.
  6. Copy this key and save it to a secure location. You will not be able to see the token again after you close this page. You use this token to make requests of the AI Defense Management API endpoint.

    Note: You cannot use this key for the AI Defense Inspection API. See Applications for Inspection API key instructions.

Revoking an API Key

To revoke an existing API key, follow these steps:

  1. In AI Defense, click Administration.
  2. In the Administration page, click API Keys.
  3. Click the name of the key you wish to revoke.
  4. At the bottom of the window, click Revoke Key.

Note: Once revoked, the key becomes inactive immediately. You must generate a new API key to continue using the API.

Authenticate with Your API Key

When you call a Management API endpoint, include your API key in each request using the custom x-cisco-ai-defense-tenant-api-key header:

x-cisco-ai-defense-tenant-api-key: <your_api_key>

Example using cURL

Here's an example in which we call GET applications to retrieve a list of all the saved applications. This example uses the North American regional base URL. See the Getting Started page for the base URL to use in your region.

curl -X GET 'https://api.us.security.cisco.com/api/ai-defense/v1/applications' \
 --header 'Accept: application/json' \
 --header 'x-cisco-ai-defense-tenant-api-key: <generated api key>' \

Here's an example in which we call POST ai-validation/start to start a validation run:

curl -X POST 'https://api.us.security.cisco.com/api/ai-defense/v1/ai-validation/start' \
 --header 'x-cisco-ai-defense-tenant-api-key: <generated api key>' \
 --header 'Content-Type: application/json' \
 --data-raw '{"key":"value"}'

Example using Python:

Here's a Python example in which we call GET applications to retrieve a list of all the saved applications. This example uses the North American regional base URL. See the Getting Started page for the base URL to use in your region.

import json

url = "https://api.us.security.cisco.com/api/ai-defense/v1/applications"

headers = {
    'Accept': 'application/json',
    'x-cisco-ai-defense-tenant-api-key': '<generated api key>'
}

response = requests.request("GET", url, headers=headers)

print(response.text)