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

# List API Keys

> Lists your own API keys in the project (`scope=own`, the default), newest first. Project owners and admins can list every member's keys with `scope=all`, with each key's owner and who disabled or revoked it.



## OpenAPI

````yaml /api-reference/openapi.json get /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:
    get:
      summary: List API keys
      description: >-
        Lists your own API keys in the project (`scope=own`, the default),
        newest first. Project owners and admins can list every member's keys
        with `scope=all`, with each key's owner and who disabled or revoked it.
      parameters:
        - in: query
          name: projectId
          required: false
          description: >-
            ID of the project (with an API key, the key's own project). Required
            with `scope=all`. Without it, `scope=own` lists your keys in every
            project and leaves out `effectiveScopes` and `hasStaleScopes`.
          schema:
            type: string
            format: uuid
            example: fbb9e8b2-2dbb-40f9-a051-9404624e3247
        - in: query
          name: scope
          required: false
          description: '`own`: your keys. `all`: every member''s keys (OWNER and ADMIN only).'
          schema:
            type: string
            enum:
              - own
              - all
            default: own
            example: own
        - in: query
          name: kind
          required: false
          description: Only keys of this kind.
          schema:
            type: string
            enum:
              - LEGACY
              - PUBLIC
              - SECRET
            example: SECRET
        - in: query
          name: search
          required: false
          description: Only keys whose name contains this.
          schema:
            type: string
            minLength: 1
            example: server
        - in: query
          name: status
          required: false
          description: '`scope=all` only: keys with this status.'
          schema:
            type: string
            enum:
              - ACTIVE
              - DISABLED
              - REVOKED
            example: ACTIVE
        - in: query
          name: ownerId
          required: false
          description: '`scope=all` only: keys of this member.'
          schema:
            type: string
            format: uuid
            example: b7d9e979-4a16-437b-8571-4ed92a94faa8
        - in: query
          name: skip
          required: false
          description: Page number, starting at 1.
          schema:
            type: integer
            minimum: 1
            default: 1
            example: 1
        - in: query
          name: take
          required: false
          description: Keys per page.
          schema:
            type: integer
            minimum: 1
            default: 10
            example: 10
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: success
                  data:
                    oneOf:
                      - title: Your keys (scope=own)
                        type: object
                        properties:
                          apiKeys:
                            type: array
                            items:
                              $ref: '#/components/schemas/ApiKeyListItem'
                          total:
                            type: integer
                            description: Number of keys that match.
                            example: 3
                          filtered:
                            type: integer
                            description: Number of keys on this page.
                            example: 3
                      - title: All project keys (scope=all)
                        type: object
                        properties:
                          apiKeys:
                            type: array
                            items:
                              $ref: '#/components/schemas/ApiKeyProjectListItem'
                          total:
                            type: integer
                            description: Number of keys that match.
                            example: 12
                          filtered:
                            type: integer
                            description: Number of keys on this page.
                            example: 10
                          owners:
                            type: array
                            description: >-
                              Everyone who owns a key in the project, for
                              filtering by `ownerId`.
                            items:
                              type: object
                              properties:
                                userId:
                                  type: string
                                  format: uuid
                                  example: b7d9e979-4a16-437b-8571-4ed92a94faa8
                                name:
                                  type: string
                                  example: Sara Haddad
                                email:
                                  type: string
                                  nullable: true
                                  example: sara@example.com
                                role:
                                  type: string
                                  nullable: true
                                  enum:
                                    - OWNER
                                    - ADMIN
                                    - USER
                                  example: USER
        '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."). `scope=all` needs the
            project OWNER or ADMIN role (`PermissionDenied`).
          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:
    ApiKeyListItem:
      type: object
      description: One of your keys.
      properties:
        id:
          type: string
          format: uuid
          description: >-
            Key ID. For a `LEGACY` key this is also the key value: keep it
            secret.
          example: 3f6c1a2e-8b4d-4e9a-9c1f-2a7d5e8b0c34
        name:
          type: string
          description: Key name, unique in the project.
          example: Backend server
        kind:
          type: string
          enum:
            - LEGACY
            - PUBLIC
            - SECRET
          description: >-
            `SECRET` (`sk_...`): for servers. The value is shown once, in the
            response that creates or rotates the key; requests that carry an
            `Origin` header (browsers) are refused. `PUBLIC` (`pk_...`): for web
            pages and apps. It can only create call tokens (`POST
            /v1/voice-agents/call-token`), for one `environment`, and its value
            can be read again at any time. `LEGACY`: the older kind, whose key
            ID is also its value. New legacy keys are being retired: when they
            are turned off, creating one returns `LegacyApiKeysRetired`.
          example: SECRET
        type:
          type: string
          enum:
            - ROOT
            - SCOPED
          description: >-
            `ROOT`: everything your role in the project allows (scopes `["*"]`).
            `SCOPED`: only the `scopes` you list, and never more than your role
            allows. Public keys are always `SCOPED` with `["agents:call"]`.
          example: SCOPED
        scopes:
          type: array
          items:
            type: string
          description: >-
            Saved scopes (presets expanded). `["*"]` for a `ROOT` key. An older
            `ROOT` key may show `[]`; it still has full access.
          example:
            - agents:read
            - agents:call
            - phone_numbers:read
            - phone_numbers:update
            - call_history:read
            - call_history:monitor
        allowedDomains:
          type: array
          items:
            type: string
          description: 'Hostnames the key may be used from. Empty: any.'
          example:
            - example.com
        environment:
          type: string
          nullable: true
          enum:
            - dev
            - staging
            - prod
          description: >-
            Public keys only: the environment their call tokens run. `null` for
            other kinds.
          example: null
        publicValue:
          type: string
          description: 'Public keys only: the full `pk_...` value.'
          example: pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        secretLast4:
          type: string
          description: >-
            Secret keys only: the last 4 characters of the value, to tell keys
            apart.
          example: xxxx
        agentIds:
          type: array
          items:
            type: string
            format: uuid
          description: >-
            Agents the key may create call tokens for (agents of this project).
            Empty or omitted: every agent.
          example:
            - 8a1d2c3b-4e5f-4a6b-9c7d-0e1f2a3b4c5d
        expiredAt:
          type: string
          format: date-time
          nullable: true
          description: 'When the key expires (end of that day). `null`: never.'
          example: '2027-12-31T23:59:59.999Z'
        previousValidUntil:
          type: string
          format: date-time
          nullable: true
          description: >-
            After a rotation: until when the old value still works. `null` when
            no old value works.
          example: null
        lastUsedAt:
          type: string
          format: date-time
          nullable: true
          description: When the current value was last used (public and secret keys).
          example: '2026-11-03T09:15:00.000Z'
        previousLastUsedAt:
          type: string
          format: date-time
          nullable: true
          description: When the old value was last used, after a rotation.
          example: null
        ref:
          type: string
          nullable: true
          description: >-
            Non-secret key ID (`key_` + 32 hex characters), safe to share and
            log.
          example: key_9f2c4e1a7b3d5f6081a2c3d4e5f60718
        isDefault:
          type: boolean
          description: '`true` for the project''s Default key or a member''s default key.'
          example: false
        createdAt:
          type: string
          format: date-time
          example: '2026-11-03T09:15:00.000Z'
        updatedAt:
          type: string
          format: date-time
          example: '2026-11-03T09:15:00.000Z'
        userId:
          type: string
          format: uuid
          description: The key's owner (you).
          example: b7d9e979-4a16-437b-8571-4ed92a94faa8
        status:
          type: string
          enum:
            - ACTIVE
            - DISABLED
            - REVOKED
          description: '`ACTIVE`, or `DISABLED` until someone enables it again.'
          example: ACTIVE
        isExpired:
          type: boolean
          description: '`true` when the key expired.'
          example: false
        last4:
          type: string
          nullable: true
          description: Last 4 characters of the key value.
          example: xxxx
        disabledAt:
          type: string
          format: date-time
          nullable: true
          example: null
        disabledBy:
          type: object
          allOf:
            - $ref: '#/components/schemas/ApiKeyPerson'
          nullable: true
          description: Who disabled the key.
        effectiveScopes:
          type: array
          items:
            type: string
          description: >-
            With `projectId` only: the saved scopes your current role still
            allows.
          example:
            - agents:read
            - agents:call
            - phone_numbers:read
            - phone_numbers:update
            - call_history:read
            - call_history:monitor
        hasStaleScopes:
          type: boolean
          description: >-
            With `projectId` only: `true` when some saved scopes go beyond your
            current role (they no longer work).
          example: false
    ApiKeyProjectListItem:
      type: object
      description: A key of any member of the project (`scope=all`).
      properties:
        id:
          type: string
          format: uuid
          description: >-
            Key ID. Left out for other members' `LEGACY` keys (it is their
            value): use `ref`.
          example: 3f6c1a2e-8b4d-4e9a-9c1f-2a7d5e8b0c34
        name:
          type: string
          description: Key name, unique in the project.
          example: Backend server
        kind:
          type: string
          enum:
            - LEGACY
            - PUBLIC
            - SECRET
          description: >-
            `SECRET` (`sk_...`): for servers. The value is shown once, in the
            response that creates or rotates the key; requests that carry an
            `Origin` header (browsers) are refused. `PUBLIC` (`pk_...`): for web
            pages and apps. It can only create call tokens (`POST
            /v1/voice-agents/call-token`), for one `environment`, and its value
            can be read again at any time. `LEGACY`: the older kind, whose key
            ID is also its value. New legacy keys are being retired: when they
            are turned off, creating one returns `LegacyApiKeysRetired`.
          example: SECRET
        type:
          type: string
          enum:
            - ROOT
            - SCOPED
          description: >-
            `ROOT`: everything your role in the project allows (scopes `["*"]`).
            `SCOPED`: only the `scopes` you list, and never more than your role
            allows. Public keys are always `SCOPED` with `["agents:call"]`.
          example: SCOPED
        scopes:
          type: array
          items:
            type: string
          description: >-
            Saved scopes (presets expanded). `["*"]` for a `ROOT` key. An older
            `ROOT` key may show `[]`; it still has full access.
          example:
            - agents:read
            - agents:call
            - phone_numbers:read
            - phone_numbers:update
            - call_history:read
            - call_history:monitor
        allowedDomains:
          type: array
          items:
            type: string
          description: 'Hostnames the key may be used from. Empty: any.'
          example:
            - example.com
        environment:
          type: string
          nullable: true
          enum:
            - dev
            - staging
            - prod
          description: >-
            Public keys only: the environment their call tokens run. `null` for
            other kinds.
          example: null
        publicValue:
          type: string
          description: 'Public keys only: the full `pk_...` value.'
          example: pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        secretLast4:
          type: string
          description: >-
            Secret keys only: the last 4 characters of the value, to tell keys
            apart.
          example: xxxx
        agentIds:
          type: array
          items:
            type: string
            format: uuid
          description: >-
            Agents the key may create call tokens for (agents of this project).
            Empty or omitted: every agent.
          example:
            - 8a1d2c3b-4e5f-4a6b-9c7d-0e1f2a3b4c5d
        expiredAt:
          type: string
          format: date-time
          nullable: true
          description: 'When the key expires (end of that day). `null`: never.'
          example: '2027-12-31T23:59:59.999Z'
        previousValidUntil:
          type: string
          format: date-time
          nullable: true
          description: >-
            After a rotation: until when the old value still works. `null` when
            no old value works.
          example: null
        lastUsedAt:
          type: string
          format: date-time
          nullable: true
          description: When the current value was last used (public and secret keys).
          example: '2026-11-03T09:15:00.000Z'
        previousLastUsedAt:
          type: string
          format: date-time
          nullable: true
          description: When the old value was last used, after a rotation.
          example: null
        ref:
          type: string
          nullable: true
          description: >-
            Non-secret key ID (`key_` + 32 hex characters), safe to share and
            log.
          example: key_9f2c4e1a7b3d5f6081a2c3d4e5f60718
        isDefault:
          type: boolean
          description: '`true` for the project''s Default key or a member''s default key.'
          example: false
        createdAt:
          type: string
          format: date-time
          example: '2026-11-03T09:15:00.000Z'
        updatedAt:
          type: string
          format: date-time
          example: '2026-11-03T09:15:00.000Z'
        last4:
          type: string
          nullable: true
          description: Last 4 characters of the key value.
          example: xxxx
        status:
          type: string
          enum:
            - ACTIVE
            - DISABLED
            - REVOKED
          example: ACTIVE
        isExpired:
          type: boolean
          example: false
        owner:
          type: object
          nullable: true
          description: The member who owns the key.
          properties:
            userId:
              type: string
              format: uuid
              example: b7d9e979-4a16-437b-8571-4ed92a94faa8
            name:
              type: string
              example: Sara Haddad
            email:
              type: string
              nullable: true
              example: sara@example.com
            role:
              type: string
              nullable: true
              enum:
                - OWNER
                - ADMIN
                - USER
              description: The owner's role. `null` if they left the project.
              example: USER
        disabledAt:
          type: string
          format: date-time
          nullable: true
          example: null
        disabledBy:
          type: object
          allOf:
            - $ref: '#/components/schemas/ApiKeyPerson'
          nullable: true
          description: Who disabled the key.
        revokedAt:
          type: string
          format: date-time
          nullable: true
          example: null
        revokedBy:
          type: object
          allOf:
            - $ref: '#/components/schemas/ApiKeyPerson'
          nullable: true
          description: Who revoked the key.
        canManage:
          type: boolean
          description: '`true` when you may revoke, disable or enable this key.'
          example: true
    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
    ApiKeyPerson:
      type: object
      nullable: true
      properties:
        userId:
          type: string
          format: uuid
          example: b7d9e979-4a16-437b-8571-4ed92a94faa8
        name:
          type: string
          example: Sara Haddad
  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.