मुख्य सामग्री पर जाएं

क्रेडिट-आधारित बिलिंग वेबहुक इवेंट्स

निम्नलिखित वेबहुक इवेंट्स क्रेडिट-आधारित बिलिंग जीवनचक्र परिवर्तन को ट्रैक करने के लिए उपलब्ध हैं। ये इवेंट्स वर्चुअल क्रेडिट अधिकारों (API कॉल, टोकन, कंप्यूट घंटे) पर लागू होते हैं, Customer Wallets (मॉनिटरी बैलेंस) पर नहीं।
EventDescription
credit.addedग्राहक को क्रेडिट प्रदान किए जाते हैं (सब्सक्रिप्शन, वन-टाइम खरीद, ऐड-ऑन, या API के माध्यम से)
credit.deductedउपयोग या मैनुअल डेबिट के माध्यम से क्रेडिट का उपभोग होता है
credit.expiredगैर-उपयोग किए गए क्रेडिट निर्धारित समाप्ति अवधि के बाद समाप्त हो जाते हैं
credit.rolled_overचक्र के अंत में गैर-उपयोग किए गए क्रेडिट एक नई ग्रांट में आगे बढ़ाए जाते हैं
credit.rollover_forfeitedअधिकतम रोलओवर सीमा पहुंचने के कारण क्रेडिट की वसूली की जाती है
credit.overage_chargedशून्य बैलेंस से आगे उपयोग जारी रहने पर ओवरएज शुल्क लागू होते हैं
credit.manual_adjustmentडैशबोर्ड या API के माध्यम से मैनुअल क्रेडिट या डेबिट समायोजन
credit.balance_lowक्रेडिट बैलेंस निर्धारित निम्न बैलेंस सीमा से नीचे चला जाता है

लेज़र इवेंट्स

सभी लेज़र इवेंट्स (credit.added से credit.manual_adjustment तक) नीचे दिए गए स्कीमा में दस्तावेजीकृत समान CreditLedgerEntryResponse पेलोड साझा करते हैं।

बैलेंस लो इवेंट (credit.balance_low)

credit.balance_low इवेंट सीमा अलर्टिंग पर केंद्रित अलग पेलोड (CreditBalanceLowPayload) का उपयोग करता है:
{
  "business_id": "bus_H4ekzPSlcg",
  "type": "credit.balance_low",
  "timestamp": "2025-08-04T06:15:00.000000Z",
  "data": {
    "payload_type": "CreditBalanceLow",
    "customer_id": "cus_8VbC6JDZzPEqfBPUdpj0K",
    "subscription_id": "sub_7EeHq2ewQuadropD2ra",
    "credit_entitlement_id": "cent_9xY2bKwQn5MjRpL8d",
    "credit_entitlement_name": "API Credits",
    "available_balance": "15",
    "subscription_credits_amount": "100",
    "threshold_percent": 20,
    "threshold_amount": "20"
  }
}
customer_id
string
उस ग्राहक का क्रेडिट बैलेंस जिसने अलर्ट ट्रिगर किया।
subscription_id
string
इस क्रेडिट अधिकार से जुड़ी सब्सक्रिप्शन।
credit_entitlement_id
string
जिस क्रेडिट अधिकार का बैलेंस कम है।
credit_entitlement_name
string
क्रेडिट अधिकार का प्रदर्शन नाम।
available_balance
string
अलर्ट के समय वर्तमान क्रेडिट बैलेंस।
subscription_credits_amount
string
इस सब्सक्रिप्शन के लिए प्रति बिलिंग चक्र जारी किए गए कुल क्रेडिट।
threshold_percent
integer
निर्धारित निम्न बैलेंस सीमा प्रतिशत।
threshold_amount
string
उस क्रेडिट राशि का मान जिसे यह सीमा दर्शाती है।

सक्रिय अलर्ट के लिए credit.balance_low का उपयोग

ग्राहक के क्रेडिट समाप्त होने से पहले उन्हें सूचित करने के लिए credit.balance_low वेबहुक का उपयोग करें:
app.post('/webhooks/dodo', async (req, res) => {
  const event = req.body;
  
  if (event.type === 'credit.balance_low') {
    const data = event.data;
    
    // Notify the customer their credits are running low
    await sendEmail(data.customer_id, {
      subject: `Your ${data.credit_entitlement_name} balance is running low`,
      body: `You have ${data.available_balance} credits remaining ` +
            `(${data.threshold_percent}% threshold reached). ` +
            `Consider upgrading your plan or purchasing additional credits.`
    });
    
    console.log(`Low balance alert for customer ${data.customer_id}`);
  }
  
  res.json({ received: true });
});
credit.balance_low को सब्सक्राइब करें ताकि ग्राहक को उनके क्रेडिट समाप्त होने से पहले सूचित किया जा सके। वास्तविक समय के उपभोग पैटर्न को ट्रैक करने के लिए credit.deducted के साथ संयोजित करें।

वेबहुक पेलोड स्कीमा

Response for a ledger entry

amount
string
आवश्यक
balance_after
string
आवश्यक
balance_before
string
आवश्यक
business_id
string
आवश्यक
created_at
string<date-time>
आवश्यक
credit_entitlement_id
string
आवश्यक
customer_id
string
आवश्यक
id
string
आवश्यक
is_credit
boolean
आवश्यक
overage_after
string
आवश्यक
overage_before
string
आवश्यक
transaction_type
enum<string>
आवश्यक
उपलब्ध विकल्प:
credit_added,
credit_deducted,
credit_expired,
credit_rolled_over,
rollover_forfeited,
overage_charged,
auto_top_up,
manual_adjustment,
refund
description
string | null
grant_id
string | null
reference_id
string | null
reference_type
string | null