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

# 创建内部转账

> 在两个 CBPay 账户之间划转余额,原子执行且始终免费——任意组合皆可:个人对个人、个人对企业、企业对个人或企业对企业。支持四个虚拟余额(默认 `USDT`、`USDC`、`BTC`、`GOLD`),且始终在**同一货币**的余额之间进行(不做兑换)。目标通过 `to_account_id`、`to_email`、`to_phone`(仅 OTP 已验证的手机号)或 `to_contact_id` 解析。每笔转账都会自动把收款人保存为联系人(用 `save_contact: false` 退出)。收款方的 webhook 订阅者会收到 `transfer_received`。



## OpenAPI

````yaml /openapi.zh.yaml post /v1/transfers
openapi: 3.1.0
info:
  title: CBPay API
  version: '1.89'
  description: >
    CBPay 是一个多币种支付平台:覆盖拉美的法币付款(payout)与收款(payin)、内部转账、链上充值与提现,以及 KYC
    筛查。每个账户持有四个相互独立的虚拟余额——USDT(运营货币)、USDC、BTC 和 GOLD(纯金克数)——它们绝不混合也不会自动兑换。

    payout 和服务费可从四个余额中的任意一个支付:

    用 `PUT /v1/settlement` 设置默认值,或在单笔 payout 中用

    `settlement_asset` 覆盖。


    所有金额均为十进制字符串,遵循各货币的精度(USDT/USDC/GOLD 为 6 位小数,BTC 为 8 位)。错误始终返回

    `{"error": "<code>", "message": "<detail>"}`。
servers:
  - url: https://api.qbank.cl/platform
    description: Live（生产环境，真实资金）
  - url: https://cryptobank.qbank.cl/platform
    description: Test（沙盒，模拟资金 — pk_test_ 密钥）
security:
  - bearerAuth: []
tags:
  - name: 凭证
    description: >-
      每笔操作的品牌化 PDF 凭证,附带公开的签名 QR 真伪校验、每个响应/webhook 中的
      receipt_url,以及最终状态时的自动邮件发送。
  - name: 身份认证
    description: 注册与登录账户成员。会话有效期 24 小时。
  - name: 账户
    description: 调用账户的档案、成员与 API key。
  - name: 余额
    description: 余额、流水历史与外汇汇率。
  - name: 付款(Payouts)
    description: 从你选择的结算余额扣款的法币派发(默认 USDT)。
  - name: 收款(Payins)
    description: 入账到 USDT 余额的法币充值。
  - name: 转账
  - name: 联系人
  - name: 兑换(Swaps)
    description: CBPay 账户之间的免费内部转账(个人或企业,任意组合)。
  - name: 加密货币
    description: 链上充值与提现(TRON、Ethereum 和 Bitcoin)。
  - name: 隔离钱包
    description: 拥有自身余额的链上钱包(企业不限数量;个人每个网络+资产组合 1 个)——创建、导入、发送、导出私钥与自动转发。余额存在于链上,从不进入账本。
  - name: QR Crypto POS
    description: >-
      面向拥有实体 POS 终端的处理商（企业账户）的定额加密货币二维码收款：已验证商户、每笔收款专属地址 +
      二维码、支付早期检测、按商户对账，以及经加密货币提现通道的退款。
  - name: KYC / KYB
  - name: AML 筛查
    description: 身份验证:个人 KYC、企业 KYB,含 AML 筛查、重新筛查与持续监控。
  - name: 钱包筛查
    description: 区块链地址的 AML 风险评估(制裁、非法资金暴露),按次收费;另附提现与充值的免费自动防护。
  - name: 分析
  - name: Webhooks
    description: 接收签名事件通知的订阅。
  - name: 状态
    description: 服务可用性。
  - name: 银行服务
    description: 真实银行账户:通过国际银行通道接收、持有与发送资金。
  - name: 卡片
    description: 以 Just-In-Time 方式从账户 USDT 余额消费的虚拟卡与实体卡,支持按卡设置消费限额。
  - name: 安全(OTP)
    description: >-
      通过 SMS/WhatsApp/email 发送的一次性验证码,保护敏感操作;并提供自助 2FA 偏好设置。仅适用于用户会话——API key
      豁免。
  - name: 通行密钥
    description: >-
      通过 WebAuthn 使用设备生物识别(Face ID、Touch ID、Windows
      Hello、安全密钥)的无密码登录、带备份码的验证器应用(TOTP),以及会话/设备管理。
  - name: 社交登录
    description: >-
      通过令牌交换以 Google、Apple、Microsoft 和 Facebook 实现无密码注册与登录。前端获取提供方凭证;API 验证后签发
      CBPay 会话。
