> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-3a82795f.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Создать ключ

> Создаёт новый API-ключ.



## OpenAPI

````yaml /ru/products/cloud/api-reference/cloud-openapi.json post /v1/organizations/{organizationId}/keys
openapi: 3.0.1
info:
  contact:
    email: support@clickhouse.com
    name: ClickHouse Support
    url: >-
      https://clickhouse.com/docs/en/cloud/manage/openapi?referrer=openapi-299828
  title: OpenAPI spec for ClickHouse Cloud
  version: '1.0'
servers:
  - url: https://api.clickhouse.cloud
security:
  - basicAuth: []
tags:
  - name: Organization
  - name: User management
  - name: Billing
  - name: Service
  - name: Backup
  - name: OpenAPI
  - name: Prometheus
  - name: ClickPipes
paths:
  /v1/organizations/{organizationId}/keys:
    post:
      tags:
        - OpenAPI
      summary: Создать ключ
      description: Создаёт новый API-ключ.
      parameters:
        - description: Идентификатор организации, которой будет принадлежать ключ.
          in: path
          name: organizationId
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiKeyPostRequest'
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  requestId:
                    description: >-
                      Уникальный идентификатор, назначаемый каждому запросу.
                      UUIDv4
                    format: uuid
                    type: string
                  result:
                    $ref: '#/components/schemas/ApiKeyPostResponse'
                  status:
                    description: Код состояния HTTP.
                    example: 200
                    type: number
                type: object
          description: Успешный ответ
        '400':
          content:
            application/json:
              schema:
                properties:
                  error:
                    description: Подробное описание ошибки.
                    type: string
                  status:
                    description: Код состояния HTTP.
                    example: 400
                    type: number
                type: object
          description: >-
            Сервер не может или не будет обрабатывать запрос из-за ошибки на
            стороне клиента.
components:
  schemas:
    ApiKeyPostRequest:
      properties:
        expireAt:
          description: >-
            Временная метка истечения срока действия ключа. Если отсутствует,
            имеет значение `null` или пуста, срок действия ключа не ограничен.
            ISO-8601.
          format: date-time
          nullable: true
          type: string
        hashData:
          $ref: '#/components/schemas/ApiKeyHashData'
        ipAccessList:
          description: >-
            Список IP-адресов, которым разрешён доступ к API с использованием
            этого ключа
          items:
            $ref: '#/components/schemas/IpAccessListEntry'
          type: array
        name:
          description: Имя ключа.
          type: string
        roles:
          description: Список ролей, назначенных ключу. Содержит как минимум 1 элемент.
          items:
            enum:
              - admin
              - developer
              - query_endpoints
            type: string
          type: array
        state:
          description: >-
            Начальное состояние ключа: 'enabled', 'disabled'. Если не указано,
            новый ключ будет 'enabled'.
          enum:
            - enabled
            - disabled
          type: string
    ApiKeyPostResponse:
      properties:
        key:
          $ref: '#/components/schemas/ApiKey'
        keyId:
          description: >-
            Сгенерированный идентификатор ключа. Предоставляется, только если в
            запросе не было 'hashData'.
          type: string
        keySecret:
          description: >-
            Сгенерированный секрет ключа. Предоставляется, только если в запросе
            не было 'hashData'.
          type: string
    ApiKeyHashData:
      properties:
        keyIdHash:
          description: 'Хеш идентификатора ключа. '
          type: string
        keyIdSuffix:
          description: >-
            Последние 4 цифры идентификатора ключа. Алгоритм: echo -n
            "yourpassword" | sha256sum | tr -d '-' | xxd -r -p | base64
          type: string
        keySecretHash:
          description: >-
            Хеш секрета ключа. Алгоритм: echo -n "yourpassword" | sha256sum | tr
            -d '-' | xxd -r -p | base64
          type: string
    IpAccessListEntry:
      properties:
        description:
          description: >-
            Необязательное описание IPv4-адреса или IPv4 CIDR, с которого
            разрешён доступ
          type: string
        source:
          description: IP-адрес или CIDR
          type: string
    ApiKey:
      properties:
        createdAt:
          description: Временная метка создания ключа. ISO-8601.
          format: date-time
          type: string
        expireAt:
          description: >-
            Временная метка истечения срока действия ключа. Если отсутствует,
            имеет значение `null` или пуста, срок действия ключа не истекает.
            ISO-8601.
          format: date-time
          nullable: true
          type: string
        id:
          description: Уникальный ID API key.
          format: uuid
          type: string
        ipAccessList:
          description: >-
            Список IP-адресов, которым разрешен доступ к API с использованием
            этого ключа
          items:
            $ref: '#/components/schemas/IpAccessListEntry'
          type: array
        keySuffix:
          description: Последние 4 символа ключа.
          type: string
        name:
          description: Имя ключа
          type: string
        roles:
          description: Список ролей, назначенных ключу. Содержит как минимум 1 элемент.
          items:
            enum:
              - admin
              - developer
              - query_endpoints
            type: string
          type: array
        state:
          description: 'Состояние ключа: ''enabled'', ''disabled''.'
          enum:
            - enabled
            - disabled
          type: string
        usedAt:
          description: >-
            Временная метка последнего использования ключа. Если отсутствует,
            ключ ни разу не использовался. ISO-8601.
          format: date-time
          type: string
  securitySchemes:
    basicAuth:
      description: >-
        Используйте идентификатор ключа и секрет ключа, полученные в консоли
        ClickHouse Cloud: https://clickhouse.com/docs/cloud/manage/openapi
      scheme: basic
      type: http

````