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

# 更新产品

> 修改产品的名称或描述。

请使用属于该产品所在组织、且为全部权限或勾选了 `products:products:write` 权限（控制台中“可创建和修改”下的**产品**）的 API 密钥进行认证。只有 `Owner` 和 `Admin` 角色可以授予该权限。

* `id` 是你组织内的产品 ID，无论该产品是通过 API 还是在控制台创建的。
* 请求体包含 `name` 和 `description`，均为可选。只有你传入的字段会被修改。
* 响应结构与[读取产品](https://docs.anyway.sh/zh/api-reference/endpoint/get-product.md)相同。
* 未知字段会被拒绝，返回 `400`。该接口没有 `Idempotency-Key`。

> [!NOTE]
>
> 银行卡结账页显示的是产品的名称和描述，因此修改后，所有已有支付链接的结账页会立即显示新内容。支付链接自己的标题显示在付款成功页上；如需修改，请使用[更新支付链接](https://docs.anyway.sh/zh/api-reference/endpoint/update-payment-link.md)。

| 状态码 | 错误码 | 含义 |
| - | - | - |
| `400` | | 校验失败：未知字段、`name` 为空、`name` 超过 255 个字符，或 `description` 超过 2000。 |
| `401` | | API 密钥缺失或无效。 |
| `403` | `INSUFFICIENT_SCOPE` | 密钥缺少 `products:products:write`。 |
| `404` | | 产品不存在，或属于其他组织。 |
| `413` | `PAYLOAD_TOO_LARGE` | 请求体超过 64 KiB。 |


## OpenAPI

````yaml api-reference/openapi.json PATCH /v1/product/{id}
openapi: 3.0.3
info:
  description: >-
    Organization-scoped commerce API for merchant backends: create and manage
    checkout sessions, and query commerce records.
  title: Anyway Merchant API
  contact: {}
  version: '1.0'
  x-source: anyway-backend-go
servers:
  - url: https://merchant-api-prod.anyway.sh
security: []
paths:
  /v1/product/{id}:
    patch:
      tags:
        - products
      summary: Update a product
      description: >-
        Changes a product's name or description; only the fields you send
        change. Requires Full access or the `products:products:write`
        permission. The response is the same as `GET /v1/product/{id}`. Renaming
        a product doesn't change its existing payment links; each link keeps its
        own title. Unknown request fields return 400. There is no
        Idempotency-Key.
      parameters:
        - description: Product ID
          name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        description: Fields to change
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/product.UpdateRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/response.ApiResponse-product_ProductResponse
        '400':
          description: >-
            Bad Request. An unknown field, an empty name, a name over 255
            characters, or a description over 2000.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/response.ApiResponse-any'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/response.ApiResponse-any'
        '403':
          description: >-
            Forbidden. The API key lacks the required permission
            (INSUFFICIENT_SCOPE).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/response.ApiResponse-any'
        '404':
          description: >-
            Not Found. The product does not exist or belongs to another
            organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/response.ApiResponse-any'
        '413':
          description: Request body larger than 64 KiB (`PAYLOAD_TOO_LARGE`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/response.ApiResponse-any'
      security:
        - APIKeyAuth: []
components:
  schemas:
    product.UpdateRequest:
      type: object
      properties:
        name:
          type: string
          maxLength: 255
          description: New product name
        description:
          type: string
          maxLength: 2000
          description: New product description
    response.ApiResponse-product_ProductResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/product.ProductResponse'
        error:
          $ref: '#/components/schemas/response.ErrorDetail'
        message:
          type: string
        success:
          type: boolean
    response.ApiResponse-any:
      type: object
      properties:
        data: {}
        error:
          $ref: '#/components/schemas/response.ErrorDetail'
        message:
          type: string
        success:
          type: boolean
    product.ProductResponse:
      type: object
      properties:
        createdAt:
          type: string
        description:
          type: string
        id:
          description: 'Deprecated: use productId.'
          type: string
          deprecated: true
        name:
          type: string
        orgId:
          type: string
        paymentLinks:
          type: array
          items:
            $ref: '#/components/schemas/product.PaymentLinkResponse'
        productId:
          type: string
        status:
          type: string
        updatedAt:
          type: string
    response.ErrorDetail:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
    product.PaymentLinkResponse:
      type: object
      properties:
        amount:
          type: number
          nullable: true
        createdAt:
          type: string
        currency:
          type: string
        flexibleAmount:
          type: boolean
        isActive:
          type: boolean
        name:
          type: string
        paymentLinkUrl:
          type: string
        pricingId:
          type: string
        pricingType:
          type: string
        provider:
          type: string
        title:
          type: string
        description:
          type: string
        minAmount:
          type: number
          nullable: true
        maxAmount:
          type: number
          nullable: true
        successUrl:
          type: string
          description: >-
            Where the customer is sent after paying. Empty when the Anyway
            receipt is used.
  securitySchemes:
    APIKeyAuth:
      description: 'Merchant API key (format: ak_BASE64)'
      type: apiKey
      name: X-API-Key
      in: header

````

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