Skip to navigation

How to delete user data from one or more accounts as an organization admin

View as Markdown

This topic demonstrates how an organization administrator can delete a user’s Personal Identifiable Information (PII) data from one or more accounts.

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

Prerequisites

  • User data can only be deleted after the user’s account has been closed for at least 24 hours.

Required data

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

Data elementDescription
{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.
Admin accessThe caller must be at least one of the following:
  • A full organization administrator
  • A delegated organization administrator
See Organization Administrators for details on Docusign Admin roles.
{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>/management
Where <domain> is api-d.docusign.net for the developer environment and api.docusign.net for production.
{ORGANIZATION_ID}A GUID value that identifies the the organization that contains the account to which the user will be added. Copy the value from the Organization ID field in the Organization section of the Account Profile page.
{USER_ID}A GUID value that identifies a specific Docusign user within a Docusign account. Copy the value from the User ID field revealed when you select the user on the Users page in your Docusign account.

Step 1: Obtain your OAuth token

To make the API call shown in this how-to, you need a valid OAuth access token. Docusign supports access tokens for three different OAuth grant types: Authorization Code Grant, Implicit Grant, and JSON Web Token (JWT) Grant. Choose the OAuth grant type appropriate for your scenario. See Authenticate for guidance on your options to get an OAuth token.

Docusign Admin OAuth access tokens are the same ones used for our eSignature REST API, although you must request one or more Docusign Admin scopes to call the Docusign Admin API. The API calls made in this how-to require that you request the Docusign Admin-specific user_data_redact scope when obtaining your access token. See Docusign Admin Authentication for the full list of Docusign Admin scopes.

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

Next, create the request body. Be sure to substitute the ID of the user whose data will be deleted for {USER_ID}. Use the memberships field to specify a list of API account IDs for the accounts that the user is a member of. The user’s data will be deleted in all of those accounts.

printf \
'{
"user_id": '${USER_ID}',
"memberships": [{
"account_id": '${ACCOUNT_ID}',
}]
}
' >>$request_data

Step 4. Call the Docusign Admin API

Now that you have constructed your API headers and request body, make a POST request to the DataDeletion: redactIndividualUserData endpoint and include the request body to delete the user’s data from the organization. Here’s how you make the call, but make sure to substitute your organization ID for {ORGANIZATION_ID}.

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

curl -w '%{http_code}' -i --request POST "${base_path}/v2/data_redaction/organizations/${ORGANIZATION_ID}/user" \
"${Headers[@]}" \
--data-binary @${request_data} \
--output ${response}

Expected response

If you run the code for this how-to from our Quickstart or launcher projects, you should see a JSON response similar to the code shown.

Sample response
{
"user_id": "57fe8897-xxxx-xxxx-xxxx-50e7112b6d29",
"status": "success",
"membership_results": [
{
"account_id": "0820f9c5-xxxx-xxxx-xxxx-8a0df87f44aa",
"status": "success"
}
]
}

Next steps