> ## 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` 角色可以授予该权限。

* 不需要请求体。
* 只有已归档的产品可以发布。
* 发布时会重新开启该产品最新价格的支付链接，链接地址不变，之前分享出去的这个链接可以再次使用。如果该价格从未有过链接，则会新建一个。该产品的其他支付链接保持关闭。
* 响应结构与[读取产品](https://docs.anyway.sh/zh/api-reference/endpoint/get-product.md)相同，`status` 为 `PUBLISHED`，已开启的链接在 `paymentLinks` 中返回。
* 该接口没有 `Idempotency-Key`。

| 状态码 | 错误码 | 含义 |
| - | - | - |
| `400` | | 组织的收款账户尚未就绪，或产品没有价格。 |
| `401` | | API 密钥缺失或无效。 |
| `403` | `INSUFFICIENT_SCOPE` | 密钥缺少 `products:products:write`。 |
| `403` | `CARD_USD_VERIFICATION_REQUIRED` | 请先完成企业认证。 |
| `403` | `ORG_FROZEN` | 组织的收款已被冻结。 |
| `404` | | 产品不存在，或属于其他组织。 |
| `409` | `PRODUCT_CONFLICT` | 产品未处于已归档状态。 |
| `503` | `CARD_USD_CAPABILITY_UNAVAILABLE` | 认证状态暂时无法获取，请稍后重试。 |


## OpenAPI

````yaml api-reference/openapi.json POST /v1/product/{id}/publish
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}/publish:
    post:
      tags:
        - products
      summary: Publish a product
      description: >-
        Publishes an archived product and turns the payment link for its newest
        price back on, at the same URL (a new link if that price never had one);
        the product's other links stay off. Requires Full access or the
        `products:products:write` permission. No request body. The response is
        the same as `GET /v1/product/{id}`, with the active link in
        `paymentLinks`. Returns 409 PRODUCT_CONFLICT if the product is not
        archived. There is no Idempotency-Key.
      parameters:
        - description: Product ID
          name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/response.ApiResponse-product_ProductResponse
        '400':
          description: >-
            Bad Request. The organization's payment account isn't ready, or the
            product has no price.
          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), the organization is frozen (ORG_FROZEN), or
            business verification is required (CARD_USD_VERIFICATION_REQUIRED).
          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'
        '409':
          description: Conflict. The product is not archived (PRODUCT_CONFLICT).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/response.ApiResponse-any'
        '503':
          description: >-
            Service Unavailable. Verification status is temporarily unavailable
            (CARD_USD_CAPABILITY_UNAVAILABLE); retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/response.ApiResponse-any'
      security:
        - APIKeyAuth: []
components:
  schemas:
    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.