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

# Activate API Key

> Sets `is_actived`. An inactive key answers `401` until it is
activated again; cached lookups of the key are dropped. Requires
`api-key:active`.




## OpenAPI

````yaml PATCH /permission/api-key/{document_id}/active
openapi: 3.0.1
info:
  title: API Key API
  description: |
    Credentials for machines and external systems (ADR 0105).

    A key has a `kind`:

    - `secret` — created through this API. The key reads
      `hzk_<env>_<prefix>_<secret>` (`env` is `live` on production and
      `test` elsewhere). Horizon stores only the `prefix` and the sha256 of
      the secret, and returns the plaintext key **once**, from create and
      rotate. Send it in the `x-api-key` header.
    - `jwt` — the MaihueGO machine path: a Bearer JWT minted at machine
      provisioning whose payload carries the key id. It keeps working until
      the key is revoked, deactivated, deleted or expired.

    A revoked (`revoked_at`), expired (`expiration_date`), inactive or
    deleted key answers `401`. Each `secret` key spends a sliding window of
    `rate_limit_per_minute` requests (600 when null); past it the API answers
    `429` with `Retry-After` and `X-RateLimit-Limit|Remaining|Reset`.
    Revocation and rotation reach every instance within 60 seconds.

    The management endpoints below require the matching `api-key:*` or
    `api-key-notification-gateway:*` permission. `secret_hash` is never
    returned, filtered or sorted on.
  version: '2026-10-21'
servers:
  - description: Production
    url: https://api.bbrands.io/api/v3
  - description: Certification
    url: https://certification.api.bbrands.io/api/v3
  - description: Development
    url: https://development.api.bbrands.io/api/v3
security:
  - bearerAuth: []
  - apiKeyAuth: []
tags:
  - name: API Key
    description: Keys, their secret lifecycle and revocation.
  - name: API Key Notification Gateway
    description: Notification gateways a key may send for.
paths:
  /permission/api-key/{document_id}/active:
    patch:
      tags:
        - API Key
      summary: Activate or deactivate API key
      description: |
        Sets `is_actived`. An inactive key answers `401` until it is
        activated again; cached lookups of the key are dropped. Requires
        `api-key:active`.
      operationId: apiKeyActive
      parameters:
        - $ref: '#/components/parameters/DocumentId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - is_actived
              properties:
                is_actived:
                  type: boolean
      responses:
        '200':
          $ref: '#/components/responses/ApiKeyOk'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  parameters:
    DocumentId:
      name: document_id
      in: path
      required: true
      description: API key identifier.
      schema:
        type: string
        format: uuid
  responses:
    ApiKeyOk:
      description: ApiKey record
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                $ref: '#/components/schemas/ApiKey'
              message:
                type: string
              meta:
                $ref: '#/components/schemas/Meta'
    BadRequest:
      description: Validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing, invalid, revoked or expired credentials
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: The caller lacks the required permission
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Record not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    TooManyRequests:
      description: Rate limit exceeded
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/RateLimitRemaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/RateLimitReset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  schemas:
    ApiKey:
      type: object
      properties:
        document_id:
          type: string
          format: uuid
        account:
          type: string
          format: uuid
          description: Account the key acts for.
        name:
          type: string
        description:
          type: string
          nullable: true
        kind:
          type: string
          enum:
            - jwt
            - secret
          description: '`secret` keys use `x-api-key`; `jwt` keys are MaihueGO machines.'
        prefix:
          type: string
          nullable: true
          description: Public lookup part of a `secret` key (8 characters).
        expiration_date:
          type: string
          format: date-time
          nullable: true
          description: The key answers 401 from this instant; null never expires.
        rate_limit_per_minute:
          type: integer
          nullable: true
          description: >-
            Requests per minute for a `secret` key; null uses the platform
            default (600).
        last_used_at:
          type: string
          format: date-time
          nullable: true
          description: Last authenticated request, written at most once per minute.
        rotated_at:
          type: string
          format: date-time
          nullable: true
        revoked_at:
          type: string
          format: date-time
          nullable: true
        revoked_by:
          type: string
          format: uuid
          nullable: true
        revoked_reason:
          type: string
          nullable: true
        created_by:
          type: string
          format: uuid
          nullable: true
        is_actived:
          type: boolean
        is_deleted:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
          nullable: true
        deleted_at:
          type: string
          format: date-time
          nullable: true
    Meta:
      type: object
      properties:
        correlation:
          type: string
          description: Request correlation id; quote it when reporting an issue.
        status:
          type: integer
        timestamp:
          type: string
          format: date-time
        version:
          type: string
          nullable: true
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code.
            errors:
              type: array
              items: {}
            message:
              type: string
        meta:
          $ref: '#/components/schemas/Meta'
  headers:
    RetryAfter:
      description: Seconds until the key's window frees a request.
      schema:
        type: integer
    RateLimitLimit:
      description: Requests per minute allowed for the key.
      schema:
        type: integer
    RateLimitRemaining:
      description: Requests left in the current window.
      schema:
        type: integer
    RateLimitReset:
      description: Unix seconds when the window frees a request.
      schema:
        type: integer
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: A `secret` API key, `hzk_<env>_<prefix>_<secret>`.

````

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