Skip to navigation

How to share access to a Docusign envelope inbox

View as Markdown
eSignature REST API 2.1 only

This topic demonstrates how to share envelope inbox access with another user and view an envelope using the SHARED ACCESS view in the Docusign UI. The Shared Access feature enables a user (the principal) to grant another user (the agent) access to the principal’s envelopes.

Important: There must be envelopes in the principal’s inbox to complete this how-to. See How to request a signature by email to learn more about creating an envelope.

See Shared Access for details on the feature and the list of supported envelope actions.

Run this code example from our Quickstart or launcher projects: Bash, C#, Java, Node.js, PHP, PowerShell, Python, or Ruby.

Required data

Running the code in this how-to requires this data:

Data elementDescription
{ACTIVATION}A string value, 50 characters or less, that you provide to the agent to activate their account. This string must not contain the symbols <, >, &, and #.
{AGENT_EMAIL}A string value for the email address of the agent.
{AGENT_NAME}A string value for the full name of the agent.
{AGENT_USER_ID}A GUID value that identifies the user. This value is automatically generated by Docusign. Copy the value from the User ID field on the Apps and Keys page.
{API_ACCOUNT_ID}A GUID value that identifies your account. This value is automatically generated by Docusign for any account you create. Copy the value from the API Account ID field on the Apps and Keys page.
{BASE_PATH}A string value that forms the root of the URL required to make API calls. The base path value in the example code is set to target the developer environment at
https://<domain>/restapi
Where <domain> is demo.docusign.net for the developer environment and is the result of the GetUserInfo call in production.
{IMPERSONATION_USER_GUID}A GUID value that identifies the user. This value is automatically generated by Docusign. Copy the value from the User ID field on the Apps and Keys page.

Step 1. Obtain your OAuth token

To make the API calls shown in this how-to, you need a valid OAuth access token. Docusign supports access tokens for three different recommended OAuth grant types: Public Authorization Code Grant, Confidential Authorization Code Grant, and JSON Web Token (JWT) Grant. Choose the OAuth grant type appropriate for your scenario.

See Confidential Authorization Code Grant for guidance on your options to get an Confidential Authorization Code Grant OAuth token.

Three icons that represent the three methods a user can use to obtain an OAuth token: JSON Web Token (JWT), Public Authorization Code Grant (ACG), and Confidential Authorization Code grant

Step 2. Construct your API headers

After you have a valid OAuth access token, you are ready to construct the API headers that you will pass to the API call. Construct your headers like this, but make sure to substitute your valid OAuth access token for {ACCESS_TOKEN}.

declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
'--header' "Accept: application/json"
'--header' "Content-Type: application/json")

Step 3. Construct the request body to create an agent and call the API

To share access to the principal’s envelopes with an agent, there must be at least two users in the principal’s account. This step creates a new agent with whom the principal’s envelope inbox will be shared. If there is already a second user in the principal’s account, you can skip this step and instead record the second user’s user ID to use in the next step.

First, create the request body for the API call to create an agent. Set the userName and email fields to the name and email address associated with the agent. Set the activationAccessCode to a string that the agent will use to activate their account. Make a POST request to the Users:create endpoint and include the request body to create the agent. Then, extract the agent’s userId from the response as {AGENT_USER_ID}. You will use it again in Step 4.

printf \
'{
"newUsers": [
{
"activationAccessCode": "'"${ACTIVATION}"'",
"userName": "'"${AGENT_NAME}"'",
"email": "'"${AGENT_EMAIL}"'"
}
]
}' >> $request_data
Status=$(curl --request POST ${base_path}/v2.1/accounts/${ACCOUNT_ID}/users \
"${Headers[@]}" \
--data-binary @${request_data} \
--output ${response})
echo ""
echo "Response: "
cat $response
echo ""
AGENT_USER_ID=`cat $response | grep userId | sed 's/.*\"userId\":\"//' | sed 's/\",.*//'`

Step 4. Construct the request body to grant authorization and call the API

This step grants shared access to the principal’s Docusign envelope inbox to the agent created in the previous step. If you already have a second user with whom you’d like to share access, you can provide their user ID in the agentUser JSON.

Now that you have created an agent, you need to authorize the agent to manage envelopes in the principal’s inbox. Set the userId field to the one associated with the agent and set the permission to manage. Make a POST request to the Users:authorization endpoint and include the request body to authorize the agent to manage the principal’s envelopes. Use the principal’s user ID as {IMPERSONATION_USER_GUID} and the principal’s API account ID as {ACCOUNT_ID} in the call.

