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

# Regenerate an app API key (invalidates the old one)
Or generate initial key if app doesn't have one yet
POST /api/apps/:app_id/regenerate-key



## OpenAPI

````yaml /openapi.yaml post /api/apps/{app_id}/regenerate-key
openapi: 3.1.0
info:
  title: OnDB API
  description: Monetize anything
  license:
    name: ''
  version: 4.0.0
servers: []
security: []
tags:
  - name: Health
    description: Health check and system status
  - name: Applications
    description: Application management
  - name: Billing
    description: Billing information and usage
  - name: Pricing
    description: Pricing information and quotes
  - name: X402 Payment Protocol
    description: Payment verification and settlement
  - name: Data Storage
    description: Store data to Celestia blockchain
  - name: Data Query
    description: Query and retrieve data
  - name: Collections
    description: Collection management
  - name: Indexes
    description: Index management and relations
  - name: Retention
    description: Data retention policies
  - name: Materialized Views
    description: Materialized view management
  - name: Predefined Queries
    description: Create and execute predefined queries
  - name: View Query
    description: Query materialized view data
  - name: Wallet
    description: App wallet management
  - name: Tasks
    description: Task tracking and status
  - name: Transactions
    description: Transaction status
  - name: Authorization
    description: Authorization grant management
  - name: API Keys
    description: API key management
  - name: Encryption
    description: Encryption settings and configuration
  - name: Payout
    description: Payout settings and history
  - name: API Collections
    description: API collection management
paths:
  /api/apps/{app_id}/regenerate-key:
    post:
      tags:
        - API Keys
      summary: |-
        Regenerate an app API key (invalidates the old one)
        Or generate initial key if app doesn't have one yet
        POST /api/apps/:app_id/regenerate-key
      operationId: regenerate_app_key_endpoint
      parameters:
        - name: app_id
          in: path
          description: Application ID
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RegenerateAppKeyRequest'
        required: true
      responses:
        '200':
          description: App API key regenerated successfully
          content:
            application/json:
              schema: {}
        '401':
          description: Unauthorized
        '404':
          description: App not found
        '500':
          description: Internal server error
      security:
        - api_key: []
components:
  schemas:
    RegenerateAppKeyRequest:
      type: object
      description: |-
        Request body for generating a new app API key.

        To create an Agent Key (for autonomous wallet-to-wallet payments), set
        `permissions: ["Pay"]` and optionally populate the `pay_limits` block.
      properties:
        name:
          type:
            - string
            - 'null'
        pay_limits:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/PayKeyLimits'
              description: >-
                Spend-limit constraints. Only enforced when the key has the
                `Pay` permission.

                All sub-fields default to `null` (unlimited / no expiry).
        permissions:
          type: array
          items:
            $ref: '#/components/schemas/AppKeyPermission'
    PayKeyLimits:
      type: object
      description: |-
        Optional spend-limit parameters for keys with the `Pay` permission.
        All fields default to `None` (unlimited / no expiry).
      properties:
        allowed_target_apps:
          type:
            - array
            - 'null'
          items:
            type: string
          description: Whitelist of target `app_id`s this key may pay. `None` = any app.
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: ISO 8601 datetime after which the key stops working.
        max_payment_per_tx:
          type:
            - integer
            - 'null'
          format: int64
          description: >-
            Maximum USDC base units (6 decimals) per single payment. `None` =
            unlimited.
          minimum: 0
        spend_allowance:
          type:
            - integer
            - 'null'
          format: int64
          description: Total lifetime spend cap in USDC base units. `None` = unlimited.
          minimum: 0
    AppKeyPermission:
      type: string
      enum:
        - Read
        - Write
        - Admin
        - Pay

````