# Cập nhật paywall

> Cập nhật Remote Config của một paywall cụ thể. Endpoint này cho phép bạn chỉnh sửa các giá trị Remote Config giúp tùy chỉnh giao diện và hành vi của paywall.
>
> **Quan trọng:** Nếu bạn cập nhật Remote Config, nó sẽ ghi đè toàn bộ các Remote Config hiện có! Nếu bạn cần giữ lại các Remote Config hiện có, trước tiên hãy lấy paywall. Sau đó, sao chép remote_configs từ đó và chỉnh sửa các đối tượng bạn cần trong yêu cầu cập nhật.

## OpenAPI

```yaml
/api-specs/adapty-api.yaml put /api/v2/server-side-api/paywalls/{paywall_id}/
openapi: 3.1.0
info:
  title: Adapty server-side API
  version: 1.0.0
servers:
  - url: https://api.adapty.io
    description: Máy chủ sản xuất
paths:
  /api/v2/server-side-api/paywalls/{paywall_id}/:
    put:
      summary: Cập nhật paywall
      description: |
        Cập nhật Remote Config của một paywall cụ thể. Endpoint này cho phép bạn chỉnh sửa các giá trị Remote Config giúp tùy chỉnh giao diện và hành vi của paywall.

        **Quan trọng:** Nếu bạn cập nhật Remote Config, nó sẽ ghi đè toàn bộ các Remote Config hiện có! Nếu bạn cần giữ lại các Remote Config hiện có, trước tiên hãy lấy paywall. Sau đó, sao chép remote_configs từ đó và chỉnh sửa các đối tượng bạn cần trong yêu cầu cập nhật.
      operationId: updatePaywall
      tags:
        - Paywalls
      security:
        - apikeyAuth: []
      parameters:
        - name: paywall_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Định danh duy nhất của paywall cần cập nhật
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PaywallUpdateRequest"
            example:
              remote_configs:
                - locale: en
                  data: "{\"title\":\"Premium Features\",\"subtitle\":\"Unlock all premium content\"}"
      responses:
        "200":
          description: Paywall được cập nhật thành công
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaywallResponse"
              example:
                title: Premium Subscription
                paywall_id: fd891d4f-5906-45b9-97c1-13cc3dc665df
                use_paywall_builder: true
                use_paywall_builder_legacy: false
                updated_at: "2025-07-30T11:13:58.798Z"
                created_at: "2025-07-30T11:13:58.798Z"
                state: live
                is_deleted: false
                web_purchase_url: https://example.com/purchase
                products:
                  - product_id: b95e9e51-a056-4eb6-9cf7-b75d139e7c3c
                    title: Premium Monthly
                    product_set: uncategorised
                    offer:
                      product_offer_id: e31a4296-f250-4faf-ac80-3cc93c2da8f5
                      title: Free Trial
                remote_configs:
                  - locale: en
                    data: "{\"title\":\"Premium Features\",\"subtitle\":\"Unlock all premium content\"}"
                main_screenshot:
                  image_id: 123456
                  url: https://public-media.adapty.io/public/screenshot.jpg
        "400":
          description: Yêu cầu không hợp lệ
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
              example:
                errors:
                  - source: remote_configs
                    errors:
                      - At least one field must be provided
                error_code: validation_error
                status_code: 400
        "401":
          description: Không được phép
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
              example:
                errors:
                  - Invalid API key
                error_code: unauthorized
                status_code: 401
        "404":
          description: Không tìm thấy paywall
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
              example:
                errors:
                  - source: null
                    errors:
                      - Paywall not found
                error_code: paywall_does_not_exist
                status_code: 404
        "500":
          description: Lỗi máy chủ nội bộ
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
components:
  schemas:
    PaywallUpdateRequest:
      type: object
      properties:
        remote_configs:
          type: array
          items:
            type: object
            properties:
              locale:
                type: string
                description: "Ngôn ngữ cho Remote Config (ví dụ: \"en\", \"es\", \"fr\")"
              data:
                type: string
                description: Chuỗi JSON chứa dữ liệu Remote Config
            required:
              - locale
              - data
          description: Mảng các đối tượng RemoteConfig cần cập nhật
      required:
        - remote_configs
      description: Phải cung cấp ít nhất một trường
    PaywallResponse:
      type: object
      properties:
        title:
          type: string
          description: Tên của paywall, được xác định trong Adapty Dashboard của bạn
        paywall_id:
          type: string
          format: uuid
          description: Định danh duy nhất của paywall
        use_paywall_builder:
          type: boolean
          description: Liệu paywall có sử dụng Paywall Builder hay không
        use_paywall_builder_legacy:
          type: boolean
          description: Liệu paywall có sử dụng Paywall Builder kế thừa hay không
        updated_at:
          type: string
          format: date-time
          description: Dấu thời gian khi paywall được cập nhật lần cuối
        created_at:
          type: string
          format: date-time
          description: Dấu thời gian khi paywall được tạo
        state:
          type: string
          enum:
            - draft
            - live
            - inactive
            - archived
          description: Trạng thái hiện tại của paywall
        is_deleted:
          type: boolean
          description: Liệu paywall có được đánh dấu là đã xóa hay không
        web_purchase_url:
          type: string
          format: uri
          nullable: true
          description: URL cho giao dịch mua trên web, nếu có
        products:
          type: array
          items:
            type: object
            properties:
              product_id:
                type: string
                format: uuid
                description: Định danh duy nhất của sản phẩm
              title:
                type: string
                description: Tiêu đề của sản phẩm
              product_set:
                type: string
                enum:
                  - weekly
                  - monthly
                  - trimonthly
                  - semiannual
                  - annual
                  - lifetime
                  - uncategorised
                  - nonsubscriptions
                  - two_months
                  - consumable
                description: Danh mục bộ sản phẩm
              offer:
                type: object
                nullable: true
                properties:
                  product_offer_id:
                    type: string
                    format: uuid
                    description: Định danh duy nhất của ưu đãi sản phẩm
                  title:
                    type: string
                    description: Tiêu đề của ưu đãi
                required:
                  - product_offer_id
                  - title
            required:
              - product_id
              - title
              - product_set
              - offer
          description: Mảng các đối tượng sản phẩm chứa thông tin sản phẩm
        remote_configs:
          type: array
          items:
            type: object
            properties:
              locale:
                type: string
                description: Ngôn ngữ cho Remote Config
              data:
                type: string
                description: Chuỗi JSON chứa dữ liệu Remote Config
            required:
              - locale
              - data
          description: Mảng các đối tượng RemoteConfig với ngôn ngữ và dữ liệu
        main_screenshot:
          type: object
          nullable: true
          properties:
            image_id:
              type: integer
              description: Định danh duy nhất của hình ảnh
            url:
              type: string
              format: uri
              description: URL của hình ảnh
          required:
            - image_id
            - url
          description: Đối tượng ảnh chụp màn hình chính với image_id và url
      required:
        - title
        - paywall_id
        - use_paywall_builder
        - use_paywall_builder_legacy
        - updated_at
        - created_at
        - state
        - is_deleted
        - products
    ErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
                nullable: true
                description: Nguồn gốc lỗi
              errors:
                type: array
                items:
                  type: string
                description: Mảng thông báo lỗi
        error_code:
          type: string
          description: Tên lỗi rút gọn
        status_code:
          type: integer
          description: Mã trạng thái HTTP
      required:
        - errors
        - error_code
        - status_code
  securitySchemes:
    apikeyAuth:
      type: apiKey
      name: Authorization
      in: header
      default: Api-Key {Your secret API key}
      description: |
        Các yêu cầu API phải được xác thực bằng secret API key của bạn trong header **Authorization**
        với giá trị `Api-Key {your_secret_api_key}`, ví dụ:
        `Api-Key secret_live_...`. Tìm key này trong Adapty Dashboard ->
        **App Settings** -> tab **General** -> phần **API keys**.
```
