---
updatedAt: 2026-05-04T21:43:38.000Z
agentTools:
  projectIndex: https://docs.toqua.ai/llms.txt
---

# Generate Api Key

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Toqua API",
    "contact": {
      "name": "Toqua",
      "url": "https://toqua.ai/",
      "email": "admin@toqua.ai"
    },
    "version": "0.26"
  },
  "servers": [
    {
      "url": "https://api.toqua.ai",
      "description": "Toqua API"
    }
  ],
  "paths": {
    "/auth/keys": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Generate Api Key",
        "operationId": "generate_api_key",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApiKeyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKey"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          },
          {
            "HTTPBearer": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "ApiKey": {
        "properties": {
          "key": {
            "type": "string",
            "format": "password",
            "title": "Secret API key",
            "writeOnly": true,
            "examples": [
              "tqk_6AZTuEkGDAuOoJX1mc09PShS7cRC4P2chZr0"
            ]
          },
          "description": {
            "type": "string",
            "maxLength": 128,
            "title": "A description of the key",
            "examples": [
              "My API key"
            ]
          },
          "creation_date": {
            "type": "string",
            "title": "Creation date",
            "description": "The date on which the API Key was generated.",
            "examples": [
              "2022-08-02T09:21:24+00:00"
            ]
          },
          "expiry_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expiry date",
            "description": "The date on which the API Key expires.",
            "examples": [
              "2022-08-02T09:21:24+00:00"
            ]
          },
          "key_id": {
            "type": "string",
            "title": "Unique key ID",
            "examples": [
              "341bcb8e-2faf-4ce6-99f7-9f9e52b38d75"
            ]
          }
        },
        "type": "object",
        "required": [
          "key",
          "description",
          "key_id"
        ],
        "title": "ApiKey"
      },
      "ApiKeyRequest": {
        "properties": {
          "description": {
            "type": "string",
            "maxLength": 255,
            "title": "A description of the key",
            "examples": [
              "My API key"
            ]
          },
          "duration": {
            "type": "integer",
            "minimum": 0,
            "title": "How many days the key will remain valid. A value of 0 means indefinitely.",
            "examples": [
              15
            ]
          },
          "owner": {
            "type": "string",
            "maxLength": 255,
            "title": "Owner of the API key",
            "examples": [
              "toqua"
            ]
          }
        },
        "type": "object",
        "required": [
          "description",
          "duration",
          "owner"
        ],
        "title": "ApiKeyRequest"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    },
    "securitySchemes": {
      "APIKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      },
      "HTTPBearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "externalDocs": {
    "description": "API Documentation",
    "url": "https://docs.toqua.ai"
  }
}
```