> ## 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.

# Revoke API Key

> Revokes a key at once; it cannot be used again. You can revoke your own keys, except the project's Default key and your last key in the project. The project OWNER can revoke any member's key; an ADMIN can revoke members' and admins' keys, not the owner's.



## OpenAPI

````yaml /api-reference/openapi.json delete /v1/projects/api-keys
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:
    delete:
      summary: Revoke an API key
      description: >-
        Revokes a key at once; it cannot be used again. You can revoke your own
        keys, except the project's Default key and your last key in the project.
        The project OWNER can revoke any member's key; an ADMIN can revoke
        members' and admins' keys, not the owner's.
      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
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - apiKeyId
              properties:
                apiKeyId:
                  type: string
                  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.
                  example: key_9f2c4e1a7b3d5f6081a2c3d4e5f60718
                name:
                  type: string
                  minLength: 1
                  deprecated: true
                  description: 'Ignored: the key''s saved name is used.'
                  example: Backend server
            examples:
              by_ref:
                summary: Revoke by ref
                value:
                  apiKeyId: 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:
                      isDeleted:
                        type: boolean
                        example: true
                      ref:
                        type: string
                        nullable: true
                        example: key_9f2c4e1a7b3d5f6081a2c3d4e5f60718
                      status:
                        type: string
                        enum:
                          - REVOKED
                        example: REVOKED
        '400':
          description: >-
            Invalid request, the project's Default key
            (`DefaultApiKeyProtected`), or your last key
            (`LastApiKeyProtected`).
          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 revoke 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 already 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.