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

# Create key

> Creates new API key.



## OpenAPI

````yaml /_specs/cloud-openapi.json post /v1/organizations/{organizationId}/keys
openapi: 3.0.1
info:
  title: OpenAPI spec for ClickHouse Cloud
  version: '1.0'
  contact:
    name: ClickHouse Support
    url: >-
      https://clickhouse.com/docs/en/cloud/manage/openapi?referrer=openapi-299828
    email: support@clickhouse.com
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: Create key
      description: Creates new API key.
      parameters:
        - in: path
          name: organizationId
          description: ID of the organization that will own the key.
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiKeyPostRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: number
                    description: HTTP status code.
                    example: 200
                  requestId:
                    type: string
                    description: Unique id assigned to every request. UUIDv4
                    format: uuid
                  result:
                    $ref: '#/components/schemas/ApiKeyPostResponse'
        '400':
          description: >-
            The server cannot or will not process the request due to something
            that is perceived to be a client error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: number
                    description: HTTP status code.
                    example: 400
                  error:
                    type: string
                    description: Detailed error description.
components:
  schemas:
    ApiKeyPostRequest:
      properties:
        name:
          description: Name of the key.
          type: string
        expireAt:
          description: >-
            Timestamp the key expires. If not present, `null` or is empty the
            key never expires. ISO-8601.
          nullable: true
          type: string
          format: date-time
        state:
          description: >-
            Initial state of the key: 'enabled', 'disabled'. If not provided the
            new key will be 'enabled'.
          type: string
          enum:
            - enabled
            - disabled
        hashData:
          $ref: '#/components/schemas/ApiKeyHashData'
        roles:
          type: array
          description: List of roles assigned to the key. Contains at least 1 element.
          items:
            type: string
            enum:
              - admin
              - developer
              - query_endpoints
        ipAccessList:
          type: array
          description: List of IP addresses allowed to access the API using this key
          items:
            $ref: '#/components/schemas/IpAccessListEntry'
    ApiKeyPostResponse:
      properties:
        key:
          $ref: '#/components/schemas/ApiKey'
        keyId:
          description: >-
            Generated key ID. Provided only if there was no 'hashData' in the
            request.
          type: string
        keySecret:
          description: >-
            Generated key secret. Provided only if there was no 'hashData' in
            the request.
          type: string
    ApiKeyHashData:
      properties:
        keyIdHash:
          description: 'Hash of the key ID. '
          type: string
        keyIdSuffix:
          description: >-
            Last 4 digits of the key ID. Algorithm: echo -n "yourpassword" |
            sha256sum | tr -d '-' | xxd -r -p | base64
          type: string
        keySecretHash:
          description: >-
            Hash of the key secret. Algorithm: echo -n "yourpassword" |
            sha256sum | tr -d '-' | xxd -r -p | base64
          type: string
    IpAccessListEntry:
      properties:
        source:
          description: IP or CIDR
          type: string
        description:
          description: >-
            Optional description of IPv4 address or IPv4 CIDR to allow access
            from
          type: string
    ApiKey:
      properties:
        id:
          description: Unique API key ID.
          type: string
          format: uuid
        name:
          description: Name of the key
          type: string
        state:
          description: 'State of the key: ''enabled'', ''disabled''.'
          type: string
          enum:
            - enabled
            - disabled
        roles:
          type: array
          description: List of roles assigned to the key. Contains at least 1 element.
          items:
            type: string
            enum:
              - admin
              - developer
              - query_endpoints
        keySuffix:
          description: Last 4 letters of the key.
          type: string
        createdAt:
          description: Timestamp the key was created. ISO-8601.
          type: string
          format: date-time
        expireAt:
          description: >-
            Timestamp the key expires. If not present, `null` or is empty the
            key never expires. ISO-8601.
          nullable: true
          type: string
          format: date-time
        usedAt:
          description: >-
            Timestamp the key was used last time. If not present the key was
            never used. ISO-8601.
          type: string
          format: date-time
        ipAccessList:
          type: array
          description: List of IP addresses allowed to access the API using this key
          items:
            $ref: '#/components/schemas/IpAccessListEntry'
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: >-
        Use key ID and key secret obtained in ClickHouse Cloud console:
        https://clickhouse.com/docs/cloud/manage/openapi

````