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

# Create API key

> Create a new API key for an organization. Plain key is returned only once!



## OpenAPI

````yaml https://api.timbrix.mx/api/openapi.json post /organizations/{organizationId}/api-keys
openapi: 3.0.0
info:
  title: Timbrix API
  description: >-
    API de facturación electrónica CFDI 4.0 para México, con servidor OAuth2
    para gestionar organizaciones, miembros y webhooks. Compatible con agentes
    de IA — ver la extensión `x-ai-agent-friendly` en la raíz de esta spec.


    REST API with OAuth2 server for managing organizations, members, and
    webhooks.
  version: '1.0'
  contact: {}
servers: []
security: []
tags:
  - name: organizations
    description: Organization management endpoints
  - name: oauth
    description: OAuth2 authentication and authorization
  - name: webhooks
    description: Webhook configuration and delivery
  - name: users
    description: User information endpoints
  - name: api-keys
    description: API Keys management and validation
paths:
  /organizations/{organizationId}/api-keys:
    post:
      tags:
        - api-keys
      summary: Create API key
      description: >-
        Create a new API key for an organization. Plain key is returned only
        once!
      operationId: ApiKeysController_create
      parameters:
        - name: organizationId
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateApiKeyDto'
      responses:
        '201':
          description: API key created successfully. Save the plain key securely!
        '400':
          description: Invalid input data. Check the validation errors in the response.
        '401':
          description: Authentication required. Provide a valid bearer token.
        '403':
          description: Access denied. Only owners and admins can create API keys.
      security:
        - bearer: []
components:
  schemas:
    CreateApiKeyDto:
      type: object
      properties:
        name:
          type: string
          description: API key name
          example: Production API Key
          minLength: 3
          maxLength: 50
        description:
          type: string
          description: API key description
          example: Used for production server
          maxLength: 200
        scopes:
          type: array
          description: >-
            API key scopes (permissions). Defaults to ['read:user'] if not
            provided
          example:
            - read:user
            - write:webhooks
          items:
            type: string
            enum:
              - read:user
              - write:user
              - read:organization
              - write:organization
              - read:members
              - write:members
              - read:webhooks
              - write:webhooks
              - read:api-keys
              - write:api-keys
              - read:invoices
              - write:invoices
        rateLimitPerMinute:
          type: number
          description: Rate limit per minute
          example: 60
          minimum: 1
          maximum: 10000
        rateLimitPerHour:
          type: number
          description: Rate limit per hour
          example: 1000
          minimum: 1
          maximum: 100000
        allowedIps:
          description: Allowed IP addresses (CIDR notation supported)
          example:
            - 192.168.1.1
            - 10.0.0.0/24
          type: array
          items:
            type: string
        expiresAt:
          type: string
          description: Expiration date
          example: '2025-12-31T23:59:59Z'
      required:
        - name
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````