> ## 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：签名 PDF

> 使用 API 密钥，下载 Didit KYC 或 KYB 会话中电子签名步骤里某份文档的已签名 PDF。

返回某份证件的已签署 PDF，前提是其签署人已完成签署。您无需自行构建 URL：决策中每份已签署证件的路径都位于 `signatures[].documents[].signed_file` 中。

```bash theme={null}
curl -L 'https://verification.didit.me/v3/session/{session_id}/signatures/{node_id}/documents/{document_id}/file/' \
  -H 'x-api-key: YOUR_API_KEY' \
  -o agreement-signed.pdf
```

该 PDF 包含签署人查看的证件，并印有其字段值，以及证据页（除非该步骤的 `signature_evidence_page` 已关闭）。高级（AES）PDF 还包含带时间戳的 PAdES 签名；简单 PDF 没有数字签名、印章或时间戳。返回文件前，Didit 会将存储文件与 `sha256_signed` 进行核对。如果两者不一致，则返回 `409` 及 `signature_document_changed`。

尚未签署的证件会返回 `404` 及 `signature_not_signed`。在您[删除会话](https://docs.didit.me/zh/sessions-api/delete-session.md)后，该路由将返回 `404`。

## 相关内容

* [电子签名报告](https://docs.didit.me/zh/core-technology/electronic-signature/report-electronic-signature.md#已签署-pdf)：已签署 PDF 的内容。
* [下载签名证据](https://docs.didit.me/zh/sessions-api/electronic-signature/download-evidence.md)
* [验证签名](https://docs.didit.me/zh/sessions-api/electronic-signature/validate-signatures.md)


## OpenAPI

````yaml zh/openapi-25.json GET /v3/session/{sessionId}/signatures/{nodeId}/documents/{documentId}/file/
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}/signatures/{nodeId}/documents/{documentId}/file/:
    get:
      tags:
        - Sessions
      summary: 下载已签署的证件
      description: >-
        下载电子签名步骤中一份文件的已签署 PDF。请使用决策中 `signatures[].documents[]` 的 `signed_file`
        路径。该 PDF 包含向签署人展示的文件，其上加盖了签署人的字段值，并附有证据页（除非 `signature_evidence_page`
        已关闭）。高级（AES）PDF 还带有包含时间戳的 PAdES 签名；简单 PDF 则没有数字签名、印章或时间戳。Didit 在返回文件前会对照
        `sha256_signed` 进行校验。


        适用于用户验证（KYC）和企业验证（KYB）会话。需要 `read:sessions` 权限；您的 API
        密钥有效。请参阅[电子签名报告](/zh/core-technology/electronic-signature/report-electronic-signature#下载已签署文档)。
      operationId: get_v3_session_signature_document_file
      parameters:
        - name: sessionId
          in: path
          required: true
          description: 用户验证（KYC）或企业验证（KYB）会话。
          schema:
            type: string
            format: uuid
            example: 11111111-2222-3333-4444-555555555555
        - name: nodeId
          in: path
          required: true
          description: 电子签名步骤：`signatures[]` 中项目的 `node_id`。
          schema:
            type: string
            example: feature_signature
        - name: documentId
          in: path
          required: true
          description: '`signatures[].documents[]` 中证件的 `id`。'
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: 已签署的 PDF。
          headers:
            Content-Disposition:
              description: 包含文件名的附件。
              schema:
                type: string
                example: attachment; filename="agreement-signed.pdf"
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        '403':
          description: 缺少凭据，或凭据无法读取此会话。缺少密钥返回 `403`；错误、已撤销或已过期的密钥返回 `401`。
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
              example:
                detail: You do not have permission to perform this action.
        '404':
          description: 没有匹配的已签名文档：会话、步骤或文档不存在、已被删除或尚未签名。
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                  code:
                    type: string
              examples:
                Not signed yet:
                  summary: 签署人尚未签署
                  value:
                    code: signature_not_signed
                    detail: signature_not_signed
                Unknown document:
                  summary: 该步骤中不存在此证件
                  value:
                    code: signature_not_found
                    detail: signature_not_found
        '409':
          description: 存储的文件与其记录的 SHA-256 不再匹配。未返回任何内容。
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                  code:
                    type: string
              examples:
                Changed file:
                  summary: 存储的文件与其哈希值不匹配
                  value:
                    code: signature_document_changed
                    detail: signature_document_changed
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            content = client.sessions.signatures.download_document(
                "11111111-2222-3333-4444-555555555555",
                "feature_signature",
                "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.signatures.downloadDocument(
              "11111111-2222-3333-4444-555555555555",
              "feature_signature",
              "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.Signatures.DownloadDocument(ctx, \"11111111-2222-3333-4444-555555555555\", \"feature_signature\", \"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().signatures().downloadDocument("11111111-2222-3333-4444-555555555555",
            "feature_signature", "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->signatures->downloadDocument('11111111-2222-3333-4444-555555555555',
            'feature_signature', '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.signatures.download_document(
              "11111111-2222-3333-4444-555555555555",
              "feature_signature",
              "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.Signatures.DownloadDocumentAsync("11111111-2222-3333-4444-555555555555",
            "feature_signature", "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.