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

# Create API Key

> Creates a new API key. This endpoint allows you to generate an API key that can be used to authenticate requests to the Attention service.



## OpenAPI

````yaml post /api_keys
openapi: 3.0.1
info:
  title: Attention Service V2
  description: Attention Service API V2
  termsOfService: https://www.attention.com/terms-of-use
  contact:
    name: Attention Team
    url: https://docs.attention.com/welcome
    email: support@attention.com
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.8.0
servers:
  - url: https://api.attention.tech/v2
security:
  - APIKeyHeader: []
paths:
  /api_keys:
    post:
      tags:
        - API Key
      summary: Create API Key
      description: >-
        Creates a new API key. This endpoint allows you to generate an API key
        that can be used to authenticate requests to the Attention service.
      operationId: createApiKey
      requestBody:
        description: Details of the application for which to generate the API key.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAPIKeyRequest'
          application/vnd.api+json:
            schema:
              $ref: '#/components/schemas/CreateAPIKeyRequest'
        required: true
      responses:
        '200':
          description: Successfully created API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIKey'
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/APIKey'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/Error'
        default:
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CreateAPIKeyRequest:
      required:
        - name
        - orgLevel
      type: object
      properties:
        name:
          type: string
          description: The name of the API key
        orgLevel:
          type: boolean
          description: Whether the API key is organization-level or user-level
      example:
        name: Admin API Key
        orgLevel: true
    APIKey:
      required:
        - id
        - lastSeenAt
        - name
        - organizationUUID
        - userUUID
        - value
      type: object
      properties:
        id:
          type: string
          description: The unique identifier of the API key
        name:
          type: string
          description: The name of the API key
        organizationUUID:
          type: string
          description: The UUID of the organization this API key belongs to, if applicable
        userUUID:
          type: string
          description: The UUID of the user this API key belongs to, if applicable
        value:
          type: string
          description: The actual API key value
        lastSeenAt:
          type: string
          description: The last time this API key was used
          format: date-time
      example:
        id: e5323e40-xxxx-4f6f-84f6-85eba56091ed
        name: Admin API Key
        organizationUUID: 16b78cec-xxxx-46d2-8213-5d3bb7d2571c
        value: >-
          eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.KMUFsIDTnFmyG3nMiGM6H9FNFUROf3wh7SmqJp-QV30
        lastSeenAt: '2024-03-20T10:00:00Z'
    Error:
      type: object
      properties:
        id:
          type: string
          description: A unique identifier for the error.
        status:
          type: string
          description: >-
            The HTTP status code applicable to this problem, expressed as a
            string value.
        code:
          type: string
          description: An application-specific error code, expressed as a string value.
        title:
          type: string
          description: A short, human-readable summary of the problem.
        detail:
          type: string
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
        source:
          type: object
          properties:
            pointer:
              type: string
            parameter:
              type: string
        meta:
          type: object
          properties: {}
      example:
        id: not_found_error
        status: '404'
        code: '404'
        title: Not Found Error
        detail: The requested resource was not found
        source:
          pointer: /data/attributes/id
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      name: Authorization
      in: header

````