> ## Documentation Index
> Fetch the complete documentation index at: https://docs.defindex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate API Key

> Generates a new API key for the authenticated user. Only one API key per user is allowed - generating a new one will revoke the previous one.



## OpenAPI

````yaml POST /api-keys/generate
openapi: 3.0.0
info:
  title: DeFindex API
  description: API documentation for DeFindex endpoints
  version: 1.0.0
  contact: {}
  x-logo:
    url: https://links.paltalabs.io/defindex-full.svg
    backgroundColor: '#0e0e0e'
    altText: DeFindex Logo
    href: https://defindex.io
servers: []
security: []
tags: []
paths:
  /api-keys/generate:
    post:
      tags:
        - API Keys
      summary: Generate API Key
      description: >-
        Generates a new API key for the authenticated user. Only one API key per
        user is allowed - generating a new one will revoke the previous one.
      operationId: ApiKeysController_generateApiKey
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiKeyGenerateDto'
      responses:
        '201':
          description: API key generated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  key:
                    type: string
                    example: sk_1234567890abcdef...
                    description: The generated API key
                  id:
                    type: number
                    example: 1
                    description: The unique identifier for the API key
      security:
        - bearer: []
components:
  schemas:
    ApiKeyGenerateDto:
      type: object
      properties:
        name:
          type: string
          example: My Server API Key
          description: >-
            Optional name for the API key. If not provided, a default name will
            be used.
          maxLength: 100
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.