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

# PDF 报告生成 API：KYC 与 KYB 合规报告

> 通过 GET /v3/session/{id}/generate-pdf/ 下载 Didit 为 KYC 或 KYB 会话生成的品牌化合规报告。支持白标、可供审计，按次付费。



生成 PDF 提示词
        将提示词复制到剪贴板



      
      

\<pre>

\`Download an audit-ready PDF report for a finished Didit verification session.

Endpoint:
GET https://verification.didit.me/v3/session/{session_id}/generate-pdf/

Authentication:
Use the x-api-key header with your Didit API key (or a user-auth token). Privilege: read:sessions.

Path parameter:
\- session_id (UUID) — works for both User Verification (KYC) and Business Verification (KYB) sessions. Didit routes to the correct template automatically.

Prerequisites:
\- Session status must be one of "Approved", "Declined", "In Review". Any other status returns 403.
\- Session must belong to the authenticated application — cross-application reads return 404.

curl example — save the PDF to disk:
curl https://verification.didit.me/v3/session/<SESSION_ID>/generate-pdf/ \
-H "x-api-key: <API_KEY>" \
-o report.pdf

Response:
\- Body is binary (application/pdf). DO NOT parse as JSON.
\- Content-Type: application/pdf
\- Content-Disposition: attachment; filename=session_<session_id>.pdf for KYC sessions, business_<session_id>.pdf for KYB sessions.
\- Typical wall time ~1-3s (server-side WeasyPrint rendering).

Template contents:
\- KYC PDF: Identity (OCR), Liveness, Face Match, AML, POA, IP analysis, reviews, events.
\- KYB PDF: Company registry data, officers, beneficial owners (UBOs), KYB documents, AML hits, questionnaires, phone verification, email verification, IP analysis, reviews, events.

White-label:
If white-label customization is enabled on your application, the PDF uses your logo and privacy-policy URL. Configure at Console → Customization.

Failure modes:
\- 401 — invalid credentials.
\- 403 — { "detail": "You do not have permission to perform this action." } when the key lacks read:sessions OR when the session is in a non-printable status (Not Started, In Progress, Expired, Abandoned, Kyc Expired, Resubmitted, Awaiting User).
\- 404 — { "detail": "Not found." } when the session is not visible to this application.

Idempotency & cost:
Safe to retry — generation is read-only. Counts against the standard rate limit.

When to call:
\- Compliance archives (regulator submissions, internal audit binders).
\- Customer support replies (proof of decision for a specific session).
\- After approve / decline via /sessions-api/update-status — render and store the resulting PDF.
\- For every session of one user in a single file, use GET /v3/users/{vendor_data}/generate-pdf/ instead (see /management-api/users/generate-pdf).

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

\</pre>



      
      

粘贴到

## KYC 与 KYB 支持同时适用于**用户验证（KYC）**和**企业验证（KYB）**会话。Didit 会自动匹配对应的 PDF 模板：- 用户验证（KYC）会话 → 报告包含身份证件验证、活体检测、人脸比对、AML 与地址证明（POA）部分。
- 企业验证（KYB）会话 → 报告包含公司登记、关键人员（UBO 与高管）、证件、AML、问卷、电话、邮箱和 IP 分析部分（前提是这些功能属于工作流的一部分）。两者使用相同的 PDF 生成流程，并支持白标定制（徽标、隐私政策 URL）。## 文件名规则| 类型 | 文件名 |
| - | - |
| 用户 | `session_<session_id>.pdf` |
| 企业 | `business_<session_id>.pdf` |通过 `Content-Disposition: attachment; filename=...` 响应头返回。## 状态要求会话必须处于 `APPROVED`、`DECLINED` 或 `IN_REVIEW` 状态才能生成 PDF。进行中或未开始的会话将返回 `403`。## 示例> [tab] 用户验证（KYC）PDF
>
> ```bash theme={null}
> curl https://verification.didit.me/v3/session/4c5c7f3a-.../generate-pdf/ \
>   -H "x-api-key: YOUR_API_KEY" \
>   -o kyc-report.pdf
> ```> [tab] 企业验证（KYB）PDF
>
> ```bash theme={null}
> curl https://verification.didit.me/v3/session/bs-01HJX1.../generate-pdf/ \
>   -H "x-api-key: YOUR_API_KEY" \
>   -o kyb-report.pdf
> ```## 白标当应用启用白标定制后，PDF 将使用您的徽标和隐私政策 URL。请在 *控制台 → 定制* 中进行配置。## 权限需要 `read:sessions` 权限。两种类型使用相同的权限范围。## 相关内容- [会话概览](https://docs.didit.me/zh/sessions-api/overview.md)
- [获取会话](https://docs.didit.me/zh/sessions-api/retrieve-session.md)：JSON 格式的同一决策结果
- [下载用户历史 PDF](https://docs.didit.me/zh/management-api/users/generate-pdf.md)：将某个用户所有可生成报告的会话合并在一个文件中
- [KYB 响应结构](https://docs.didit.me/zh/business-verification/response-schema.md)：企业 PDF 中包含的字段


## OpenAPI

````yaml zh/openapi-25.json GET /v3/session/{sessionId}/generate-pdf/
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}/generate-pdf/:
    get:
      tags:
        - Sessions
      summary: 下载验证会话的 PDF 报告
      description: >-
        为已完成的验证会话渲染并下载合规级 PDF 报告。同一路径同时支持用户验证（KYC）和企业验证（KYB）会话，服务器会针对这两种会话类型解析
        `sessionId` 并选择匹配的报告模板。


        **符合条件的会话状态。** 会话必须已处于最终状态或可审核状态：


        - KYC 会话：`Approved`、`Declined`、`In Review` 或 `Kyc Expired`。

        - KYB 会话：`Approved`、`Declined` 或 `In Review`。


        任何其他状态（`Not Started`、`In Progress`、`Expired`、`Abandoned` 等）均会返回 `403`
        及解释性 `detail` 字符串，请参见下方的 `403` 响应。


        **报告内容。** PDF 反映了发起请求时控制台中的会话视图：


        - **KYC**：汇总的会话状态、警告列表以及每个已执行功能对应的独立板块：身份证件验证（证件图像及提取的字段）、NFC
        验证、活体检测、人脸比对、邮箱验证、电话验证、地址证明、问卷答案、数据库核验、AML 筛查和 IP
        分析，随后是会话标签、控制台审核活动（评论与状态变更）以及会话事件时间线。

        - **KYB**：登记核验（公司数据）、AML 筛查、企业证件验证、关键人员核验、问卷响应、电话/邮箱验证、IP
        分析以及会话事件时间线，随后是标签和审核活动。


        **品牌定制。** 如果您的应用启用了白标定制，报告将使用您的 Logo 渲染并包含指向您隐私政策 URL 的链接；否则将采用 Didit
        品牌标识。报告以英文渲染，不提供语言参数。


        **无缓存。** 每次调用都会基于当前的会话数据重新渲染
        PDF，因此在人工审核后生成的报告会体现审核员的决策。针对同一会话的两次调用可能会生成字节不完全相同的文件；如果您需要不可变副本，请对下载的文件进行归档。


        **延迟。** 渲染过程在排版 PDF
        之前需要下载所有已存储的图像（证件正反面、自拍照、额外文件），因此媒体文件较多的会话可能需要几秒钟。建议设置较充裕的客户端读取超时时间（推荐
        60 秒）并将响应体流式传输至磁盘。


        **末尾斜杠。** 规范路由以斜杠结尾（`…/generate-pdf/`）。不带斜杠的请求将直接处理并返回相同的响应：不存在 `301`
        重定向，因此客户端无需跟随重定向，`curl` 也不需要 `-L`。请按照示例使用带斜杠的 URL。


        如果您需要基础数据 JSON 而非渲染后的报告，请使用 `GET
        /v3/session/{sessionId}/decision/`。如果需要将单个用户的所有可报告会话整合到单个文档中，请使用 `GET
        /v3/users/{vendor_data}/generate-pdf/`。
      operationId: get_v3_session_generate_pdf
      parameters:
        - name: sessionId
          in: path
          required: true
          description: >-
            要渲染的用户验证（KYC）或企业验证（KYB）会话的 UUID — 即 `POST /v3/session/` 返回的
            `session_id`。同一路径适用于两种会话类型；可通过响应中的 `Content-Disposition`
            文件名区分您收到的报告类型。


            **必须是格式规范的小写 UUID。** 该路由仅匹配有效 UUID，因此格式错误的值在任何应用代码运行之前就会被 URL
            路由器拒绝，且响应为 `404` **HTML** 页面，而不是如下所示的 JSON `{"detail": ...}` 信封。路由的
            UUID 转换器仅匹配标准规范小写格式 — 大写十六进制 UUID 会被拒绝并返回 HTML 404。
          schema:
            type: string
            format: uuid
            example: 11111111-2222-3333-4444-555555555555
      responses:
        '200':
          description: >-
            渲染生成的 PDF 文档，直接以二进制 `application/pdf` 形式返回，没有 JSON 包装，也没有下载 URL
            重定向。正文以 `%PDF` 魔数开头（PDF 1.7）。可将其保存为 `.pdf` 文件或直接流式传输给您的调用方。
          headers:
            Content-Disposition:
              description: >-
                KYC 会话为 `attachment; filename=session_{sessionId}.pdf`，KYB 会话为
                `attachment; filename=business_{sessionId}.pdf`，前缀指示渲染了哪个报告模板。
              schema:
                type: string
                example: >-
                  attachment;
                  filename=session_11111111-2222-3333-4444-555555555555.pdf
            Content-Length:
              description: PDF 的总大小（以字节为单位）；正文未分块。
              schema:
                type: integer
                example: 25191
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        '403':
          description: >-
            身份验证、授权或会话状态失败。缺少密钥将返回 `403`；错误、已撤销或已过期的密钥将返回 `401`。可通过 `detail`
            字符串区分失败模式：


            - `"Authentication credentials were not provided or are invalid."` —
            未提供 `x-api-key` 请求头（且未提供 `Authorization: Bearer`
            token），或者提供的凭证未通过自省（已撤销、已过期或格式错误）。

            - `"You do not have permission to perform this action."` —
            凭证有效但无法读取此会话：控制台用户的 Bearer token 缺少 `read:sessions` 权限或无法访问所属应用，或者
            API 密钥属于与该会话不同的组织。

            - `"You can only generate a PDF for sessions in review, declined,
            approved or kyc expired"` — KYC 会话存在但尚未处于符合条件的状态（例如 `Not Started` 或
            `In Progress`）。在请求报告前请等待 `status.updated` Webhook。

            - `"You can only generate a PDF for sessions in review, declined or
            approved"` — KYB 会话的相同条件。


            请注意，对于完全未知的 `sessionId`，endpoint
            会在验证凭证之前先解析所属应用，因此如果会话不存在，即使凭证缺失或无效，也会返回 `404`。
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: >-
                      You can only generate a PDF for sessions in review,
                      declined, approved or kyc expired
              examples:
                Missing or invalid credentials:
                  summary: 缺少 x-api-key 请求头，或该密钥自省失败
                  value:
                    detail: >-
                      Authentication credentials were not provided or are
                      invalid.
                Insufficient permissions:
                  summary: 凭证有效，但缺少 read:sessions 权限或无法访问所属应用
                  value:
                    detail: You do not have permission to perform this action.
                KYC session not finished:
                  summary: KYC 会话仍处于未开始/进行中状态
                  value:
                    detail: >-
                      You can only generate a PDF for sessions in review,
                      declined, approved or kyc expired
                KYB session not finished:
                  summary: KYB 会话仍处于未开始/进行中状态
                  value:
                    detail: >-
                      You can only generate a PDF for sessions in review,
                      declined or approved
        '404':
          description: >-
            不存在具有此 `sessionId`
            的活跃会话：从未创建，或已被删除。所有者解析发生在凭证验证之前，因此即使是未通过身份验证的请求也会返回此
            `404`。根据具体未匹配到的查询，`detail` 字符串为 `"Not found."`（常见情况）或 `"Session not
            found."`。
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: Not found.
              examples:
                Unknown session:
                  summary: sessionId 与任何 KYC 或 KYB 会话均不匹配
                  value:
                    detail: Not found.
                Recently deleted session:
                  summary: 在两次查找之间会话已被删除
                  value:
                    detail: Session not found.
        '429':
          description: >-
            超出速率限制。除全局 600 次/分钟的 GET 限制外，PDF 生成还具有**每个凭证每分钟 50 次请求**的专属限制（API
            密钥、Bearer token，或未认证时的源 IP）。请等待 `Retry-After` 秒（也会反映在
            `X-RateLimit-*` 响应头中），然后重试。报告不会在服务端缓存，因此请下载每份报告一次并保存文件，而不是重复获取。
          headers:
            Retry-After:
              description: 重试请求前需等待的秒数。
              schema:
                type: integer
                minimum: 1
                example: 30
            X-RateLimit-Limit:
              description: 当前时间窗口内允许的最大 PDF 生成次数（50）。
              schema:
                type: integer
                example: 50
            X-RateLimit-Remaining:
              description: 当前时间窗口内剩余的请求数。
              schema:
                type: integer
                example: 0
            X-RateLimit-Reset:
              description: 当前窗口重置的 Unix 时间戳（秒）。
              schema:
                type: integer
                example: 1750000000
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    description: 超出速率限制的便于人类阅读的说明。
                    example: >-
                      Session PDF generation rate limit exceeded. You can make
                      up to 50 requests per minute.
              examples:
                Throttled:
                  summary: 同一凭证在一分钟内生成的 PDF 超过 50 份
                  value:
                    detail: >-
                      Session PDF generation rate limit exceeded. You can make
                      up to 50 requests per minute.
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: cURL
          source: |-
            curl --fail \
              https://verification.didit.me/v3/session/11111111-2222-3333-4444-555555555555/generate-pdf/ \
              -H 'x-api-key: YOUR_API_KEY' \
              --output report.pdf
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            content = client.sessions.generate_pdf(
                "11111111-2222-3333-4444-555555555555",
            )
            with open("download.pdf", "wb") as file:
                file.write(content)
        - lang: javascript
          label: Node.js
          source: >-
            import { writeFile } from "node:fs/promises";

            import Didit from "@didit-protocol/sdk-node";


            // Reads DIDIT_API_KEY.

            const didit = new Didit();


            const content = await
            didit.sessions.generatePdf("11111111-2222-3333-4444-555555555555");

            await writeFile("download.pdf", Buffer.from(await
            content.arrayBuffer()));
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// Reads DIDIT_API_KEY.\nclient := didit.NewClient()\n\nresp, err := client.Sessions.GeneratePDF(ctx, \"11111111-2222-3333-4444-555555555555\")\nif err != nil {\n\tlog.Fatal(err)\n}\ndefer resp.Body.Close()\nfile, err := os.Create(\"download.pdf\")\nif err != nil {\n\tlog.Fatal(err)\n}\ndefer file.Close()\nif _, err := io.Copy(file, resp.Body); err != nil {\n\tlog.Fatal(err)\n}"
        - lang: java
          label: Java
          source: >-
            import java.nio.file.Path;

            import me.didit.Didit;


            // Reads DIDIT_API_KEY.

            Didit client = new Didit();


            client.sessions().generatePdf("11111111-2222-3333-4444-555555555555")
                    .writeTo(Path.of("download.pdf"));
        - lang: php
          label: PHP
          source: >-
            <?php


            require 'vendor/autoload.php';


            use Didit\DiditClient;


            // Reads DIDIT_API_KEY.

            $didit = new DiditClient();


            $content =
            $didit->sessions->generatePdf('11111111-2222-3333-4444-555555555555');

            $content->saveTo('download.pdf');
        - lang: ruby
          label: Ruby
          source: >-
            require "didit"


            # Reads DIDIT_API_KEY.

            didit = Didit::Client.new


            content =
            didit.sessions.generate_pdf("11111111-2222-3333-4444-555555555555")

            File.binwrite("download.pdf", content)
        - lang: csharp
          label: .NET
          source: >-
            using System;

            using Didit;


            // Reads DIDIT_API_KEY.

            using var client = new DiditClient();


            var content = await
            client.Sessions.GeneratePdfAsync("11111111-2222-3333-4444-555555555555");

            await content.SaveToAsync("download.pdf");
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        您的应用 API 密钥，可在 Business Console 的“开发者 -> API
        密钥”中获取。主密钥拥有完整访问权限。指定名称的密钥可设置作用域：针对每个资源设为无权限、只读或读写，限定于特定工作流或已通过的会话、限定于
        IP 地址列表，以及设置到期日期。401 表示密钥错误、已撤销或已过期；403 表示未发送密钥、密钥无权访问该资源或操作，或请求来自其 IP
        列表之外的地址；在会话路由上返回 404 表示该会话不在该密钥允许的工作流或状态范围内。没有媒体访问权限的密钥获取到的图片、视频和 PDF
        URL 将为 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.