perkbrian
perkbrian

Reputation: 23

Templates inside of Docusign Shared Templates folder through API

Listing the folders and their contents (templates) from the "My Templates" section is easily done, but listing the Folders and Templates inside of the "Shared Templates" section does not seem to be documented.

I am looking for a way to accomplish the same thing as using "GET https://{server}/restapi/{apiVersion}/accounts/{accountId}/templates?folder={folder}", but for a folder inside of the "Shared Templates" section.

I cannot find any documentation for this functionality.

Upvotes: 2

Views: 542

Answers (3)

David Cruwys
David Cruwys

Reputation: 6842

I have been banging my head against this problem for 2 days now and have tried many API calls/configurations to work this out for my self.

I believe (as highlighted from the documentation) that this feature may not be supported.

I'm still investigating a little further and will change this response if I find a solution.

Set not support

The following information is what I have tried, ultimately did not work.

I am providing this information to help others who stumble across this thread looking for an answer to see what I have tried while looking for an answer, and also for my own clarity if I come back to this problem.

The use of this DocusignIntegration::DocusignModel in the code below is from a custom model that I created that knows how to translate back and forth between snake_case (ruby) and camelCase (Docusign Data)

I have manually moved a template into a local folder and shared a template in a shared folder

UX

The following result is based on the Account::ListSharedAccess endpoint, using the following query options.

Query Shared Access using 'folders' item type

options.item_type = 'folders'
options.folder_ids = 'id-for-local-folder,id-for-shared-folder'

Notice that you don't get any information about templates when querying folders

{
  "accountId": "040-1111",
  "sharedAccess": [
    {
      "folders": [
        {
          "folderId": "id-for-local-folder",
          "name": "Local Folder",
          "uri": "/folder/id-for-local-folder",
          "sharedUsers": [
            {
              "user": {
                "userName": "David",
                "userId": "30a59"
              },
              "shared": "shared_to"
            }
          ]
        },
        {
          "folderId": "id-for-shared-folder",
          "name": "Shared Folder",
          "uri": "/folder/id-for-shared-folder",
          "sharedUsers": [
            {
              "user": {
                "userName": "David",
                "userId": "30a594"
              },
              "shared": "shared_to"
            }
          ],
          "sharedGroups": [
            {
              "group": {
                "groupId": "7319013",
                "groupName": "CanIShareTemplateToFolderViaGroups-TestNo37",
                "groupType": "custom"
              },
              "shared": "shared_to"
            }
          ]
        }
      ]
    }
  ]
}

Query using 'templates' item type

options.item_type = 'templates'
options.folder_ids = 'id-for-my-template'

Notice that you don't get any information about folders when querying templates

{
  "accountId": "040-1111",
  "sharedAccess": [
    {
      "templates": [
        {
          "templateId": "id-for-my-template",
          "templateName": "red",
          "owner": {
            "userName": "David",
            "userId": "30a594",
          },
          "sharedGroups": [
            {
              "group": {
                "groupId": "7319013",
                "groupName": "CanIShareTemplateToFolderViaGroups-TestNo37",
                "groupType": "custom"
              },
              "shared": "shared_to"
            }
          ]
        }
      ]
    }
  ]
}

Update Shared Access using 'templates' item type

The following code for assigning a template to a group works expected.

options.item_type = 'templates'
def self.share_template_to_group(account_id:, template_id:, group_id:)
  # Group group to share with
  group = DocusignIntegration::DocusignModel.new(group_id: group_id)

  member_group_shared_item = DocusignIntegration::DocusignModel.new(group: group,
                                                                    shared: 'shared_to')

  # What template to share
  template_shared_item = DocusignIntegration::DocusignModel.new(template_id: template_id,
                                                                shared: 'shared_to',
                                                                shared_groups: [member_group_shared_item])

  member_shared_item = DocusignIntegration::DocusignModel.new(templates: [template_shared_item])

  # Configured AccountSharedAccess object
  DocusignIntegration::DocusignModel.new(account_id: account_id,
                                          shared_access: [member_shared_item])
end
{
    "accountId": "040-1111",
    "sharedAccess": [
    {
      "user": {
        "userName": "David",
        "userId": "30a594"
      },
      "templates": [
        {
          "templateId": "id-for-my-template",
          "sharedGroups": [
            {
              "group": {
                "groupId": "7319013",
                "groupName": "CanIShareTemplateToFolderViaGroups-TestNo37",
                "groupType": "custom"
              },
              "shared": "shared_to"
            }
          ]
        }
      ]
    }
  ]
}

Linking the template to the Shared Folder.

I have tried multiple techniques via the API.

One of those techniques (which can be done via code or the UX) is to assign a template to a group and then share the shared_folder with that same group.

Unfortunately, that does not mean that the template suddenly becomes visible in the folder, but it does enable the user that is part of the group to share the template into the shared_folder via the user interface, thus making it available to all users in the group.

See this flow:

Select share on shared_folder enter image description here

Share the folder with the group that you shared the template with

enter image description here

Now the user (who is not the original template owner) can share that template to the Shared Folder

enter image description here

Upvotes: 0

Laurel
Laurel

Reputation: 96

Templates can be shared a number of ways and how they are returned and show up in the response is based on how those templates have been shared. The API doesn't currently return templates shared via Shared Template Folders in either the /templates or /folders calls. Templates shared directly via Users or Groups will show up in the /templates calls with sharing information but do not have Folder information associated with them.

Upvotes: 0

David W Grigsby
David W Grigsby

Reputation: 1574

perkbrian,

That would be nice, but you can get what you want with the below call. You will need to do the correlation between "shared" and what that unique "folderName/folderId" correlates with. Since this information in internet time changes infrequently, this operation is cheaper (1) call and you can check to see if it has changed or use what has been cached. Also, you can see all the Rest Methods supported at https://www.docusign.net/restapi/help

GET /restapi/v2/accounts/225705/templates 
Host: demo.docusign.net
X-DocuSign-Authentication: {omitted}
Accept: application/json

{
  "envelopeTemplates": [
    {
      "templateId": "1b3e7760-812f-44f1-bc55-445d579fbd8a",
      "name": "0001 - Blank1pg.pdf",
      "shared": "true",
      "password": "",
      "description": "Blank Page 1 - Sample",
      "lastModified": "2014-07-10T19:04:49.7700000Z",
      "pageCount": 1,
      "uri": "/templates/1b3e7760-812f-44f1-bc55-445d579fbd8a",
      "folderName": "Templates",
      "folderId": "5aacfca4-d6ac-4578-9f44-648aef02a7a4",
      "folderUri": "/folders/5aacfca4-d6ac-4578-9f44-648aef02a7a4",
      "owner": {
        "userName": "ProServ Demo SoapUI DocuSign",
        "email": "[email protected]",
        "userId": "ddcd3fc7-2b3c-40d4-98ed-ff90add317ca"
      },
      "emailSubject": "Please DocuSign this document: 0001 - Blank1pg.pdf",
      "emailBlurb": "",
      "signingLocation": "Online",
      "authoritativeCopy": "false",
      "enableWetSign": "true",
      "allowMarkup": "false",
      "allowReassign": "true"
    },

Upvotes: 2

Related Questions