> 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 one or more accounts as an organization admin

> Learn how an organization administrator can delete a user's Personal Identifiable Information (PII) data from one or more accounts.

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

> **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 at least one of the following:- A full organization administrator
- A delegated organization administratorSee [Organization Administrators](https://support.docusign.com/s/document-item?language=en_US\&rsc_301\&bundleId=rrf1583359212854\&topicId=god1583359152535.html&_LANG=enus) 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](http://guid.one/) 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](https://admindemo.docusign.com/authenticate?goTo=accountProfile) page.                             |
| \{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 accountsApi = new AccountsApi(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}`. 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.

**`Bash`**

```bash title="Bash"
printf \
'{
  "user_id": '${USER_ID}',
  "memberships": [{
    "account_id": '${ACCOUNT_ID}',
  }]
}
' >>$request_data
```

**`C#`**

```csharp title="C#"
var membershipDataRedaction = new IndividualMembershipDataRedactionRequest(Guid.Parse(userId));
```

**`Java`**

```java title="Java"
IndividualUserDataRedactionRequest userRedactionRequest = new IndividualUserDataRedactionRequest();
userRedactionRequest.setUserId(user.getId());
userRedactionRequest.setMemberships(Arrays.asList(memberships));
```

**`Node.js`**

```javascript title="Node.js"
const organizationsApi = new docusignAdmin.OrganizationsApi(apiClient);
const userRedactionRequest =
  docusignAdmin.IndividualUserDataRedactionRequest.constructFromObject({
    user_id: user.id,
    memberships: [
      docusignAdmin.MembershipDataRedactionRequest.constructFromObject({
        account_id: user.memberships[0].account_id,
      }),
    ],
  });
```

**`PHP`**

```php title="PHP"
$userRedactionRequest = new IndividualUserDataRedactionRequest();
$userRedactionRequest->setUserId($user->getId());
$userRedactionRequest->setMemberships([
    new MembershipDataRedactionRequest([
        "account_id" => $user->getMemberships()[0]->getAccountId()
    ])
]);
```

**`PowerShell`**

```text title="PowerShell"
$body = @"
  {
    "user_id": "$userId",
    "memberships": [{
      "account_id": "$accountId",
    }]
  }
"@
```

**`Python`**

```python title="Python"
organizations_api = OrganizationsApi(api_client=api_client)
user_data_redaction_request = IndividualUserDataRedactionRequest(
    user_id=user.id,
    memberships=[MembershipDataRedactionRequest(account_id=user.memberships[0].account_id)]
)
```

**`Ruby`**

```ruby title="Ruby"
organizations_api = DocuSign_Admin::OrganizationsApi.new(api_client)
user_data_redaction_request = DocuSign_Admin::IndividualUserDataRedactionRequest.new(
  user_id: user.id,
  memberships: [
    DocuSign_Admin::MembershipDataRedactionRequest.new(
      account_id: user.memberships[0].account_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: redactIndividualUserData](/docs/admin-api/reference/usermanagement/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}`.

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

**`Bash`**

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

**`C#`**

```csharp title="C#"
var response = accountsApi.RedactIndividualMembershipDataWithHttpInfo(accountId, membershipDataRedaction);
response.Headers.TryGetValue("X-RateLimit-Remaining", out string remaining);
response.Headers.TryGetValue("X-RateLimit-Reset", out string 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 = organizationsApi
        .redactIndividualUserDataWithHttpInfo(organizationId, userRedactionRequest);

headers = response.getHeaders();
remaining = headers.get("X-RateLimit-Remaining");
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 organizationsApi.redactIndividualUserData(userRedactionRequest, args.organizationId);
```

**`PHP`**

```php title="PHP"
$response = $organizationsApi->redactIndividualUserDataWithHttpInfo($organizationId, $userRedactionRequest);

$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/organizations/${organizationId}/user"

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

**`Python`**

```python title="Python"
(results, status, headers) = organizations_api.redact_individual_user_data_with_http_info(org_id, user_data_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 = organizations_api.redact_individual_user_data_with_http_info(args[:organization_id], user_data_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": "57fe8897-xxxx-xxxx-xxxx-50e7112b6d29",
  "status": "success",
  "membership_results": [
    {
      "account_id": "0820f9c5-xxxx-xxxx-xxxx-8a0df87f44aa",
      "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.