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

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# B2B Organization Management

> Learn how to manage account groups, accounts, and users for whitelabel partnerships.

Yuno provides a suite of B2B Organization Management APIs designed for platforms and whitelabel partners who need to manage multiple sub-organizations and their users. These APIs allow you to automate your merchants' onboarding by creating a hierarchical structure of Account Groups, Accounts, and Users.

> [!NOTE]
>
> **Prerequisites**
> To use these APIs, your organization must have the **whitelabel** property enabled in the Yuno Dashboard. Contact your Yuno account manager to enable this feature.

## Core Management Flow

Follow these steps to set up a new merchant environment.

**1. Create an Account Group**

The account group acts as the parent entity for your merchant, centralizing the management of related accounts. Use the [Create Account Group](https://docs.y.uno/reference/organizations/create-account-group.md) endpoint to initialize this group.

```bash theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
curl --request POST \
  --url https://api-sandbox.y.uno/v1/organizations/account-groups \
  --header 'PRIVATE-SECRET-KEY: <YOUR_PRIVATE_SECRET_KEY>' \
  --header 'PUBLIC-API-KEY: <YOUR_PUBLIC_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Acme Payments",
    "merchant_id": "acme_001"
  }'
```

**Output & Next Steps**: The response will include a unique `id` for the Account Group. Store this ID, as you will need it to create specific merchant accounts in the next step.

**2. Create an Account**

Within the newly created account group, you can create one or more accounts. This structure allows you to separate business logic, regions, or business lines for the same merchant. Use the [Create Account](https://docs.y.uno/reference/organizations/create-account.md) endpoint.

```bash theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
curl --request POST \
  --url https://api-sandbox.y.uno/v1/organizations/account-groups/{account_group_id}/accounts \
  --header 'PRIVATE-SECRET-KEY: <YOUR_PRIVATE_SECRET_KEY>' \
  --header 'PUBLIC-API-KEY: <YOUR_PUBLIC_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Acme Production"
  }'
```

**Output & Next Steps**: You will receive an `id` for the merchant account. This ID is used to scope payments, sessions, and configurations specifically to this merchant environment.

**3. Create a User and Assign Permissions**

Finally, create a physical user and grant them access to the account or the entire account group. Assigning roles (like `merchant-admin`) ensures the user has the necessary permissions to manage the merchant dashboard. Use the [Create User](https://docs.y.uno/reference/organizations/create-user.md) endpoint.

```bash theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
curl --request POST \
  --url https://api-sandbox.y.uno/v1/organizations/users \
  --header 'PRIVATE-SECRET-KEY: <YOUR_PRIVATE_SECRET_KEY>' \
  --header 'PUBLIC-API-KEY: <YOUR_PUBLIC_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "email": "admin@acmepay.com",
    "first_name": "John",
    "last_name": "Doe",
    "account_group_permissions": [
      {
        "account_group_id": "{account_group_id}",
        "role_id": "merchant-admin"
      }
    ]
  }'
```

**Output & Next Steps**: The user will be created in the system. To allow them to log in to your whitelabel portal, use the [Authenticate Whitelabel User](https://docs.y.uno/reference/organizations/authenticate-whitelabel-user.md) endpoint to generate a secure access token.

## Nest account groups

Account groups can be nested to mirror how your organization is structured: a group can hold accounts and sub-groups, and a sub-group can hold groups of its own. Every group has at most one parent, and a group cannot be nested inside its own subtree.

A group is always created as a root. To nest it, set `parent_code` on [Update Account Group](https://docs.y.uno/reference/organizations/update-account-group.md); send `parent_code: null` to detach it and make it a root again. Every account-group response reports the parent under `parent_code` (`null` for a root).

```bash theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
curl --request PATCH \
  --url https://api-sandbox.y.uno/v1/organizations/account-groups/{account_group_id} \
  --header 'PRIVATE-SECRET-KEY: <YOUR_PRIVATE_SECRET_KEY>' \
  --header 'PUBLIC-API-KEY: <YOUR_PUBLIC_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "parent_code": "{parent_account_group_id}"
  }'
```

Nesting is structural only: moving a group grants and revokes nothing, so existing user permissions are untouched. A group that still has sub-groups or accounts cannot be deleted — move or [remove them](https://docs.y.uno/reference/organizations/remove-account-from-group.md) first.

## Manage providers through the API

Once your merchants can log in, the **Providers** tab of your white-label dashboard decides which payment providers they can connect to, and what your users read while they do it. That overlay is configurable through the API: which providers you offer, and the name, connection instructions, documentation link and logo shown for each one.

See the [White-label Providers Overview](https://docs.y.uno/reference/organizations/whitelabel/overview.md) for the common contract and the endpoints.

## Environment Availability

The B2B Organization Management APIs are available in both **Sandbox** and **Production** environments. For more information on how to manage your API keys and base URLs, visit the [Environments](https://docs.y.uno/docs/using-yuno/environments.md) page.

## Next Steps

Explore the full API reference for more advanced management options:

* [Account Groups Reference](https://docs.y.uno/reference/organizations/list-account-groups.md)
* [Accounts Reference](https://docs.y.uno/reference/organizations/list-accounts.md)
* [Users Reference](https://docs.y.uno/reference/organizations/list-users.md)
* [User Permissions Reference](https://docs.y.uno/reference/organizations/retrieve-user-account-permissions.md)
* [White-label Providers Reference](https://docs.y.uno/reference/organizations/whitelabel/overview.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.