मुख्य सामग्री पर जाएं
PATCH
/
discounts
/
{discount_id}
JavaScript
import DodoPayments from 'dodopayments';

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

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

console.log(discount.business_id);
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
)
discount = client.discounts.update(
discount_id="dsc_qxxEmg5PuM1uNTE0LgkP9",
)
print(discount.business_id)
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(),
"dsc_qxxEmg5PuM1uNTE0LgkP9",
dodopayments.DiscountUpdateParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", discount.BusinessID)
}
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("dsc_qxxEmg5PuM1uNTE0LgkP9");
}
}
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("dsc_qxxEmg5PuM1uNTE0LgkP9")
}
require "dodopayments"

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

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

puts(discount)
<?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 {
$discount = $client->discounts->update(
'dsc_qxxEmg5PuM1uNTE0LgkP9',
amount: 0,
code: 'code',
expiresAt: new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
metadata: ['foo' => 'string'],
name: 'name',
preserveOnPlanChange: true,
restrictedTo: ['string'],
subscriptionCycles: 0,
type: DiscountType::PERCENTAGE,
usageLimit: 0,
);

var_dump($discount);
} catch (APIException $e) {
echo $e->getMessage();
}
using System;
using DodoPayments.Client;
using DodoPayments.Client.Models.Discounts;

DodoPaymentsClient client = new();

DiscountUpdateParams parameters = new()
{
DiscountID = "dsc_qxxEmg5PuM1uNTE0LgkP9"
};

var discount = await client.Discounts.Update(parameters);

Console.WriteLine(discount);
use dodopayments::Client;

#[tokio::main]
async fn main() -> dodopayments::Result<()> {
let client = Client::from_env()?;
let discount_id = "discount_id";
let result = client
.discounts()
.update()
.discount_id(discount_id)
.body(Default::default())
.await?;
println!("{result:?}");
Ok(())
}
curl --request PATCH \
--url https://test.dodopayments.com/discounts/{discount_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 123,
"code": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"metadata": {},
"name": "<string>",
"preserve_on_plan_change": true,
"restricted_to": [
"<string>"
],
"subscription_cycles": 123,
"type": "percentage",
"usage_limit": 123
}
'
{
  "amount": 123,
  "business_id": "<string>",
  "code": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "discount_id": "<string>",
  "metadata": {},
  "preserve_on_plan_change": true,
  "restricted_to": [
    "<string>"
  ],
  "times_used": 123,
  "type": "percentage",
  "expires_at": "2023-11-07T05:31:56Z",
  "name": "<string>",
  "subscription_cycles": 123,
  "usage_limit": 123
}

प्राधिकरण

Authorization
string
header
आवश्यक

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

पथ पैरामीटर

discount_id
string
आवश्यक

Discount Id

बॉडी

application/json

Request body for patching (updating) a discount.

All fields are optional and only update if provided.

amount
integer<int32> | null

If present, update the discount amount in basis points (e.g., 540 = 5.4%, 10000 = 100%).

Must be at least 1 if provided.

code
string | null

If present, update the discount code (uppercase).

expires_at
string<date-time> | null
metadata
null | Metadata · object

Additional metadata for the discount

name
string | null
preserve_on_plan_change
boolean | null

Whether this discount should be preserved when a subscription changes plans. If not provided, the existing value is kept.

restricted_to
string[] | null

If present, replaces all restricted product IDs with this new set. To remove all restrictions, send empty array

subscription_cycles
integer<int32> | null

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
null | enum<string>

If present, update the discount type. Currently only percentage is supported.

उपलब्ध विकल्प:
percentage
usage_limit
integer<int32> | null

प्रतिक्रिया

Updated discount

amount
integer<int32>
आवश्यक

The discount amount in basis points (e.g., 540 => 5.4%).

business_id
string
आवश्यक

The business this discount belongs to.

code
string
आवश्यक

The discount code (up to 16 chars).

created_at
string<date-time>
आवश्यक

Timestamp when the discount is created

discount_id
string
आवश्यक

The unique discount ID

metadata
Metadata · object
आवश्यक

Arbitrary key-value metadata. Values can be string, integer, number, or boolean.

preserve_on_plan_change
boolean
आवश्यक

Whether this discount should be preserved when a subscription changes plans. Default: false (discount is removed on plan change)

restricted_to
string[]
आवश्यक

List of product IDs to which this discount is restricted.

times_used
integer<int32>
आवश्यक

How many times this discount has been used.

type
enum<string>
आवश्यक

The type of discount. Currently only percentage is supported.

उपलब्ध विकल्प:
percentage
expires_at
string<date-time> | null

Optional date/time after which discount is expired.

name
string | null

Name for the Discount

subscription_cycles
integer<int32> | null

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.

usage_limit
integer<int32> | null

Usage limit for this discount, if any.

अंतिम संशोधन 1 अप्रैल 2026