> ## 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.

# Validate Discount

> Validate a discount code to check if it is valid and can be applied to the current cart.



## OpenAPI

````yaml get /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}:
    get:
      tags:
        - Discounts
      summary: GET /discounts/{discount_id}
      operationId: get_discount_handler
      parameters:
        - name: discount_id
          in: path
          description: Discount Id
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Fetched discount by ID
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DiscountResponse'
        '404':
          description: 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.retrieve('discount_id');

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

            client = DodoPayments(
                bearer_token="My Bearer Token",
            )
            discount = client.discounts.retrieve(
                "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.Get(context.TODO(), "discount_id")
              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.DiscountRetrieveParams;

            public final class Main {
                private Main() {}

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

                    Discount discount = client.discounts().retrieve("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.DiscountRetrieveParams

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

                val discount: Discount = client.discounts().retrieve("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.retrieve("discount_id")

            puts(discount)
components:
  schemas:
    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

````