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

# تحديث الاستبيان عبر API: تعديل نموذج KYC

> عدّل استبيان KYC في Didit: أعد تسميته، واستبدل الأسئلة المرتبة، وحدّث التسميات متعددة اللغات. إدارة برمجية لنماذج الامتثال، بالدفع لكل استدعاء.



موجه API لتحديث الاستبيان
        نسخ الموجّه إلى الحافظة



      
      

\<pre>

\`Update a simple Didit questionnaire through the Management API.

Endpoint:
PATCH https://verification.didit.me/v3/questionnaires/{questionnaire_uuid}/

Authentication:
Use the x-api-key header with my Didit API key.

Requirements:
\- Use PATCH and include only the fields I want to change.
\- To rename the questionnaire, send title or description only.
\- To change questions, send the full desired form_elements array. This replaces the existing question list.
\- Do not send graph, branches, next, required_if, or conditional logic.
\- Keep languages consistent with the questionnaire. Include en labels for every form element.
\- Capture the questionnaire_id returned by the response because published updates may return a new version id.

Example metadata update body:
\{
"title": "Updated Customer Onboarding"
}

Example full question replacement body:
\{
"form_elements": [
\{
  "id": "occupation",
  "element_type": "short_text",
  "label": { "en": "What is your occupation?" },
  "is_required": true
},
\{
  "id": "source_of_funds",
  "element_type": "multiple_choice",
  "label": { "en": "Source of funds" },
  "options": [
    \{ "value": "employment", "label": { "en": "Employment" } },
    \{ "value": "business", "label": { "en": "Business" } }
  ]
}
]
}

Build the API call, handle validation errors, and return the latest questionnaire_id from the response.`

\</pre>



      
      

الصق في

استخدم `PATCH` للتحديثات الجزئية. لإعادة تسمية الاستبيان، أرسل `title` أو `description` فقط.```json theme={null}
{
  "title": "Updated Customer Onboarding"
}
```لتحديث الأسئلة، أرسل مصفوفة `form_elements` الكاملة المطلوبة. هذا يستبدل قائمة الأسئلة السابقة. احتفظ بأي أسئلة موجودة ما زلت تريد عرضها.```json theme={null}
{
  "form_elements": [
    {
      "id": "occupation",
      "element_type": "short_text",
      "label": { "en": "What is your occupation?" },
      "is_required": true
    },
    {
      "id": "source_of_funds",
      "element_type": "multiple_choice",
      "label": { "en": "Source of funds" },
      "options": [
        { "value": "employment", "label": { "en": "Employment" } },
        { "value": "business", "label": { "en": "Business" } }
      ]
    }
  ]
}
```تدعم واجهة برمجة التطبيقات v3 الاستبيانات الخطية البسيطة فقط. وترفض `graph` و`branches` و`next` والقواعد الشرطية.تتضمّن الاستجابة `questionnaire_id`. عند تحديث استبيان `published`، قد تُنشئ واجهة برمجة التطبيقات إصداراً جديداً. احفظ قيمة `questionnaire_id` المُرجعة واستخدمها في سير العمل، بدلاً من افتراض أن المعرّف الموجود في عنوان URL هو أحدث إصدار.


## OpenAPI

````yaml ar/openapi-25.json PATCH /v3/questionnaires/{questionnaire_uuid}/
openapi: 3.0.0
info:
  version: 3.0.0
  title: Didit Verification API
  description: API التحقق من الهوية. قم بالمصادقة باستخدام الرأس x-api-key.
servers:
  - url: https://verification.didit.me
