> ## 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 组织管理

> 了解如何为白标合作伙伴关系管理账户组、账户和用户。

Yuno 提供一套 B2B 组织管理 API，专为需要管理多个子组织及其用户的平台和白标合作伙伴而设计。这些 API 让您可以通过创建由账户组、账户和用户组成的层级结构，实现商户 onboarding 的自动化。

> [!NOTE]
>
> **前提条件**
> 要使用这些 API，您的组织必须在 Yuno Dashboard 中启用 **whitelabel** 属性。请联系您的 Yuno 客户经理启用此功能。

## 核心管理流程

按照以下步骤设置新的商户环境。

**1. 创建账户组**

账户组作为您商户的父实体，集中管理相关账户。使用[创建账户组](https://docs.y.uno/reference/organizations/create-account-group.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 \
  --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"
  }'
```

**输出和后续步骤**：响应将包含账户组的唯一 `id`。请保存此 ID，因为您将在下一步中使用它创建具体的商户账户。

**2. 创建账户**

在新创建的账户组中，您可以创建一个或多个账户。此结构让您可以为同一商户区分业务逻辑、地区或业务线。使用[创建账户](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"
  }'
```

**输出和后续步骤**：您将收到商户账户的 `id`。此 ID 用于将支付、会话和配置的范围专门限定到此商户环境。

**3. 创建用户并分配权限**

最后，创建一个实际用户，并授予其对该账户或整个账户组的访问权限。分配角色（例如 `merchant-admin`）可确保该用户拥有管理商户 dashboard 所需的权限。使用[创建用户](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"
      }
    ]
  }'
```

**输出和后续步骤**：系统将创建该用户。要允许其登录您的白标门户，请使用[认证白标用户](https://docs.y.uno/reference/organizations/authenticate-whitelabel-user.md) endpoint 生成安全访问令牌。

## 嵌套账户组

账户组可以嵌套，以反映您组织的结构：一个组可以包含账户和子组，而子组也可以包含它自己的组。每个组最多只有一个父组，且一个组不能嵌套在它自己的子树中。

组在创建时始终是根组。要嵌套它，请在[更新账户组](https://docs.y.uno/reference/organizations/update-account-group.md)中设置 `parent_code`；发送 `parent_code: null` 可将其分离并使其重新成为根组。每个账户组响应都会在 `parent_code` 下报告父组（根组为 `null`）。

```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}"
  }'
```

嵌套仅涉及结构：移动组不会授予或撤销任何权限，因此现有用户权限不受影响。仍包含子组或账户的组无法删除，请先移动或[移除它们](https://docs.y.uno/reference/organizations/remove-account-from-group.md)。

## 通过 API 管理服务提供商

当您的商户可以登录后，您白标 dashboard 的 **Providers** 选项卡将决定他们可以连接哪些支付服务提供商，以及您的用户在连接时看到哪些内容。该叠加层可以通过 API 配置：您提供哪些服务提供商，以及为每个服务提供商显示的名称、连接说明、文档链接和徽标。

请参阅[白标服务提供商概述](https://docs.y.uno/reference/organizations/whitelabel/overview.md)，了解通用约定和 endpoint。

## 环境可用性

B2B 组织管理 API 在 **Sandbox** 和**生产环境**中均可用。有关如何管理 API 密钥和基础 URL 的更多信息，请访问[环境](https://docs.y.uno/zh-hans/docs/using-yuno/environments.md)页面。

## 后续步骤

浏览完整的 API 参考，了解更多高级管理选项：

* [账户组参考](https://docs.y.uno/reference/organizations/list-account-groups.md)
* [账户参考](https://docs.y.uno/reference/organizations/list-accounts.md)
* [用户参考](https://docs.y.uno/reference/organizations/list-users.md)
* [用户权限参考](https://docs.y.uno/reference/organizations/retrieve-user-account-permissions.md)
* [白标服务提供商参考](https://docs.y.uno/reference/organizations/whitelabel/overview.md)


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