paths:
  /v1/transfers:
    post:
      tags:
        - 转账
      summary: 创建内部转账
      description: >-
        在两个 CBPay 账户之间划转余额,原子执行且始终免费——任意组合皆可:个人对个人、个人对企业、企业对个人或企业对企业。支持四个虚拟余额(默认
        `USDT`、`USDC`、`BTC`、`GOLD`),且始终在**同一货币**的余额之间进行(不做兑换)。目标通过
        `to_account_id`、`to_email`、`to_phone`(仅 OTP 已验证的手机号)或 `to_contact_id`
        解析。每笔转账都会自动把收款人保存为联系人(用 `save_contact: false` 退出)。收款方的 webhook 订阅者会收到
        `transfer_received`。
      operationId: createTransfer
      parameters:
        - $ref: '#/components/parameters/idempotencyKeyHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - amount
              properties:
                to_account_id:
                  type: string
                  format: uuid
                to_email:
                  type: string
                  format: email
                to_phone:
                  type: string
                  description: >-
                    目标账户的 E.164 手机号。只有 OTP 已验证手机号的账户能被解析(否则 404
                    recipient_not_found;若多个账户共用该号码则 422 recipient_ambiguous)。
                to_contact_id:
                  type: string
                  format: uuid
                  description: 直接发送给通讯录中的联系人(使用其关联的 CBPay 账户,或其已验证的手机号)。
                to_qr_token:
                  type: string
                  description: >-
                    目标账户的个人资料二维码令牌(从其 CBPay
                    二维码扫描)。也接受扩展的结账二维码载荷(`cbpay:pay?to=…&checkout=…`)——嵌入的结账令牌会自动生效。
                checkout_token:
                  type: string
                  description: >-
                    可选的通用收款链接令牌,用于直接支付该链接。目的账户被强制为链接的账户,金额必须覆盖服务端以所选资产报价的应付额(否则返回
                    `422 checkout_amount_mismatch` 并附最新应付额)。完成后链接结清并自动兑换为其
                    `settlement_asset`。
                asset:
                  type: string
                  enum:
                    - USDT
                    - USDC
                    - BTC
                    - GOLD
                  default: USDT
                  description: 要划转的余额币种;接收方以同一币种入账。
                amount:
                  type: string
                  description: 正数十进制字符串,不超过该货币的小数位数(USDT/USDC/GOLD 为 6 位,BTC 为 8 位)。
                  example: '10.500000'
                description:
                  type: string
                idempotency_key:
                  type: string
                save_contact:
                  type: boolean
                  default: true
                  description: 收款目的地会自动保存为联系人;传 false 可跳过。
            examples:
              by_phone:
                summary: 按已验证手机号
                value:
                  to_phone: '+56987654321'
                  amount: '25.000000'
                  description: 午餐
                  idempotency_key: lunch-2026-07-10-a
              by_contact:
                summary: 发送给已保存的联系人
                value:
                  to_contact_id: 3f8a1b2c-4d5e-6f70-8a9b-0c1d2e3f4a5b
                  amount: '10.000000'
                  idempotency_key: t-991
              by_email:
                summary: 个人 → 个人,按邮箱
                value:
                  to_email: carlos@example.com
                  amount: '25.000000'
                  description: 费用分摊
                  idempotency_key: split-2026-07-06-a
              by_account_id:
                summary: 个人 → 企业,按 account_id
                value:
                  to_account_id: ae8cf540-22a9-414d-82cc-8ac04732be4f
                  amount: '120.500000'
                  description: 月度服务费
                  idempotency_key: serv-2026-07-a
              payroll:
                summary: 企业 → 个人(发薪)
                value:
                  to_email: employee@example.com
                  amount: '850.000000'
                  description: 七月工资
                  idempotency_key: payroll-2026-07-emp01
              gold:
                summary: 另一种货币(GOLD,黄金克数)
                value:
                  to_email: carlos@example.com
                  asset: GOLD
                  amount: '2.500000'
                  description: 黄金赠礼
                  idempotency_key: gold-2026-07-09-a
      responses:
        '200':
          description: 幂等重放。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Transfer'
              example:
                transfer_id: 2a7b9c1d-4e5f-6a70-8b9c-0d1e2f3a4b5c
                from_account_id: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
                to_account_id: 5e6f7a8b-9c0d-1e2f-3a4b-5c6d7e8f9a0b
                asset: USDT
                amount: '25.000000'
                description: 费用分摊
                status: completed
                created_at: '2026-07-07T12:00:00Z'
                idempotency_hit: true
        '201':
          description: 转账已完成。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Transfer'
              example:
                transfer_id: 2a7b9c1d-4e5f-6a70-8b9c-0d1e2f3a4b5c
                from_account_id: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
                to_account_id: 5e6f7a8b-9c0d-1e2f-3a4b-5c6d7e8f9a0b
                asset: USDT
                amount: '25.000000'
                description: 费用分摊
                status: completed
                created_at: '2026-07-07T12:00:00Z'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/InsufficientFunds'
        '404':
          description: 找不到目标(`recipient_not_found`)。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: recipient_not_found
                message: no account matches that email
        '422':
          description: 目标无法接收转账(`recipient_unavailable`)。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: recipient_unavailable
                message: destination account cannot receive transfers
components:
  parameters:
    idempotencyKeyHeader:
      name: Idempotency-Key
      in: header
      required: false
      description: '`idempotency_key` 请求体字段的替代方式。'
      schema:
        type: string
  schemas:
    Transfer:
      type: object
      properties:
        transfer_id:
          type: string
          format: uuid
        from_account_id:
          type: string
          format: uuid
        to_account_id:
          type: string
          format: uuid
        asset:
          type: string
          example: USDT
        amount:
          type: string
        description:
          type: string
        status:
          type: string
          example: completed
        created_at:
          type: string
          format: date-time
        idempotency_hit:
          type: boolean
    Error:
      type: object
      properties:
        error:
          type: string
          description: 机器可读的错误代码(snake_case)。
          example: insufficient_funds
        message:
          type: string
          description: 人类可读的说明。
  responses:
    BadRequest:
      description: 请求无效(具体校验见 `error` 代码)。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: invalid_json
            message: 'request body is not valid JSON: unknown field'
    Unauthorized:
      description: 凭证缺失或无效(`unauthorized`)。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: unauthorized
            message: invalid or missing credentials
    InsufficientFunds:
      description: 账户余额不足以完成此操作(`insufficient_funds`)。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: insufficient_funds
            message: account balance is not enough for this operation
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |
        会话 JWT(来自注册/登录)或 API key(`pk_...`)。
        也接受 `X-API-Key: <token>` 作为替代请求头。

````