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

# Regenerate a doctor account's API key

> Rotate the API key for a doctor account, identified by its `publicId` (`acc_*`) or `internalCode`. The previous key is revoked with a short grace window; the new raw key is returned **once** — store it securely. Limited to one regeneration per account every 2 minutes (`429 rate_limit_exceeded`).



## OpenAPI

````yaml /pt-BR/scribe-api/openapi-institutional.json post /v1/institutional/accounts/{account_id}/api-keys/regenerate
openapi: 3.1.0
info:
  title: Scribe Public API
  description: >-
    API REST externa para integração com a plataforma Telepatia. Autentique-se
    com chaves de API, defina o contexto da consulta e busque sessões de scribe.
  version: 0.1.0
servers:
  - url: https://scribe-api.telepatia.ai
    description: Production
security:
  - BearerAuth: []
paths:
  /v1/institutional/accounts/{account_id}/api-keys/regenerate:
    post:
      tags:
        - Institutional
        - Institutional
      summary: Regenerate a doctor account's API key
      description: >-
        Rotate the API key for a doctor account, identified by its `publicId`
        (`acc_*`) or `internalCode`. The previous key is revoked with a short
        grace window; the new raw key is returned **once** — store it securely.
        Limited to one regeneration per account every 2 minutes (`429
        rate_limit_exceeded`).
      operationId: >-
        api_institutional_account_api_key_regenerated_v1_institutional_accounts__account_id__api_keys_regenerate_post
      parameters:
        - name: account_id
          in: path
          required: true
          schema:
            type: string
            title: Account Id
      requestBody:
        content:
          application/json:
            schema:
              anyOf:
                - $ref: '#/components/schemas/RegenerateApiKeyRequest'
                - type: 'null'
              title: Request
            example:
              validForDays: 365
      responses:
        '200':
          description: Resposta bem-sucedida
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RegenerateApiKeyResponse'
              example:
                accountId: acc_a1b2c3d4e5f6g7h8
                apiKey: <shown-once-store-securely>
                expiresAt: '2027-01-15T10:30:00Z'
                id: ak_a1b2c3d4e5f6g7h8
                mode: prod
                prefix: sk_prod_a1b2c3d4...e5f6
        '401':
          description: Não autorizado — chave de API ausente ou inválida.
          content:
            application/json:
              examples:
                authentication_required:
                  summary: Invalid or missing API key
                  value:
                    error:
                      type: authentication_error
                      code: authentication_required
                      message: Invalid API key.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Não encontrado — o recurso solicitado não existe.
          content:
            application/json:
              examples:
                resource_not_found:
                  summary: Resource not found
                  value:
                    error:
                      type: invalid_request_error
                      code: resource_not_found
                      message: No session scribe found for the given consultation ID.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too Many Requests
          content:
            application/json:
              examples:
                rate_limit_exceeded:
                  summary: Rate limit exceeded
                  value:
                    error:
                      type: invalid_request_error
                      code: rate_limit_exceeded
                      message: Too many requests. Please wait before trying again.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Serviço indisponível — uma dependência externa está indisponível.
          content:
            application/json:
              examples:
                service_unavailable:
                  summary: External service unavailable
                  value:
                    error:
                      type: api_error
                      code: service_unavailable
                      message: >-
                        Unable to generate verification code. Please try again
                        later.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    RegenerateApiKeyRequest:
      properties:
        validForDays:
          anyOf:
            - type: integer
              maximum: 365
              minimum: 1
            - type: 'null'
          title: Validfordays
          description: >-
            New key lifetime in days (1–365). Omit to keep the account's default
            lifetime.
          examples:
            - 365
      type: object
      title: RegenerateApiKeyRequest
      description: Request body for regenerating (rotating) a doctor account's API key.
      examples:
        - validForDays: 365
    RegenerateApiKeyResponse:
      properties:
        accountId:
          type: string
          title: Accountid
          description: Account publicId (acc_*) the key belongs to.
          examples:
            - acc_a1b2c3d4e5f6g7h8
        apiKey:
          type: string
          title: Apikey
          description: Raw API key. Shown only once — store it securely.
          examples:
            - <shown-once-store-securely>
        id:
          type: string
          title: Id
          description: API key publicId (ak_*).
          examples:
            - ak_a1b2c3d4e5f6g7h8
        prefix:
          type: string
          title: Prefix
          description: Non-secret key prefix, safe to display/store for identification.
          examples:
            - sk_prod_a1b2c3d4...e5f6
        mode:
          type: string
          title: Mode
          examples:
            - prod
        expiresAt:
          anyOf:
            - type: string
            - type: 'null'
          title: Expiresat
          examples:
            - '2027-01-15T10:30:00Z'
      type: object
      required:
        - accountId
        - apiKey
        - id
        - prefix
        - mode
      title: RegenerateApiKeyResponse
      description: >-
        Response after rotating a doctor account's API key.


        Mirrors the API-key fields returned on account creation, for the rotated
        key.

        The raw key is shown only once — store it securely.
      examples:
        - accountId: acc_a1b2c3d4e5f6g7h8
          apiKey: <shown-once-store-securely>
          expiresAt: '2027-01-15T10:30:00Z'
          id: ak_a1b2c3d4e5f6g7h8
          mode: prod
          prefix: sk_prod_a1b2c3d4...e5f6
    ErrorResponse:
      description: Envelope padronizado de resposta de erro.
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      required:
        - error
      title: ErrorResponse
      type: object
    ErrorDetail:
      description: >-
        Detalhe do erro com códigos legíveis por máquina e mensagem legível por
        humanos.
      properties:
        type:
          description: Broad error category for high-level handling.
          examples:
            - invalid_request_error
          title: Type
          type: string
        code:
          description: Machine-readable error code. Clients should switch on this value.
          examples:
            - parameter_invalid
          title: Code
          type: string
        message:
          description: Human-readable error message ending with a period.
          examples:
            - >-
              idCountry must be a valid country name, ISO alpha-2, or ISO
              alpha-3 code.
          title: Message
          type: string
        param:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: The request field that caused the error, if applicable.
          examples:
            - idCountry
          title: Param
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          default: null
          description: Optional structured, machine-readable context for the error.
          examples:
            - pendingConsultations:
                - sessionId: abc123
                  url: https://...
          title: Details
      required:
        - type
        - code
        - message
      title: ErrorDetail
      type: object
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Chave de API enviada como token Bearer

````