DocuSign:在从模板创建信封时,documentId来自何处?

时间:2016-01-26 20:53:40

标签: docusignapi

我正在从模板创建信封。我需要知道将在信封中提前创建的documentIds,这样我就可以处理一个奇怪的特殊情况预填充单选按钮。 (我可以更详细地解释原因,但这与这个问题并不相关。)

那么这些文件ID来自何处?我正在使用REST api。

这是我的模板:

GET https://demo.docusign.net/restapi/v2/accounts/{{accountId}}/templates/78b351c5-84f8-49c9-af48-redacted

{
    "envelopeTemplateDefinition": {
        "templateId": "78b351c5-84f8-49c9-af48-redacted",
        "name": "my dev template",
        .... truncated for brevity ....
    },
    "documents": [
        {
            "documentId": "73370178",
            "uri": "/envelopes/78b351c5-84f8-49c9-af48-redacted/documents/73370178",
            "name": "DS_Testing_Doc1.pdf",
            "order": "1",
            "pages": "1"
        },
        {
            "documentId": "13535052",
            "uri": "/envelopes/78b351c5-84f8-49c9-af48-redacted/documents/13535052",
            "name": "DS_Testing_Doc2.pdf",
            "order": "2",
            "pages": "1"
        }
    ],
    "recipients": {
            .... truncated for brevity ....
    }
}

这是我从模板调用创建信封:

POST https://demo.docusign.net/restapi/v2/accounts/{{accountId}}/envelopes/

{ "envelopeId":null,
   "accountId":"redacted",
   "templateId":"78b351c5-84f8-49c9-af48-redacted",
   "status":"sent",
   "templateRoles":[  
      {  
         "id":null,
         "roleName":"producer",
         "email":"myemail@mycompany.com",
         "name":"Eric",
         "clientUserId":"",
         "status":"sent",
         "tabs":{  
            .... truncated for brevity ....
         }
      },
      {  
         "id":null,
         "roleName":"hidden",
         "email":"myemail2@mycompany.com",
         "name":"My Agent",
         "clientUserId":"",
         "status":"created",
         "tabs":{  
            .... truncated for brevity ....
         }
      }
   ],
   "voidedReason":null
}

创建信封的回复:

{
    "envelopeId": "2ab1e693-6f30-4f93-9902-redacted",
    "uri": "/envelopes/2ab1e693-6f30-4f93-9902-redacted",
    "statusDateTime": "2016-01-26T20:41:59.2400000Z",
    "status": "sent"
}

现在获取信封中有关文件的详细信息:

GET https://demo.docusign.net/restapi/v2/accounts/{{accountId}}/envelopes/2ab1e693-6f30-4f93-9902-redacted/documents

{
    "envelopeId": "2ab1e693-6f30-4f93-9902-redacted",
    "envelopeDocuments": [
        {
            "documentId": "1",
            "name": "DS_Testing_Doc1.pdf",
            "type": "content",
            "uri": "/envelopes/2ab1e693-6f30-4f93-9902-redacted/documents/1",
            "order": "1",
            "pages": "1",
            "availableDocumentTypes": [
                {
                    "type": "electronic",
                    "isDefault": "true"
                }
            ]
        },
        {
            "documentId": "2",
            "name": "DS_Testing_Doc2.pdf",
            "type": "content",
            "uri": "/envelopes/2ab1e693-6f30-4f93-9902-redacted/documents/2",
            "order": "2",
            "pages": "1",
            "availableDocumentTypes": [
                {
                    "type": "electronic",
                    "isDefault": "true"
                }
            ]
        },
        {
            "documentId": "certificate",
            "name": "Summary",
            "type": "summary",
            "uri": "/envelopes/2ab1e693-6f30-4f93-9902-redacted/documents/certificate",
            "order": "999",
            "pages": "1",
            "availableDocumentTypes": [
                {
                    "type": "electronic",
                    "isDefault": "true"
                }
            ]
        }
    ]
}

在最后一次调用中,我查看有关信封中文档的详细信息,ID为“1”和“2”。但是,在我的模板中,documentID为“73370178”和“13535052”。

那么,在从模板创建信封时如何分配documentId?它们是否与模板中的“顺序”相对应?我可以依靠它们总是从那里开始增加吗?

是否可以在模板中定义documentIds并在创建信封时使它们相同?

是否可以在从模板创建信封时分配documentIds(假设PDF已上传到模板,而不是发送整个PDF字节流)?

干杯

1 个答案:

答案 0 :(得分:3)

documentId实际上完全取决于您 - 它是客户端定义的值并采用字符串,所以您可以使用任何您想要的命名标准(即数字,字母或组合)。许多集成对documentIds使用简单数字(1,2,3等),而其他集成使用字符串或其他标识符。

在任何情况下,如果您想稍后将无线电标签分配给该文档的收件人,您只需要记住为给定文档设置的值。

注意:如果在创建信封时未提供documentId,系统将自动生成GUID并将其指定为documentId,然后您可以进行Get Documents API调用以检索该ID。