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

# إنشاء أو تسجيل مفتاح مُصدر

> ينشئ مفتاحًا مُدارًا مخصصًا أو يسجل مفتاح تحقق عام خارجي. يدعم التوليد المُدار Ed25519 و ES256 و ES384 و RS256 و RS512 و PS256 و PS512. يدعم الاستيراد بالإضافة إلى ذلك ES512 و RS384 و PS384؛ استيراد مفتاح عام لا يمكّن سك العملة من جانب الخادم.

ينشئ مفتاحًا مُدارًا أو يسجل مادة مفتاح عام للمصدر المحدد بواسطة معلمة المسار `id`.

## التوقيع المدار

استخدم `provider: "KMS"` و`alg` المطلوب. يدعم التوليد المدار **Ed25519, ES256, ES384, RS256, RS512, PS256 and PS512**. راجع [algorithm support and encoding](https://docs.truthlocks.com/ar/enterprise/signing-algorithms.md). استخدم `kid` الذي تم إنشاؤه والذي تم إرجاعه في الاستجابة؛ لا يتم الاحتفاظ بمعرف مفتاح مطلوب عشوائي في هذا الوضع.

```json theme={null}
{"provider": "KMS", "alg": "Ed25519"}
```

يعتمد توفر الخوارزمية على المزود المنشور. اسم الخوارزمية وحده لا يثبت الامتثال لمعيار صناعي أو حكومي.

## تسجيل المفتاح العام

يتطلب وضع الاستيراد `kid` و `alg` و `public_key_b64url`. `algorithm` و `public_key` ليسا بديلين. قم بترميز بايتات المفتاح العام DER SubjectPublicKeyInfo كـ base64url غير مبطن.

تسجيل مفتاح عام **لا** يوفر مفتاحه الخاص، وهو غير كافٍ بحد ذاته لسك العملات من جانب الخادم. لا ترسل أبدًا مادة المفتاح الخاص في هذا الطلب.

يتضمن الرد `issuer_id`، `kid`، `alg`، `public_key_b64url`، `provider`، و`created_at`. تأكد من توفر التوقيع قبل السك.


## OpenAPI

````yaml ar/mint-openapi.yaml POST /v1/issuers/{id}/keys
openapi: 3.0.3
info:
  title: Truthlocks API
  description: >
    Truthlocks هي بنية تحتية عالمية للتحقق من المستندات وبيانات الاعتماد والأصول
    الرقمية.يحدد هذا المواصفات واجهة برمجة التطبيقات (API) الأساسية للتفاعل مع
    خدمات Truthlocks.


    ## عناوين URL الأساسية

    - **الإنتاج**: `https://api.truthlocks.com`

    - **البيئة التجريبية (Sandbox)**: `https://sandbox-api.truthlocks.com`


    ## المصادقة

    - **مفاتيح API**: استخدم رأس `X-API-Key` للعمليات من جهاز إلى جهاز

    - **رموز Bearer**: استخدم `Authorization: Bearer <jwt>` للعمليات التي يبدأها
    المستخدم


    ## هوية المستأجر

    في بيئة الإنتاج، تُستمد هوية المستأجر من السياق المصادق عليه (مفتاح API أو
    JWT).

    يتم تجاهل رأس `X-Tenant-ID` في بيئة الإنتاج لمنع الانتحال.
  version: 1.0.0
  contact:
    name: Truthlocks Support
    url: https://truthlocks.com/support
    email: support@truthlocks.com
servers:
  - url: https://api.truthlocks.com
    description: واجهة برمجة تطبيقات الإنتاج
  - url: https://sandbox-api.truthlocks.com
    description: بيئة اختبار (Sandbox)
security:
  - APIKey: []
  - BearerAuth: []
tags:
  - name: Authentication
    description: إدارة مفاتيح ورموز API
  - name: Issuers
    description: تسجيل المصدر وإدارة الثقة
  - name: Keys
    description: إدارة المفاتيح التشفيرية لجهات الإصدار
  - name: Attestations
    description: دورة حياة الإشهاد (السك، الإلغاء، الاستبدال)
  - name: Verification
    description: حزم التحقق والإثبات للإشهاد
  - name: Governance
    description: سير عمل حوكمة المصدر (للمسؤول فقط)
  - name: Identity
    description: إدارة المنظمة والمستخدمين والأدوار
  - name: Audit
    description: استعلامات أحداث التدقيق
  - name: Tenant Console
    description: ملف تعريف المستأجر ونقاط نهاية دورة الحياة
  - name: Health
    description: نقاط نهاية صحة الخدمة وجاهزيتها
  - name: Risk
    description: استيعاب إشارة المخاطر واكتشاف الاحتيال
  - name: Risk Enforcement
    description: إجراءات إنفاذ المخاطر — الحظر والتحدي والحجر والتكوين
  - name: Billing
    description: إدارة الفوترة والاشتراكات والإضافات
  - name: Machine Identity
    description: >-
      بروتوكول هوية وكيل الآلة (MAIP) — تسجيل الوكيل، الجلسات، الثقة، الشهادة،
      الامتثال، التنسيق، والمراقبة
externalDocs:
  description: واجهة برمجة تطبيقات الشفافية للقراءة فقط (مواصفات خدمة منفصلة)
  url: >-
    https://github.com/truthlocks/truthlock/blob/main/docs/transparency/openapi.yaml
paths:
  /v1/issuers/{id}/keys:
    post:
      tags:
        - Keys
      summary: تسجيل مفتاح
      description: >-
        ينشئ مفتاحًا مُدارًا مخصصًا أو يسجل مفتاح تحقق عام خارجي. يدعم التوليد
        المُدار Ed25519 و ES256 و ES384 و RS256 و RS512 و PS256 و PS512. يدعم
        الاستيراد بالإضافة إلى ذلك ES512 و RS384 و PS384؛ استيراد مفتاح عام لا
        يمكّن سك العملة من جانب الخادم.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              properties:
                alg:
                  $ref: '#/components/schemas/SigningAlgorithm'
                  description: >-
                    يجب أن يتطابق مع المفتاح العام. يدعم التوليد المدار
                    الخوارزميات السبع المذكورة أعلاه؛ الافتراضي هو Ed25519.
                kid:
                  type: string
                provider:
                  type: string
                  enum:
                    - KMS
                    - DEV
                  description: >-
                    ينشئ KMS مفتاح توقيع مخصصًا. يسجل DEV مواد التحقق العامة
                    فقط.
                public_key_b64url:
                  type: string
                  description: >-
                    SubjectPublicKeyInfo بتنسيق DER base64url غير محشو؛ مطلوب
                    للاستيراد، لا ترسل أبدًا مادة المفتاح الخاص.
              type: object
              oneOf:
                - title: Managed signing key
                  required:
                    - provider
                  properties:
                    provider:
                      enum:
                        - KMS
                - title: Imported public verification key
                  required:
                    - kid
                    - alg
                    - public_key_b64url
                  properties:
                    provider:
                      enum:
                        - DEV
      responses:
        '201':
          description: تم تسجيل المفتاح
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Key'
        '400':
          description: خوارزمية أو تنسيق مفتاح غير صالح
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              example:
                code: VALIDATION_ERROR
                message: >-
                  Unsupported algorithm. Must be one of: ES256, ES384, ES512,
                  RS256, RS384, RS512, PS256, PS384, PS512, Ed25519
                http_status: 400
      security:
        - APIKey: []
        - BearerAuth: []
components:
  schemas:
    SigningAlgorithm:
      type: string
      enum:
        - Ed25519
        - ES256
        - ES384
        - ES512
        - RS256
        - RS384
        - RS512
        - PS256
        - PS384
        - PS512
      description: خوارزمية التوقيع لتوليد المفتاح
    Key:
      type: object
      properties:
        kid:
          type: string
          description: معرف المفتاح
        issuer_id:
          type: string
          format: uuid
        algorithm:
          $ref: '#/components/schemas/SigningAlgorithm'
        public_key:
          type: string
          description: المفتاح العام المشفر بـ Base64
        status:
          type: string
          enum:
            - ACTIVE
            - DISABLED
            - EXPIRED
        not_before:
          type: string
          format: date-time
        expires_at:
          type: string
          format: date-time
    ErrorEnvelope:
      type: object
      required:
        - code
        - message
        - http_status
      properties:
        code:
          type: string
          description: رمز خطأ قابل للقراءة آليًا
          enum:
            - AUTH_REQUIRED
            - AUTH_INVALID
            - PERMISSION_DENIED
            - TENANT_IDENTITY_UNVERIFIED
            - NOT_FOUND
            - VALIDATION_ERROR
            - CONFLICT
            - PAYLOAD_TOO_LARGE
            - RATE_LIMIT_EXCEEDED
            - QUOTA_EXCEEDED
            - SERVICE_UNAVAILABLE
            - INTERNAL_ERROR
        message:
          type: string
          description: رسالة خطأ مقروءة بشريًا
        http_status:
          type: integer
          description: رمز حالة HTTP
        retry_after_ms:
          type: integer
          description: عدد المللي ثانية للانتظار قبل إعادة المحاولة (لحدود المعدل)
        details:
          type: object
          description: سياق خطأ إضافي
      example:
        code: AUTH_REQUIRED
        message: Authentication required
        http_status: 401
  securitySchemes:
    APIKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: مفتاح API للمصادقة من جهاز إلى جهاز
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT للعمليات التي يبدأها المستخدم

````

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