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

# Create API Key Permission

> Creates a api key permission. Unknown body fields are rejected. Requires `api-key-permission:create`.



## OpenAPI

````yaml POST /permission/api-key/permission
openapi: 3.0.1
info:
  title: API Key Permission API
  description: >
    Grants of a permission to an API key (`api_key_permission`, ADR 0105).
    Writes drop the key's cached grants. A populated `api_key` never carries
    `secret_hash`.


    List paging and sorting read the snake_case keys `page_size`,
    `max_page_size_override` and `order_by`. Every route requires the
    `api-key-permission:<action>` permission named in its description.
  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 Permission
    description: Permissions granted to an API key.
paths:
  /permission/api-key/permission:
    post:
      tags:
        - API Key Permission
      summary: Create api key permission
      description: >-
        Creates a api key permission. Unknown body fields are rejected. Requires
        `api-key-permission:create`.
      operationId: apiKeyPermissionCreate
      parameters:
        - $ref: '#/components/parameters/Populate'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiKeyPermissionCreateBody'
      responses:
        '201':
          description: API key permission created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ApiKeyPermission'
                  message:
                    type: string
                  meta:
                    $ref: '#/components/schemas/Meta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  parameters:
    Populate:
      name: populate
      in: query
      description: Whether to expand foreign keys into nested objects.
      schema:
        type: boolean
        default: true
  schemas:
    ApiKeyPermissionCreateBody:
      type: object
      additionalProperties: false
      required:
        - api_key
        - permission
      properties:
        api_key:
          type: string
          format: uuid
        permission:
          type: string
          format: uuid
    ApiKeyPermission:
      type: object
      properties:
        document_id:
          type: string
          format: uuid
        api_key:
          type: string
          format: uuid
          description: >-
            Related record id; with `populate` (the default) the related record
            is embedded instead.
        permission:
          type: string
          format: uuid
          description: >-
            Related record id; with `populate` (the default) the related record
            is embedded instead.
        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'
  responses:
    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'
    Conflict:
      description: The record conflicts with an existing one
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    TooManyRequests:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      headers:
        Retry-After:
          description: Seconds until a request is allowed again.
          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.