> ## 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の検証セッションに対応しています。



Document AIデータAPIのプロンプトを更新
        プロンプトをクリップボードにコピー



      
      

\<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/ja/core-technology/document-ai/overview.md)を、セッションの判定のどこに結果が表示されるかについては[Document AIレポート](https://docs.didit.me/ja/core-technology/document-ai/report-document-ai.md)を参照してください。


## OpenAPI

````yaml ja/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: >-
        KYCまたはKYBセッションで、アップロードされた1件の書類からDocument
        AIが抽出したフィールドを修正するか、そのレビューステータスを設定するか、またはその両方を行います。`extracted_data`はJSONオブジェクトである必要があり、キーごとにマージされます。送信したキーは保存済みの値を置き換え（`null`として送信したキーは`null`として保存されます）、送信しなかったキーは値が保持されます。書類のステータスは、セッションの判定におけるワークフローノードのDocument
        AI結果に反映されますが、セッションのステータス自体は再計算されません。何も変更しない呼び出しを含め、成功した呼び出しのたびに、トリガー`manual_review`の`data.updated`[Webhook](https://docs.didit.me/ja/integration/webhooks)が送信されます。スコープ付きのAPIキーには`decisions:
        write`が必要です。詳しくは[Document
        AI](https://docs.didit.me/ja/core-technology/document-ai/overview)を参照してください。
      operationId: patch_v3_document_ai_document
      parameters:
        - name: sessionId
          in: path
          required: true
          description: >-
            検証セッションのUUID(`POST
            /v3/session/`が返す`session_id`)。ユーザー認証(KYC)と法人確認(KYB)の両方のセッションIDを受け付けます。サーバーは両方のセッションタイプにわたってIDを解決します。正しい形式のUUIDである必要があります。形式が不正な値はルートに一致せず、HTMLの`404`を返します。
          schema:
            type: string
            format: uuid
            example: 11111111-2222-3333-4444-555555555555
        - name: documentUuid
          in: path
          required: true
          description: >-
            Document AI書類のUUID (`GET
            /v3/session/{sessionId}/decision/`内の`document_ai_documents[].items[].uuid`)
            です。パスで指定したセッションに属している必要があります。
          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がenumに含まれていません
                  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: >-
            認証または認可に失敗しました。キーがない場合、別のアプリケーションのキーの場合、このエンドポイントに必要な権限を持たないスコープ付きキーの場合、キーのIP許可リスト外からのリクエストの場合は`403`を返し、誤った、失効した、または期限切れのキーの場合は`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: このIDのセッションが存在しないか、削除されています
                  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: >-
            レート制限を超過しました。書き込み（POST、PATCH、DELETE）リクエストはAPIキーごとに1分あたり300件までです。`Retry-After`秒待ってから再試行してください。`X-RateLimit-*`ヘッダーで利用枠を確認できます。
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    description: 人が読めるエラーメッセージ。
              examples:
                Rate limited:
                  summary: 現在の1分間の上限を使い切りました
                  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キーです。Business ConsoleのDevelopers -> API
        keysで取得できます。プライマリキーはフルアクセス権を持ちます。名前付きキーにはスコープを設定できます。リソースごとのアクセス権（なし、読み取り、書き込み）、一部のワークフローまたは承認済みセッションへの限定、IPアドレスのリストへの限定、有効期限の設定です。401は、キーが誤っている、失効している、または期限切れであることを意味します。403は、キーが送信されていない、キーにこのリソースやアクションへのアクセス権がない、またはIPリスト外のアドレスからリクエストが送信されたことを意味します。セッションのルートでの404は、セッションがキーのワークフローまたはステータスの対象外であることを意味します。メディアへのアクセス権がないキーでは、画像、動画、PDFのURLがnullで返されます。セッションの書き込み権限がないキーでは、セッションのリンクとトークンがnullで返されます。詳細は次を参照してください:
        https://docs.didit.me/console/api-keys

````

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