> You are reading the Docusign Developer Documentation. For clean Markdown of any page, append .md to the page URL.
>
> Documentation indexes by section:
> - APIs and SDKs: https://docusign.docs.buildwithfern.com/docs/llms.txt
> - Platform 101: https://docusign.docs.buildwithfern.com/platform/llms.txt
> - Extension Apps: https://docusign.docs.buildwithfern.com/extension-apps/llms.txt
> - Docusign CLI: https://docusign.docs.buildwithfern.com/docusign-cli/llms.txt
>
> Authentication (OAuth, JWT Grant, M2M): https://docusign.docs.buildwithfern.com/platform/auth
> Webhooks and Connect: https://docusign.docs.buildwithfern.com/platform/webhooks
>
> OpenAPI specifications: https://docusign.docs.buildwithfern.com/openapi.json
> MCP server: https://docusign.docs.buildwithfern.com/_mcp/server

# How to delete user data from an account as an account admin

> Learn how an eSignature (account) administrator can delete a user's Personal Identifiable Information (PII) data from an account.

This topic demonstrates how an eSignature (account) administrator can [delete a user's Personal Identifiable Information (PII) data](/docs/admin-api/admin101/concepts/delete-personal-data) from an account.

> **Note**
>
> Run this code example from our [Quickstart](/docs/esign-rest-api/quickstart) or launcher projects: [Bash](https://github.com/docusign/code-examples-bash), [C#](https://github.com/docusign/code-examples-csharp), [Java](https://github.com/docusign/code-examples-java), [Node.js](https://github.com/docusign/code-examples-node), [PHP](https://github.com/docusign/code-examples-php), [PowerShell](https://github.com/docusign/code-examples-powershell), [Python](https://github.com/docusign/code-examples-python), or [Ruby](https://github.com/docusign/code-examples-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 element      | Description                                                                                                                                                                                                                                                                                            |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| \{API_ACCOUNT_ID} | A [GUID](http://guid.one/) 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](https://admindemo.docusign.com/authenticate?goTo=appsAndKeys) page.               |
| Admin access      | The caller must be an eSignature account administrator.                                                                                                                                                                                                                                                |
| \{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. |
| \{USER_ID}        | A [GUID](http://guid.one/) 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](https://admindemo.docusign.com/authenticate?goTo=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](/platform/auth) 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](/docs/esign-rest-api/esign101/auth), although you must request one or more  [Docusign Admin scopes](/docs/admin-api/admin101/auth) 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](/docs/admin-api/admin101/auth) 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](/_fern-files/_img/64f473773042ee439449a096bf7673292b1585b86a4ccc55f82ba0dda41f61a1.webp)

## 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}`.

**`Bash`**

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

**`C#`**

```csharp title="C#"
var docusignClient = new DocuSignClient(basePath);
docusignClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);

var usersApi = new UsersApi(docusignClient);
```

**`Java`**

```java title="Java"
ApiClient apiClient = new ApiClient(basePath);
apiClient.addDefaultHeader(
        HttpHeaders.AUTHORIZATION,
        BEARER_AUTHENTICATION + accessToken);
```

**`Node.js`**

```javascript title="Node.js"
const apiClient = new docusignAdmin.ApiClient();
apiClient.setBasePath(args.basePath);
apiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
```

**`PHP`**

```php title="PHP"
$config = new Configuration();
$config->setAccessToken($accessToken);
$config->setHost('https://api-d.docusign.net/management');
$config->addDefaultHeader('Authorization', 'Bearer ' . $accessToken);
$this->apiClient = new ApiClient($config);
```

**`PowerShell`**

```text title="PowerShell"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.add("Authorization", "Bearer $accessToken")
$headers.add("Content-Type", "application/json")
$headers.add("Accept", "application/json")
```

**`Python`**

```python title="Python"
api_client = ApiClient(host=DS_CONFIG["admin_api_client_host"])
api_client.set_default_header(
    header_name="Authorization",
    header_value=f"Bearer {access_token}"
)
```

**`Ruby`**

```ruby title="Ruby"
configuration = DocuSign_Admin::Configuration.new
configuration.host = Rails.configuration.admin_host

api_client = DocuSign_Admin::ApiClient.new(configuration)
api_client.set_default_header('Authorization', "Bearer #{args[:access_token]}")
```

## 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}`.

**`Bash`**

```bash title="Bash"
printf \
'{
  "user_id": "'${USER_ID}'"
}
' >>$request_data
```

**`C#`**

```csharp title="C#"
var userRedactionRequest = new IndividualUserDataRedactionRequest
{
    UserId = user?.Id,
    Memberships = new List<MembershipDataRedactionRequest>
    {
        new MembershipDataRedactionRequest
        {
            AccountId = user?.Memberships?[0].AccountId,
        },
    },
};
```

**`Java`**

```java title="Java"
IndividualMembershipDataRedactionRequest membershipDataRedaction = new IndividualMembershipDataRedactionRequest();
membershipDataRedaction.userId(userId);
```

**`Node.js`**

```javascript title="Node.js"
const accountsApi = new docusignAdmin.AccountsApi(apiClient);
const membershipDataRedactionRequest = docusignAdmin.IndividualMembershipDataRedactionRequest.constructFromObject({
  user_id: args.userId,
});
```

**`PHP`**

```php title="PHP"
$membershipDataRedaction = new IndividualMembershipDataRedactionRequest();
$membershipDataRedaction->setUserId($userId);
```

**`PowerShell`**

```text title="PowerShell"
$body = @"
  {
    "user_id": "$userId",
  }
"@
```

**`Python`**

```python title="Python"
accounts_api = AccountsApi(api_client=api_client)
membership_redaction_request = IndividualMembershipDataRedactionRequest(user_id=user_id)
```

**`Ruby`**

```ruby title="Ruby"
accounts_api = DocuSign_Admin::AccountsApi.new(api_client)
membership_redaction_request = DocuSign_Admin::IndividualMembershipDataRedactionRequest.new(
  user_id: args[:user_id]
)
```

## 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: redactIndividualMembershipData](/docs/admin-api/reference/usermanagement/datadeletion/redactindividualmembershipdata) 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 account ID for `{API_ACCOUNT_ID}`.

> **Note**
>
> View the source code for this how-to on GitHub: [Bash](https://github.com/docusign/code-examples-bash/blob/master/examples/Admin/eg011DeleteUserDataFromAccount.sh),  [C#](https://github.com/docusign/code-examples-csharp/blob/master/launcher-csharp/Admin/Examples/DeleteUserDataFromAccount.cs), [Java](https://github.com/docusign/code-examples-java/blob/master/src/main/java/com/docusign/controller/admin/examples/A011DeleteUserDataFromAccount.java), [Node.js](https://github.com/docusign/code-examples-node/blob/master/lib/admin/examples/deleteUserDataFromAccount.js), [PHP](https://github.com/docusign/code-examples-php/blob/master/src/Services/Examples/Admin/DeleteUserDataFromAccountService.php), [PowerShell](https://github.com/docusign/code-examples-powershell/blob/master/examples/Admin/eg011DeleteUserDataFromAccount.ps1), [Python](https://github.com/docusign/code-examples-python/blob/master/app/admin/examples/eg011_delete_user_data_from_account.py), or [Ruby](https://github.com/docusign/code-examples-ruby/blob/master/app/services/admin_api/eg011_delete_user_data_from_account_service.rb).

**`Bash`**

```bash title="Bash"
curl -w '%{http_code}' -i --request POST "${base_path}/v2/data_redaction/accounts/${API_ACCOUNT_ID}/user" \
  "${Headers[@]}" \
  --data-binary @${request_data} \
  --output ${response}
```

**`C#`**

```csharp title="C#"
var response = organizationsApi.RedactIndividualUserDataWithHttpInfo(organizationId, userRedactionRequest);
response.Headers.TryGetValue("X-RateLimit-Remaining", out remaining);
response.Headers.TryGetValue("X-RateLimit-Reset", out reset);

if (reset != null && remaining != null)
{
    DateTime resetDate = DateTimeOffset.FromUnixTimeSeconds(long.Parse(reset)).UtcDateTime;
    Console.WriteLine("API calls remaining: " + remaining);
    Console.WriteLine("Next Reset: " + resetDate);
}

return response.Data;
```

**`Java`**

```java title="Java"
ApiResponse<IndividualUserDataRedactionResponse> response = accountsApi
        .redactIndividualMembershipDataWithHttpInfo(accountId, membershipDataRedaction);

Map<String, List<String>> headers = response.getHeaders();
List<String> remaining = headers.get("X-RateLimit-Remaining");
List<String> reset = headers.get("X-RateLimit-Reset");

if (remaining != null & reset != null) {
    Instant resetInstant = Instant.ofEpochSecond(Long.parseLong(reset.get(0)));
    System.out.println("API calls remaining: " + remaining);
    System.out.println("Next Reset: " + resetInstant);
}

return response.getData();
```

**`Node.js`**

```javascript title="Node.js"
return await accountsApi.redactIndividualMembershipData(membershipDataRedactionRequest, args.accountId);
```

**`PHP`**

```php title="PHP"
$response = $accountsApi->redactIndividualMembershipDataWithHttpInfo($accountId, $membershipDataRedaction);
$remaining = $response[2]['X-RateLimit-Remaining'] ?? null;
$reset = $response[2]['X-RateLimit-Reset'] ?? null;

if ($remaining !== null && $reset !== null) {
    $resetInstant = (new DateTime())->setTimestamp((int)$reset);
    error_log("API calls remaining: $remaining");
    error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
}
return $response[0];
```

**`PowerShell`**

```text title="PowerShell"
$uri = "${basePath}/v2/data_redaction/accounts/${APIAccountId}/user"

	$result = Invoke-WebRequest -uri $uri -headers $headers -body $body -method POST
	$result.content
```

**`Python`**

```python title="Python"
(results, status, headers) = accounts_api.redact_individual_membership_data_with_http_info(account_id, membership_redaction_request)

remaining = headers.get("X-RateLimit-Remaining")
reset = headers.get("X-RateLimit-Reset")

if remaining is not None and reset is not None:
    reset_date = dt.fromtimestamp(int(reset), tz=timezone.utc)
    print(f"API calls remaining: {remaining}")
    print(f"Next Reset: {reset_date}")
```

**`Ruby`**

```ruby title="Ruby"
results, _status, headers = accounts_api.redact_individual_membership_data_with_http_info(args[:account_id], membership_redaction_request)

remaining = headers['X-RateLimit-Remaining']
reset = headers['X-RateLimit-Reset']

if remaining && reset
  reset_date = Time.at(reset.to_i).utc
  puts "API calls remaining: #{remaining}"
  puts "Next Reset: #{reset_date}"
end
```

## 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`**

```json title="Sample response"
{
  "user_id": "a9a8647d-xxxx-xxxx-xxxx-8ac7ba5c6081",
  "status": "success",
  "membership_results": [
    {
      "account_id": "559960c8-xxxx-xxxx-xxxx-c200eabc8a86",
      "status": "success"
    }
  ]
}
```

## Next steps

* Run this code example from our [Quickstart](/docs/esign-rest-api/quickstart) or launcher projects: [Bash](https://github.com/docusign/code-examples-bash).
* See [Delete personal data for your users](/docs/admin-api/admin101/concepts/delete-personal-data).
* Learn [How to create a new active eSignature user](/docs/admin-api/how-to/create-active-user).
* See how to [Go-Live](/docs/esign-rest-api/go-live) with a completed app and find the base path for API calls in the production environment.