> ## 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.

# تحديث بيانات Document AI API

> تصحيح الحقول التي استخرجها Didit من مستند Document AI، أو تعيين حالة مراجعته، داخل جلسة التحقق من نوع KYC أو KYB في Didit.



واجهة برمجة تطبيقات تحديث بيانات Document AI
        نسخ الموجّه إلى الحافظة



      
      

\<pre>

\`Correct the extracted data of a Document AI document, or set its review status, on a Didit verification session through the API.

Endpoint:
PATCH https://verification.didit.me/v3/document-ai/{session_id}/documents/{document_uuid}/

Authentication:
Send my Didit API key in the x-api-key header. A scoped key needs decisions: write.

Goal:
\- Fix a value Document AI misread, or approve or decline a document the workflow sent to review.

Request body (JSON, both fields optional):
\- extracted_data: a JSON object of field keys to new values. Merged key by key: sent keys replace the stored values (a null value clears one), keys I leave out keep their values. Do not send extracted_data itself as null (400); leave it out instead.
\- status: "Approved", "Declined", "In Review" or "Not Finished".

Behavior:
\- Works for user (KYC) and business (KYB) session IDs.
\- {document_uuid} is document_ai_documents[].items[].uuid from GET /v3/session/{session_id}/decision/, and the document must belong to that session.
\- The document status feeds the Document AI result of its workflow node in the decision. The session status is not recomputed.
\- Every successful call, even one that changes nothing, sends a data.updated webhook with trigger "manual_review".

Example call:
curl -X PATCH "https://verification.didit.me/v3/document-ai/11111111-2222-3333-4444-555555555555/documents/44444444-5555-6666-7777-888888888888/" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"extracted_data": {"invoice_number": "INV-2026-0042"}, "status": "Approved"}'

What to read from the response:
\- extracted_data: all extracted fields after the merge.
\- status: the document's review status.
\- file_url: the storage path of the file, not a download link. Read the presigned file_url from the session decision to download it.

Failure modes:
\- 400: status is not one of the allowed values, or extracted_data is null (checked before the document is looked up).
\- 401: the API key has expired.
\- 403: missing key (a wrong, revoked or expired key gets 401), a key of another application, a scoped key without decisions: write, or a request from outside the key's IP allowlist.
\- 404: the session does not exist, was deleted, or is outside a scoped key's limits, or the document does not belong to the session.

Side effects: updates the document and sends a data.updated webhook.

For the full integration shape, see /integration/integration-prompt.`

\</pre>



      
      

الصق في

