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

# إنشاء مفتاح

> ينشئ مفتاح API جديدًا.



## OpenAPI

````yaml /ar/_specs/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: قائمة الأدوار المعيّنة إلى المفتاح. تحتوي على عنصر واحد على الأقل.
          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: المعرّف الفريد لمفتاح API.
          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: قائمة الأدوار المعيّنة للمفتاح. تحتوي على عنصر واحد على الأقل.
          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 console:
        https://clickhouse.com/docs/cloud/manage/openapi
      scheme: basic
      type: http

````