> ## 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：承認済み・却下メールを事前確認

> DiditのAPIで、セッションのステータスを変更する前に、ユーザーが受け取る承認済みまたは却下のメールを、受信者・送信者・言語とあわせて確認できます。



判定メールプレビューのプロンプト
        プロンプトをクリップボードにコピー



      
      

\<pre>

\`Preview the Approved or Declined email a Didit session sends the person, then confirm the decision so exactly that email goes out.

Endpoint:
POST https://verification.didit.me/v3/session/{session_id}/decision-email-preview/

Authentication:
x-api-key (client API key) or a user-auth token. Privilege: write:sessions. A scoped API key needs write access to decisions.

Path parameter:
\- session_id (UUID): KYC or KYB; Didit resolves it against both session types.

Request body:
\- new_status (string, required): "Approved" or "Declined".
\- email_language (string, optional, default "en"): language of the email. A language that is not offered falls back to English.

The session's current status must be one of: Approved, Declined, In Review, Kyc Expired, Abandoned, Resubmitted.

Previewing changes nothing and sends nothing.

Response (200, Cache-Control: no-store):
\- recipient: the person's own address (the one they verified in the flow, else the one in contact_details). Empty string when none is known.
\- recipient_source: "email_verification", "contact_details", or "" when there is no address.
\- sender, sender_name, sender_email: the From header and its parts.
\- sender_kind: "customer" (your verified sender domain) or "didit" (Didit's sender).
\- subject, html: the email exactly as sent. Render html in a sandboxed frame.
\- language: the language actually used.
\- will_be_sent (boolean) and not_sent_reason: null, "status_unchanged", "notification_emails_disabled", "no_recipient" or "sandbox".
\- preview_token: receipt for this exact email, valid 15 minutes. Empty when there is no recipient.

Confirm with PATCH https://verification.didit.me/v3/session/{session_id}/update-status/:
\{
"new_status": "<same new_status>",
"send_email": true,
"email_address": "<recipient>",
"email_language": "<language>",
"email_preview_token": "<preview_token>"
}
If the recipient, language, session status, sender or email changed since the preview, or the receipt is older than 15 minutes, update-status returns 409 { "detail": "This email preview changed or expired. Preview the message again before confirming." } and changes nothing. Preview again and confirm with the new receipt.

curl example:
curl -X POST https://verification.didit.me/v3/session/<SESSION_ID>/decision-email-preview/ \
-H "x-api-key: <API_KEY>" \
-H "Content-Type: application/json" \
-d '{ "new_status": "Approved", "email_language": "en" }'

Failure modes:
\- 400: the session is not in an accepted status ({ "detail": "Only sessions with status ... can be updated. Current status: ..." }), or new_status is missing or invalid.
\- 401: the scoped API key has expired.
\- 403: missing credentials (a wrong, revoked or expired key gets 401), the caller lacks write:sessions, a scoped key lacks decisions write, or the session belongs to another application ({ "detail": "You do not have permission to perform this action." }).
\- 404: { "detail": "Not found." } when no session with this session_id exists.

For end-to-end Didit integration, paste in the full prompt at /integration/integration-prompt.`

\</pre>



      
      

貼り付け先

