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

# Update Discount

> Update a discount in your account.



## OpenAPI

````yaml patch /discounts/{discount_id}
openapi: 3.1.0
info:
  title: public
  description: ''
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 1.61.5
servers:
  - url: https://test.dodopayments.com/
    description: Test Mode Server Host
  - url: https://live.dodopayments.com/
    description: Live Mode Server Host
security: []
tags:
  - name: Products
  - name: Payments
  - name: Subscriptions
  - name: Addons
  - name: Customers
  - name: Refunds
  - name: Disputes
  - name: Events
  - name: License Keys
  - name: Licenses
  - name: Discounts
  - name: Meters
  - name: Outgoing Webhooks
  - name: Checkout
  - name: Webhook Events
paths:
  /discounts/{discount_id}:
    patch:
      tags:
        - Discounts
      summary: PATCH /discounts/{discount_id}
      operationId: patch_discount_handler
      parameters:
        - name: discount_id
          in: path
          description: Discount Id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchDiscountRequest'
        required: true
      responses:
        '200':
          description: Updated discount
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DiscountResponse'
        '404':
          description: Discount not found or soft-deleted
        '500':
          description: Something went wrong :(
      security:
        - API_KEY: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import DodoPayments from 'dodopayments';

            const client = new DodoPayments({
              bearerToken: 'My Bearer Token',
            });

            const discount = await client.discounts.update('discount_id');

            console.log(discount.business_id);
        - lang: Python
          source: |-
            from dodopayments import DodoPayments

            client = DodoPayments(
                bearer_token="My Bearer Token",
            )
            discount = client.discounts.update(
                discount_id="discount_id",
            )
            print(discount.business_id)
        - lang: Go
          source: |
            package main

            import (
              "context"
              "fmt"

              "github.com/dodopayments/dodopayments-go"
              "github.com/dodopayments/dodopayments-go/option"
            )

            func main() {
              client := dodopayments.NewClient(
                option.WithBearerToken("My Bearer Token"),
              )
              discount, err := client.Discounts.Update(
                context.TODO(),
                "discount_id",
                dodopayments.DiscountUpdateParams{

                },
              )
              if err != nil {
                panic(err.Error())
              }
              fmt.Printf("%+v\n", discount.BusinessID)
            }
        - lang: Java
          source: |-
            package com.dodopayments.api.example;

            import com.dodopayments.api.client.DodoPaymentsClient;
            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;
            import com.dodopayments.api.models.discounts.Discount;
            import com.dodopayments.api.models.discounts.DiscountUpdateParams;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();

                    Discount discount = client.discounts().update("discount_id");
                }
            }
        - lang: Kotlin
          source: |-
            package com.dodopayments.api.example

            import com.dodopayments.api.client.DodoPaymentsClient
            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient
            import com.dodopayments.api.models.discounts.Discount
            import com.dodopayments.api.models.discounts.DiscountUpdateParams

            fun main() {
                val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()

                val discount: Discount = client.discounts().update("discount_id")
            }
        - lang: Ruby
          source: |-
            require "dodopayments"

            dodo_payments = Dodopayments::Client.new(
              bearer_token: "My Bearer Token",
              environment: "test_mode" # defaults to "live_mode"
            )

            discount = dodo_payments.discounts.update("discount_id")

            puts(discount)
components:
  schemas:
    PatchDiscountRequest:
      type: object
      description: |-
        Request body for patching (updating) a discount.

        All fields are optional and only update if provided.
      properties:
        amount:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            If present, update the discount amount:

            - If `discount_type` is `percentage`, this represents **basis
            points** (e.g., `540` = `5.4%`).

            - Otherwise, this represents **USD cents** (e.g., `100` = `$1.00`).


            Must be at least 1 if provided.
        code:
          type:
            - string
            - 'null'
          description: If present, update the discount code (uppercase).
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
        name:
          type:
            - string
            - 'null'
        restricted_to:
          type:
            - array
            - 'null'
          items:
            type: string
          description: |-
            If present, replaces all restricted product IDs with this new set.
            To remove all restrictions, send empty array
        subscription_cycles:
          type:
            - integer
            - 'null'
          format: int32
          description: |-
            Number of subscription billing cycles this discount is valid for.
            If not provided, the discount will be applied indefinitely to
            all recurring payments related to the subscription.
        type:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/DiscountType'
              description: If present, update the discount type.
        usage_limit:
          type:
            - integer
            - 'null'
          format: int32
    DiscountResponse:
      type: object
      required:
        - discount_id
        - business_id
        - type
        - code
        - amount
        - times_used
        - restricted_to
        - created_at
      properties:
        amount:
          type: integer
          format: int32
          description: |-
            The discount amount.

            - If `discount_type` is `percentage`, this is in **basis points**
              (e.g., 540 => 5.4%).
            - Otherwise, this is **USD cents** (e.g., 100 => `$1.00`).
        business_id:
          type: string
          description: The business this discount belongs to.
        code:
          type: string
          description: The discount code (up to 16 chars).
        created_at:
          type: string
          format: date-time
          description: Timestamp when the discount is created
        discount_id:
          type: string
          description: The unique discount ID
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Optional date/time after which discount is expired.
        name:
          type:
            - string
            - 'null'
          description: Name for the Discount
        restricted_to:
          type: array
          items:
            type: string
          description: List of product IDs to which this discount is restricted.
        subscription_cycles:
          type:
            - integer
            - 'null'
          format: int32
          description: |-
            Number of subscription billing cycles this discount is valid for.
            If not provided, the discount will be applied indefinitely to
            all recurring payments related to the subscription.
        times_used:
          type: integer
          format: int32
          description: How many times this discount has been used.
        type:
          $ref: '#/components/schemas/DiscountType'
          description: The type of discount, e.g. `percentage`, `flat`, or `flat_per_unit`.
        usage_limit:
          type:
            - integer
            - 'null'
          format: int32
          description: Usage limit for this discount, if any.
    DiscountType:
      type: string
      enum:
        - percentage
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````