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

# Create API Key

> Create a new API key for edge agents. The raw key is only returned once
in the response. Store it securely.


<Warning>
  The `raw_key` in the response is only shown once at creation time. Store it securely—it cannot be retrieved later.
</Warning>


## OpenAPI

````yaml POST /api/v1/api-keys
openapi: 3.0.3
info:
  title: LogFleet API
  description: >
    LogFleet is a distributed edge observability platform for fleet management.


    ## Overview

    LogFleet collects logs from distributed edge devices, stores them locally
    with

    configurable retention, extracts metrics for cloud observability platforms,

    and provides on-demand log streaming and remote access.


    ## Authentication

    LogFleet uses two authentication methods:


    - **JWT Bearer Token**: For dashboard and user operations. Obtain via
    `/auth/login`

    - **API Key**: For edge agents. Create via `/api-keys` endpoint


    ## Rate Limits

    - General endpoints: 100 requests/minute

    - Streaming endpoints: 20 requests/minute

    - Edge/metrics endpoints: 1000 requests/minute


    ## Multi-Tenancy

    All resources are scoped to organizations. Users can only access resources

    belonging to their organization.
  version: 1.0.0
  contact:
    name: LogFleet Support
    email: support@logfleet.io
    url: https://logfleet.io
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
servers:
  - url: https://api.logfleet.io
    description: Production
  - url: http://localhost:8080
    description: Local development
security: []
tags:
  - name: Authentication
    description: User registration and authentication
  - name: Organization
    description: Organization management
  - name: Agents
    description: Edge agent management
  - name: API Keys
    description: API key management for edge agents
  - name: Dashboard
    description: Dashboard metrics and summaries
  - name: Streaming
    description: Real-time log streaming
  - name: Billing
    description: Plans, quotas, and invoices
  - name: Metric Configs
    description: Custom metric extraction configuration
  - name: Edge API
    description: Edge agent communication endpoints
paths:
  /api/v1/api-keys:
    post:
      tags:
        - API Keys
      summary: Create API key
      description: |
        Create a new API key for edge agents. The raw key is only returned once
        in the response. Store it securely.
      operationId: createAPIKey
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAPIKeyRequest'
      responses:
        '201':
          description: API key created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateAPIKeyResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
      security:
        - BearerAuth: []
components:
  schemas:
    CreateAPIKeyRequest:
      type: object
      required:
        - name
        - permissions
      properties:
        name:
          type: string
          example: Production Edge Agents
        permissions:
          type: array
          items:
            type: string
            enum:
              - edge:register
              - edge:heartbeat
              - edge:metrics
              - edge:stream
          minItems: 1
        expires_at:
          type: string
          format: date-time
    CreateAPIKeyResponse:
      type: object
      properties:
        api_key:
          $ref: '#/components/schemas/APIKeyResponse'
        raw_key:
          type: string
          description: The actual API key. Only shown once!
    APIKeyResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
        organization_id:
          type: string
          format: uuid
        name:
          type: string
        key_prefix:
          type: string
          description: First 8 characters of the key
        permissions:
          type: array
          items:
            type: string
        last_used_at:
          type: string
          format: date-time
        expires_at:
          type: string
          format: date-time
        revoked_at:
          type: string
          format: date-time
        created_by:
          type: string
          format: uuid
        created_at:
          type: string
          format: date-time
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Error message
        message:
          type: string
          description: Additional details
  responses:
    Unauthorized:
      description: Authentication required
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT token obtained from /auth/login

````