プレビューしても何も変更されず、何も送信されません。
レスポンスには、`send_email: true`を指定してセッションを`Approved`または`Declined`に設定したときに本人が受け取るメールが、そのままの形で表示されます。
あわせて、誰が受け取るのか、誰から送信されるのか、そして確定したときに実際に送信されるかどうかもわかります。## メールの受信者メールは本人のメールアドレスに送信されます。ワークフローのメールアドレス認証ステップで本人が検証したアドレスがあればそのアドレスに、なければセッション作成時に`contact_details`で指定されたアドレスに送信されます。
どちらが適用されるかは`recipient_source`(`email_verification`または`contact_details`)で示されます。
セッションに本人のアドレスがない場合、`recipient`、`recipient_source`、`preview_token`は空文字列になり、メールは送信できません。[ホワイトラベル設定](https://docs.didit.me/ja/console/white-label.md)が適用される場合、メールはアプリケーションの検証済み送信ドメインから送信されます(`sender_kind: customer`)。それ以外の場合はDiditの送信元から送信されます(`sender_kind: didit`)。## メールが送信されるかどうか`send_email: true`で変更を確定したときにメールが送信される場合、`will_be_sent`は`true`になります。
`false`の場合は、`not_sent_reason`にその理由が示されます。| `not_sent_reason` | 意味 |
| - | - |
| `status_unchanged` | セッションがすでにこのステータスであるため、更新しても何も変更されず、何も送信されません。 |
| `notification_emails_disabled` | セッションが`contact_details.send_notification_emails: true`なしで作成されたため、`contact_details`で指定されたアドレスには判定メールが送信されません。 |
| `no_recipient` | 本人のアドレスが不明です。 |
| `sandbox` | セッションがサンドボックスのセッションであり、受信者がサンドボックスでのメール配信をオプトインしていないため、メールはシミュレーションのみとなります。[メールのオプトイン](https://docs.didit.me/ja/integration/sandbox-testing.md#otpコードとメールのオプトイン)を参照してください。 |## 判定を確定する次のフィールドを指定して[セッションステータスの更新](https://docs.didit.me/ja/sessions-api/update-status.md)を呼び出します。| セッションステータスの更新のフィールド | 値 |
| - | - |
| `new_status` | プレビューした`new_status`と同じ値 |
| `send_email` | `true` |
| `email_address` | プレビューの`recipient` |
| `email_language` | プレビューの`language` |
| `email_preview_token` | プレビューの`preview_token` |この受領証は15分後に期限切れになります。
プレビュー以降に受信者、言語、セッションのステータス、送信元、またはメールが変わった場合、更新は何も変更する前に`409`を返します。
もう一度プレビューし、新しい受領証で確定してください。## 関連情報- [セッションステータスの更新](https://docs.didit.me/ja/sessions-api/update-status.md): セッションを承認または却下し、メールを送信します。
- [再提出メールのプレビュー](https://docs.didit.me/ja/sessions-api/preview-resubmission.md): 代わりに再提出用のメールをプレビューします。
- [ホワイトラベル](https://docs.didit.me/ja/console/white-label.md): メールで使用される送信元とブランディングです。


## OpenAPI

````yaml ja/openapi-25.json POST /v3/session/{sessionId}/decision-email-preview/
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/session/{sessionId}/decision-email-preview/:
    post:
      tags:
        - Sessions
      summary: セッションの判定メールをプレビューする
      description: >-
        `send_email:
        true`を指定してセッションを`Approved`または`Declined`に設定したときに本人が受け取るメールを、セッションを変更したり何かを送信したりせずにレンダリングします。レスポンスには、送信されるとおりの件名とHTML、受信者、送信者、言語、そして変更を確定した場合に実際にメールが送信されるかどうか(`will_be_sent`、`not_sent_reason`)が含まれます。


        受信者は本人自身のアドレスです。フローのメールアドレス認証ステップで本人が検証したアドレス、それがない場合はセッション作成時に`contact_details`で指定されたアドレスです。送信者は、ホワイトラベルが適用される場合はアプリケーションの検証済み送信ドメイン(`sender_kind:
        customer`)、それ以外の場合はDiditの送信元(`sender_kind: didit`)です。


        プレビューしたとおりの内容を送信するには、同じ`new_status`、`send_email:
        true`、`recipient`の値を設定した`email_address`、`language`の値を設定した`email_language`、`preview_token`の値を設定した`email_preview_token`を指定して[Update
        Session
        Status](/ja/sessions-api/update-status)を呼び出します。このレシートの有効期限は15分です。プレビュー後に受信者、言語、セッションのステータス、送信者、またはメールが変更された場合、更新は何も変更する前に`409`を返します。再度プレビューし、新しいレシートで確定してください。


        `Approved`、`Declined`、`In Review`、`Kyc
        Expired`、`Abandoned`、`Resubmitted`ステータスのユーザー認証(KYC)および法人確認(KYB)セッションで利用できます。ステータスのチェックはボディの検証より前に実行されます。`write:sessions`権限が必要です。スコープ付きAPIキーには判定への書き込みアクセスが必要です。レスポンスには`Cache-Control:
        no-store`が使用されます。機密性の高い検証コンテンツとして扱ってください。
      operationId: post_v3_session_decision_email_preview
      parameters:
        - in: path
          name: sessionId
          required: true
          description: 検証セッションのUUID。ユーザー(KYC)と企業(KYB)の両方のセッションIDを受け付けます。
          schema:
            type: string
            format: uuid
            example: 3fa85f64-5717-4562-b3fc-2c963f66afa6
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - new_status
              properties:
                new_status:
                  type: string
                  enum:
                    - Approved
                    - Declined
                  description: メールをプレビューする対象の判定です。
                  example: Approved
                email_language:
                  type: string
                  default: en
                  description: >-
                    メールの言語。デフォルトはUpdate Session
                    Statusと同じです。提供されていない言語は英語にフォールバックします。実際に使用される言語はレスポンスの`language`で確認できます。
                  example: en
            examples:
              Approved:
                summary: 承認済みメールを英語でプレビューする
                value:
                  new_status: Approved
              Declined in Spanish:
                summary: 却下メールをスペイン語でプレビューする
                value:
                  new_status: Declined
                  email_language: es
      responses:
        '200':
          description: プレビューのみです。セッションは変更されず、メールも送信されません。
          headers:
            Cache-Control:
              description: 常に`no-store`です。プレビューには認証内容が含まれるため、キャッシュしてはなりません。
              schema:
                type: string
                example: no-store
          content:
            application/json:
              schema:
                type: object
                required:
                  - recipient
                  - recipient_source
                  - sender
                  - sender_name
                  - sender_email
                  - sender_kind
                  - subject
                  - html
                  - text
                  - language
                  - will_be_sent
                  - not_sent_reason
                  - preview_token
                properties:
                  recipient:
                    type: string
                    description: >-
                      メールの送信先アドレス。その人物のアドレスが不明な場合は空文字列です。その場合はメールを送信できず、`preview_token`も空になります。確認時に`email_address`として渡してください。
                    example: person@example.com
                  recipient_source:
                    type: string
                    enum:
                      - email_verification
                      - contact_details
                      - ''
                    description: >-
                      `recipient`の取得元。`email_verification`：フローのメールアドレス認証ステップで本人が認証したアドレス。`contact_details`：セッション作成時に`contact_details`で指定されたアドレス。アドレスがない場合は空文字列です。
                    example: email_verification
                  sender:
                    type: string
                    description: メールの送信時に使われる`From`ヘッダーです。
                    example: Example App <no-reply@mail.example.com>
                  sender_name:
                    type: string
                    description: '`sender`の表示名の部分です。'
                    example: Example App
                  sender_email:
                    type: string
                    format: email
                    description: '`sender`のアドレス部分。'
                    example: no-reply@mail.example.com
                  sender_kind:
                    type: string
                    enum:
                      - customer
                      - didit
                    description: >-
                      `customer`:
                      メールはアプリケーションの検証済み送信元ドメインから送信されます（ホワイトラベル）。`didit`:
                      メールはDidit独自の送信元から送信されます。
                    example: customer
                  subject:
                    type: string
                    description: 送信されたとおりの件名。
                    example: Your verification has been approved in Example App
                  html:
                    type: string
                    description: >-
                      送信されるとおりのメールのHTMLで、ロゴはデータURLとして埋め込まれています。サンドボックス化されたフレーム内でレンダリングし、アプリケーションのDOMに直接レンダリングしないでください。
                    example: <!DOCTYPE html><html><body>...</body></html>
                  text:
                    type: string
                    description: >-
                      コンパクトなプレビュー用の、メール本文のプレーンテキストです。本人のメッセージスレッドに保存されている内容と同じです（本人が受け取るメールはHTMLのままです）。
                    example: >-
                      Verification Approved


                      Your identity has been successfully verified with Acme
                      Pay. No further action is needed on your part.
                  language:
                    type: string
                    description: メールの記述言語です。指定した`email_language`が提供されていない場合は英語(`en`)です。
                    example: en
                  will_be_sent:
                    type: boolean
                    description: >-
                      `send_email:
                      true`で変更を確定したときにこのメールが送信されるかどうかです。`not_sent_reason`が設定されている場合は`false`です。
                    example: true
                  not_sent_reason:
                    type: string
                    nullable: true
                    enum:
                      - status_unchanged
                      - notification_emails_disabled
                      - no_recipient
                      - sandbox
                      - null
                    description: >-
                      確定してもメールが送信されない理由、または送信される場合は`null`。`status_unchanged`：セッションはすでにこのステータスであるため、更新しても何も変わらず、何も送信されません。`notification_emails_disabled`：セッションが`contact_details.send_notification_emails:
                      true`なしで作成されたため、`contact_details`で指定したアドレスに判定メールは送信されません。`no_recipient`：本人のアドレスが不明です。`sandbox`：受信者がサンドボックスでのメール配信をオプトインしていないサンドボックスセッションのため、送信はシミュレーションのみです。
                    example: null
                  preview_token:
                    type: string
                    description: >-
                      このメールに対する署名付きレシートで、有効期間は15分です。[セッションステータスを更新](/ja/sessions-api/update-status)に`email_preview_token`として渡してください。受信者がいない場合は空文字列です。
                    example: >-
                      eyJkaWdlc3QiOiI0ZjJhIn0:1uExAm:Pl3x4mpleS1gnatureValue000000000000000
              examples:
                Will Be Sent:
                  summary: 「承認済み」メールは、フローで検証されたメールアドレスに送信されます
                  value:
                    recipient: person@example.com
                    recipient_source: email_verification
                    sender: Example App <no-reply@mail.example.com>
                    sender_name: Example App
                    sender_email: no-reply@mail.example.com
                    sender_kind: customer
                    subject: Your verification has been approved in Example App
                    html: <!DOCTYPE html><html><body>...</body></html>
                    language: en
                    will_be_sent: true
                    not_sent_reason: null
                    preview_token: >-
                      eyJkaWdlc3QiOiI0ZjJhIn0:1uExAm:Pl3x4mpleS1gnatureValue000000000000000
                No Recipient:
                  summary: この人物の住所は不明です
                  value:
                    recipient: ''
                    recipient_source: ''
                    sender: Example App <no-reply@mail.example.com>
                    sender_name: Example App
                    sender_email: no-reply@mail.example.com
                    sender_kind: customer
                    subject: Your verification has been declined in Example App
                    html: <!DOCTYPE html><html><body>...</body></html>
                    language: en
                    will_be_sent: false
                    not_sent_reason: no_recipient
                    preview_token: ''
        '400':
          description: >-
            セッションがこのエンドポイントで受け付けるステータスではない（`{"detail":
            ...}`）か、リクエストボディが無効です（`{"<field>": ["<message>"]}`）。
          content:
            application/json:
              examples:
                Wrong Current Status:
                  summary: セッションが、このエンドポイントで受け付けるステータスではありません
                  value:
                    detail: >-
                      Only sessions with status Approved, Declined, In Review,
                      Kyc Expired, Abandoned, Resubmitted can be updated.
                      Current status: In Progress
                Invalid new_status:
                  summary: new_statusがApprovedでもDeclinedでもない
                  value:
                    new_status:
                      - '"Resubmitted" is not a valid choice.'
                Missing new_status:
                  summary: 必須フィールドが省略されています
                  value:
                    new_status:
                      - This field is required.
        '401':
          description: スコープ付きAPIキーの有効期限が切れています。
          content:
            application/json:
              examples:
                Expired API Key:
                  summary: 有効期限を過ぎたスコープ付きAPIキー
                  value:
                    detail: This API key has expired.
        '403':
          description: >-
            認証情報がない、呼び出し元に`write:sessions`権限がない、スコープ付きAPIキーにこのエンドポイントに必要なアクセス権がない、または`session_id`が別のアプリケーションに属しています。
          content:
            application/json:
              examples:
                Invalid Credentials:
                  summary: x-api-keyがないか無効です
                  value:
                    detail: >-
                      Authentication credentials were not provided or are
                      invalid.
                Missing Privilege:
                  summary: 呼び出し元にwrite:sessions権限がありません
                  value:
                    detail: You do not have permission to perform this action.
                Scoped Key Without Access:
                  summary: このアクセス権を持たないスコープ付きAPIキー
                  value:
                    detail: This API key has no write access to decisions.
        '404':
          description: この`session_id`を持つKYCまたはKYBセッションが存在しません。
          content:
            application/json:
              examples:
                Not Found:
                  summary: 不明なsession_id
                  value:
                    detail: Not found.
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: curl
          source: |-
            curl -X POST \
              https://verification.didit.me/v3/session/3fa85f64-5717-4562-b3fc-2c963f66afa6/decision-email-preview/ \
              -H 'x-api-key: YOUR_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{"new_status": "Approved", "email_language": "en"}'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.sessions.preview_decision_email(
                "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                new_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.previewDecisionEmail("3fa85f64-5717-4562-b3fc-2c963f66afa6",
            {
              new_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.PreviewDecisionEmail(ctx, \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", didit.SessionsPreviewDecisionEmailParams{\n\tNewStatus: \"Approved\",\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.SessionsPreviewDecisionEmailParams;


            // Reads DIDIT_API_KEY.

            Didit client = new Didit();


            var result =
            client.sessions().previewDecisionEmail("3fa85f64-5717-4562-b3fc-2c963f66afa6",
            SessionsPreviewDecisionEmailParams.builder()
                    .newStatus(SessionsPreviewDecisionEmailParams.NewStatus.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->previewDecisionEmail('3fa85f64-5717-4562-b3fc-2c963f66afa6',
            [
                'new_status' => 'Approved',
            ]);

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

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

            result = didit.sessions.preview_decision_email(
              "3fa85f64-5717-4562-b3fc-2c963f66afa6",
              new_status: "Approved"
            )
            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.Sessions.PreviewDecisionEmailAsync("3fa85f64-5717-4562-b3fc-2c963f66afa6",
            new SessionsPreviewDecisionEmailParams

            {
                NewStatus = "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.