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

# Getting started

> Start programatically accepting payments, paying other people, and building businesses.

# Use cases

1. Create a checkout configuration
2. Onboard sub-merchants
3. Complete your own KYC
4. Programmatically pay out users
5. Generate KYC links for your users
6. Build chat bots

<CodeGroup>
  ```bash Typescript theme={null}
  pnpm install @whop/sdk
  ```

  ```bash Python theme={null}
  pip install whop-sdk
  ```

  ```bash Ruby theme={null}
  gem install whop_sdk
  ```
</CodeGroup>

Before you begin, you will need to obtain an API key from [here](https://whop.com/dashboard/developer/).

<CodeGroup>
  ```python Python theme={null}
  from whop_sdk import Whop, BadRequestError
  import random

  client = Whop(
      api_key="YOUR_API_KEY",
  )

  your_company_id = "YOUR_COMPANY_ID"

  # 1. Create a checkout configuration
  checkout = client.checkout_configurations.create(
      currency="usd",
      plan={
          "initial_price": 10.0,
          "plan_type": "one_time",
          "company_id": your_company_id,
          "currency": "usd",
          "payment_method_configuration": {
              "enabled": [
                  "crypto", # low fees
                  "us_bank_transfer", # very low fees
                  "apple_pay", # standard cc rates
              ],
              "disabled": [
                  "acss_debit",
                  "affirm",
                  "afterpay_clearpay",
                  "alipay",
                  "alma",
                  "amazon_pay",
              ],
          },
      },
      metadata={
          "order_id": "order_12345",
      },
  )

  checkout_link = f"https://whop.com/checkout/{checkout.plan.id}"
  print(f"\n✅ Checkout created → {checkout_link}\n   (redirect customers here to pay or embed it)")
  input("\nPress Enter to continue...")

  # 2. Onboard sub-merchants to pay them out
  sub_merchant = client.companies.create(
      email="merchant@example.com",
      parent_company_id=your_company_id,
      title="Acme Merchant Store #" + str(random.randint(1, 200)),
      # logo=FileAttachment("https://example.com/logo.png"),
      metadata={
          "internal_user_id": "user_12345",
          "seller_tier": "gold",
      },
  )
  print(f"\n✅ Sub-merchant onboarded → {sub_merchant.id}")

  # 2.5 KYC yourself (skip if you have already done this)
  print(f"\n🔐 Complete your KYC before transferring:\n   https://whop.com/payouts/{sub_merchant.id}/verify/")
  input("\nPress Enter when done...")

  # 3. Programmatically pay out users
  while True:
      try:
          transfer = client.transfers.create(
              amount=1.0,
              currency="usd",
              origin_id=your_company_id,
              destination_id=sub_merchant.id,
              metadata={"reason": "creator_payout"},
          )
          print(f"\n✅ Transfer complete → {transfer.id}")
          break
      except BadRequestError as e:
          print(f"\n❌ Transfer failed: {e}")
          input("\nFix the issue above, then press Enter to retry...")


  # 4. KYC users
  account_link = client.account_links.create(
      company_id=sub_merchant.id,
      refresh_url="https://yourapp.com/onboarding/refresh",
      return_url="https://yourapp.com/onboarding/complete",
      use_case="account_onboarding",
  )
  print(f"\n✅ Account link created → {account_link.url}\n   (give this to your users to complete KYC)")

  # 5. Build chat bots
  message = client.messages.create(
      channel_id="channel_xxxxxxxxxxxxx",
      content="Hello from my bot! **Markdown** is supported",
  )
  print(f"\n✅ Message sent → {message.id}")
  ```

  ```typescript Typescript theme={null}
  import Whop from "@whop/sdk";
  import * as readline from "node:readline/promises";

  const client = new Whop({
    apiKey: "YOUR_API_KEY",
  });

  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
  const yourCompanyId = "YOUR_COMPANY_ID";

  // 1. Create a checkout configuration
  const checkout = await client.checkoutConfigurations.create({
    currency: "usd",
    plan: {
      initial_price: 10.0,
      plan_type: "one_time",
      company_id: yourCompanyId,
      currency: "usd",
      payment_method_configuration: {
        enabled: [
          "crypto", // low fees
          "us_bank_transfer", // very low fees
          "apple_pay", // standard cc rates
        ],
        disabled: [
          "acss_debit",
          "affirm",
          "afterpay_clearpay",
          "alipay",
          "alma",
          "amazon_pay",
        ],
      },
    },
    metadata: {
      order_id: "order_12345",
    },
  });

  const checkoutLink = `https://whop.com/checkout/${checkout.plan.id}`;
  console.log(`\n✅ Checkout created → ${checkoutLink}\n   (redirect customers here to pay or embed it)`);
  await rl.question("\nPress Enter to continue...");

  // 2. Onboard sub-merchants to pay them out
  const subMerchant = await client.companies.create({
    email: "merchant@example.com",
    parent_company_id: yourCompanyId,
    title: `Acme Merchant Store #${Math.floor(Math.random() * 200) + 1}`,
    // logo: new File([...], "logo.png"),
    metadata: {
      internal_user_id: "user_12345",
      seller_tier: "gold",
    },
  });
  console.log(`\n✅ Sub-merchant onboarded → ${subMerchant.id}`);

  // 2.5 KYC yourself (skip if you have already done this)
  console.log(`\n🔐 Complete your KYC before transferring:\n   https://whop.com/payouts/${subMerchant.id}/verify/`);
  await rl.question("\nPress Enter when done...");

  // 3. Programmatically pay out users
  while (true) {
    try {
      const transfer = await client.transfers.create({
        amount: 1.0,
        currency: "usd",
        origin_id: yourCompanyId,
        destination_id: subMerchant.id,
        metadata: { reason: "creator_payout" },
      });
      console.log(`\n✅ Transfer complete → ${transfer.id}`);
      break;
    } catch (err) {
      if (err instanceof Whop.BadRequestError) {
        console.log(`\n❌ Transfer failed: ${err.message}`);
        await rl.question("\nFix the issue above, then press Enter to retry...");
        continue;
      }
      throw err;
    }
  }

  // 4. KYC users
  const accountLink = await client.accountLinks.create({
    company_id: subMerchant.id,
    refresh_url: "https://yourapp.com/onboarding/refresh",
    return_url: "https://yourapp.com/onboarding/complete",
    use_case: "account_onboarding",
  });
  console.log(`\n✅ Account link created → ${accountLink.url}\n   (give this to your users to complete KYC)`);

  // 5. Build chat bots
  const message = await client.messages.create({
    channel_id: "channel_xxxxxxxxxxxxx",
    content: "Hello from my bot! **Markdown** is supported",
  });
  console.log(`\n✅ Message sent → ${message.id}`);

  rl.close();
  ```

  ```ruby Ruby theme={null}
  require "whop_sdk"

  whop = WhopSDK::Client.new(
    api_key: "YOUR_API_KEY",
  )

  your_company_id = "YOUR_COMPANY_ID"

  # 1. Create a checkout configuration
  checkout = whop.checkout_configurations.create(
    currency: "usd",
    plan: {
      initial_price: 10.0,
      plan_type: "one_time",
      company_id: your_company_id,
      currency: "usd",
      payment_method_configuration: {
        enabled: [
          "crypto", # low fees
          "us_bank_transfer", # very low fees
          "apple_pay", # standard cc rates
        ],
        disabled: [
          "acss_debit",
          "affirm",
          "afterpay_clearpay",
          "alipay",
          "alma",
          "amazon_pay",
        ],
      },
    },
    metadata: {
      order_id: "order_12345",
    },
  )

  checkout_link = "https://whop.com/checkout/#{checkout.plan.id}"
  puts "\n✅ Checkout created → #{checkout_link}\n   (redirect customers here to pay or embed it)"
  print "\nPress Enter to continue..."
  gets

  # 2. Onboard sub-merchants to pay them out
  sub_merchant = whop.companies.create(
    email: "merchant@example.com",
    parent_company_id: your_company_id,
    title: "Acme Merchant Store ##{rand(1..200)}",
    metadata: {
      internal_user_id: "user_12345",
      seller_tier: "gold",
    },
  )
  puts "\n✅ Sub-merchant onboarded → #{sub_merchant.id}"

  # 2.5 KYC yourself (skip if you have already done this)
  puts "\n🔐 Complete your KYC before transferring:\n   https://whop.com/payouts/#{sub_merchant.id}/verify/"
  print "\nPress Enter when done..."
  gets

  # 3. Programmatically pay out users
  loop do
    begin
      transfer = whop.transfers.create(
        amount: 1.0,
        currency: "usd",
        origin_id: your_company_id,
        destination_id: sub_merchant.id,
        metadata: { reason: "creator_payout" },
      )
      puts "\n✅ Transfer complete → #{transfer.id}"
      break
    rescue WhopSDK::Errors::BadRequestError => e
      puts "\n❌ Transfer failed: #{e.message}"
      print "\nFix the issue above, then press Enter to retry..."
      gets
    end
  end

  # 4. KYC users
  account_link = whop.account_links.create(
    company_id: sub_merchant.id,
    refresh_url: "https://yourapp.com/onboarding/refresh",
    return_url: "https://yourapp.com/onboarding/complete",
    use_case: "account_onboarding",
  )
  puts "\n✅ Account link created → #{account_link.url}\n   (give this to your users to complete KYC)"

  # 5. Build chat bots
  message = whop.messages.create(
    channel_id: "channel_xxxxxxxxxxxxx",
    content: "Hello from my bot! **Markdown** is supported",
  )
  puts "\n✅ Message sent → #{message.id}"
  ```
</CodeGroup>

# API Keys

<AccordionGroup>
  <Accordion title="Company API keys" icon="building">
    Use company API keys when you only want to fetch data, or perform actions for your own company,
    and or [connected account companies](/supported-business-models/platforms).

    1. Go to [your developer dashboard](https://whop.com/dashboard/developer).
    2. Click the "Create" button in the "Company API Keys" section
    3. Give your api key a name. For example "Data pipeline" or "GHL Integration"
    4. Select a role or a custom set of permissions. (You can always update this later and add more if you need)
    5. Create the api key, and copy it from the modal.
  </Accordion>

  <Accordion title="App API keys" icon="code">
    Use app API keys when you are building an app and need to access data on companies that have installed your app.

    1. Go to [your developer dashboard](https://whop.com/dashboard/developer).
    2. Click the **Create app** button and give your app a name. *You can change this name later.*
    3. Your API key is the hidden text after `WHOP_API_KEY` in the `Environment variables` section.
       Use the reveal button to show the key, copy it and keep it in a safe place.
       You will need it to make API calls.
  </Accordion>

  <Accordion title="OAuth tokens" icon="user">
    Use OAuth tokens when you want users to sign in with their Whop account and grant your app permission to act on their behalf. Unlike API keys which use your app's permissions, OAuth tokens are scoped to what each individual user can access.

    Common use cases:

    * "Sign in with Whop" authentication
    * Accessing a user's memberships, purchases, or profile
    * Performing actions as a specific user (not as your app)

    OAuth tokens are obtained through the OAuth 2.1 + PKCE flow:

    1. Redirect users to Whop's authorization page
    2. User logs in and approves your requested scopes
    3. Exchange the authorization code for access and refresh tokens
    4. Use the access token as your API key in SDK calls or the `Authorization` header

    See the [OAuth guide](/developer/guides/oauth) for full implementation details.
  </Accordion>
</AccordionGroup>

# Making API calls

Our public api is available at `https://api.whop.com/api/v1`

You can test the api by using curl to fetch your public user profile data:

```bash theme={null}
# replace "j" with your own whop username
curl https://api.whop.com/api/v1/users/j
```

To make authenticated requests you need to include your API key in the `Authorization` header using the `Bearer` scheme:

```bash theme={null}
# replace "YOUR_API_KEY" with your real API key
curl https://api.whop.com/api/v1/payments?company_id=biz_xxxxxxxxxxx \
    -H "Authorization: Bearer YOUR_API_KEY"
```

# SDK Reference

* [Typescript / Javascript](https://npmjs.com/package/@whop/sdk) / [Docs](https://github.com/whopio/whopsdk-typescript)
* [Python](https://pypi.org/project/whop-sdk) / [Docs](https://github.com/whopio/whopsdk-python)
* [Ruby](https://rubygems.org/gems/whop-sdk) / [Docs](https://github.com/whopio/whopsdk-ruby)

## MCP

You can also access the API via our mcp server available at
`https://mcp.whop.com/mcp` (cursor) or `https://mcp.whop.com/sse` (claude)

[Learn more here](/developer/guides/ai_and_mcp)
