> 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 clone an account

> Learn how to create a new Docusign eSignature account in your organization cloning an existing account.

This topic demonstrates how to create a new Docusign eSignature account in your organization by cloning an existing account.

**Note:** Cloning copies some features of the source account to the target account, but not others; see [Clone eSignature accounts](/docs/admin-api/admin101/clone-accounts) for details.

> **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).

## Required data

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

| Data element       | Description                                                                                                                                                                                                                                                                                            |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| \{ACCOUNT_NAME}    | The name of the new account.                                                                                                                                                                                                                                                                           |
| Admin access       | The caller must be a full organization administrator. See [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. |
| countryCode        | The two-character [ISO 3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) of the country where the target account will reside.                                                                                                                                           |
| \{EMAIL_ADDRESS}   | The email address of the administrator for the target account.                                                                                                                                                                                                                                         |
| \{FIRST_NAME}      | The first name of the administrator for the target account.                                                                                                                                                                                                                                            |
| \{LAST_NAME}       | The last name of the administrator for the target account.                                                                                                                                                                                                                                             |
| \{ORGANIZATION_ID} | A [GUID](http://guid.one/) value that identifies the organization to which the account 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.                |

## Step 1. Obtain your OAuth token

To make the API call(s) 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.

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 endpoint calls made in this how-to require that you request the following Docusign Admin-specific scopes when obtaining your access token: `asset_group_account_read`, `asset_group_account_clone_write`, and `asset_group_account_clone_read`.

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(AuthorizationHeader, Bearer + accessToken);
```

**`Java`**

```java title="Java"
ApiClient apiClient = createApiClient(accessToken, basePath);
return new ProvisionAssetGroupApi(apiClient);
```

**`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. Get the list of eligible accounts

First, determine the accounts in your organization that are eligible to be cloned. To get a list of accounts in an organization that are [in compliance](/docs/admin-api/admin101/clone-accounts#source-accounts-must-be-compliant), call the [AccountCloning:getAssetGroupAccounts](/docs/admin-api/reference/accountprovisioning/accountcloning/getassetgroupaccounts) endpoint. Be sure to substitute your organization ID for `{ORGANIZATION_ID}`.

**`Bash`**

```bash title="Bash"
Status=$(curl --request GET ${base_path}/v1/organizations/${ORGANIZATION_ID}/assetGroups/accounts?compliant=true \
"${Headers[@]}" \
--output ${response})
```

**`C#`**

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

ProvisionAssetGroupApi assetGroupApi = new ProvisionAssetGroupApi(docuSignClient);
ProvisionAssetGroupApi.GetAssetGroupAccountsOptions options = new ProvisionAssetGroupApi.GetAssetGroupAccountsOptions
{
    compliant = true,
};

var response = assetGroupApi.GetAssetGroupAccountsWithHttpInfo(orgId, options);
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"
ProvisionAssetGroupApi.GetAssetGroupAccountsOptions options = provisionAssetGroupApi.new GetAssetGroupAccountsOptions();
options.setCompliant(true);
ApiResponse<AssetGroupAccountsResponse> response = provisionAssetGroupApi
        .getAssetGroupAccountsWithHttpInfo(organizationId, options);

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"
const assetGroupApi = new docusignAdmin.ProvisionAssetGroupApi(apiClient);
const options = {
  compliant: true,
};
const accounts = await assetGroupApi.getAssetGroupAccounts(args.organizationId, options);
```

**`PHP`**

```php title="PHP"
$options = new GetAssetGroupAccountsOptions();
$options->setCompliant(true);

$result = $provisionAssetGroupApi->getAssetGroupAccountsWithHttpInfo($organizationId, $options);

$remaining = $result[2]['X-RateLimit-Remaining'] ?? null;
$reset = $result[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 $result[0];
```

**`PowerShell`**

```text title="PowerShell"
$uri = "${basePath}/v1/organizations/${organizationId}/assetGroups/accounts?compliant=true"
	$response = Invoke-WebRequest -uri $uri -UseBasicParsing -headers $headers -method GET
```

**`Python`**

```python title="Python"
asset_group_api = ProvisionAssetGroupApi(api_client=api_client)
(accounts, status, headers) = asset_group_api.get_asset_group_accounts_with_http_info(args["organization_id"], compliant=True)

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"
asset_group_api = DocuSign_Admin::ProvisionAssetGroupApi.new(api_client)
options = DocuSign_Admin::GetAssetGroupAccountsOptions.new
options.compliant = true
results, _status, headers = asset_group_api.get_asset_group_accounts_with_http_info(args[:organization_id], options)

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

## Step 4. Construct the request body

Next, construct the request body for the API call that will clone the account. Replace `{SOURCE_ACCOUNT_ID}` with the ID of one of the compliant accounts that was identified in the previous step. This is the ID of the account that will be cloned. Inside the targetAccount object, replace `{ACCOUNT_NAME}`, `{FIRST_NAME}`, `{LAST_NAME}`, and `{EMAIL}` with the name and email address of the administrator for the new account. This administrator should already exist as an admin user in your organization.

The `countryCode` parameter is used to determine the data residency for the new account. In the developer environment there is only one region available, and the value should be set to `"US"`. In the production environment this value can be set to the two-character [ISO 3166 country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) for the country of the target account.

**`Bash`**

```bash title="Bash"
# The country code value is set to "US" for the developer environment
# In production, set the value to the code for the country of the target account
printf \
'{
    "sourceAccount": {
        "id": "'${SOURCE_ACCOUNT_ID}'"
    },
    "targetAccount": {
        "name": "'${ACCOUNT_NAME}'",
        "admin": {
            "firstName": "'${FIRST_NAME}'",
            "lastName": "'${LAST_NAME}'",
            "email": "'${EMAIL}'"
        },
        "countryCode": "US"
    }
}
' >>$request_data
```

**`C#`**

```csharp title="C#"
string countryCode = "US";
var accountData = new AssetGroupAccountClone
{
    SourceAccount = new AssetGroupAccountCloneSourceAccount
    {
        Id = sourceAccountId,
    },
    TargetAccount = new AssetGroupAccountCloneTargetAccount
    {
        Name = targetAccountName,
        Admin = new AssetGroupAccountCloneTargetAccountAdmin
        {
            FirstName = targetAccountFirstName,
            LastName = targetAccountLastName,
            Email = targetAccountEmail,
        },
        CountryCode = countryCode,
    },
};
```

**`Java`**

```java title="Java"
String countryCode = "US";

AssetGroupAccountClone accountData = new AssetGroupAccountClone();
AssetGroupAccountCloneSourceAccount sourceAccount = new AssetGroupAccountCloneSourceAccount();
sourceAccount.setId(sourceAccountId);

AssetGroupAccountCloneTargetAccount targetAccount = new AssetGroupAccountCloneTargetAccount();
targetAccount.setName(targetAccountName);
targetAccount.setCountryCode(countryCode);

AssetGroupAccountCloneTargetAccountAdmin admin = new AssetGroupAccountCloneTargetAccountAdmin();
admin.setEmail(targetAccountEmail);
admin.setFirstName(targetAccountFirstName);
admin.setLastName(targetAccountLastName);

targetAccount.admin(admin);
accountData.setSourceAccount(sourceAccount);
accountData.setTargetAccount(targetAccount);
```

**`Node.js`**

```javascript title="Node.js"
const accountData = docusignAdmin.AssetGroupAccountClone.constructFromObject({
  sourceAccount: {
    id: args.sourceAccountId,
  },
  targetAccount: {
    name: args.targetAccountName,
    admin: {
      firstName: args.targetAccountFirstName,
      lastName: args.targetAccountLastName,
      email: args.targetAccountEmail,
    },
    countryCode: 'US',
  }
});
```

**`PHP`**

```php title="PHP"
$countryCode = "US";

$accountData = new AssetGroupAccountClone([
    'source_account' => new AssetGroupAccountCloneSourceAccount(
        [
            'id' => $sourceAccountId,
        ]
    ),
    'target_account' => new AssetGroupAccountCloneTargetAccount(
        [
            'name' => $targetAccountName,
            'country_code' => $countryCode,
            'admin' => new AssetGroupAccountCloneTargetAccountAdmin(
                [
                    'first_name' => $targetAccountFirstName,
                    'last_name' => $targetAccountLastName,
                    'email' => $targetAccountEmail,
                ]
            ),
        ]
    ),
]);
```

**`PowerShell`**

```text title="PowerShell"
# The country code value is set to "US" for the developer environment
# In production, set the value to the code for the country of the target account
$body = @"
{
  "sourceAccount": {
    "id": "$sourceAccountId"
  },
  "targetAccount": {
    "name": "$targetAccountName",
    "admin": {
      "firstName": "$targetAccountFirstName",
      "lastName": "$targetAccountLastName",
      "email": "$targetAccountEmail"
    },
    "countryCode": "US"
  }
}
"@
```

**`Python`**

```python title="Python"
account_data = AssetGroupAccountClone(
    source_account=AssetGroupAccountCloneSourceAccount(
        id=args["source_account_id"]
    ),
    target_account=AssetGroupAccountCloneTargetAccount(
        name=args["target_account_name"],
        admin=AssetGroupAccountCloneTargetAccountAdmin(
            first_name=args["target_account_first_name"],
            last_name=args["target_account_last_name"],
            email=args["target_account_email"]
        ),
        country_code="US"
    )
)
```

**`Ruby`**

```ruby title="Ruby"
source_account = DocuSign_Admin::AssetGroupAccountCloneSourceAccount.new
source_account.id = args[:source_account_id]

target_account_admin = DocuSign_Admin::AssetGroupAccountCloneTargetAccountAdmin.new
target_account_admin.first_name = args[:target_account_first_name]
target_account_admin.last_name = args[:target_account_last_name]
target_account_admin.email = args[:target_account_email]

target_account = DocuSign_Admin::AssetGroupAccountCloneTargetAccount.new
target_account.name = args[:target_account_name]
target_account.admin = target_account_admin
target_account.country_code = 'US'

account_data = DocuSign_Admin::AssetGroupAccountClone.new
account_data.source_account = source_account
account_data.target_account = target_account
```

## Step 5. Call the Docusign Admin API to clone the account

Now that you have constructed your API headers and request body, make a POST request to the [AccountCloning:cloneAssetGroupAccount](/docs/admin-api/reference/accountprovisioning/accountcloning/cloneassetgroupaccount) method and include the request body to clone the account. Here’s how you make the call, but make sure to substitute your organization ID for `{ORGANIZATION_ID}`. This will clone the source account into a new Docusign eSignature account.

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

**`Bash`**

```bash title="Bash"
Status=$(curl --request POST ${base_path}/v1/organizations/${ORGANIZATION_ID}/assetGroups/accountClone \
"${Headers[@]}" \
--data-binary @${request_data} \
--output ${response})
```

**`C#`**

```csharp title="C#"
var assetGroupApi = new ProvisionAssetGroupApi(docuSignClient);
return assetGroupApi.CloneAssetGroupAccount(orgId, accountData);
```

**`Java`**

```java title="Java"
ApiResponse<AssetGroupAccountClone> response = provisionAssetGroupApi
        .cloneAssetGroupAccountWithHttpInfo(organizationId, accountData);

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"
const assetGroupApi = new docusignAdmin.ProvisionAssetGroupApi(apiClient);
return assetGroupApi.cloneAssetGroupAccount(accountData, args.organizationId);
```

**`PHP`**

```php title="PHP"
$response = $provisionAssetGroupApi->cloneAssetGroupAccountWithHttpInfo($organizationId, $accountData);

$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}/v1/organizations/${organizationId}/assetGroups/accountClone"
	$response = Invoke-WebRequest -uri $uri -headers $headers -body $body -method POST
	$response.Content | ConvertFrom-Json | ConvertTo-Json -Depth 5
```

**`Python`**

```python title="Python"
asset_group_api = ProvisionAssetGroupApi(api_client=api_client)
(results, status, headers) = asset_group_api.clone_asset_group_account_with_http_info(args["organization_id"], account_data)

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"
asset_group_api = DocuSign_Admin::ProvisionAssetGroupApi.new(api_client)
results, _status, headers = asset_group_api.clone_asset_group_account_with_http_info(args[:organization_id], account_data)

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 this code example from our Quickstart or launcher projects, you should see a JSON response similar to the code shown.

Depending on the organization settings, the admin of the new account will receive an email with a link to activate the new account, or the account will automatically be activated. If the account does need to be activated, the status in the JSON response will be “Pending” until the account is activated.

**`Sample response`**

```json title="Sample response"
{
  "sourceAccount": {
    "id": "ed3efc40-xxxx-xxxx-xxxx-17b8f1caab2b"
  },
  "targetAccount": {
    "id": "00000000-xxxx-xxxx-xxxx-000000000000",
    "name": "Target Account",
    "region": "NA",
    "site": "Demo",
    "admin": {
      "email": "example@example.com",
      "firstName": "Donna",
      "lastName": "Developer"
    }
  },
  "assetGroupWorkId": "56cf1cf2-xxxx-xxxx-xxxx-00758573acdf",
  "assetGroupId": "ef233c93-xxxx-xxxx-xxxx-5e53e7a3c56b",
  "assetGroupWorkType": "AccountAssetClone",
  "status": "Pending",
  "attempts": 0,
  "createdDate": "2023-08-14T20:49:45.2754641Z",
  "message": "Awaiting Asset Group Work Job"
}
```

## 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), [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).
* Learn more about [cloning eSignature accounts](/docs/admin-api/admin101/clone-accounts).
* Learn [How to create a new active eSignature user](/docs/admin-api/how-to/create-active-user).
* See how to [Go-Live](/docs/admin-api/go-live) with a completed app and find the base path for API calls in the production environment.