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

# Update an existing API key by ID

> Update an existing API key by ID



## OpenAPI

````yaml /api/openapi.json post /api/auth/api-key/update
openapi: 3.1.0
info:
  description: HTTP API for the Rootprint log management platform.
  title: Rootprint API
  version: 0.3.4
servers:
  - description: Rootprint API
    url: https://example.com
security:
  - cookieAuth: []
paths:
  /api/auth/api-key/update:
    post:
      tags:
        - Personal API keys
      summary: Update an existing API key by ID
      description: Update an existing API key by ID
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              properties:
                configId:
                  description: >-
                    The configuration ID to use for the API key lookup. If not
                    provided, the default configuration will be used.
                  type:
                    - string
                    - 'null'
                enabled:
                  description: Whether the Api Key is enabled or not
                  type:
                    - boolean
                    - 'null'
                expiresIn:
                  type: string
                keyId:
                  description: The id of the Api Key
                  type: string
                metadata:
                  type:
                    - string
                    - 'null'
                name:
                  description: The name of the key
                  type:
                    - string
                    - 'null'
                permissions:
                  type: string
                rateLimitEnabled:
                  description: Whether the key has rate limiting enabled.
                  type:
                    - boolean
                    - 'null'
                rateLimitMax:
                  description: >-
                    Maximum amount of requests allowed within a window. Once the
                    `maxRequests` is reached, the request will be rejected until
                    the `timeWindow` has passed, at which point the `timeWindow`
                    will be reset. server-only. Eg: 100
                  type:
                    - number
                    - 'null'
                rateLimitTimeWindow:
                  description: >-
                    The duration in milliseconds where each request is counted.
                    server-only. Eg: 1000
                  type:
                    - number
                    - 'null'
                refillAmount:
                  description: The refill amount
                  type:
                    - number
                    - 'null'
                refillInterval:
                  description: The refill interval
                  type:
                    - number
                    - 'null'
                remaining:
                  description: The number of remaining requests
                  type:
                    - number
                    - 'null'
                userId:
                  description: >-
                    The id of the user which the api key belongs to.
                    server-only. Eg: "some-user-id"
                  type:
                    - string
                    - 'null'
              required:
                - keyId
                - expiresIn
                - permissions
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  createdAt:
                    description: created at
                    format: date-time
                    type: string
                  enabled:
                    default: true
                    description: Sets if key is enabled or disabled
                    type: boolean
                  expiresAt:
                    description: Expiry date of a key
                    format: date-time
                    nullable: true
                    type: string
                  id:
                    description: ID
                    type: string
                  lastRefillAt:
                    description: The last refill date
                    format: date-time
                    nullable: true
                    type: string
                  lastRequest:
                    description: When last request occurred
                    format: date-time
                    nullable: true
                    type: string
                  metadata:
                    additionalProperties: true
                    description: Extra metadata about the apiKey
                    nullable: true
                    type: object
                  name:
                    description: The name of the key
                    nullable: true
                    type: string
                  permissions:
                    description: Permissions for the api key (stored as JSON string)
                    nullable: true
                    type: string
                  prefix:
                    description: The API Key prefix. Stored as plain text.
                    nullable: true
                    type: string
                  rateLimitEnabled:
                    description: Whether the key has rate limiting enabled
                    type: boolean
                  rateLimitMax:
                    description: Maximum amount of requests allowed within a window
                    nullable: true
                    type: number
                  rateLimitTimeWindow:
                    description: The duration in milliseconds
                    nullable: true
                    type: number
                  refillAmount:
                    description: The amount to refill
                    nullable: true
                    type: number
                  refillInterval:
                    description: >-
                      The interval in milliseconds between refills of the
                      `remaining` count. Example: 3600000 // refill every hour
                      (3600000ms = 1h)
                    nullable: true
                    type: number
                  remaining:
                    description: >-
                      Remaining requests (every time api key is used this should
                      updated and should be updated on refill as well)
                    nullable: true
                    type: number
                  requestCount:
                    description: >-
                      The number of requests made within the rate limit time
                      window
                    type: number
                  start:
                    description: >-
                      Shows the first few characters of the API key, including
                      the prefix. This allows you to show those few characters
                      in the UI to make it easier for users to identify the API
                      key.
                    nullable: true
                    type: string
                  updatedAt:
                    description: updated at
                    format: date-time
                    type: string
                  userId:
                    description: The owner of the user id
                    type: string
                required:
                  - id
                  - userId
                  - enabled
                  - rateLimitEnabled
                  - requestCount
                  - createdAt
                  - updatedAt
                type: object
          description: API key updated successfully
        '400':
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                required:
                  - message
                type: object
          description: >-
            Bad Request. Usually due to missing parameters, or invalid
            parameters.
        '401':
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                required:
                  - message
                type: object
          description: Unauthorized. Due to missing or invalid authentication.
        '403':
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                type: object
          description: >-
            Forbidden. You do not have permission to access this resource or to
            perform this action.
        '404':
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                type: object
          description: Not Found. The requested resource was not found.
        '429':
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                type: object
          description: >-
            Too Many Requests. You have exceeded the rate limit. Try again
            later.
        '500':
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                type: object
          description: >-
            Internal Server Error. This is a problem with the server that you
            cannot fix.
      security:
        - bearerAuth: []
components:
  securitySchemes:
    cookieAuth:
      in: cookie
      name: better-auth.session_token
      type: apiKey
    bearerAuth:
      description: Bearer token authentication
      scheme: bearer
      type: http

````