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

# 创建连接

> 根据服务提供商目录填写凭证和配置，创建状态为 ACTIVE 的连接。

根据服务提供商目录填写凭证和配置，创建状态为 `ACTIVE` 的连接。响应中包含 `connection_id`，您将使用它在路由规则中引用此连接。

### 标头

**X-account-code** `string` *required*

创建连接所属账户的代码。账户由此标头决定，而不是由请求体决定。

**X-Idempotency-Key** `string` *required*

UUID，有效范围 24 小时。重新发送相同的键和请求体会返回缓存的响应；相同的键搭配不同的请求体会返回 `409`。

### 请求体

**merchant\_connection\_id** `string` *required*

您为此连接设置的标签。在账户内必须唯一。自由格式（例如 `"adyen-us-prod-001"`、`"stripe-eu-test"`）。

**provider\_id** `string` *required*

Yuno 服务提供商标识符（例如 `"STRIPE"`、`"ADYEN"`）。必须存在于目录中。

**flow\_type** `enum`

可选。默认为 `"PAYIN"`，这是唯一支持的值。

**payment\_methods** `string[]`

可选。服务提供商 `payment_method_type[]`（来自目录）的子集。

省略此字段即可启用该服务提供商支持的所有支付方式。服务提供商之后新增的支付方式也会添加到该连接中。

如果发送此字段，请至少包含一种支付方式。空数组（`[]`）会被驳回并返回 `400 VALIDATION_ERROR`：请省略该字段，或发送带值的字段。

**params** `object[]` *required*

您提供的每个参数对应一个 `{param_id, value}` 对。**扁平数组**：即使是嵌套的目录参数也在顶层提交；Yuno 会根据目录树解析层级关系。

必填参数（目录中 `optional: false` 的参数）必须存在且不能为空。激活一个 `boolean` 父项（`"value": true`）会使其 `optional: false` 的子项变为必填。

**项**

**param\_id** `string` *required*

目录中的确切 `param_id`。大小写敏感。

**value** `string | boolean | number | array` *required*

与目录中的 `field_type` 保持一致。数值以 JSON 数字提交（如果目录标明 `field_type: "string"`，则以字符串提交）。对于 `field_type: "array"`，请提交 JSON 数组。

**costs** `object[]`

可选。按连接设置的成本配置。如果连接没有成本，请省略此字段。`currency` 必须是该服务提供商支持的币种。

**项**

**sort\_number** `integer`

成本条目的优先级顺序。

**cost\_name** `string`

成本条目的标签。

**currency** `string`

ISO 4217 币种代码。

**cost\_values** `object`

**successful | unsuccessful**

**fixed\_fee** `number`

固定费用金额。

**percentage** `number`

百分比费用。

### 响应

**connection\_id** `string`

连接的唯一标识符。**请保存此值**，以便在路由规则中引用。

**merchant\_connection\_id** `string`

您为此连接设置的内部标签。

**provider\_id** `string`

此连接所属的服务提供商（例如 `ADYEN`）。

**status** `string`

当前状态（创建时始终为 `ACTIVE`）。

**flow\_type** `string`

始终为 `PAYIN`。

**payment\_methods** `string[]`

支持的支付方式列表。

**params** `object[]`

回显的参数。敏感值以 `***` 掩码显示。

**costs** `object[]`

连接的成本配置。

**created\_at** `string`

ISO 8601 时间戳。

**updated\_at** `string`

ISO 8601 时间戳。

```bash cURL theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
curl -X POST 'https://api.y.uno/v1/connections' \
  -H 'public-api-key: <YOUR_PUBLIC_KEY>' \
  -H 'private-secret-key: <YOUR_SECRET_KEY>' \
  -H 'X-account-code: <ACCOUNT_CODE>' \
  -H 'Content-Type: application/json' \
  -H 'X-Idempotency-Key: <UUID>' \
  -d '{
    "merchant_connection_id": "stripe-us-prod-001",
    "provider_id": "STRIPE",
    "flow_type": "PAYIN",
    "payment_methods": ["CARD"],
    "params": [
      { "param_id": "INTEGRATION_TYPE",             "value": "STRIPE_CHARGES" },
      { "param_id": "SECRET_KEY",                   "value": "sk_live_..." },
      { "param_id": "RADAR_FRAUD_ANALYSIS",         "value": false },
      { "param_id": "SEND_RECEIPT_EMAIL_PARAMETER", "value": false },
      { "param_id": "SETUP_FUTURE_USAGE",           "value": false },
      { "param_id": "ORDER_ID",                     "value": "DEFAULT" }
    ],
    "costs": [
      {
        "sort_number": 1,
        "cost_name": "Transaction Fee",
        "currency": "USD",
        "cost_values": {
          "successful":   { "fixed_fee": 0.30, "percentage": 2.9 },
          "unsuccessful": { "fixed_fee": 0.0,  "percentage": 0.0 }
        }
      }
    ]
  }'
```

