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

# Update a discount code

> Change a discount code. Only the fields you send are changed. If you send `form_ids`, it replaces the list of forms. If you do not send it, the forms stay as they are.

> [!NOTE]
>
> Replace `{your-subdomain}` with your workspace’s subdomain. \
> Learn how to find your subdomain in [Workspace subdomain](https://apidocs.neetoform.com/api/workspace-subdomain.md).


## OpenAPI

````yaml bundled/discount-codes.yaml PATCH /discount_codes/{id}
openapi: 3.0.3
info:
  title: NeetoForm Discount Codes APIs
  version: 2.0.0
servers:
  - description: NeetoForm APIs
    url: https://{your-subdomain}.neetoform.com/api/external/v2
    variables:
      your-subdomain:
        default: spinkart
        description: >-
          Replace **spinkart** with your [workspace's
          subdomain](/api/workspace-subdomain).
security: []
tags:
  - name: Discount Codes
    description: APIs to manage discount codes, see their redemptions and get reports.
paths:
  /discount_codes/{id}:
    patch:
      tags:
        - Discount Codes
      summary: Update a discount code
      description: >-
        Change a discount code. Only the fields you send are changed. If you
        send `form_ids`, it replaces the list of forms. If you do not send it,
        the forms stay as they are.
      parameters:
        - $ref: '#/components/parameters/api_key_header'
        - $ref: '#/components/parameters/DiscountCodeId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                discount_code:
                  $ref: '#/components/schemas/DiscountCodeUpdateInput'
              required:
                - discount_code
            example:
              discount_code:
                value: 20
                redeems_limit: 200
      responses:
        '200':
          description: OK - Discount code updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/discount_code_response'
        '400':
          description: Bad Request - The `discount_code` object is missing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error_response'
              example:
                error: 'param is missing or the value is empty: discount_code'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          description: Unprocessable Entity - The input is not valid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error_response'
              example:
                error: >-
                  A fixed-amount code can only be enabled on a form whose
                  payment currency matches the code's currency.
components:
  parameters:
    api_key_header:
      in: header
      name: X-Api-Key
      description: >-
        Use the X-Api-Key header to provide your workspace API key. Refer to
        [Authentication](/api/authentication) for more information.
      required: true
      schema:
        type: string
        default: your-api-key
    DiscountCodeId:
      in: path
      name: id
      description: >-
        Id of the discount code. You can get it by using the [List discount
        codes](/api/discount-codes/list) API.
      required: true
      schema:
        type: string
        example: 6f1c2a7e-2b1d-4a51-9a0e-1f8f3b0c9d11
  schemas:
    DiscountCodeUpdateInput:
      type: object
      properties:
        code:
          type: string
          example: WELCOME
        value:
          type: number
          example: 20
        kind:
          type: string
          enum:
            - percentage
            - fixed
        currency:
          type: string
          example: usd
        expires_at:
          type: string
          example: '2026-12-31'
        redeems_limit:
          type: integer
          example: 200
        form_ids:
          type: array
          items:
            type: string
          description: >-
            Ids of the forms to enable the code on. This replaces the current
            list. Leave it out to keep the current forms.
          example:
            - c3b0a8d2-5e44-4f4e-8a35-0d2f5a1b7c90
    discount_code_response:
      type: object
      properties:
        discount_code:
          $ref: '#/components/schemas/discount_code_with_forms'
    error_response:
      type: object
      properties:
        error:
          type: string
    discount_code_with_forms:
      allOf:
        - $ref: '#/components/schemas/discount_code'
        - type: object
          properties:
            forms:
              type: array
              description: Forms that the code is enabled on.
              items:
                type: object
                properties:
                  id:
                    type: string
                    example: c3b0a8d2-5e44-4f4e-8a35-0d2f5a1b7c90
                  title:
                    type: string
                    example: Workshop signup
    discount_code:
      type: object
      properties:
        id:
          type: string
          example: 6f1c2a7e-2b1d-4a51-9a0e-1f8f3b0c9d11
        code:
          type: string
          description: The code that people enter. It is stored in upper case.
          example: SUMMER
        value:
          type: string
          description: >-
            Discount value. It is a percentage for `percentage` codes and an
            amount for `fixed` codes.
          example: '10.0'
        kind:
          type: string
          enum:
            - percentage
            - fixed
          example: percentage
        currency:
          type: string
          nullable: true
          description: Currency of a `fixed` code. It is null for `percentage` codes.
          example: null
        expires_at:
          type: string
          format: date-time
          nullable: true
          example: '2026-12-31T00:00:00.000Z'
        redeems_limit:
          type: integer
          nullable: true
          description: >-
            Maximum number of times the code can be used. It is null when there
            is no limit.
          example: 100
        created_at:
          $ref: '#/components/schemas/date_time_field'
        updated_at:
          $ref: '#/components/schemas/date_time_field'
        redeems_count:
          type: integer
          description: Number of completed redemptions.
          example: 12
        status:
          type: string
          enum:
            - active
            - expired
            - exhausted
          example: active
    date_time_field:
      type: string
      format: date-time
  responses:
    NotFound:
      description: Not Found - Discount code with the given ID does not exist
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error_response'
          example:
            error: DiscountCode does not exist.

````

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