Skip to content

Commit f40b1f0

Browse files
devkiransteven-teycoderabbitai[bot]
authored
Add discount code API and webhook docs. (#443)
Co-authored-by: Steven Tey <stevensteel97@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 6f81574 commit f40b1f0

11 files changed

Lines changed: 473 additions & 14 deletions

File tree

docs.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,14 @@
491491
"docs/api-reference/customers/delete"
492492
]
493493
},
494+
{
495+
"group": "Discount codes",
496+
"pages": [
497+
"docs/api-reference/discount-codes/list",
498+
"docs/api-reference/discount-codes/create",
499+
"docs/api-reference/discount-codes/delete"
500+
]
501+
},
494502
{
495503
"group": "Bounty submissions",
496504
"pages": [
@@ -597,7 +605,9 @@
597605
"docs/webhooks/events/partner-application-submitted",
598606
"docs/webhooks/events/lead-created",
599607
"docs/webhooks/events/sale-created",
600-
"docs/webhooks/events/commission-created"
608+
"docs/webhooks/events/commission-created",
609+
"docs/webhooks/events/discount-code-created",
610+
"docs/webhooks/events/discount-code-deleted"
601611
]
602612
},
603613
{
@@ -788,6 +798,14 @@
788798
"source": "/docs/webhooks/event-types#commission-created",
789799
"destination": "/docs/webhooks/events/commission-created"
790800
},
801+
{
802+
"source": "/docs/webhooks/event-types#discount-code-created",
803+
"destination": "/docs/webhooks/events/discount-code-created"
804+
},
805+
{
806+
"source": "/docs/webhooks/event-types#discount-code-deleted",
807+
"destination": "/docs/webhooks/events/discount-code-deleted"
808+
},
791809
{
792810
"source": "/docs/webhooks/event-types#payout-confirmed",
793811
"destination": "/docs/webhooks/events/payout-confirmed"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
openapi: post /discount-codes
3+
sidebarTitle: Create discount code
4+
---
5+
6+
<Note>
7+
Discount codes endpoints require a [Business
8+
plan](https://dub.co/pricing/partners) subscription or higher.
9+
</Note>
10+
11+
<Tip>
12+
The partner's group must already have a discount assigned, and each referral
13+
link can only have one discount code. If you omit `code`, Dub generates one
14+
from the partner's name.
15+
</Tip>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
openapi: delete /discount-codes/{idOrCode}
3+
sidebarTitle: Delete discount code
4+
---
5+
6+
<Note>
7+
Discount codes endpoints require a [Business
8+
plan](https://dub.co/pricing/partners) subscription or higher.
9+
</Note>
10+
11+
<Tip>
12+
You can identify the discount code by its unique ID (e.g. `dcode_...`) or by
13+
the alphanumeric code (e.g. `STEVEN10OFF`).
14+
</Tip>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
openapi: get /discount-codes
3+
sidebarTitle: List discount codes
4+
---
5+
6+
<Note>
7+
Discount codes endpoints require a [Business
8+
plan](https://dub.co/pricing/partners) subscription or higher.
9+
</Note>
10+
11+
<Tip>
12+
Filter by `partnerId` or `discountId`. If both are omitted, this returns
13+
discount codes for the whole program.
14+
</Tip>

docs/integrations.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,5 @@ Here's a list of the webhooks that Dub supports:
130130
- [`lead.created`](/docs/webhooks/events/lead-created) – when a new lead is created
131131
- [`sale.created`](/docs/webhooks/events/sale-created) – when a new sale is created
132132
- [`partner.enrolled`](/docs/webhooks/events/partner-enrolled) – when a new partner is enrolled in your program
133+
- [`discount_code.created`](/docs/webhooks/events/discount-code-created) – when a discount code is created
134+
- [`discount_code.deleted`](/docs/webhooks/events/discount-code-deleted) – when a discount code is deleted

docs/webhooks/event-types.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Webhooks send real-time notifications when events happen in your Dub workspace.
3131
| [`lead.created`](/docs/webhooks/events/lead-created) | Occurs when a **new lead is tracked**. |
3232
| [`sale.created`](/docs/webhooks/events/sale-created) | Occurs when a **new sale is tracked**. |
3333
| [`commission.created`](/docs/webhooks/events/commission-created) | Occurs when a **new commission is generated** — from a tracked conversion or created manually in the dashboard. |
34+
| [`discount_code.created`](/docs/webhooks/events/discount-code-created) | Occurs when a **discount code is created** for a partner. |
35+
| [`discount_code.deleted`](/docs/webhooks/events/discount-code-deleted) | Occurs when a **discount code is deleted**. |
3436

3537
## Dub Links
3638

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
title: discount_code.created
3+
icon: ticket
4+
---
5+
6+
import { WebhookResponseBodyParameters } from "/snippets/webhook-response-body-parameters.mdx";
7+
8+
Event triggered when a [discount code is created](/docs/api-reference/discount-codes/create).
9+
10+
<Tip>
11+
This event is sent when a discount code is created via the API, the dashboard,
12+
or auto-provisioning when a partner joins a group.
13+
14+
If the discount uses the **custom** provider, listen to this webhook to create
15+
the corresponding promo code in your own system. For Stripe and
16+
Shopify discounts, Dub creates the code in the connected provider
17+
automatically.
18+
19+
</Tip>
20+
21+
<WebhookResponseBodyParameters type="discount_code.created">
22+
<ParamField body="id" type="string">
23+
Unique identifier for the discount code (e.g. <code>dcode_...</code>).
24+
</ParamField>
25+
<ParamField body="code" type="string">
26+
The alphanumeric discount code customers can apply at checkout.
27+
</ParamField>
28+
<ParamField body="partnerId" type="string">
29+
ID of the partner this discount code is assigned to.
30+
</ParamField>
31+
<ParamField body="linkId" type="string">
32+
ID of the partner's referral link this discount code is associated with.
33+
</ParamField>
34+
<ParamField body="disabledAt" type="string | null">
35+
ISO 8601 timestamp when the code was disabled, or <code>null</code> if it is
36+
active.
37+
</ParamField>
38+
<ParamField body="discount" type="object | null">
39+
The discount this code belongs to.
40+
41+
<Expandable title="discount object">
42+
<ParamField body="id" type="string">
43+
Unique identifier for the discount.
44+
</ParamField>
45+
<ParamField body="amount" type="number">
46+
Discount amount. For <code>percentage</code> discounts this is the
47+
percent off (e.g. <code>10</code> = 10% off). For <code>flat</code>
48+
discounts this is the amount in cents (e.g. <code>500</code> = $5.00).
49+
</ParamField>
50+
<ParamField body="type" type="string">
51+
Discount type: <code>percentage</code> or <code>flat</code>.
52+
</ParamField>
53+
<ParamField body="maxDuration" type="number | null">
54+
Maximum duration in months. <code>0</code> is one-time,
55+
<code>null</code> is lifetime.
56+
</ParamField>
57+
<ParamField body="provider" type="string">
58+
Discount provider: <code>stripe</code>, <code>shopify</code>, or
59+
<code>custom</code>.
60+
</ParamField>
61+
</Expandable>
62+
63+
</ParamField>
64+
</WebhookResponseBodyParameters>
65+
66+
<ResponseExample>
67+
68+
```json Response
69+
{
70+
"id": "evt_KleiO4HBwZFbO1vZLWIPZ2AtX",
71+
"event": "discount_code.created",
72+
"createdAt": "2026-08-19T10:48:15.468Z",
73+
"data": {
74+
"id": "dcode_1K39DGZG3MHY9RP4PD0AS2C5P",
75+
"code": "STEVEN10OFF",
76+
"partnerId": "pn_1K9BZE1K285BSTX4W6MPKXJFZ",
77+
"linkId": "link_5myDHLqhIQvUmUPjchVygF9R",
78+
"disabledAt": null,
79+
"discount": {
80+
"id": "disc_1KEC01MXC5H50XQMSN83VCW65",
81+
"amount": 10,
82+
"type": "percentage",
83+
"maxDuration": 6,
84+
"provider": "custom"
85+
}
86+
}
87+
}
88+
```
89+
90+
</ResponseExample>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
title: discount_code.deleted
3+
icon: ticket
4+
---
5+
6+
import { WebhookResponseBodyParameters } from "/snippets/webhook-response-body-parameters.mdx";
7+
8+
Event triggered when a [discount code is deleted](/docs/api-reference/discount-codes/delete).
9+
10+
<Tip>
11+
This event is also sent when a discount code is removed automatically — for
12+
example when a partner is banned or deactivated, a linked referral link is
13+
deleted, or a partner is moved to a group without an equivalent discount.
14+
15+
If the discount uses the **custom** provider, listen to this webhook to
16+
disable the corresponding promo code in your own system. For Stripe
17+
and Shopify discounts, Dub disables the code in the connected provider
18+
automatically.
19+
20+
</Tip>
21+
22+
<WebhookResponseBodyParameters type="discount_code.deleted">
23+
<ParamField body="id" type="string">
24+
Unique identifier for the discount code (e.g. <code>dcode_...</code>).
25+
</ParamField>
26+
<ParamField body="code" type="string">
27+
The alphanumeric discount code that was deleted.
28+
</ParamField>
29+
<ParamField body="partnerId" type="string">
30+
ID of the partner this discount code was assigned to.
31+
</ParamField>
32+
<ParamField body="linkId" type="string">
33+
ID of the partner's referral link this discount code was associated with.
34+
</ParamField>
35+
<ParamField body="disabledAt" type="string | null">
36+
ISO 8601 timestamp when the code was disabled. Set when a partner is banned
37+
or deactivated; otherwise <code>null</code>.
38+
</ParamField>
39+
<ParamField body="discount" type="object | null">
40+
The discount this code belonged to.
41+
42+
<Expandable title="discount object">
43+
<ParamField body="id" type="string">
44+
Unique identifier for the discount.
45+
</ParamField>
46+
<ParamField body="amount" type="number">
47+
Discount amount. For <code>percentage</code> discounts this is the
48+
percent off (e.g. <code>10</code> = 10% off). For <code>flat</code>
49+
discounts this is the amount in cents (e.g. <code>500</code> = $5.00).
50+
</ParamField>
51+
<ParamField body="type" type="string">
52+
Discount type: <code>percentage</code> or <code>flat</code>.
53+
</ParamField>
54+
<ParamField body="maxDuration" type="number | null">
55+
Maximum duration in months. <code>0</code> is one-time,
56+
<code>null</code> is lifetime.
57+
</ParamField>
58+
<ParamField body="provider" type="string">
59+
Discount provider: <code>stripe</code>, <code>shopify</code>, or
60+
<code>custom</code>.
61+
</ParamField>
62+
</Expandable>
63+
64+
</ParamField>
65+
</WebhookResponseBodyParameters>
66+
67+
<ResponseExample>
68+
69+
```json Response
70+
{
71+
"id": "evt_64dv6vxYVgltzJBKc9ujJ1ghL",
72+
"event": "discount_code.deleted",
73+
"createdAt": "2026-08-19T10:48:15.468Z",
74+
"data": {
75+
"id": "dcode_1K39DGZG3MHY9RP4PD0AS2C5P",
76+
"code": "STEVEN10OFF",
77+
"partnerId": "pn_1K9BZE1K285BSTX4W6MPKXJFZ",
78+
"linkId": "link_5myDHLqhIQvUmUPjchVygF9R",
79+
"disabledAt": null,
80+
"discount": {
81+
"id": "disc_1KEC01MXC5H50XQMSN83VCW65",
82+
"amount": 10,
83+
"type": "percentage",
84+
"maxDuration": 6,
85+
"provider": "custom"
86+
}
87+
}
88+
}
89+
```
90+
91+
</ResponseExample>

0 commit comments

Comments
 (0)