printf \
'{
"agentUser":
{
"userId": "'"${AGENT_USER_ID}"'",
"accountId": "'"${ACCOUNT_ID}"'"
},
"permission": "manage"
}' >> $request_data
Status=$(curl --request POST ${base_path}/v2.1/accounts/${ACCOUNT_ID}/users/${IMPERSONATION_USER_GUID}/authorization \
"${Headers[@]}" \
--data-binary @${request_data} \
--output ${response})

Expected response

Now that the agent has been authorized, the agent should be able to see the principal’s envelopes in their Shared Access UI. To verify that the principal’s envelopes can be viewed by the agent, log in to the agent’s Docusign developer account, then open the Agreements tab in the eSignature UI. Select SHARED ACCESS in the upper left, then select the principal’s account. The principal’s envelopes should be displayed in Sent.

Viewing shared envelopes in the Sent folder

Step 5. Call the eSignature REST API as the agent

The following API call will be made by the agent. Before making this API call, you need to authenticate as the agent.

After you have authenticated as the agent, confirm that the envelope inbox has been shared by calling the Envelopes:listStatus endpoint. Any API calls made on behalf of the principal need to include the X-DocuSign-Act-On-Behalf header and substitute the principal’s user ID for {IMPERSONATION_USER_GUID}. Be sure to also substitute the API account ID of the agent for {ACCOUNT_ID}.

View the source code for this how-to on GitHub: Bash, C#, Java, Node.js, PHP, PowerShell, Python, or Ruby.

response=$(mktemp /tmp/response-bs.XXXXXX)
if date -v -10d &> /dev/null ; then
# Mac
from_date=`date -v -10d '+%Y-%m-%dT%H:%M:%S%z'`
else
# Not a Mac
from_date=`date --date='-10 days' '+%Y-%m-%dT%H:%M:%S%z'`
curl --header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "X-DocuSign-Act-On-Behalf: ${IMPERSONATION_USER_GUID}" \
--header "Content-Type: application/json" \
--get \
--output $response \
--data-urlencode "from_date=${from_date}" \
--request GET ${base_path}/v2.1/accounts/${ACCOUNT_ID}/envelopes/

Expected response

If you run this code example from our Quickstart or launcher projects, you should see a JSON response of the envelopes in the principal’s account.

Sample response
{
"resultSetSize": "1",
"startPosition": "0",
"endPosition": "1",
"totalSetSize": "1",
"nextUri": "",
"previousUri": "",
"envelopes": [
{
"status": "sent",
"documentsUri": "/envelopes/e63fd3e2-xxxx-xxxx-xxxx-5a73e59c7f9d/documents",
"recipientsUri": "/envelopes/e63fd3e2-xxxx-xxxx-xxxx-5a73e59c7f9d/recipients",
"attachmentsUri": "/envelopes/e63fd3e2-xxxx-xxxx-xxxx-5a73e59c7f9d/attachments",
"envelopeUri": "/envelopes/e63fd3e2-xxxx-xxxx-xxxx-5a73e59c7f9d",
"emailSubject": "Please sign this document set",
"envelopeId": "e63fd3e2-xxxx-xxxx-xxxx-5a73e59c7f9d",
"signingLocation": "online",
"customFieldsUri": "/envelopes/e63fd3e2-xxxx-xxxx-xxxx-5a73e59c7f9d/custom_fields",
"notificationUri": "/envelopes/e63fd3e2-xxxx-xxxx-xxxx-5a73e59c7f9d/notification",
"allowMarkup": "false",
"createdDateTime": "2023-04-12T01:09:04.2170000Z",
"lastModifiedDateTime": "2023-04-12T01:09:04.2330000Z",
"sentDateTime": "2023-04-12T01:09:05.5600000Z",
"statusChangedDateTime": "2023-04-12T01:09:05.5600000Z",
"documentsCombinedUri": "/envelopes/e63fd3e2-xxxx-xxxx-xxxx-5a73e59c7f9d/documents/combined",
"certificateUri": "/envelopes/e63fd3e2-xxxx-xxxx-xxxx-5a73e59c7f9d/documents/certificate",
"templatesUri": "/envelopes/e63fd3e2-xxxx-xxxx-xxxx-5a73e59c7f9d/templates",
"expireEnabled": "true",
"expireAfter": "120",
"sender": {
"userName": "Susan Signer",
"userId": "c316f86c-xxxx-xxxx-xxxx-6b39358381d2",
"accountId": "b71dbd28-xxxx-xxxx-xxxx-8d99842a7982",
"email": "test@example.com",
"ipAddress": "12.xxx.xxx.35"
},
"purgeState": "unpurged",
"envelopeIdStamping": "true",
"autoNavigation": "true",
"isSignatureProviderEnvelope": "false",
"anySigner": null,
"envelopeLocation": "not_specified"
}
]
}

Next steps