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

# List API keys

> Lists all API keys for the authenticated user, ordered by creation date descending.
Raw keys are **never** returned after initial creation.


List your API keys. Only the key prefix is returned, never the full key.


## OpenAPI

````yaml serva-webapp-openapi.yaml GET /keys
openapi: 3.0.3
info:
  title: Serva Encoder API
  version: 1.3.0
  description: >
    High-performance file encoding API. File encodes produce plaintext SRVA;

    AES-256-GCM decoding stays for files issued while encoding still locked
    them.


    ## Quick Start for Frontend Developers


    **Base URL (production):** All API requests use a single base URL. No need
    to switch between auth/backend hosts.


    | Environment | Base URL |

    |-------------|----------|

    | **Production** | `https://serva.servamind.com` |


    **Typical flows:**

    1. **Login:** `POST /auth/google/callback` with Google ID token → session
    cookie set automatically

    2. **Encode:** `POST /api/encode` → `POST /api/stream/{file_reference}` →
    `GET /download/{file_id}`

    3. **Decode:** `POST /api/decode` (JSON) → `POST /api/decode` (binary +
    X-Streaming-Token) → `GET /download/{file_id}`


    **Note:** The decode stream uses the **same path** `POST /api/decode`. When
    `X-Streaming-Token` is present, the request is routed to the backend. Do not
    use `/backend/decode` — that path does not exist in production.


    ## Pricing Model


    **Beta Period (Until May 4, 2026):**

    - First 1TB/month: FREE

    - Over 1TB: $0.005/GB (billed, NOT blocked)


    **Post-Beta (After May 4, 2026):**

    - All usage: $0.005/GB (no free tier)


    **Important:** Users are NEVER blocked from encoding. Quota tracking

    is for billing only. Beta users can encode beyond 1TB and pay for overage.


    ## Authentication


    Protected endpoints support two authentication methods:


    ### 1. httpOnly Session Cookie (Web UI)


    The primary authentication for the web frontend. On successful Google OAuth
    login,

    the Auth Service sets a `session` httpOnly cookie (never exposed to
    JavaScript).

    All subsequent requests from the browser automatically include this cookie.


    ### 2. Authorization Header (Programmatic Access)


    For API keys and legacy token usage, send `Authorization: Bearer <token>`:


    | Type | Format | TTL | Notes |

    |------|--------|-----|-------|

    | **Session Token** | `sess_...` | 24 hours | Also available via httpOnly
    cookie. |

    | **Google ID Token** | JWT (3 base64 segments) | ~1 hour | Validated
    against Google tokeninfo API on every request. |

    | **Service API Key** | `sk_live_...` | Never (until revoked) | For
    programmatic / server-to-server access. |


    Authentication priority: httpOnly cookie is checked first, then
    Authorization header.


    **Recommended login flow (Web UI):**

    1. Call `POST /auth/google/callback` with the Google ID token.

    2. The server sets a `session` httpOnly cookie automatically.

    3. All subsequent requests include the cookie automatically (no manual token
    management).

    4. On logout, call `POST /auth/logout` to revoke the token and delete the
    cookie.


    **Recommended flow (Programmatic / API Key):**

    1. Generate a Service API Key via `POST /keys`.

    2. Send `Authorization: Bearer <sk_live_...>` on all requests.


    ## Encode Flow

    ```

    POST /api/encode  (Auth Service)  →  returns { streaming_token, file_id,
    download_url }

    POST /api/stream/{file_reference}  (Backend, X-Streaming-Token header)  → 
    raw file bytes

    GET  /download/{file_id}  (Backend)  →  .serva binary

    ```


    ## Decode Flow

    ```

    POST /api/decode  (Auth Service)  →  returns { streaming_token,
    file_reference }

    POST /api/decode  (Backend, X-Streaming-Token + X-Decode-Password headers) 
    →  raw .serva bytes

    GET  /download/{file_id}  (Backend)  →  original file binary

    ```


    **Decode password handling:** A password is only needed for a `.serva`
    issued while

    encoding still locked files. For one of those, send `user_password` in the
    Auth Service

    request body and the same value in `X-Decode-Password` when streaming to the
    Backend. Never stored

    in Redis or any persistent storage.
  x-readme:
    samples-languages:
      - curl
      - javascript
      - python
servers:
  - url: https://serva.servamind.com
    description: >-
      Production (single base URL for all endpoints — auth, encode, decode,
      download)
security: []
tags:
  - name: Authentication
    description: Google OAuth login, session management, and logout
  - name: API Keys
    description: Generate, list, and revoke Service API Keys
  - name: Usage
    description: Monthly usage, quota, and billing information
  - name: Encode
    description: File encoding pipeline — Auth orchestration and Backend streaming
  - name: Decode
    description: File decoding pipeline — Auth orchestration and Backend streaming
  - name: Download
    description: Retrieve encoded or decoded files
  - name: Statistics
    description: Public platform-wide aggregate statistics
  - name: Billing
    description: >-
      Stripe subscription webhook handler (server-to-server only — do not call
      from frontend)
    x-internal: true
  - name: Health
    description: Service health checks
  - name: Internal
    description: >-
      Service-to-service endpoints (not exposed via nginx — frontend should not
      use)
    x-internal: true
paths:
  /keys:
    servers:
      - url: https://serva.servamind.com
        description: Production
    get:
      tags:
        - API Keys
      summary: List API keys
      description: >
        Lists all API keys for the authenticated user, ordered by creation date
        descending.

        Raw keys are **never** returned after initial creation.
      operationId: listApiKeys
      responses:
        '200':
          description: Array of API key metadata.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ApiKeyInfo'
        '401':
          description: Invalid or expired token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded (30 req/min per user). See `Retry-After` header.
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    ApiKeyInfo:
      type: object
      properties:
        key_id:
          type: string
          format: uuid
          example: 123e4567-e89b-12d3-a456-426614174001
        key_prefix:
          type: string
          example: sk_live_ab12
        revoked:
          type: boolean
          example: false
        created_at:
          type: string
          format: date-time
          example: '2025-11-01T00:00:00Z'
        last_used_at:
          type: string
          format: date-time
          nullable: true
          example: '2025-11-15T10:30:00Z'
    ErrorResponse:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message.
          example: Invalid or expired session token
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >
        Accepts one of three credential types (detected by format):

        - **Session token** (`sess_...`) — O(1) Redis lookup, 24h TTL.
        Preferred.

        - **Google ID Token** (JWT — three `.`-separated base64 segments) —
        calls Google tokeninfo API per request.

        - **Service API Key** (`sk_live_...`) — HMAC-SHA256 constant-time
        validation, never expires unless revoked.


        **Note:** The web UI authenticates via a `session` httpOnly cookie (set
        during login).

        The cookie is checked first; the Authorization header is the fallback
        for programmatic clients.

````

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