```json 201 Created — Stripe theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "connection_id": "f1a3c4d5-7b8e-4a2c-9d1e-3f4a5b6c7d8e",
  "merchant_connection_id": "stripe-us-prod-001",
  "provider_id": "STRIPE",
  "status": "ACTIVE",
  "flow_type": "PAYIN",
  "payment_methods": ["CARD"],
  "params": [
    { "param_id": "INTEGRATION_TYPE",             "value": "STRIPE_CHARGES" },
    { "param_id": "SECRET_KEY",                   "value": "***" },
    { "param_id": "RADAR_FRAUD_ANALYSIS",         "value": false },
    { "param_id": "SEND_RECEIPT_EMAIL_PARAMETER", "value": false },
    { "param_id": "SETUP_FUTURE_USAGE",           "value": false },
    { "param_id": "ORDER_ID",                     "value": "DEFAULT" }
  ],
  "costs": [
    {
      "sort_number": 1,
      "cost_name": "Transaction Fee",
      "currency": "USD",
      "cost_values": {
        "successful":   { "fixed_fee": 0.30, "percentage": 2.9 },
        "unsuccessful": { "fixed_fee": 0.0,  "percentage": 0.0 }
      }
    }
  ],
  "created_at": "2026-05-12T10:24:00Z",
  "updated_at": "2026-05-12T10:24:00Z"
}
```

```json 201 Created — Adyen theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "connection_id": "b2c4d5e6-1a2b-3c4d-5e6f-7a8b9c0d1e2f",
  "merchant_connection_id": "adyen-eu-prod-001",
  "provider_id": "ADYEN",
  "status": "ACTIVE",
  "flow_type": "PAYIN",
  "payment_methods": ["CARD", "GOOGLE_PAY"],
  "params": [
    { "param_id": "merchantAccount",        "value": "ACME_LIVE" },
    { "param_id": "x-api-key",              "value": "***" },
    { "param_id": "transaction-identifier", "value": "MERCHANT_REFERENCE" }
  ],
  "created_at": "2026-05-12T10:31:42Z",
  "updated_at": "2026-05-12T10:31:42Z"
}
```

```json 400 — Missing Param theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "type": "validation_error",
  "code": "MISSING_REQUIRED_PARAM",
  "message": "Required param 'SECRET_KEY' is missing for provider 'STRIPE'",
  "details": { "provider_id": "STRIPE", "param_id": "SECRET_KEY" }
}
```

```json 409 — Conflict theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "type": "conflict",
  "code": "CONNECTION_MERCHANT_ID_CONFLICT",
  "message": "A connection with merchant_connection_id 'stripe-us-prod-001' already exists in this account",
  "details": { "merchant_connection_id": "stripe-us-prod-001" }
}
```

> [!NOTE]
>
> Yuno 会根据服务提供商目录校验 `param_id` 值、必填参数和 `costs[].currency`。它不会调用服务提供商来检查凭证，因此错误的密钥也会以 `201` 被接受。

> [!NOTE]
>
> **密钥信息处理**：目录中标记为 `secret: true` 的任何参数都会以 `"value": "***"` 返回。您提交的密钥信息以加密形式存储，绝不会回显。

### 错误

| HTTP | `code` |
| - | - |
| `400` | `PROVIDER_NOT_FOUND` 未知的 `provider_id`。 |
| `400` | `MISSING_REQUIRED_PARAM` 缺少必填参数。`details.param_id` 指明缺少的是哪一个。 |
| `400` | `UNSUPPORTED_PAYMENT_METHOD` `payment_methods` 包含该服务提供商不支持的支付方式。 |
| `400` | `NO_SUPPORTED_PAYMENT_METHODS` 省略了 `payment_methods`，且该服务提供商没有适用于该连接集成类型的支付方式。 |
| `400` | `VALIDATION_ERROR` 请求体未通过校验，例如 `payment_methods` 以空数组发送。`details` 指明出错的字段。 |
| `400` | `UNSUPPORTED_CURRENCY` 某个 `costs[].currency` 不在该服务提供商支持的列表中。 |
| `401` | `NOT_AUTHENTICATED` API 密钥缺失或无效。 |
| `409` | `CONNECTION_MERCHANT_ID_CONFLICT` `merchant_connection_id` 已存在于此账户中。 |


