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

# ドキュメントAI API：カスタム書類データ抽出

> DiditのPOST /v3/document-ai/は、PDFや画像から指定したフィールドをサーバー間で抽出し、氏名照合と改ざんチェックも実行します。料金は書類1件あたり$0.20です。

書類を1件と、その書類から読み取りたいフィールドのリストを送信します。Diditはファイルに対してデフォルトの抽出モデルを実行し、すべてのフィールドを型付きで返します（`text`、`number`、または`YYYY-MM-DD`形式の`date`）。さらに、対応するQRコードやバーコードを検出・デコードし、ファイルに改ざんがないかをチェックし、必要に応じて書類上の名前を想定する個人または企業と照合します。資金証明、給与明細、銀行取引明細書、税務書類、請求書など、固定のテンプレートに当てはまらないあらゆる書類に利用できます。

これは、ホスト型の[Document AI](https://docs.didit.me/ja/core-technology/document-ai/overview.md)ステップのサーバー間連携版です。リクエストは`multipart/form-data`形式で、ファイルは`document`に、フィールド定義はJSONエンコードした1つの配列文字列として`fields`に入れます。

## 抽出するフィールドを定義する

`fields`は1〜30項目のJSON配列で、1つの文字列として送信します。各項目には、`key`（小文字の英字、数字、アンダースコアで構成し、リクエスト内で一意）、人間が判読できる`name`、モデルに何を探すかを指示する`instruction`、`type`（`text`、`number`、または`date`）、そして`required`と`is_full_name`の2つのフラグがあります。

```json theme={null}
[
  {
    "key": "account_holder",
    "name": "Account holder",
    "instruction": "Full name of the person or company the account belongs to",
    "type": "text",
    "required": true,
    "is_full_name": true
  },
  {
    "key": "balance",
    "name": "Closing balance",
    "instruction": "Closing balance shown on the statement, as a number without the currency symbol",
    "type": "number",
    "required": true
  },
  {
    "key": "currency",
    "name": "Currency",
    "instruction": "Three-letter currency code of the balance",
    "type": "text"
  },
  {
    "key": "statement_date",
    "name": "Statement date",
    "instruction": "Date the statement was issued",
    "type": "date",
    "required": true
  }
]
```

multipartリクエストでは、配列全体が1つのフォーム値になります。

```bash theme={null}
curl -X POST https://verification.didit.me/v3/document-ai/ \
  -H "x-api-key: $DIDIT_API_KEY" \
  -F "document=@./bank-statement.pdf" \
  -F 'fields=[{"key":"account_holder","name":"Account holder","instruction":"Full name of the account holder","type":"text","required":true,"is_full_name":true},{"key":"balance","name":"Closing balance","instruction":"Closing balance as a number","type":"number","required":true}]' \
  -F "expected_first_name=Jane" \
  -F "expected_last_name=Doe"
```

レスポンスでは、正規化された`fields`がエコーバックされ、指定した`key`の値をキーとする`extracted_data`が返されます。モデルが見つけられなかった項目は`null`になります。各項目の`name`、`instruction`、`type`は省略可能で（`type`のデフォルトは`text`）、`key`は必須です。`fields`をブラケット形式のフォームキー（`fields[0][key]=...`）で送信した場合や、JSON配列以外の形式で送信した場合は、抽出の実行前に`400`が返されるため、料金は一切発生しません。

## QRコードとバーコード

成功したすべてのレスポンスには`document_ai.detected_codes`が含まれます。各項目の内容は次のとおりです。

| フィールド | 説明 |
| - | - |
| `type` | 検出されたシンボル体系（`QR_CODE`、`CODE_128`、`EAN_13`、`DATA_MATRIX`、`PDF_417`など） |
| `page_number` | 1始まりのページ番号 |
| `position` | レンダリングされたページのピクセル単位で表した検出ポリゴン。信頼できる位置が得られない場合は`null` |
| `x`, `y`, `width`, `height` | レンダリングされたページのピクセル単位で表したバウンディングボックス。信頼できる位置が得られない場合は`null` |
| `page_width`, `page_height` | 座標の基準となる、レンダリングされたページの寸法 |
| `parsed_payload` | デコードされた文字列または構造化された値。コードの位置しか特定できない場合は`null` |
| `raw_payload` | 利用可能な場合はbase64文字列形式の生のデコーダーペイロード。それ以外の場合は空文字列 |

この配列はPDFの処理対象となったすべてのページを網羅し、対応するコードが見つからない場合は空になります。Diditがペイロードを推測することはありません。破損したQRコードは位置情報と`parsed_payload: null`とともに返される場合があり、コード検出に失敗してもDocument AIリクエスト自体は失敗しません。

## 名前の照合

`is_full_name: true`を指定するフィールドは最大1つとし、書類の名義人として想定する名前を送信します。

| 検証対象 | 送信するもの | 名前の照合先 |
| - | - | - |
| 個人 | `expected_first_name` + `expected_last_name` | その人の氏名 |
| 企業 | `expected_company_name`（+ 任意で2文字のISOコードの`expected_company_country`） | 企業名 |

どちらか一方のグループのみを送信し、両方を送信しないでください。名前が抽出され、想定する名前が指定されている場合、レスポンスには`name_match_score`（0〜100）と`name_on_document`が含まれます。スコアが`document_ai_name_match_score_threshold`（デフォルトは`80`）を下回ると、`DOCUMENT_AI_NAME_MISMATCH`警告が発生し、`document_ai_name_mismatch_action`が適用されます。`is_full_name`が指定されたフィールドがない場合、Diditはキーが名前を示す最初のテキストフィールド（`name`、`holder`、`full_name`、`account_holder`）を代わりに使用します。照合に使う値を制御したい場合は、フィールドを明示的に指定してください。書類上に名前の値が見つからない場合、または想定する名前が送信されていない場合、名前チェックはスキップされ、`name_match_score`は`null`になります。

## リスクとアクション

以下の各リスクは、リクエストごとに設定できるアクションパラメーター（`DECLINE`、`REVIEW`、`NO_ACTION`）に対応しています。トリガーされたアクションのうち最も厳しいものが`document_ai.status`を決定し（`Declined` > `In Review` > `Approved`）、トリガーされたすべてのリスクが`document_ai.warnings`に一覧表示されます。デフォルト値はホスト型ワークフローのステップと同じです。各リスクの検出方法については、[Document AIのルールと警告](https://docs.didit.me/ja/core-technology/document-ai/warnings-document-ai.md)を参照してください。

| リスク | パラメーター | デフォルト |
| - | - | - |
| `DOCUMENT_AI_UNREADABLE_DOCUMENT` | `document_ai_unreadable_document_action` | `REVIEW` |
| `DOCUMENT_AI_MISSING_REQUIRED_FIELDS` | `document_ai_missing_required_fields_action` | `REVIEW` |
| `DOCUMENT_AI_SUSPECTED_MANIPULATION` | `document_ai_document_tampering_action` | `DECLINE` |
| `DOCUMENT_AI_NAME_MISMATCH` | `document_ai_name_mismatch_action` | `NO_ACTION` |
| `DOCUMENT_AI_UNSUPPORTED_FILE` | `document_ai_unsupported_file_action` | `REVIEW` |

## ファイル・保存・請求

* **対応ファイル：** PDF（複数ページに対応）、JPG、JPEG、PNG、TIFF、WebP、または書類を含むZIPで、最大30MBまでです。暗号化されたPDFの場合は`400`が返されます。代わりに復号済みのPDFまたは写真をアップロードしてください。
* **`save_api_request`**（デフォルトは`true`）：リクエスト、抽出されたフィールド、検出されたコードがBusiness Consoleの**Manual Checks**に表示され、チームでレビューできます。保存しない場合は`false`に設定してください。
* **`vendor_data`**と**`metadata`**はレスポンスでそのまま返されるため、結果を自社の記録と紐付けることができます。
* **料金：** 書類1件あたり\$0.20で、書類が処理されステータスが返された時点で請求されます。ご利用のプランの割引が適用されます。詳しくは[料金](https://docs.didit.me/ja/getting-started/pricing.md#スタンドアロンapiの料金-サーバー間)を参照してください。

> [!NOTE]
>
> ユーザー自身に書類をアップロードしてもらう、1つのフローで最大3件の書類を収集する、アップロード画面を自動翻訳する、または抽出したフィールドを本人確認書類やアンケートのデータと照合する必要がある場合は、代わりにホスト型の[Document AIワークフローステップ](https://docs.didit.me/ja/core-technology/document-ai/overview.md)を使用してください。


## OpenAPI

````yaml ja/openapi-25.json POST /v3/document-ai/
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/:
    post:
      tags:
        - Standalone APIs
      summary: Document AI(カスタムフィールド抽出と改ざんチェック)
      description: >-
        給与明細、資金証明、資産の出所に関する書簡、納税証明書、契約書、請求書など、あらゆる補足書類から、**お客様自身**が定義したフィールドを1回の呼び出しで抽出します。ファイルと`fields`定義（キー、名前、抽出指示、型）を送信すると、型付きの値（`text`、`number`、`YYYY-MM-DD`形式の`date`）、想定される個人または企業との名前の一致スコア（任意）、PDF/EXIFの改ざんシグナル、`Approved`/`Declined`/`In
        Review`のいずれかの`status`、検出されたすべての問題を説明する`warnings`リストが返されます。これはホスト型のDocument
        AIワークフローステップ（`/core-technology/document-ai/overview`を参照）に対応するサーバー間連携版です。Diditのデフォルトの抽出モデルを使用し、プロバイダーの選択は提供していません。


        **レイテンシ。**
        抽出はLLMベースです。通常の呼び出しには**5–15秒**、複数ページのPDFでは最大**約30秒**かかります。クライアントのタイムアウトは**45秒以上**に設定し、呼び出しが完了する前に再試行しないでください。


        **リクエスト形式。**
        `multipart/form-data`のみ対応しています。`fields`は**JSONエンコードされた1つの配列文字列**（1–30項目、最大16
        KB）です。ブラケット形式のフォーム配列は`400`で拒否されます。各項目は`{key, name, instruction, type,
        required,
        is_full_name}`です。`key`はレスポンスで返されるJSONキー（`^[a-z0-9_]{1,64}$`、一意）、`instruction`はモデルに何を読み取るかを指示し、`type`は`text`（デフォルト）
        | `number` |
        `date`のいずれかです。`required`を指定すると、値を読み取れない場合に`DOCUMENT_AI_MISSING_REQUIRED_FIELDS`が発生します。`is_full_name:
        true`を設定できるのは最大1つのフィールドのみで、これにより想定される名前と比較する値を指定します。


        **名前照合。** `expected_first_name` +
        `expected_last_name`（個人）**または**`expected_company_name`（+
        任意で`expected_company_country`）を渡します。両方を渡すことはできません。`is_full_name`フィールドの値（指定がない場合は、キーが名前らしい最初のテキストフィールド）があいまい比較されます。両方の値が存在する場合、`name_match_score`（0–100）と`name_on_document`は常に返されます。スコアが`document_ai_name_match_score_threshold`（デフォルト80）を下回ると`DOCUMENT_AI_NAME_MISMATCH`が追加され、その扱いは`document_ai_name_mismatch_action`によって決まります。


        **判定ロジック。** 各リスクは設定可能なアクションに対応します。`DECLINE` → `status:
        "Declined"`、`REVIEW` → `status: "In Review"`、`NO_ACTION` →
        情報提供のみです。デフォルトはワークフローステップと同じで、読み取れない書類は`REVIEW`、必須フィールドの欠落は`REVIEW`、改ざんの疑いは`DECLINE`、名前の不一致は`NO_ACTION`、サポートされていないファイルは`REVIEW`です。まったく処理できない書類は`400`を返し、読み取れるものの問題がある書類は`Declined`/`In
        Review`とともに`200`を返します。HTTPコードだけでなく、必ず`document_ai.status`と`document_ai.warnings`を確認してください。


        **請求。** `200`レスポンスごとにDocument AI
        APIクレジットを1つ消費します。定価は**書類1件あたり$0.20**で、プランのクレジットまたはチャージ残高から支払われます。組織の残高で呼び出しをまかなえない場合、エンドポイントは処理を開始する前に`403`を返します。サンドボックスのAPIキーは決定論的なモックレスポンスを返し、課金されません。


        **永続化。**
        `save_api_request=true`（デフォルト）の場合、呼び出しはAPIタイプのセッションとして保存されます。書類、抽出された値、フィールド定義、名前照合のスナップショットが保持され、セッションはBusiness
        Consoleに表示され、`request_id`は`GET
        /v3/session/{sessionId}/decision/`で使用できます。
      operationId: post_v3document-ai
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - document
                - fields
              properties:
                document:
                  type: string
                  format: binary
                  description: >-
                    読み取る書類です。使用可能な拡張子:
                    `tiff`、`jpg`、`jpeg`、`png`、`pdf`、`webp`、`zip`。最大アップロードサイズ:
                    **30
                    MB**（これを超えるファイルは`400`で拒否されます）。複数ページのPDFに対応しています（レイテンシーは長くなります）。暗号化されたPDFは`400`で拒否されます。画像は処理前に自動的に圧縮されます。
                fields:
                  type: string
                  description: >-
                    **1〜30**個のフィールド定義を含む、JSONエンコードされた配列文字列1つ(最大16KB)。各項目:
                    `key`(必須、`^[a-z0-9_]{1,64}$`、一意。`extracted_data`で返されるキー)、`name`(100文字以内、メッセージに表示)、`instruction`(500文字以内、モデルが読み取る内容)、`type`(`text`(デフォルト)、`number`、`date`のいずれか)、`required`(真偽値、デフォルトは`false`)、`is_full_name`(真偽値、デフォルトは`false`、1リクエストにつき最大1つ)。ブラケット形式のフォーム配列、無効なJSON、重複するキー、または複数の`is_full_name`がある場合は、処理や課金が行われる前に`400`が返されます。
                  example: >-
                    [{"key": "employer_name", "name": "Employer name",
                    "instruction": "The employer or company issuing the
                    payslip.", "type": "text", "required": true, "is_full_name":
                    false}, {"key": "employee_name", "name": "Employee name",
                    "instruction": "The full name of the employee as printed on
                    the payslip.", "type": "text", "required": true,
                    "is_full_name": true}, {"key": "net_pay", "name": "Net pay",
                    "instruction": "The net amount paid to the employee for the
                    period.", "type": "number", "required": true,
                    "is_full_name": false}, {"key": "pay_date", "name": "Pay
                    date", "instruction": "The payment date shown on the
                    payslip.", "type": "date", "required": false,
                    "is_full_name": false}]
                expected_first_name:
                  type: string
                  description: >-
                    書類の氏名フィールドと照合する名です（音訳を考慮したあいまい一致）。`expected_last_name`と併用してください。`expected_company_name`とは組み合わせられません。
                  example: Sophia
                expected_last_name:
                  type: string
                  description: >-
                    書類の氏名フィールドと照合する姓。`expected_first_name`と組み合わせて`name_match_score`を算出します。
                  example: Martinez
                expected_company_name:
                  type: string
                  description: >-
                    書類の名前フィールドと照合する会社名（企業の書類の場合）。`expected_first_name` /
                    `expected_last_name`とは併用できません（例の値は意図的に記載していません。生成されるリクエストサンプルでは個人のフィールドを使用しているため、企業の書類を検証する場合はこのフィールドに置き換えてください）。
                expected_company_country:
                  type: string
                  description: >-
                    `expected_company_name`の企業名正規化を調整する任意のISO 3166-1
                    alpha-2国コード（2文字のASCII英字、例:
                    `FR`）です。`expected_company_name`と併用する場合にのみ使用されます。
                document_ai_name_match_score_threshold:
                  type: integer
                  minimum: 0
                  maximum: 100
                  default: 80
                  description: >-
                    名前が一致したとみなす`name_match_score`の最小値（0〜100）。これより低いスコアの場合は`DOCUMENT_AI_NAME_MISMATCH`が追加され、その扱いは`document_ai_name_mismatch_action`で決まります。
                  example: 80
                document_ai_unreadable_document_action:
                  type: string
                  enum:
                    - DECLINE
                    - REVIEW
                    - NO_ACTION
                  default: REVIEW
                  description: >-
                    書類からフィールドを1つも読み取れなかった場合の処理です（`DOCUMENT_AI_UNREADABLE_DOCUMENT`）。
                document_ai_missing_required_fields_action:
                  type: string
                  enum:
                    - DECLINE
                    - REVIEW
                    - NO_ACTION
                  default: REVIEW
                  description: >-
                    `required`フィールドのうち少なくとも1つを読み取れなかった場合の処理です（`DOCUMENT_AI_MISSING_REQUIRED_FIELDS`。該当するフィールドは`additional_data.missing_fields`に列挙されます）。
                document_ai_document_tampering_action:
                  type: string
                  enum:
                    - DECLINE
                    - REVIEW
                    - NO_ACTION
                  default: DECLINE
                  description: >-
                    PDF/EXIFのフォレンジック分析で改ざんが疑われる場合の処理です。デジタル署名後の変更、既知のPDF編集ソフトの使用、オーバーレイテキストによる改ざん、不審な再エクスポート、画像の異常が対象です（`DOCUMENT_AI_SUSPECTED_MANIPULATION`）。
                document_ai_name_mismatch_action:
                  type: string
                  enum:
                    - DECLINE
                    - REVIEW
                    - NO_ACTION
                  default: NO_ACTION
                  description: >-
                    `name_match_score`がしきい値を下回る場合の処理です（`DOCUMENT_AI_NAME_MISMATCH`）。
                document_ai_unsupported_file_action:
                  type: string
                  enum:
                    - DECLINE
                    - REVIEW
                    - NO_ACTION
                  default: REVIEW
                  description: >-
                    アップロードが空である、または処理可能なファイルではない場合（`DOCUMENT_AI_UNSUPPORTED_FILE`）の対応です。
                save_api_request:
                  type: boolean
                  default: true
                  description: >-
                    `true`（デフォルト）の場合、呼び出しはAPIタイプのセッションとして保存されます。このセッションはBusiness
                    Consoleに表示され、返された`request_id`を使って`GET
                    /v3/session/{sessionId}/decision/`で取得でき、アップロードされた書類、抽出された値、フィールド定義、氏名照合のスナップショットが保存されます。`false`の場合、何も保存されず、`request_id`はレスポンスの照合専用の一時的なUUIDになります。この場合も呼び出しは課金されます。
                  example: true
                vendor_data:
                  type: string
                  description: >-
                    任意の不透明な文字列（社内のユーザーID、メールアドレス、UUIDなど）です。保存されたセッションに格納され、レスポンスでそのまま返されます。API呼び出しを自社の記録と関連付けたり、後でセッションを絞り込んだりするために使用します。
                  example: user-123
                metadata:
                  type: object
                  additionalProperties: true
                  description: >-
                    セッションとともに保存され（`save_api_request=true`の場合）、レスポンスでそのまま返される任意のJSONオブジェクトです。マルチパートリクエストでは、JSONエンコードされた文字列フィールドとして送信してください（例:
                    `metadata={"flow":"onboarding"}`）。オブジェクトとして解析されます。
                  example:
                    flow: onboarding
      responses:
        '200':
          description: >-
            書類が処理されました。`document_ai.status`は`Approved`、`Declined`、`In
            Review`のいずれかで、検出されたすべての問題は`document_ai.warnings`に個別に列挙されます。問題のある書類でも`200`が返されるため、HTTPコードだけでなくボディを確認してください。`save_api_request=true`の場合、`request_id`は永続化されたセッションIDです。
          content:
            application/json:
              examples:
                Approved:
                  summary: 給与明細が正しく読み取られ、氏名が一致
                  value:
                    request_id: 9d6a3b1e-2f0c-4a8e-9b7d-1c2e3f4a5b6c
                    document_ai:
                      status: Approved
                      extracted_data:
                        employer_name: Acme Payments Ltd
                        employee_name: Sophia Martinez
                        net_pay: 3120.5
                        pay_date: '2026-07-31'
                      detected_codes:
                        - type: CODE_128
                          page_number: 1
                          position:
                            - - 96
                              - 456
                            - - 96
                              - 616
                            - - 1012
                              - 611
                            - - 1015
                              - 456
                          x: 96
                          'y': 456
                          width: 919
                          height: 160
                          page_width: 1200
                          page_height: 1700
                          raw_payload: SU5WLTIwMjYtMDA0Mg==
                          parsed_payload: INV-2026-0042
                      fields:
                        - key: employer_name
                          name: Employer name
                          instruction: The employer or company issuing the payslip.
                          type: text
                          required: true
                          is_full_name: false
                        - key: employee_name
                          name: Employee name
                          instruction: >-
                            The full name of the employee as printed on the
                            payslip.
                          type: text
                          required: true
                          is_full_name: true
                        - key: net_pay
                          name: Net pay
                          instruction: The net amount paid to the employee for the period.
                          type: number
                          required: true
                          is_full_name: false
                        - key: pay_date
                          name: Pay date
                          instruction: The payment date shown on the payslip.
                          type: date
                          required: false
                          is_full_name: false
                      name_match_score: 100
                      name_on_document: Sophia Martinez
                      warnings: []
                    vendor_data: user-123
                    metadata:
                      flow: onboarding
                    created_at: '2026-08-19T16:40:12.318Z'
                In Review — missing required field:
                  summary: '`net_pay`を読み取れませんでした。デフォルトのアクションはREVIEWです'
                  value:
                    request_id: 3f2a9c7b-5d4e-4b1a-8c6f-0e9d8c7b6a5f
                    document_ai:
                      status: In Review
                      extracted_data:
                        employer_name: Acme Payments Ltd
                        employee_name: Sophia Martinez
                        net_pay: null
                        pay_date: '2026-07-31'
                      detected_codes: []
                      fields:
                        - key: employer_name
                          name: Employer name
                          instruction: The employer or company issuing the payslip.
                          type: text
                          required: true
                          is_full_name: false
                        - key: employee_name
                          name: Employee name
                          instruction: >-
                            The full name of the employee as printed on the
                            payslip.
                          type: text
                          required: true
                          is_full_name: true
                        - key: net_pay
                          name: Net pay
                          instruction: The net amount paid to the employee for the period.
                          type: number
                          required: true
                          is_full_name: false
                        - key: pay_date
                          name: Pay date
                          instruction: The payment date shown on the payslip.
                          type: date
                          required: false
                          is_full_name: false
                      name_match_score: 100
                      name_on_document: Sophia Martinez
                      warnings:
                        - risk: DOCUMENT_AI_MISSING_REQUIRED_FIELDS
                          feature: DOCUMENT_AI
                          additional_data:
                            missing_fields:
                              - Net pay
                          log_type: warning
                          short_description: Required fields could not be extracted
                          long_description: >-
                            One or more fields configured as required could not
                            be extracted from the uploaded document.
                    vendor_data: null
                    metadata: null
                    created_at: '2026-08-19T16:41:05.002Z'
                Declined — suspected manipulation:
                  summary: PDFフォレンジックで既知の編集ソフトが検出されました。デフォルトのアクションはDECLINE
                  value:
                    request_id: 7c1d2e3f-4a5b-4c6d-8e9f-0a1b2c3d4e5f
                    document_ai:
                      status: Declined
                      extracted_data:
                        employer_name: Acme Payments Ltd
                        employee_name: Sophia Martinez
                        net_pay: 3120.5
                        pay_date: '2026-07-31'
                      detected_codes: []
                      fields:
                        - key: employer_name
                          name: Employer name
                          instruction: The employer or company issuing the payslip.
                          type: text
                          required: true
                          is_full_name: false
                        - key: employee_name
                          name: Employee name
                          instruction: >-
                            The full name of the employee as printed on the
                            payslip.
                          type: text
                          required: true
                          is_full_name: true
                        - key: net_pay
                          name: Net pay
                          instruction: The net amount paid to the employee for the period.
                          type: number
                          required: true
                          is_full_name: false
                        - key: pay_date
                          name: Pay date
                          instruction: The payment date shown on the payslip.
                          type: date
                          required: false
                          is_full_name: false
                      name_match_score: null
                      name_on_document: Sophia Martinez
                      warnings:
                        - risk: DOCUMENT_AI_SUSPECTED_MANIPULATION
                          feature: DOCUMENT_AI
                          additional_data:
                            detection_method: known_editor
                            processed_by_known_editor: ilovepdf
                          log_type: error
                          short_description: Suspected document manipulation
                          long_description: >-
                            The system detected signs of potential manipulation
                            or editing in the uploaded document.
                    vendor_data: null
                    metadata: null
                    created_at: '2026-08-19T16:42:40.771Z'
              schema:
                type: object
                properties:
                  request_id:
                    type: string
                    format: uuid
                    description: >-
                      `save_api_request=true`の場合は保存されたセッションID(`GET
                      /v3/session/{sessionId}/decision/`で使用可能)、それ以外の場合は一時的な相関UUIDです。
                  document_ai:
                    type: object
                    properties:
                      status:
                        type: string
                        enum:
                          - Approved
                          - Declined
                          - In Review
                        description: >-
                          却下またはレビューに該当する警告がない場合は`Approved`、少なくとも1つのリスクが`DECLINE`に対応する場合は`Declined`、それ以外で少なくとも1つが`REVIEW`に対応する場合は`In
                          Review`になります。理由は`warnings`リストで確認できます。
                      extracted_data:
                        type: object
                        additionalProperties: true
                        description: >-
                          要求されたフィールドキーごとに1エントリー。値はフィールドの`type`に従って型付けされます。`text`は文字列、`number`は数値、`date`は`YYYY-MM-DD`形式の文字列で、値を読み取れなかった場合は`null`です。
                        example:
                          employer_name: Acme Payments Ltd
                          employee_name: Sophia Martinez
                          net_pay: 3120.5
                          pay_date: '2026-07-31'
                      detected_codes:
                        type: array
                        description: >-
                          処理済みのすべてのページで検出されたQRコードとバーコード。見つからない場合は空です。位置は特定できたもののデコードできないQRコードは`parsed_payload:
                          null`となります。
                        items:
                          $ref: '#/components/schemas/DocumentAIDetectedCode'
                      fields:
                        type: array
                        description: >-
                          この抽出に使用された正規化済みのフィールド定義をそのまま返します（`save_api_request=true`の場合はセッションにも保存されます）。
                        items:
                          type: object
                          properties:
                            key:
                              type: string
                            name:
                              type: string
                            instruction:
                              type: string
                            type:
                              type: string
                              enum:
                                - text
                                - number
                                - date
                            required:
                              type: boolean
                            is_full_name:
                              type: boolean
                      name_match_score:
                        type: number
                        nullable: true
                        minimum: 0
                        maximum: 100
                        description: >-
                          `name_on_document`と、想定される人物名または企業名とのあいまい類似度（0–100）。名前の値と想定される名前の両方が存在する場合は、一致時**および**不一致時のいずれでも返されます。それ以外の場合は`null`です。
                        example: 96
                      name_on_document:
                        type: string
                        nullable: true
                        description: >-
                          書類から取得された名前の値(`is_full_name`フィールド、または最初の名前に類するテキストフィールド)で、想定される名前と比較されたものです。名前の値が取得できなかった場合は`null`です。
                        example: Sophia Martinez
                      warnings:
                        type: array
                        description: >-
                          問題なく承認された場合は空です。各エントリは検出されたリスク1件を説明します。`log_type:
                          "error"`のエントリは`status`を`Declined`に設定し、`log_type:
                          "warning"`のエントリは`In Review`に設定します。
                        items:
                          type: object
                          properties:
                            risk:
                              type: string
                              enum:
                                - DOCUMENT_AI_UNREADABLE_DOCUMENT
                                - DOCUMENT_AI_MISSING_REQUIRED_FIELDS
                                - DOCUMENT_AI_SUSPECTED_MANIPULATION
                                - DOCUMENT_AI_NAME_MISMATCH
                                - DOCUMENT_AI_UNSUPPORTED_FILE
                              description: >-
                                機械可読なリスクコードです。それぞれ、対応する`document_ai_*_action`リクエストオプションで制御されます。
                              example: DOCUMENT_AI_MISSING_REQUIRED_FIELDS
                            feature:
                              type: string
                              enum:
                                - DOCUMENT_AI
                              description: 警告を発生させた機能。このエンドポイントでは常に`DOCUMENT_AI`です。
                            additional_data:
                              type: object
                              nullable: true
                              additionalProperties: true
                              description: >-
                                リスクに関する追加コンテキストです。必須フィールドが欠けている場合は`{"missing_fields":
                                ["Net pay"]}`、氏名が一致しない場合は`{"name_on_document",
                                "score",
                                "threshold"}`、改ざんの疑いがある場合はフォレンジックの検出結果(`detection_method`、作成ツール/編集ツールの詳細)が入ります。追加する情報がない場合は`null`です。
                              example:
                                missing_fields:
                                  - Net pay
                            log_type:
                              type: string
                              enum:
                                - error
                                - warning
                                - information
                              description: >-
                                設定されたアクションから導出される重大度：`error`（DECLINE）、`warning`（REVIEW）、`information`（NO_ACTION）。
                            short_description:
                              type: string
                              description: リスクを説明する、人が読める形式の1行の説明。
                              example: Required fields could not be extracted
                            long_description:
                              type: string
                              description: 人が読める説明文。必要に応じて`additional_data`の値が埋め込まれます。
                  vendor_data:
                    type: string
                    nullable: true
                    description: 送信した`vendor_data`のエコー、または`null`。
                  metadata:
                    type: object
                    nullable: true
                    additionalProperties: true
                    description: 送信した`metadata`オブジェクトのエコー、または`null`。
                  created_at:
                    type: string
                    format: date-time
                    description: リクエストが処理された日時（UTC、ISO 8601）。
        '400':
          description: >-
            バリデーションまたは処理のエラーです。フィールド単位の問題は、DRFの標準エンベロープ(問題のあるフィールドごとにメッセージの配列が1つ)で返されます。暗号化された書類や読み取れない書類、抽出の失敗は`{"error":
            ...}`を返します。
          content:
            application/json:
              examples:
                Missing document:
                  summary: フォームデータに`document`が含まれていません
                  value:
                    document:
                      - No file was submitted.
                Invalid fields payload:
                  summary: '`fields`がJSONエンコードされた単一の配列文字列ではありません'
                  value:
                    fields:
                      - fields must be a valid JSON array string.
                Duplicate field keys:
                  summary: 2つの項目が同じ`key`を共有しています
                  value:
                    fields:
                      - Every fields item must have a unique key.
                Conflicting expectations:
                  summary: 個人と企業の期待値を同時に送信
                  value:
                    non_field_errors:
                      - >-
                        Provide either person expected-name fields or
                        expected_company_name, not both.
                Invalid metadata:
                  summary: '`metadata`がJSONオブジェクトではありません（またはNUL文字を含みます）'
                  value:
                    metadata:
                      - Metadata must be a JSON object.
                Oversized vendor_data:
                  summary: '`vendor_data`が上限の2,000バイトを超えている'
                  value:
                    vendor_data:
                      - vendor_data is too long (maximum 2000 bytes).
                Encrypted PDF:
                  summary: パスワードで保護されたPDF
                  value:
                    error: >-
                      The PDF is encrypted. Please upload a decrypted PDF or a
                      photo instead.
                Extraction failed:
                  summary: 抽出パイプラインで書類を処理できませんでした
                  value:
                    error:
                      - Error extracting Document AI information
              schema:
                type: object
                additionalProperties: true
        '403':
          description: >-
            権限がありません。`x-api-key`ヘッダーがない場合に加え、呼び出し元の組織の残高が呼び出しを賄えない場合にも返されます。誤った、取り消された、または期限切れのキーの場合は`401`が返されます。キーがない場合は`{"detail":
            ...}`とともに`403`が返され、誤った、取り消された、または期限切れのキーの場合は`401`が返されます。クレジット不足の場合、および料金表にDocument
            AI APIの項目がない契約請求の組織の場合は、書類の処理が行われる前に`{"error": ...}`とともに`403`が返されます。
          content:
            application/json:
              examples:
                Missing or invalid API key:
                  summary: '`x-api-key`ヘッダーがないか、キーが無効または失効しています'
                  value:
                    detail: You do not have permission to perform this action.
                Not enough credits:
                  summary: 組織の残高でこの呼び出しの料金を賄えません
                  value:
                    error: >-
                      You don't have enough credits to perform this request.
                      Please top up at https://business.didit.me
                Contract rate missing:
                  summary: 料金表にDocument AI APIの項目がない、契約請求の組織
                  value:
                    error: >-
                      Document AI API is not included in your contract rate
                      card. Contact support@didit.me to enable it.
              schema:
                type: object
                properties:
                  detail:
                    type: string
                  error:
                    type: string
        '429':
          description: >-
            レート制限を超過しました。すべてのPOST/PATCH/DELETEエンドポイントは、APIキーごとに1分あたり300件の書き込みリクエストという共通の上限を共有します。レスポンスには`X-RateLimit-Limit`、`X-RateLimit-Remaining`、`X-RateLimit-Reset`、`Retry-After`ヘッダーが含まれます。
          content:
            application/json:
              examples:
                Write rate limit exceeded:
                  summary: 現在の1分間に300件を超える書き込みリクエスト
                  value:
                    detail: >-
                      Write request rate limit exceeded. You can make up to 300
                      requests per minute.
              schema:
                type: object
                properties:
                  detail:
                    type: string
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.document_ai.analyze(
                document=open("document.pdf", "rb"),
                fields="[{\"key\": \"employer_name\", \"name\": \"Employer name\", \"instruction\": \"The employer or company issuing the payslip.\", \"type\": \"text\", \"required\": true, \"is_full_name\": false}, {\"key\": \"employee_name\", \"name\": \"Employee name\", \"instruction\": \"The full name of the employee as printed on the payslip.\", \"type\": \"text\", \"required\": true, \"is_full_name\": true}, {\"key\": \"net_pay\", \"name\": \"Net pay\", \"instruction\": \"The net amount paid to the employee for the period.\", \"type\": \"number\", \"required\": true, \"is_full_name\": false}, {\"key\": \"pay_date\", \"name\": \"Pay date\", \"instruction\": \"The payment date shown on the payslip.\", \"type\": \"date\", \"required\": false, \"is_full_name\": false}]",
            )
            print(result)
        - lang: javascript
          label: Node.js
          source: |-
            import Didit, { fileFromPath } from "@didit-protocol/sdk-node";

            // Reads DIDIT_API_KEY.
            const didit = new Didit();

            const result = await didit.documentAi.analyze({
              document: await fileFromPath("document.pdf"),
              fields: "[{\"key\": \"employer_name\", \"name\": \"Employer name\", \"instruction\": \"The employer or company issuing the payslip.\", \"type\": \"text\", \"required\": true, \"is_full_name\": false}, {\"key\": \"employee_name\", \"name\": \"Employee name\", \"instruction\": \"The full name of the employee as printed on the payslip.\", \"type\": \"text\", \"required\": true, \"is_full_name\": true}, {\"key\": \"net_pay\", \"name\": \"Net pay\", \"instruction\": \"The net amount paid to the employee for the period.\", \"type\": \"number\", \"required\": true, \"is_full_name\": false}, {\"key\": \"pay_date\", \"name\": \"Pay date\", \"instruction\": \"The payment date shown on the payslip.\", \"type\": \"date\", \"required\": false, \"is_full_name\": false}]",
            });
            console.log(result);
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// Reads DIDIT_API_KEY.\nclient := didit.NewClient()\n\nresult, err := client.DocumentAi.Analyze(ctx, didit.DocumentAiAnalyzeParams{\n\tDocument: didit.FileFromPath(\"document.pdf\"),\n\tFields:   \"[{\\\"key\\\": \\\"employer_name\\\", \\\"name\\\": \\\"Employer name\\\", \\\"instruction\\\": \\\"The employer or company issuing the payslip.\\\", \\\"type\\\": \\\"text\\\", \\\"required\\\": true, \\\"is_full_name\\\": false}, {\\\"key\\\": \\\"employee_name\\\", \\\"name\\\": \\\"Employee name\\\", \\\"instruction\\\": \\\"The full name of the employee as printed on the payslip.\\\", \\\"type\\\": \\\"text\\\", \\\"required\\\": true, \\\"is_full_name\\\": true}, {\\\"key\\\": \\\"net_pay\\\", \\\"name\\\": \\\"Net pay\\\", \\\"instruction\\\": \\\"The net amount paid to the employee for the period.\\\", \\\"type\\\": \\\"number\\\", \\\"required\\\": true, \\\"is_full_name\\\": false}, {\\\"key\\\": \\\"pay_date\\\", \\\"name\\\": \\\"Pay date\\\", \\\"instruction\\\": \\\"The payment date shown on the payslip.\\\", \\\"type\\\": \\\"date\\\", \\\"required\\\": false, \\\"is_full_name\\\": false}]\",\n})\nif err != nil {\n\tlog.Fatal(err)\n}\nfmt.Printf(\"%+v\\n\", result)"
        - lang: java
          label: Java
          source: >-
            import java.nio.file.Path;

            import me.didit.Didit;

            import me.didit.types.DocumentAiAnalyzeParams;


            // Reads DIDIT_API_KEY.

            Didit client = new Didit();


            var result =
            client.documentAi().analyze(DocumentAiAnalyzeParams.builder()
                    .document(Path.of("document.pdf"))
                    .fields("[{\"key\": \"employer_name\", \"name\": \"Employer name\", \"instruction\": \"The employer or company issuing the payslip.\", \"type\": \"text\", \"required\": true, \"is_full_name\": false}, {\"key\": \"employee_name\", \"name\": \"Employee name\", \"instruction\": \"The full name of the employee as printed on the payslip.\", \"type\": \"text\", \"required\": true, \"is_full_name\": true}, {\"key\": \"net_pay\", \"name\": \"Net pay\", \"instruction\": \"The net amount paid to the employee for the period.\", \"type\": \"number\", \"required\": true, \"is_full_name\": false}, {\"key\": \"pay_date\", \"name\": \"Pay date\", \"instruction\": \"The payment date shown on the payslip.\", \"type\": \"date\", \"required\": false, \"is_full_name\": false}]")
                    .build());
            System.out.println(result);
        - lang: php
          label: PHP
          source: |-
            <?php

            require 'vendor/autoload.php';

            use Didit\DiditClient;
            use Didit\File;

            // Reads DIDIT_API_KEY.
            $didit = new DiditClient();

            $result = $didit->documentAi->analyze([
                'document' => File::fromPath('document.pdf'),
                'fields' => '[{"key": "employer_name", "name": "Employer name", "instruction": "The employer or company issuing the payslip.", "type": "text", "required": true, "is_full_name": false}, {"key": "employee_name", "name": "Employee name", "instruction": "The full name of the employee as printed on the payslip.", "type": "text", "required": true, "is_full_name": true}, {"key": "net_pay", "name": "Net pay", "instruction": "The net amount paid to the employee for the period.", "type": "number", "required": true, "is_full_name": false}, {"key": "pay_date", "name": "Pay date", "instruction": "The payment date shown on the payslip.", "type": "date", "required": false, "is_full_name": false}]',
            ]);
            print_r($result->toArray());
        - lang: ruby
          label: Ruby
          source: |-
            require "didit"

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

            result = didit.document_ai.analyze(
              document: Pathname("document.pdf"),
              fields: "[{\"key\": \"employer_name\", \"name\": \"Employer name\", \"instruction\": \"The employer or company issuing the payslip.\", \"type\": \"text\", \"required\": true, \"is_full_name\": false}, {\"key\": \"employee_name\", \"name\": \"Employee name\", \"instruction\": \"The full name of the employee as printed on the payslip.\", \"type\": \"text\", \"required\": true, \"is_full_name\": true}, {\"key\": \"net_pay\", \"name\": \"Net pay\", \"instruction\": \"The net amount paid to the employee for the period.\", \"type\": \"number\", \"required\": true, \"is_full_name\": false}, {\"key\": \"pay_date\", \"name\": \"Pay date\", \"instruction\": \"The payment date shown on the payslip.\", \"type\": \"date\", \"required\": false, \"is_full_name\": false}]"
            )
            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.DocumentAi.AnalyzeAsync(new
            DocumentAiAnalyzeParams

            {
                Document = FileUpload.FromPath("document.pdf"),
                Fields = "[{\"key\": \"employer_name\", \"name\": \"Employer name\", \"instruction\": \"The employer or company issuing the payslip.\", \"type\": \"text\", \"required\": true, \"is_full_name\": false}, {\"key\": \"employee_name\", \"name\": \"Employee name\", \"instruction\": \"The full name of the employee as printed on the payslip.\", \"type\": \"text\", \"required\": true, \"is_full_name\": true}, {\"key\": \"net_pay\", \"name\": \"Net pay\", \"instruction\": \"The net amount paid to the employee for the period.\", \"type\": \"number\", \"required\": true, \"is_full_name\": false}, {\"key\": \"pay_date\", \"name\": \"Pay date\", \"instruction\": \"The payment date shown on the payslip.\", \"type\": \"date\", \"required\": false, \"is_full_name\": false}]",
            });

            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  schemas:
    DocumentAIDetectedCode:
      type: object
      required:
        - type
        - page_number
        - position
        - x
        - 'y'
        - width
        - height
        - page_width
        - page_height
        - raw_payload
        - parsed_payload
      properties:
        type:
          type: string
          description: 検出されたシンボロジー。例：`QR_CODE`、`CODE_128`、`EAN_13`、`DATA_MATRIX`、`PDF_417`。
        page_number:
          type: integer
          minimum: 1
          description: ページ番号（1始まり）。
        position:
          type: array
          nullable: true
          description: レンダリングされたページのピクセル座標で表した、検出されたポリゴン。信頼できる位置が得られない場合は`null`です。
          items:
            type: array
            minItems: 2
            maxItems: 2
            items:
              type: integer
        x:
          type: integer
          nullable: true
          description: バウンディングボックスの左端。レンダリングされたページのピクセル単位で表します。
        'y':
          type: integer
          nullable: true
          description: レンダリングされたページのピクセル単位で表した、バウンディングボックスの上端。
        width:
          type: integer
          nullable: true
          description: レンダリングされたページのピクセル単位でのバウンディングボックスの幅。
        height:
          type: integer
          nullable: true
          description: レンダリングされたページのピクセル単位でのバウンディングボックスの高さ。
        page_width:
          type: integer
          description: レンダリングされたページの幅(ピクセル)。
        page_height:
          type: integer
          description: レンダリングされたページの高さ(ピクセル)。
        raw_payload:
          type: string
          description: 利用可能な場合はデコーダーの生のペイロードをBase64文字列で返し、それ以外の場合は空文字列を返します。
        parsed_payload:
          nullable: true
          description: デコードされた文字列または構造化された値。コードの位置は特定できたもののデコードできなかった場合は`null`です。
  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.