security: []
tags: []
paths:
  /v3/questionnaires/{questionnaire_uuid}/:
    patch:
      tags:
        - Questionnaires
      summary: تحديث الاستبيان
      description: >-
        تحديث استبيان. يعتمد تحديد الإصدارات على حقل `status` الذي ترسله والحالة
        الحالية للإصدار: (1) عدم وجود `status` لإصدار **منشور** ← يتم تحديث
        الإصدار المنشور في مكانه (نفس `questionnaire_id`، ونفس `version`)؛ (2)
        عدم وجود `status` لـ **مسودة** ← يتم تحديث المسودة ونشرها على الفور؛ (3)
        ‏`status: "published"` لإصدار **منشور** ← يتم إنشاء إصدار منشور جديد ضمن
        نفس `questionnaire_group_id` (معرّف `questionnaire_id` جديد، و`version`
        + 1) وإرجاعه، وتُحذف أي مسودة موجودة في المجموعة؛ (4) ‏`status: "draft"`
        يبقي المسودة كمسودة (حفظ تلقائي) ولكن يتم رفضه برمز 400 للإصدار المنشور
        (`"Cannot revert a published version to draft."`).
      operationId: update_questionnaire
      parameters:
        - name: questionnaire_uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: معرف UUID لكل إصدار من الاستبيان المطلوب تحديثه.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SimpleQuestionnaireUpdateRequest'
            examples:
              Rename:
                summary: إعادة تسمية استبيان
                value:
                  title: Updated Customer Onboarding
              Replace questions:
                summary: استبدال قائمة الأسئلة الخطية الكاملة
                value:
                  form_elements:
                    - id: occupation
                      element_type: short_text
                      label:
                        en: What is your occupation?
                      is_required: true
                    - id: source_of_funds
                      element_type: multiple_choice
                      label:
                        en: Source of funds
                      options:
                        - value: employment
                          label:
                            en: Employment
                        - value: business
                          label:
                            en: Business
      responses:
        '200':
          description: >-
            تم تحديث الاستبيان. يمثل محتوى الاستجابة أحدث حالة للإصدار الناتج —
            الإصدار المحدث في مكانه، أو الإصدار المنشور المنشأ حديثاً عند إرسالك
            `status: "published"` في صف منشور (في هذه الحالة يختلف
            `questionnaire_id` و`version` عما قمت بتعديله). يمثل
            `questionnaire_id` في الاستجابة معرّف UUID الخاص بالإصدار؛ استخدم
            `questionnaire_group_id` إذا كنت بحاجة إلى معرّف المجموعة الثابت.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QuestionnaireDetail'
        '400':
          description: >-
            خطأ في التحقق — قيمة `element_type` غير معروفة، أو ترجمة مفقودة، أو
            حقول تفريع/شرطية غير مدعومة، أو `languages` لا تتضمن `en`، أو
            `default_language` غير موجود في `languages`، أو خيار بدون تسمية، أو
            إرسال `graph` خام، أو `status: "draft"` لنسخة منشورة (`"Cannot
            revert a published version to draft."`). نص الاستجابة عبارة عن خطأ
            في التحقق من DRF مفهرس بحسب اسم الحقل.
        '403':
          description: مفتاح API مفقود أو غير صالح.
          content:
            application/json:
              examples:
                Invalid token:
                  value:
                    detail: You do not have permission to perform this action.
        '404':
          description: لا يوجد استبيان بهذا `questionnaire_uuid` للتطبيق المُصادَق عليه.
        '415':
          description: 'نوع وسائط غير مدعوم. عيّن `Content-Type: application/json`.'
        '429':
          description: تم تجاوز حد المعدل. أعد المحاولة مع تراجع أسي.
        '500':
          description: خطأ غير متوقع في الخادم. يمكن إعادة المحاولة بأمان.
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: cURL
          source: >-
            curl -X PATCH
            'https://verification.didit.me/v3/questionnaires/11111111-2222-3333-4444-555555555555/'
            \
              -H 'x-api-key: YOUR_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{"title": "Updated Customer Onboarding"}'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.questionnaires.update(
                "11111111-2222-3333-4444-555555555555",
                title="Updated Customer Onboarding",
            )
            print(result)
        - lang: javascript
          label: Node.js
          source: >-
            import Didit from "@didit-protocol/sdk-node";


            // Reads DIDIT_API_KEY.

            const didit = new Didit();


            const result = await
            didit.questionnaires.update("11111111-2222-3333-4444-555555555555",
            {
              title: "Updated Customer Onboarding",
            });

            console.log(result);
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// Reads DIDIT_API_KEY.\nclient := didit.NewClient()\n\nresult, err := client.Questionnaires.Update(ctx, \"11111111-2222-3333-4444-555555555555\", didit.SimpleQuestionnaireUpdateRequest{\n\tTitle: didit.String(\"Updated Customer Onboarding\"),\n})\nif err != nil {\n\tlog.Fatal(err)\n}\nfmt.Printf(\"%+v\\n\", result)"
        - lang: java
          label: Java
          source: >-
            import me.didit.Didit;

            import me.didit.types.SimpleQuestionnaireUpdateRequest;


            // Reads DIDIT_API_KEY.

            Didit client = new Didit();


            var result =
            client.questionnaires().update("11111111-2222-3333-4444-555555555555",
            SimpleQuestionnaireUpdateRequest.builder()
                    .title("Updated Customer Onboarding")
                    .build());
            System.out.println(result);
        - lang: php
          label: PHP
          source: >-
            <?php


            require 'vendor/autoload.php';


            use Didit\DiditClient;


            // Reads DIDIT_API_KEY.

            $didit = new DiditClient();


            $result =
            $didit->questionnaires->update('11111111-2222-3333-4444-555555555555',
            [
                'title' => 'Updated Customer Onboarding',
            ]);

            print_r($result->toArray());
        - lang: ruby
          label: Ruby
          source: |-
            require "didit"

            # Reads DIDIT_API_KEY.
            didit = Didit::Client.new

            result = didit.questionnaires.update(
              "11111111-2222-3333-4444-555555555555",
              title: "Updated Customer Onboarding"
            )
            puts result.to_h
        - lang: csharp
          label: .NET
          source: >-
            using System;

            using System.Text.Json;

            using Didit;


            // Reads DIDIT_API_KEY.

            using var client = new DiditClient();


            var result = await
            client.Questionnaires.UpdateAsync("11111111-2222-3333-4444-555555555555",
            new SimpleQuestionnaireUpdateRequest

            {
                Title = "Updated Customer Onboarding",
            });

            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  schemas:
    SimpleQuestionnaireUpdateRequest:
      type: object
      description: >-
        تحديث البيانات الوصفية للاستبيان أو استبدال قائمة `form_elements` الخطية
        الكاملة.
      properties:
        title:
          type: string
        description:
          type: string
          nullable: true
        languages:
          type: array
          items:
            type: string
        default_language:
          type: string
        is_active:
          type: boolean
        status:
          type: string
          enum:
            - draft
            - published
        form_elements:
          type: array
          minItems: 1
          description: إذا تم توفيره، فإن هذا يستبدل قائمة الأسئلة الخطية بالكامل.
          items:
            $ref: '#/components/schemas/SimpleQuestionnaireElement'
    QuestionnaireDetail:
      type: object
      description: >-
        تفاصيل الاستبيان الكاملة المرجعة من endpoint الخاصة بـ GET وPOST (إنشاء)
        وPATCH (تحديث).
      properties:
        questionnaire_id:
          type: string
          format: uuid
          description: >-
            المعرّف الفريد للاستبيان. استخدم هذا المعرّف عند الإشارة إلى
            الاستبيان من سير العمل أو في طلبات التحديث/الحذف اللاحقة.
        title:
          type: string
        description:
          type: string
          nullable: true
        languages:
          type: array
          items:
            type: string
        default_language:
          type: string
        is_active:
          type: boolean
        is_simple_questionnaire:
          type: boolean
        graph:
          type: object
          description: هيكل المخطط مع start_node وخريطة العقد.
        sections:
          type: array
          description: محتوى الاستبيان مجمّعاً في أقسام (مستمد من المخطط).
          items:
            type: object
        questionnaire_group_id:
          type: string
          format: uuid
          description: معرّف ثابت يجمع جميع إصدارات الاستبيان نفسه.
        version:
          type: integer
        status:
          type: string
          enum:
            - draft
            - published
        published_at:
          type: string
          format: date-time
          nullable: true
        is_editable:
          type: boolean
          description: >-
            تكون القيمة True عندما يكون من الممكن تعديل الاستبيان مباشرة في
            مكانه (إصدارات المسودة).
    SimpleQuestionnaireElement:
      type: object
      required:
        - element_type
        - label
      properties:
        id:
          type: string
          description: >-
            معرّف سؤال ثابت واختياري. إذا تم حذفه، تنشئ API المعرّفات `q1` و
            `q2` وما إلى ذلك. استخدم أحرفاً صغيرة وأرقاماً وشرطات سفلية لسهولة
            القراءة.
          example: source_of_funds
        element_type:
          type: string
          description: >-
            نوع السؤال. تقبل الـ API هذه القيم بالأحرف الصغيرة وما يعادلها
            بالأحرف الكبيرة.
          enum:
            - short_text
            - long_text
            - dropdown
            - single_choice
            - multiple_choice
            - number
            - image
            - file_upload
            - time
            - email
            - address
            - phone
            - country
            - date_picker
            - consent
            - section_header
            - separator
            - heading
            - paragraph
        label:
          type: object
          description: >-
            تسمية السؤال حسب رمز اللغة، على سبيل المثال `{ "en": "Source of
            funds" }`.
          additionalProperties:
            type: string
        description:
          type: object
          nullable: true
          additionalProperties:
            type: string
        placeholder:
          type: object
          nullable: true
          additionalProperties:
            type: string
        is_required:
          type: boolean
          default: false
        options:
          type: array
          description: >-
            يُستخدم مع `dropdown` و`single_choice` و`multiple_choice`. إذا تم
            حذف `value`، تنشئ واجهة API قيمة استناداً إلى تسمية الخيار.
          items:
            type: object
            required:
              - label
            properties:
              value:
                type: string
              label:
                type: object
                additionalProperties:
                  type: string
        max_files:
          type: integer
          minimum: 1
          maximum: 5
          description: يُستخدم مع `file_upload` أو `image`.
        validation:
          type: object
          nullable: true
          description: >-
            التحقق الاختياري من التنسيق لـ `short_text` أو `long_text` أو
            `number`. يُفرَض أثناء ملء المستخدم للحقل (لا يمكنه المتابعة حتى
            يجتازه) وتتم إعادة التحقق منه بواسطة API عند الإرسال.
          properties:
            pattern:
              type: string
              description: >-
                تعبير نمطي (مجموعة فرعية من ECMA-262) يجب أن تتطابق القيمة معه
                بالكامل. لـ `short_text` و`long_text`. لا تضف محددات البداية
                والنهاية ^/$؛ حيث تتم مطابقة القيمة بالكامل.
            min_length:
              type: integer
              minimum: 0
              description: الحد الأدنى لعدد الأحرف. لكل من `short_text` و`long_text`.
            max_length:
              type: integer
              minimum: 0
              description: الحد الأقصى لعدد الأحرف. خاص بـ `short_text` و`long_text`.
            min:
              type: number
              description: الحد الأدنى للقيمة الرقمية. لـ `number`.
            max:
              type: number
              description: الحد الأقصى للقيمة العددية. خاص بـ `number`.
            error_message:
              type: object
              description: رسالة مترجمة تظهر عند فشل التحقق، مفهرسة برمز اللغة.
              additionalProperties:
                type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        مفتاح API الخاص بتطبيقك، من Developers -> API keys في Business Console.
        يمتلك المفتاح الأساسي وصولاً كاملاً. يمكن تحديد نطاق المفتاح المسمى: لا
        شيء، أو قراءة، أو كتابة لكل مورد، ومحدوداً ببعض مسارات العمل أو بالجلسات
        المقبولة، وبقائمة من عناوين IP، وبتاريخ انتهاء الصلاحية. يشير 401 إلى أن
        المفتاح غير صحيح أو ملغى أو منتهي الصلاحية؛ ويشير 403 إلى أنه لم يتم
        إرسال أي مفتاح، أو أن المفتاح ليس لديه حق الوصول إلى هذا المورد أو
        الإجراء، أو أن الطلب جاء من عنوان خارج قائمة عناوين IP الخاصة به؛ ويشير
        404 في مسار جلسة إلى أن الجلسة خارج مسارات العمل أو الحالات الخاصة
        بالمفتاح. يتلقى المفتاح الذي لا يمتلك حق الوصول إلى الوسائط عناوين URL
        للصور ومقاطع الفيديو وملفات PDF كـ null، ويتلقى المفتاح الذي لا يمتلك
        إذن كتابة للجلسات روابط الجلسة وtoken كـ null. راجع
        https://docs.didit.me/console/api-keys.

````

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