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

# Update Api Key

> Update an existing {id}



## OpenAPI

````yaml /api-reference/openapi.json patch /v1/api_key/{id}
openapi: 3.1.0
info:
  title: Diga API
  version: 0.1.0
servers:
  - url: https://api.diga.io
    description: Production
security: []
paths:
  /v1/api_key/{id}:
    patch:
      tags:
        - API Keys
      summary: Update Api Key
      description: Update an existing {id}
      operationId: update_api_key_v1_api_key__id__patch
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: API Key ID
            description: The ID of the API key to update
          description: The ID of the API key to update
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiKeyUpdateRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RedactedApiKeyResponseSchema'
        '403':
          description: Forbidden - Insufficient permissions
          content:
            application/json:
              example:
                status: error
                error_code: INTERNAL_SERVER_ERROR
                message: Missing required permissions
              schema:
                $ref: '#/components/schemas/ErrorResponseSchema'
        '404':
          description: Api Key Not Found
          content:
            application/json:
              example:
                status: error
                error_code: API_KEY_NOT_FOUND
                message: Error from ApiKeyNotFoundException
              schema:
                $ref: '#/components/schemas/ErrorResponseSchema'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              example:
                status: error
                error_code: INTERNAL_SERVER_ERROR
                message: 'Error: Internal Server Error'
              schema:
                $ref: '#/components/schemas/ErrorResponseSchema'
      security:
        - CustomHTTPBearer: []
components:
  schemas:
    ApiKeyUpdateRequest:
      properties:
        name:
          type: string
          title: API Key Name
          description: Nuevo nombre de la API key
        restricted:
          type: boolean
          title: Restricted
          description: Indica si la API key es restringida o no.
        permissions:
          anyOf:
            - items:
                $ref: '#/components/schemas/Permission'
              type: array
            - type: 'null'
          title: Permissions
          description: Lista completa de permisos para reemplazar (solo keys restringidas).
      type: object
      title: ApiKeyUpdateRequest
    RedactedApiKeyResponseSchema:
      properties:
        id:
          type: string
          format: uuid
          title: API Key ID
          description: The unique identifier for the API key
        name:
          type: string
          title: API Key Name
          description: The name of the API key
        created_date:
          type: string
          format: date-time
          title: Created Date
          description: The date and time when the API key was created
        last_four_digits:
          type: string
          title: Last Four Digits
          description: The last four digits of the API key
        creator_id:
          type: string
          format: uuid
          title: Creator ID
          description: The ID of the user who created the API key
        permissions:
          anyOf:
            - items:
                $ref: '#/components/schemas/Permission'
              type: array
            - type: 'null'
          title: Permissions
          description: The permissions associated with the API key
        restricted:
          type: boolean
          title: Restricted
          description: Whether the API key is restricted to a set of specific permissions
      type: object
      required:
        - id
        - name
        - created_date
        - last_four_digits
        - creator_id
        - restricted
      title: RedactedApiKeyResponseSchema
    ErrorResponseSchema:
      properties:
        status:
          type: string
          title: Status
          description: Status of the response, always 'error' for error responses
          default: error
        error_code:
          type: string
          title: Error Code
          description: Machine-readable error code in SCREAMING_SNAKE_CASE format
          examples:
            - PROJECT_NOT_FOUND
            - INVALID_EMAIL
            - UNAUTHORIZED_ROLE
        message:
          type: string
          title: Message
          description: Human-readable error message with details
          examples:
            - Project with id 550e8400-e29b-41d4-a716-446655440000 not found
            - The email invalid@email is not valid
            - Insufficient permissions to perform this action
      type: object
      required:
        - error_code
        - message
      title: ErrorResponseSchema
      description: Standard error response format for all API errors.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Permission:
      type: string
      enum:
        - companies.delete
        - companies.update
        - calls.create
        - calls.delete
        - calls.update
        - calls.view
        - messages.view
        - agents.view
        - agents.create
        - agents.update
        - agents.delete
        - phones.view
        - phones.purchase
        - phones.delete
        - phones.update
        - phones.import
        - tools.view
        - tools.create
        - tools.delete
        - tools.update
        - contacts.view
        - contacts.delete
        - conversational_paths.view
        - conversational_paths.create
        - conversational_paths.delete
        - conversational_paths.update
        - knowledge_bases.view
        - knowledge_bases.create
        - knowledge_bases.delete
        - knowledge_bases.update
        - webhooks.view
        - webhooks.create
        - webhooks.delete
        - webhooks.update
        - members.view
        - members.create
        - members.delete
        - members.update
        - billing.view
        - billing.update
        - api_keys.view
        - api_keys.create
        - api_keys.delete
        - api_keys.update
        - voices.view
        - transcriptions.view
        - recordings.view
        - stats.view
        - verifications.create
        - verifications.view
        - notifications.view
        - notifications.update
        - logs.view
        - integrations.view
        - integrations.create
        - integrations.update
        - integrations.delete
        - workflows.view
        - workflows.create
        - workflows.update
        - workflows.delete
      title: Permission
      description: App permissions.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    CustomHTTPBearer:
      type: http
      scheme: bearer

````