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

# Daftar Diskon

> Ambil daftar semua diskon yang terkait dengan akun Anda.



## OpenAPI

````yaml get /discounts
openapi: 3.1.0
info:
  title: public
  description: ''
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 1.110.1
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: Entitlements
  - name: Licenses
  - name: Discounts
  - name: Meters
  - name: Credit Entitlements
  - name: Credit Entitlement Balances
  - name: Outgoing Webhooks
  - name: Checkout
  - name: Webhook Events
  - name: Payment Connector Webhooks
paths:
  /discounts:
    get:
      tags:
        - Discounts
      summary: GET /discounts
      operationId: list_discounts_handler
      parameters:
        - name: page_size
          in: query
          description: Page size (default = 10, max = 100).
          required: false
          schema:
            type: integer
            format: int32
            minimum: 0
          style: form
        - name: page_number
          in: query
          description: Page number (default = 0).
          required: false
          schema:
            type: integer
            format: int32
            minimum: 0
          style: form
        - name: code
          in: query
          description: Filter by discount code (partial match, case-insensitive)
          required: false
          schema:
            type: string
          style: form
        - name: discount_type
          in: query
          description: Filter by discount type
          required: false
          schema:
            $ref: '#/components/schemas/DiscountType'
          style: form
        - name: active
          in: query
          description: |-
            Filter by active status. `true` = currently redeemable (started, not
            expired, not usage-exhausted). `false` = not currently redeemable
            (expired, usage-exhausted, or pending a future `starts_at`).
          required: false
          schema:
            type: boolean
          style: form
        - name: product_id
          in: query
          description: >-
            Filter by product restriction (only discounts that apply to this
            product)
          required: false
          schema:
            type: string
          style: form
      responses:
        '200':
          description: List of active Discounts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetDiscountsListResponse'
        '422':
          description: Invalid Request Object or Parameters
        '500':
          description: Something went wrong :(
      security:
        - API_KEY: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import DodoPayments from 'dodopayments';

            const client = new DodoPayments({
              bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // This is the default and can be omitted
            });

            // Automatically fetches more pages as needed.
            for await (const discount of client.discounts.list()) {
              console.log(discount.business_id);
            }
        - lang: Python
          source: |-
            import os
            from dodopayments import DodoPayments

            client = DodoPayments(
                bearer_token=os.environ.get("DODO_PAYMENTS_API_KEY"),  # This is the default and can be omitted
            )
            page = client.discounts.list()
            page = page.items[0]
            print(page.business_id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/dodopayments/dodopayments-go\"\n\t\"github.com/dodopayments/dodopayments-go/option\"\n)\n\nfunc main() {\n\tclient := dodopayments.NewClient(\n\t\toption.WithBearerToken(\"My Bearer Token\"),\n\t)\n\tpage, err := client.Discounts.List(context.TODO(), dodopayments.DiscountListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n"
        - 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.DiscountListPage;
            import com.dodopayments.api.models.discounts.DiscountListParams;

            public final class Main {
                private Main() {}

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

                    DiscountListPage page = client.discounts().list();
                }
            }
        - 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.DiscountListPage
            import com.dodopayments.api.models.discounts.DiscountListParams

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

                val page: DiscountListPage = client.discounts().list()
            }
        - lang: Ruby
          source: |-
            require "dodopayments"

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

            page = dodo_payments.discounts.list

            puts(page)
        - lang: PHP
          source: |-
            <?php

            require_once dirname(__DIR__) . '/vendor/autoload.php';

            use Dodopayments\Client;
            use Dodopayments\Core\Exceptions\APIException;
            use Dodopayments\Discounts\DiscountType;

            $client = new Client(
              bearerToken: getenv('DODO_PAYMENTS_API_KEY') ?: 'My Bearer Token',
              environment: 'test_mode',
            );

            try {
              $page = $client->discounts->list(
                active: true,
                code: 'code',
                discountType: DiscountType::FLAT,
                pageNumber: 0,
                pageSize: 0,
                productID: 'product_id',
              );

              var_dump($page);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: C#
          source: |-
            using System;
            using DodoPayments.Client;
            using DodoPayments.Client.Models.Discounts;

            DodoPaymentsClient client = new();

            DiscountListParams parameters = new();

            var page = await client.Discounts.List(parameters);
            await foreach (var item in page.Paginate())
            {
                Console.WriteLine(item);
            }
        - lang: Rust
          source: |-
            use dodopayments::Client;

            #[tokio::main]
            async fn main() -> dodopayments::Result<()> {
                let client = Client::from_env()?;
                let result = client
                    .discounts()
                    .list()
                    .query(serde_json::json!({}))
                    .await?;
                println!("{result:?}");
                Ok(())
            }
components:
  schemas:
    DiscountType:
      type: string
      enum:
        - flat
        - percentage
    GetDiscountsListResponse:
      type: object
      required:
        - items
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/DiscountResponse'
          description: Array of active (non-deleted) discounts for the current page.
    DiscountResponse:
      type: object
      required:
        - discount_id
        - business_id
        - type
        - code
        - amount
        - times_used
        - restricted_to
        - created_at
        - preserve_on_plan_change
        - customer_eligibility
        - metadata
      properties:
        amount:
          type: integer
          format: int32
          description: The discount amount in **basis points** (e.g., 540 => 5.4%).
        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
        currency_options:
          type: array
          items:
            $ref: '#/components/schemas/CurrencyOptionResponse'
          description: >-
            Per-currency options (flat deduction / percentage cap + minimum
            subtotal).

            Empty for discounts without any configured currency options.
        customer_eligibility:
          $ref: '#/components/schemas/CustomerEligibility'
          description: Who may redeem this discount code.
        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.
        metadata:
          $ref: '#/components/schemas/Metadata'
        name:
          type:
            - string
            - 'null'
          description: Name for the Discount
        per_customer_usage_limit:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Maximum number of times a single customer may redeem this discount,
            if any.
        preserve_on_plan_change:
          type: boolean
          description: >-
            Whether this discount should be preserved when a subscription
            changes plans.

            Default: false (discount is removed on plan change)
        restricted_to:
          type: array
          items:
            type: string
          description: List of product IDs to which this discount is restricted.
        starts_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            Optional date/time before which the discount is not yet active. NULL
            = active immediately.
        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 (`percentage` or `flat`).
        usage_limit:
          type:
            - integer
            - 'null'
          format: int32
          description: Usage limit for this discount, if any.
    CurrencyOptionResponse:
      type: object
      description: |-
        A per-currency discount option (response shape). `max_amount_possible`
        mirrors the DB column of the same name.
      required:
        - currency
        - minimum_subtotal
        - is_default
      properties:
        currency:
          $ref: '#/components/schemas/Currency'
          description: The currency this option applies to.
        is_default:
          type: boolean
          description: Whether this is the default row FX conversions pivot from.
        max_amount_possible:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            The most this code discounts in this currency's subunits (flat
            deduction

            or percentage cap).
        minimum_subtotal:
          type: integer
          format: int32
          description: >-
            Eligible-cart threshold in this currency's subunits (0 = no
            minimum).
    CustomerEligibility:
      type: string
      description: >-
        Who may redeem a discount code. Mirrors the Postgres enum

        `discount_customer_eligibility` (migration
        `20260714063329_discount_expansion`).
      enum:
        - any
        - first_time
        - existing
        - specific
    Metadata:
      type: object
      title: Metadata
      description: >-
        Arbitrary key-value metadata. Values can be string, integer, number, or
        boolean.
      additionalProperties:
        oneOf:
          - type: string
            title: String
          - type: integer
            title: Integer
            format: int64
          - type: number
            title: Number
            format: double
          - type: boolean
            title: Boolean
        title: Metadata Value
        description: Metadata value can be a string, integer, number, or boolean
    Currency:
      type: string
      enum:
        - AED
        - ALL
        - AMD
        - ANG
        - AOA
        - ARS
        - AUD
        - AWG
        - AZN
        - BAM
        - BBD
        - BDT
        - BGN
        - BHD
        - BIF
        - BMD
        - BND
        - BOB
        - BRL
        - BSD
        - BWP
        - BYN
        - BZD
        - CAD
        - CHF
        - CLP
        - CNY
        - COP
        - CRC
        - CUP
        - CVE
        - CZK
        - DJF
        - DKK
        - DOP
        - DZD
        - EGP
        - ETB
        - EUR
        - FJD
        - FKP
        - GBP
        - GEL
        - GHS
        - GIP
        - GMD
        - GNF
        - GTQ
        - GYD
        - HKD
        - HNL
        - HRK
        - HTG
        - HUF
        - IDR
        - ILS
        - INR
        - IQD
        - JMD
        - JOD
        - JPY
        - KES
        - KGS
        - KHR
        - KMF
        - KRW
        - KWD
        - KYD
        - KZT
        - LAK
        - LBP
        - LKR
        - LRD
        - LSL
        - LYD
        - MAD
        - MDL
        - MGA
        - MKD
        - MMK
        - MNT
        - MOP
        - MRU
        - MUR
        - MVR
        - MWK
        - MXN
        - MYR
        - MZN
        - NAD
        - NGN
        - NIO
        - NOK
        - NPR
        - NZD
        - OMR
        - PAB
        - PEN
        - PGK
        - PHP
        - PKR
        - PLN
        - PYG
        - QAR
        - RON
        - RSD
        - RUB
        - RWF
        - SAR
        - SBD
        - SCR
        - SEK
        - SGD
        - SHP
        - SLE
        - SLL
        - SOS
        - SRD
        - SSP
        - STN
        - SVC
        - SZL
        - THB
        - TND
        - TOP
        - TRY
        - TTD
        - TWD
        - TZS
        - UAH
        - UGX
        - USD
        - UYU
        - UZS
        - VES
        - VND
        - VUV
        - WST
        - XAF
        - XCD
        - XOF
        - XPF
        - YER
        - ZAR
        - ZMW
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````