## OpenAPI

````yaml openapi/zh-hans/organizations/connections/create-connection.json POST /connections
openapi: 3.1.0
info:
  title: Connections API - Create
  version: 1.0.0
servers:
  - url: https://api-sandbox.y.uno/v1
    description: Sandbox
  - url: https://api.y.uno/v1
    description: Production (US)
security:
  - sec0: []
    sec1: []
paths:
  /connections:
    post:
      summary: 创建连接
      description: 创建状态为 ACTIVE 的连接。
      operationId: create-connection
      parameters:
        - name: X-account-code
          in: header
          required: true
          description: 拥有该连接的账户。
          schema:
            type: string
        - name: X-Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - merchant_connection_id
                - provider_id
                - params
              properties:
                merchant_connection_id:
                  type: string
                  example: stripe-us-prod-001
                provider_id:
                  type: string
                  example: STRIPE
                flow_type:
                  type: string
                  description: 可选。默认为 PAYIN。
                  example: PAYIN
                payment_methods:
                  type: array
                  items:
                    type: string
                  minItems: 1
                  description: >-
                    可选。服务提供商 payment_method_type[]
                    的子集。省略则启用服务提供商支持的所有支付方式，包括以后新增的。如果发送，必须至少包含一个值：空数组会被拒绝，并返回
                    400 VALIDATION_ERROR。
                  example:
                    - CARD
                params:
                  type: array
                  items:
                    type: object
                    properties:
                      param_id:
                        type: string
                      value:
                        type:
                          - string
                          - boolean
                          - number
                          - array
                costs:
                  type: array
                  description: 可选。每个连接的成本配置。
                  items:
                    type: object
                    properties:
                      sort_number:
                        type: integer
                      cost_name:
                        type: string
                      currency:
                        type: string
                      cost_values:
                        type: object
            example:
              merchant_connection_id: stripe-us-prod-001
              provider_id: STRIPE
              flow_type: PAYIN
              payment_methods:
                - CARD
              params:
                - param_id: INTEGRATION_TYPE
                  value: STRIPE_CHARGES
                - param_id: SECRET_KEY
                  value: sk_live_...
                - param_id: RADAR_FRAUD_ANALYSIS
                  value: false
                - param_id: SEND_RECEIPT_EMAIL_PARAMETER
                  value: false
                - param_id: SETUP_FUTURE_USAGE
                  value: false
                - param_id: ORDER_ID
                  value: DEFAULT
              costs:
                - sort_number: 1
                  cost_name: Transaction Fee
                  currency: USD
                  cost_values:
                    successful:
                      fixed_fee: 0.3
                      percentage: 2.9
                    unsuccessful:
                      fixed_fee: 0
                      percentage: 0
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  connection_id:
                    type: string
                    example: f1a3c4d5-7b8e-4a2c-9d1e-3f4a5b6c7d8e
                  merchant_connection_id:
                    type: string
                    example: stripe-us-prod-001
                  provider_id:
                    type: string
                    example: STRIPE
                  status:
                    type: string
                    example: ACTIVE
                  flow_type:
                    type: string
                    example: PAYIN
                  payment_methods:
                    type: array
                    items:
                      type: string
                    example:
                      - CARD
                  params:
                    type: array
                    items:
                      type: object
                  costs:
                    type: array
                    items:
                      type: object
                  created_at:
                    type: string
                    format: date-time
                    example: '2026-05-12T10:24:00Z'
                  updated_at:
                    type: string
                    format: date-time
                    example: '2026-05-12T10:24:00Z'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: validation_error
                  code:
                    type: string
                    example: MISSING_REQUIRED_PARAM
                  message:
                    type: string
                    example: Required param 'SECRET_KEY' is missing
                  details:
                    type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: auth_error
                  code:
                    type: string
                    example: NOT_AUTHENTICATED
                  message:
                    type: string
                    example: Not authenticated
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    example: conflict
                  code:
                    type: string
                    example: CONNECTION_MERCHANT_ID_CONFLICT
                  message:
                    type: string
                    example: >-
                      A connection with this merchant_connection_id already
                      exists
components:
  securitySchemes:
    sec0:
      type: apiKey
      in: header
      name: PUBLIC-API-KEY
      x-default: <Your PUBLIC-API-KEY>
    sec1:
      type: apiKey
      in: header
      name: PRIVATE-SECRET-KEY
      x-default: <Your PRIVATE-SECRET-KEY>

````

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