> ## Documentation Index
> Fetch the complete documentation index at: https://fortal-pay.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Atualizar cupom

> Partially update a coupon owned by the merchant associated with the API key.

Envie somente os campos que precisam ser alterados. Ao menos um valor não nulo é obrigatório.


## OpenAPI

````yaml openapi.yaml PUT /coupons/{id}
openapi: 3.1.0
info:
  title: FortalPay API
  version: '1'
  description: >
    API para gerenciar clientes, produtos e cupons e para criar ou listar
    cobranças.

    A autenticação utiliza uma API key no cabeçalho `Authorization`.
servers:
  - url: https://api-sandbox.fortalpay.tech/v1
    description: Produção — API v1
security:
  - apiKeyAuth: []
tags:
  - name: Clientes
    description: Crie, filtre, consulte e remova clientes do lojista associado à API key.
  - name: Charges
    description: >-
      Create Pix charges and list charges owned by the merchant associated with
      the API key.
  - name: Checkouts
    description: Crie páginas de pagamento hospedadas pela FortalPay usando uma API key.
  - name: Produtos
    description: >-
      Crie, liste, consulte, atualize e remova produtos do lojista associado à
      API key.
  - name: Coupons
    description: >-
      Create, list, retrieve, update, and delete coupons owned by the merchant
      associated with the API key.
paths:
  /coupons/{id}:
    put:
      tags:
        - Coupons
      summary: Update a coupon
      description: >-
        Partially updates a coupon owned by the authenticated merchant. At least
        one field must be provided. Requires a FULL_ACCESS API key.
      operationId: updateCoupon
      parameters:
        - $ref: '#/components/parameters/CouponId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCouponRequest'
            example:
              value: 15
              max_uses: 200
              expires_at: '2026-09-30T23:59:59'
              status: ACTIVE
      responses:
        '200':
          description: Coupon updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CouponEnvelope'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  parameters:
    CouponId:
      name: id
      in: path
      required: true
      description: Identificador público do cupom.
      schema:
        type: string
        format: uuid
  schemas:
    UpdateCouponRequest:
      type: object
      minProperties: 1
      additionalProperties: false
      properties:
        code:
          type:
            - string
            - 'null'
          minLength: 1
          maxLength: 50
          description: Merchant-unique code. It is trimmed and converted to uppercase.
        type:
          oneOf:
            - $ref: '#/components/schemas/CouponType'
            - type: 'null'
        value:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 1
          description: >-
            Integer percentage from 1 to 100 for PERCENTAGE; discount in cents
            for FIXED_AMOUNT.
        max_uses:
          $ref: '#/components/schemas/CouponMaxUses'
        starts_at:
          $ref: '#/components/schemas/CouponLocalDateTime'
        expires_at:
          $ref: '#/components/schemas/CouponLocalDateTime'
        status:
          oneOf:
            - $ref: '#/components/schemas/CouponStatus'
            - type: 'null'
    CouponEnvelope:
      type: object
      required:
        - data
        - success
        - error
      properties:
        data:
          $ref: '#/components/schemas/Coupon'
        success:
          type: boolean
          const: true
        error:
          type: 'null'
    CouponType:
      type: string
      enum:
        - PERCENTAGE
        - FIXED_AMOUNT
    CouponMaxUses:
      description: Maximum number of uses. Null or -1 means unlimited.
      oneOf:
        - type: integer
          const: -1
        - type: integer
          minimum: 1
        - type: 'null'
    CouponLocalDateTime:
      type:
        - string
        - 'null'
      pattern: ^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?$
      description: >-
        Local date in `yyyy-MM-dd` format or local date and time in
        `yyyy-MM-dd'T'HH:mm:ss` format. Date-only `starts_at` uses 00:00:00 and
        date-only `expires_at` uses 23:59:59.
    CouponStatus:
      type: string
      enum:
        - ACTIVE
        - INACTIVE
    Coupon:
      type: object
      required:
        - id
        - code
        - type
        - value
        - used_count
        - status
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
          description: Identificador público do cupom.
          example: 6f84d2b5-a612-4e67-8af5-69f98de980f5
        code:
          type: string
        type:
          $ref: '#/components/schemas/CouponType'
        value:
          type: number
          description: >-
            Percentual inteiro para PERCENTAGE; valor decimal em reais para
            FIXED_AMOUNT.
          examples:
            - 10
            - 1.01
        max_uses:
          type:
            - integer
            - 'null'
          description: Null or -1 represents unlimited usage.
        used_count:
          type: integer
        starts_at:
          type:
            - string
            - 'null'
          format: date-time
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
        status:
          $ref: '#/components/schemas/CouponStatus'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    ErrorEnvelope:
      type: object
      required:
        - data
        - success
        - error
      properties:
        data:
          type: 'null'
        success:
          type: boolean
          const: false
        error:
          $ref: '#/components/schemas/ApiError'
    ApiError:
      type: object
      required:
        - timestamp
        - status
        - message
        - path
      properties:
        timestamp:
          type: string
          format: date-time
        status:
          type: integer
        message:
          type: string
          description: Current backend messages are returned in Portuguese.
        path:
          type: string
        fields:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/FieldError'
    FieldError:
      type: object
      required:
        - field
        - message
      properties:
        field:
          type: string
        message:
          type: string
  responses:
    BadRequest:
      description: Uma regra de negócio rejeitou a requisição ou o estado atual do recurso.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    Unauthorized:
      description: >-
        A API key está ausente, malformada, não existe, foi revogada, expirou ou
        é incompatível com o ambiente do lojista.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    Forbidden:
      description: >-
        A API key foi autenticada, mas não possui permissão para acessar a rota
        solicitada.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    NotFound:
      description: >-
        O recurso não existe, foi removido ou não pertence ao lojista
        autenticado.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    ValidationError:
      description: Um ou mais campos da requisição são inválidos.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >
        Todas as requisições devem incluir sua API key no cabeçalho
        `Authorization`

        usando o formato `ApiKey <sua_api_key>`. Não use o esquema `Bearer`.

        Sem esse cabeçalho, a requisição será rejeitada.


        Use `fpay_sk_test_...` no ambiente de teste e `fpay_sk_live_...` em
        produção.

        [Saiba como criar e usar uma API key](/authentication).

````