مفاتيح الحقول هي المفاتيح التي قمت بتهيئتها للمستند في سير العمل. راجع [Document AI](https://docs.didit.me/ar/core-technology/document-ai/overview.md) لمعرفة كيفية إعداد المستندات والحقول، و[تقرير Document AI](https://docs.didit.me/ar/core-technology/document-ai/report-document-ai.md) لمعرفة المكان الذي تظهر فيه النتيجة ضمن قرار الجلسة.


## OpenAPI

````yaml ar/openapi-25.json PATCH /v3/document-ai/{sessionId}/documents/{documentUuid}/
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/document-ai/{sessionId}/documents/{documentUuid}/:
    patch:
      tags:
        - Sessions
      summary: تحديث مستند في Document AI
      description: >-
        صحّح الحقول التي استخرجها Document AI من مستند واحد تم رفعه، أو اضبط
        حالة مراجعته، أو كلاهما، في جلسة KYC أو KYB. يجب أن يكون
        `extracted_data` كائن JSON ويتم دمجه مفتاحاً بمفتاح: المفتاح الذي ترسله
        يحل محل القيمة المخزنة (المفتاح المرسل كـ `null` يُخزّن كـ `null`)
        والمفاتيح التي تتجاهلها تحتفظ بقيمها. تُغذي حالة المستند نتيجة Document
        AI لعقدة سير العمل الخاصة به في قرار الجلسة؛ ولا يُعاد احتساب حالة
        الجلسة نفسها. يُرسل كل استدعاء ناجح، بما في ذلك الاستدعاء الذي لا يغير
        أي شيء، [webhook](https://docs.didit.me/ar/integration/webhooks) بالحدث
        `data.updated` والمُشغِّل `manual_review`. يحتاج مفتاح API ذو نطاق محدد
        إلى `decisions: write`؛ راجع [Document
        AI](https://docs.didit.me/ar/core-technology/document-ai/overview).
      operationId: patch_v3_document_ai_document
      parameters:
        - name: sessionId
          in: path
          required: true
          description: >-
            معرّف UUID لجلسة التحقق (`session_id` الذي تم إرجاعه بواسطة `POST
            /v3/session/`). يقبل معرّفات جلسات التحقق من المستخدمين (KYC)
            والتحقق من الشركات (KYB): يطابق الخادم المعرّف عبر كلا نوعي الجلسات.
            يجب أن يكون UUID صالح البنية؛ تؤدي القيمة غير صالحة البنية إلى عدم
            مطابقة المسار وإرجاع `404` بتنسيق HTML.
          schema:
            type: string
            format: uuid
            example: 11111111-2222-3333-4444-555555555555
        - name: documentUuid
          in: path
          required: true
          description: >-
            معرّف UUID لمستند Document AI
            (`document_ai_documents[].items[].uuid` في `GET
            /v3/session/{sessionId}/decision/`). يجب أن ينتمي إلى الجلسة
            الموجودة في المسار.
          schema:
            type: string
            format: uuid
            example: 44444444-5555-6666-7777-888888888888
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                extracted_data:
                  type: object
                  additionalProperties: true
                  description: >-
                    مفاتيح الحقول (المفاتيح التي قمت بتهيئتها للمستند) وقيمها
                    المصححة. يجب أن تكون كائن JSON؛ وتُدمج مفتاحاً بمفتاح في
                    البيانات المخزنة. لا تُرسلها بدلاً من إرسال `null`، حيث يؤدي
                    ذلك إلى إرجاع `400`.
                  example:
                    invoice_number: INV-2026-0042
                status:
                  type: string
                  enum:
                    - Approved
                    - Declined
                    - In Review
                    - Not Finished
                  description: حالة المراجعة الجديدة للمستند.
                  example: Approved
            example:
              extracted_data:
                invoice_number: INV-2026-0042
              status: Approved
      responses:
        '200':
          description: تم تحديث المستند. يُرجع المستند بعد الدمج.
          content:
            application/json:
              schema:
                type: object
                required:
                  - uuid
                  - document_key
                  - original_filename
                  - file_url
                  - status
                  - extracted_data
                properties:
                  uuid:
                    type: string
                    format: uuid
                    description: معرّف المستند.
                  document_key:
                    type: string
                    description: المستند المُعَدّ الذي يتوافق معه هذا الرفع.
                  original_filename:
                    type: string
                    nullable: true
                    description: اسم الملف الذي رُفع به المستند.
                  file_url:
                    type: string
                    nullable: true
                    description: >-
                      مسار تخزين الملف المرفوع. هذا ليس رابط تنزيل: اقرأ
                      `file_url` الموقّع مسبقاً من قرار الجلسة لتنزيل الملف.
                  status:
                    type: string
                    enum:
                      - Not Finished
                      - Approved
                      - Declined
                      - In Review
                      - Resub Requested
                    description: حالة مراجعة المستند.
                  extracted_data:
                    type: object
                    nullable: true
                    additionalProperties: true
                    description: جميع الحقول المستخرجة بعد الدمج، مفهرسة حسب مفتاح الحقل.
              example:
                uuid: 44444444-5555-6666-7777-888888888888
                document_key: invoice
                original_filename: invoice-2026-09.pdf
                file_url: >-
                  document_ai/11111111-2222-3333-4444-555555555555-66666666-7777-8888-9999-000000000000.pdf
                status: Approved
                extracted_data:
                  invoice_number: INV-2026-0042
                  total_amount: 1250
                  issue_date: '2026-09-01'
        '400':
          description: >-
            خطأ في التحقق، يتم فحصه قبل البحث عن المستند: قيمة `status` ليست من
            القيم المسموح بها، أو تم إرسال `extracted_data` كـ `null`.
          content:
            application/json:
              examples:
                Invalid status:
                  summary: status ليس ضمن التعداد
                  value:
                    status:
                      - '"Rejected" is not a valid choice.'
                Null extracted_data:
                  summary: extracted_data بقيمة null
                  value:
                    extracted_data:
                      - This field may not be null.
        '401':
          description: >-
            انتهت صلاحية مفتاح API محدد النطاق. هذه هي الحالة الوحيدة التي تُرجع
            `401`: بينما يُرجع المفتاح المفقود أو غير الصالح أو الملغى الرمز
            `403`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    description: رسالة خطأ سهلة القراءة.
              examples:
                Expired key:
                  summary: انقضى تاريخ الانتهاء للمفتاح
                  value:
                    detail: This API key has expired.
        '403':
          description: >-
            فشل في المصادقة أو التفويض. يؤدي المفتاح المفقود إلى إرجاع `403`،
            وكذلك المفتاح التابع لتطبيق آخر، أو المفتاح محدد النطاق الذي يفتقر
            إلى الإذن الذي يتطلبه هذا endpoint، أو الطلب الوارد من خارج قائمة IP
            المسموح بها للمفتاح؛ بينما يؤدي المفتاح الخاطئ أو الملغى أو منتهي
            الصلاحية إلى إرجاع `401`. يمكنك التمييز بينها من خلال `detail`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    description: رسالة خطأ سهلة القراءة.
              examples:
                Missing or invalid credentials:
                  summary: لا يوجد رأس x-api-key، أو فشل التحقق من صحة المفتاح
                  value:
                    detail: >-
                      Authentication credentials were not provided or are
                      invalid.
                Other application:
                  summary: مفتاح صالح ينتمي إلى تطبيق مختلف عن الجلسة
                  value:
                    detail: You do not have permission to perform this action.
                Scoped key without decisions write:
                  summary: 'المفتاح محدد النطاق يفتقر إلى decisions: write'
                  value:
                    detail: This API key has no write access to decisions.
                IP not allowed:
                  summary: الطلب وارد من خارج قائمة IP المسموح بها للمفتاح
                  value:
                    detail: This API key can't be used from this IP address.
        '404':
          description: >-
            الجلسة غير موجودة، أو تم حذفها، أو أنها خارج حدود مفتاح ذي نطاق
            محدد، أو لا يوجد مستند حالي بمعرّف UUID هذا ينتمي إليها. يتم البحث
            عن الجلسة قبل التحقق من بيانات الاعتماد، لذلك فإن معرّف `sessionId`
            غير المعروف يُعيد `404` حتى بدون مفتاح صالح.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    description: رسالة خطأ سهلة القراءة.
              examples:
                Unknown session:
                  summary: لا توجد جلسة بهذا المعرّف، أو أنها حُذفت
                  value:
                    detail: Not found.
                Outside key limits:
                  summary: >-
                    الجلسة خارج حدود مفتاح ذي نطاق محدد (تُعاد أيضاً للجلسة
                    المحذوفة منذ لحظات)
                  value:
                    detail: Session not found.
                Unknown document:
                  summary: documentUuid لا ينتمي إلى الجلسة
                  value:
                    detail: Document AI document not found.
        '429':
          description: >-
            تم تجاوز حد المعدل: 300 طلب كتابة (POST وPATCH وDELETE) في الدقيقة
            لكل مفتاح API. انتظر عدد الثواني المحدد في `Retry-After` قبل إعادة
            المحاولة؛ تُظهر رؤوس `X-RateLimit-*` الميزانية.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    description: رسالة خطأ سهلة القراءة.
              examples:
                Rate limited:
                  summary: استُنفدت الميزانية المخصصة للدقيقة الحالية
                  value:
                    detail: >-
                      Write request rate limit exceeded. You can make up to 300
                      requests per minute.
          headers:
            Retry-After:
              description: عدد الثواني الواجب انتظارها قبل إعادة المحاولة.
              schema:
                type: integer
                minimum: 1
                example: 30
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: curl
          source: >-
            curl -X PATCH
            'https://verification.didit.me/v3/document-ai/11111111-2222-3333-4444-555555555555/documents/44444444-5555-6666-7777-888888888888/'
            \
              -H 'x-api-key: YOUR_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{"extracted_data": {"invoice_number": "INV-2026-0042"}, "status": "Approved"}'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.sessions.update_document_ai_data(
                "11111111-2222-3333-4444-555555555555",
                "44444444-5555-6666-7777-888888888888",
                extracted_data={"invoice_number": "INV-2026-0042"},
                status="Approved",
            )
            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.sessions.updateDocumentAiData(
              "11111111-2222-3333-4444-555555555555",
              "44444444-5555-6666-7777-888888888888",
              {
                extracted_data: { invoice_number: "INV-2026-0042" },
                status: "Approved",
              },
            );
            console.log(result);
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// Reads DIDIT_API_KEY.\nclient := didit.NewClient()\n\nresult, err := client.Sessions.UpdateDocumentAiData(ctx, \"11111111-2222-3333-4444-555555555555\", \"44444444-5555-6666-7777-888888888888\", didit.SessionsUpdateDocumentAiDataParams{\n\tExtractedData: didit.Some(map[string]any{\"invoice_number\": \"INV-2026-0042\"}),\n\tStatus:        didit.Some(didit.SessionsUpdateDocumentAiDataParamsStatus(\"Approved\")),\n})\nif err != nil {\n\tlog.Fatal(err)\n}\nfmt.Printf(\"%+v\\n\", result)"
        - lang: java
          label: Java
          source: >-
            import java.util.Map;

            import me.didit.Didit;

            import me.didit.types.SessionsUpdateDocumentAiDataParams;


            // Reads DIDIT_API_KEY.

            Didit client = new Didit();


            var result =
            client.sessions().updateDocumentAiData("11111111-2222-3333-4444-555555555555",
            "44444444-5555-6666-7777-888888888888",
            SessionsUpdateDocumentAiDataParams.builder()
                    .extractedData(Map.of("invoice_number", "INV-2026-0042"))
                    .status(SessionsUpdateDocumentAiDataParams.Status.of("Approved"))
                    .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->sessions->updateDocumentAiData('11111111-2222-3333-4444-555555555555',
            '44444444-5555-6666-7777-888888888888', [
                'extracted_data' => ['invoice_number' => 'INV-2026-0042'],
                'status' => 'Approved',
            ]);

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

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

            result = didit.sessions.update_document_ai_data(
              "11111111-2222-3333-4444-555555555555",
              "44444444-5555-6666-7777-888888888888",
              extracted_data: { invoice_number: "INV-2026-0042" },
              status: "Approved"
            )
            puts result.to_h
        - lang: csharp
          label: .NET
          source: >-
            using System;

            using System.Collections.Generic;

            using System.Text.Json;

            using Didit;


            // Reads DIDIT_API_KEY.

            using var client = new DiditClient();


            var result = await
            client.Sessions.UpdateDocumentAiDataAsync("11111111-2222-3333-4444-555555555555",
            "44444444-5555-6666-7777-888888888888", new
            SessionsUpdateDocumentAiDataParams

            {
                ExtractedData = new Dictionary<string, object> { ["invoice_number"] = "INV-2026-0042" },
                Status = new SessionsUpdateDocumentAiDataParamsStatus("Approved"),
            });

            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  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.