> ## Documentation Index
> Fetch the complete documentation index at: https://docs.whop.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Search and read these docs, and act on live Whop data, with the Whop MCP server: https://mcp.whop.com/mcp (browser sign-in, no API key in the client config). Setup: https://docs.whop.com/developer/guides/ai_and_mcp.md

# Enroll Subaccounts

> Onboard businesses or individuals to your platform and facilitate payments

To enroll a subaccount on your platform, create an Account object for them under your platform account. That account can then accept direct charges, receive transfers, and use Whop payout flows.

## Example

Create an account for the subaccount:

```typescript TypeScript theme={null}
import { WhopClient } from "@whop/sdk";

const client = new WhopClient({
	token: "Account API Key",
});

const account = await client.accounts.create({
	email: "merchant@example.com",
	title: "Acme Merchant Store",
	metadata: {
		external_id: "user_12345",
		seller_tier: "gold",
	},
});

console.log(account.id);
```

```python Python theme={null}
from whop_sdk import Whop

client = Whop(
    token="Account API Key",
)

account = client.accounts.create(
    email="merchant@example.com",
    title="Acme Merchant Store",
    metadata={
        "external_id": "user_12345",
        "seller_tier": "gold",
    },
)

print(account.id)
```

```rust Rust theme={null}
use whop_sdk::prelude::*;

let config = ClientConfig {
    token: Some("Account API Key".to_string()),
    ..Default::default()
};
let client = Whop::new(config).expect("Failed to build client");

let account = client
    .accounts
    .create(
        &CreateAccountsRequest {
            email: Some("merchant@example.com".to_string()),
            title: "Acme Merchant Store".to_string(),
            metadata: Some(HashMap::from([
                ("external_id".to_string(), json!("user_12345")),
                ("seller_tier".to_string(), json!("gold")),
            ])),
            ..Default::default()
        },
        None,
    )
    .await?;

println!("{}", account.id);
```

```go Go theme={null}
import (
    "context"
    "fmt"
    "log"

    whopsdk "github.com/whopio/whopsdk-go/v2"
    "github.com/whopio/whopsdk-go/v2/client"
    "github.com/whopio/whopsdk-go/v2/option"
)

client := client.NewWhop(option.WithToken("Account API Key"))

account, err := client.Accounts.Create(context.TODO(), &whopsdk.CreateAccountsRequest{
    Email: whopsdk.String("merchant@example.com"),
    Title: "Acme Merchant Store",
    Metadata: map[string]any{
        "external_id": "user_12345",
        "seller_tier":      "gold",
    },
})
if err != nil {
    log.Fatal(err)
}

fmt.Println(account.ID)
```

In this example:

* `email` is the subaccount's email address. Whop uses it to identify the subaccount and send important notifications.
* The Account API key determines which platform account owns the subaccount.
* `title` is the required display name for the subaccount.
* `metadata` contains custom key-value pairs:
  * `external_id`: Your platform's identifier for this subaccount. Whop uses it to tell apart subaccounts that share an email address.
  * `seller_tier`: A classification or tier level for the subaccount (e.g., "bronze," "silver," or "gold")
* The response includes an `account.id` that you can use to reference this subaccount in future API calls

> [!TIP]
>
> The email address should belong to the subaccount (business or
> individual) who will be managing the account. This person will receive account
> setup and payment notifications.

## Reusing an email address

Several subaccounts can share one email address, as long as each one has a distinct `metadata.external_id`. Creating an account is idempotent on the email and `external_id` pair:

* **New `external_id`**: Whop creates a new subaccount, even when the email is already in use.
* **Same email and `external_id`**: Whop returns the existing subaccount instead of creating a duplicate, so retries are safe.
* **No `external_id`**: Whop returns the existing subaccount for that email that has no `external_id`, if there is one.

Accounts that share an email are managed by the same Whop user, the person who receives that inbox.

## Finish onboarding

If the recipient doesn't already have a Whop account, send them an account onboarding link after you create the account. They complete Know Your Customer (KYC) verification through that link, and then the account can receive transfers and other payout flows.

```typescript TypeScript theme={null}
const accountLink = await client.accountLinks.create({
	company_id: account.id,
	refresh_url: "https://yourapp.com/onboarding/refresh",
	return_url: "https://yourapp.com/onboarding/complete",
	use_case: "account_onboarding",
});

console.log(accountLink.url);
```

```python Python theme={null}
account_link = client.account_links.create(
    company_id=account.id,
    refresh_url="https://yourapp.com/onboarding/refresh",
    return_url="https://yourapp.com/onboarding/complete",
    use_case="account_onboarding",
)

print(account_link.url)
```

```rust Rust theme={null}
let account_link = client
    .account_links
    .create(
        &CreateAccountLinksRequest {
            company_id: "biz_xxxxxxxxxxxxx".to_string(),
            refresh_url: "https://yourapp.com/onboarding/refresh".to_string(),
            return_url: "https://yourapp.com/onboarding/complete".to_string(),
            use_case: AccountLinkUseCases::AccountOnboarding,
        },
        None,
    )
    .await?;

println!("{}", account_link.url);
```

```go Go theme={null}
accountLink, err := client.AccountLinks.Create(context.TODO(), &whopsdk.CreateAccountLinksRequest{
    CompanyID:  "biz_xxxxxxxxxxxxx",
    RefreshURL: "https://yourapp.com/onboarding/refresh",
    ReturnURL:  "https://yourapp.com/onboarding/complete",
    UseCase:    whopsdk.AccountLinkUseCasesAccountOnboarding,
})
if err != nil {
    log.Fatal(err)
}

fmt.Println(accountLink.URL)
```

After the recipient completes onboarding, you can:

* create checkout flows for them with application fees.
* transfer funds to their account balance.
* let them withdraw funds with the payout portal.

## Getting started

Before you can enroll subaccounts, you need to set up your platform account:

1. **Sign up for a platform account**: Create an account at [whop.com/dashboard](https://whop.com/dashboard)
2. **Generate an Account API key**: Go to your developer settings page and generate an Account API key
3. **Use the API key for authentication**: This API key is how you authenticate with the Current API and control your subaccounts

The Account API key provides the necessary permissions to create and manage subaccounts under your platform account.

## Custom metadata

You can attach custom metadata to accounts when creating them. Metadata lets you store additional information about each subaccount as key-value pairs. This is useful for:

* Storing your internal user or merchant identifiers
* Tracking subaccount tiers or classifications
* Linking to your platform's database records

Whop stores metadata on the Account object. You can retrieve it later for reporting, filtering, or integration purposes.

## API reference

> [card] [Create Account API](https://docs.whop.com/api-reference/beta/accounts/create-account.md)
>
> See the full API reference for creating accounts and all available parameters

## Next steps

After creating an Account for a subaccount:

> [card] [Collect and split payments](https://docs.whop.com/developer/platforms/collect-payments-for-subaccounts.md)
>
> Choose between direct charges and transfers

> [card] [Render payout portal](https://docs.whop.com/developer/platforms/render-payout-portal.md)
>
> Let subaccounts withdraw their funds


## Related topics

- [Collect Payments for Subaccounts](https://docs.whop.com/developer/platforms/collect-payments-for-subaccounts.md)
- [Sync Your Users](https://docs.whop.com/developer/guides/chat/sync-users.md)
- [Platform Quickstart](https://docs.whop.com/developer/platforms/quickstart.md)
