You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用DocuSign API创建多文档信封仅导入首个文档的问题

问题原因

当请求中同时包含templateId和documents数组时,DocuSign默认将documents中的内容视为替换模板内的原有文档,而非追加新文档。若模板本身仅包含1个文档,那么documents数组中只有第一个元素会生效,后续文档会被自动忽略,且API不会返回错误。

解决方案

改用compositeTemplates结构组合模板与多个自定义文档,该结构能明确指定每个文档的处理逻辑(保留模板内容/追加新文档),同时支持添加任意数量的额外文档。

修改后的请求体示例:

{
  "emailSubject": "[Dossier XXXXX ] NAME OF THE PERSONNE",
  "compositeTemplates": [
    // 加载原模板配置与收件人角色
    {
      "serverTemplates": [
        {
          "sequence": "1",
          "templateId": "7b9b4c21-91db-428a-b405-0f045804c053"
        }
      ],
      "inlineTemplates": [
        {
          "sequence": "2",
          "templateRoles": [
            {
              "email": "test@test.com",
              "name": "Testname",
              "defaultRecipient": true,
              "routingOrder": "1",
              "roleName": "EMPRUNTEUR",
              "tabs": {
                "signHereTabs": [
                  {
                    "documentId": "1",
                    "height": "60",
                    "locked": "false",
                    "pageNumber": 5,
                    "required": "true",
                    "tabId": "signature",
                    "tabLabel": "signer ici",
                    "width": "120",
                    "xPosition": "58",
                    "yPosition": 360
                  }
                ]
              }
            }
          ]
        }
      ]
    },
    // 追加第一个自定义文档
    {
      "inlineTemplates": [
        {
          "sequence": "3",
          "documents": [
            {
              "documentBase64": "第一个文档的Base64编码内容",
              "name": "test first document",
              "fileExtension": "pdf",
              "documentId": "101"
            }
          ]
        }
      ]
    },
    // 追加第二个自定义文档
    {
      "inlineTemplates": [
        {
          "sequence": "4",
          "documents": [
            {
              "documentBase64": "第二个文档的Base64编码内容",
              "name": "test second document",
              "fileExtension": "pdf",
              "documentId": "102"
            }
          ]
        }
      ]
    }
  ]
}
关键注意事项
  • sequence字段控制内容的处理顺序,数值越小越先执行,确保模板加载在自定义文档之前。
  • 自定义文档的documentId需设置为与模板内文档ID不重复的值,避免替换模板原有内容。
  • 若需在新添加的文档上配置签名字段,只需在templateRoles的tabs中指定对应文档的documentId即可。

内容的提问来源于stack exchange,提问作者RomainTeclesGGVie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 15:00:49