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

# Disable API Key

> Turns a key off until it is enabled again: requests with it are refused. You can disable your own keys; the project OWNER any key, an ADMIN any key except the owner's. Disabling a disabled key changes nothing.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/projects/api-keys/{apiKeyId}/disable
openapi: 3.0.1
info:
  title: Hamsa API
  description: >-
    The Hamsa API: voice agents and their calls, phone numbers, batch calls and
    knowledge bases; speech to text, text to speech, voices and AI content.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.tryhamsa.com
security: []
paths:
  /v1/projects/api-keys/{apiKeyId}/disable:
    post:
      summary: Disable an API key
      description: >-
        Turns a key off until it is enabled again: requests with it are refused.
        You can disable your own keys; the project OWNER any key, an ADMIN any
        key except the owner's. Disabling a disabled key changes nothing.
      parameters:
        - in: query
          name: projectId
          required: true
          description: >-
            ID of the project. With an API key, it must be the key's own
            project.
          schema:
            type: string
            format: uuid
            example: fbb9e8b2-2dbb-40f9-a051-9404624e3247
        - in: path
          name: apiKeyId
          required: true
          description: >-
            The key's `id`, or its `ref` (`key_` + 32 hex characters). Use `ref`
            for other members' keys: a legacy key's `id` is its value.
          schema:
            type: string
            example: key_9f2c4e1a7b3d5f6081a2c3d4e5f60718
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: success
                  data:
                    type: object
                    properties:
                      ref:
                        type: string
                        nullable: true
                        example: key_9f2c4e1a7b3d5f6081a2c3d4e5f60718
                      status:
                        type: string
                        enum:
                          - ACTIVE
                          - DISABLED
                          - REVOKED
                        example: DISABLED
        '400':
          description: 'Invalid request: a field is missing or not valid.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyError'
        '401':
          description: 'Unauthorized: missing or invalid API key.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '403':
          description: >-
            A limited key can't manage API keys (`ApiKeyScopeRouteNotAllowed`,
            "This route needs a full-access API key."). You may not disable this
            member's key (`PermissionDenied`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyError'
        '404':
          description: No such key in this project (`ApiKeyNotFound`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyError'
        '409':
          description: The key was revoked (`ApiKeyAlreadyRevoked`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyError'
        '500':
          description: Server Side Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    ApiKeyError:
      type: object
      description: Error returned by the API key routes.
      properties:
        code:
          type: integer
          enum:
            - 5400
            - 5403
            - 5404
            - 5409
            - 5500
          description: 'Service error code: 5000 + the HTTP status.'
          example: 5409
        message:
          type: string
          description: What went wrong, in English.
          example: This API key was already revoked.
        messageKey:
          type: string
          enum:
            - PermissionDenied
            - ApiKeyNotFound
            - ApiKeyExpired
            - ApiKeyAlreadyRevoked
            - LegacyApiKeysRetired
            - DefaultApiKeyProtected
            - LastApiKeyProtected
            - SomethingWentWrong
          description: >-
            Stable error key to branch on. `SomethingWentWrong` for errors
            without their own key (read `message`).
          example: ApiKeyAlreadyRevoked
        params:
          type: object
          additionalProperties: true
          description: >-
            Details for some errors: `action` (for example `api_keys:revoke`) on
            `PermissionDenied`, `reason: "DISABLED_BY_OTHER"` and `disabledBy`
            when you try to enable your own key that someone else disabled,
            `expired` on `LastApiKeyProtected`.
          example:
            action: api_keys:revoke
    ErrorSchema:
      type: object
      properties:
        code:
          type: integer
          description: >-
            Service error code: the HTTP status with a service prefix (for
            example `8404`). Missing when the service has no code for that
            status.
          example: 8404
        message:
          type: string
          description: >-
            What went wrong. Some services (calls and recordings) put the error
            key here, for example `CallNotFoundOrUnavailable`, and send no
            `messageKey`.
          example: Policy not found!
        messageKey:
          type: string
          description: >-
            Stable key for the error, safe to match on in code. Not returned by
            every service.
          example: PolicyNotFound
        params:
          type: object
          additionalProperties: true
          description: >-
            Details for some errors (for example `reason`). Not returned by
            every service.
          example:
            reason: NO_DRAFT
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Pass the API key in the Authorization header, You need to put Token
        keyword before the API key. e.g. 'Authorization: Token <api-key>'

````

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