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

# Update discount



## OpenAPI

````yaml /openapi.yaml patch /v1/discounts/{id}
openapi: 3.1.0
info:
  title: Lojou API
  version: 1.0.0
  description: |
    Official reference for the Lojou `/v1` API — everything a developer needs
    to create products, process orders, manage plans, and receive webhooks
    from a Lojou store.
servers:
  - url: https://api.lojou.app
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Health
  - name: OAuth
  - name: User
  - name: Products
  - name: Plans
  - name: Orders
  - name: Customers
  - name: Files
  - name: Webhooks
  - name: Discounts
  - name: Affiliates
paths:
  /v1/discounts/{id}:
    patch:
      tags:
        - Discounts
      summary: Update discount
      operationId: patchV1DiscountById
      parameters:
        - $ref: '#/components/parameters/IdParam'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchDiscountRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
              example:
                status: success
                message: Discount updated successfully.
                discount:
                  id: 9
                  code: LANCAMENTO25
                  type: percent
                  value: 25
                  status: active
                  product_ids:
                    - 272
                    - 305
                  uses_limit: 100
                  used_count: 34
                  available_uses: 66
                  single_use: false
                  never_expires: false
                  expires_at: '2026-12-31T23:59:59.000000Z'
                  created_at: '2026-08-01T08:00:00.000000Z'
                  updated_at: '2026-08-31T16:35:00.000000Z'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '409':
          description: A discount with the new code already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: A discount with this code already exists.
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  parameters:
    IdParam:
      name: id
      in: path
      required: true
      description: Resource identifier.
      schema:
        type: string
  schemas:
    PatchDiscountRequest:
      type: object
      properties:
        code:
          type: string
        type:
          type: string
          description: fixed|amount|percent|percentage|percentual|%
        value:
          type: number
          minimum: 0.01
        product_ids:
          type: array
          items:
            oneOf:
              - type: integer
              - type: string
        uses_limit:
          type: integer
          minimum: 1
          nullable: true
        single_use:
          type: boolean
        expires_at:
          type: string
          format: date-time
          nullable: true
        never_expires:
          type: boolean
        status:
          type: string
          enum:
            - active
            - inactive
            - enabled
            - disabled
            - published
            - unpublished
          nullable: true
    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          example: error
        message:
          type: string
      additionalProperties: true
    ValidationErrorResponse:
      allOf:
        - $ref: '#/components/schemas/ErrorResponse'
        - type: object
          properties:
            errors:
              type: object
              additionalProperties:
                type: array
                items:
                  type: string
  responses:
    UnauthorizedError:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: error
            message: Unauthorized user.
    ForbiddenError:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: error
            message: Permission denied for this endpoint.
            error_code: insufficient_scope
            required_scopes:
              - orders.read
            missing_scopes:
              - orders.read
            granted_scopes:
              - products.read
              - products.write
    NotFoundError:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: error
            message: Resource not found.
    ValidationError:
      description: Validation failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationErrorResponse'
          example:
            status: error
            message: Validation failed.
            errors:
              amount:
                - The amount field is required.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        Send an API key or an OAuth access token in the `Authorization` header
        as a Bearer token. See [Authentication](/authentication) for details.

````