# discount_code.created

import { WebhookResponseBodyParameters } from "/snippets/webhook-response-body-parameters.mdx";

Occurs whenever a [discount code is created](/docs/api-reference/discount-codes/create) for a partner.

<Tip>
  This event is sent when a discount code is created via the API, the dashboard,
  or auto-provisioning when a partner joins a group.

If the discount uses the **custom** provider, listen to this webhook to create
the corresponding promo code in your own system. For Stripe and
Shopify discounts, Dub creates the code in the connected provider
automatically.

</Tip>

<WebhookResponseBodyParameters type="discount_code.created">
  <ParamField body="id" type="string">
    Unique identifier for the discount code (e.g. <code>dcode_...</code>).
  </ParamField>
  <ParamField body="code" type="string">
    The alphanumeric discount code customers can apply at checkout.
  </ParamField>
  <ParamField body="partnerId" type="string">
    ID of the partner this discount code is assigned to.
  </ParamField>
  <ParamField body="linkId" type="string">
    ID of the partner's referral link this discount code is associated with.
  </ParamField>
  <ParamField body="disabledAt" type="string | null">
    ISO 8601 timestamp when the code was disabled, or <code>null</code> if it is
    active.
  </ParamField>
  <ParamField body="discount" type="object | null">
    The discount this code belongs to.

    <Expandable title="discount object">
      <ParamField body="id" type="string">
        Unique identifier for the discount.
      </ParamField>
      <ParamField body="amount" type="number">
        Discount amount. For <code>percentage</code> discounts this is the
        percent off (e.g. <code>10</code> = 10% off). For <code>flat</code>
        discounts this is the amount in cents (e.g. <code>500</code> = $5.00).
      </ParamField>
      <ParamField body="type" type="string">
        Discount type: <code>percentage</code> or <code>flat</code>.
      </ParamField>
      <ParamField body="maxDuration" type="number | null">
        Maximum duration in months. <code>0</code> is one-time,
        <code>null</code> is lifetime.
      </ParamField>
      <ParamField body="provider" type="string">
        Discount provider: <code>stripe</code>, <code>shopify</code>, or
        <code>custom</code>.
      </ParamField>
    </Expandable>

  </ParamField>
</WebhookResponseBodyParameters>

<ResponseExample>

```json Response
{
  "id": "evt_KleiO4HBwZFbO1vZLWIPZ2AtX",
  "event": "discount_code.created",
  "createdAt": "2026-08-19T10:48:15.468Z",
  "data": {
    "id": "dcode_1K39DGZG3MHY9RP4PD0AS2C5P",
    "code": "STEVEN10OFF",
    "partnerId": "pn_1K9BZE1K285BSTX4W6MPKXJFZ",
    "linkId": "link_5myDHLqhIQvUmUPjchVygF9R",
    "disabledAt": null,
    "discount": {
      "id": "disc_1KEC01MXC5H50XQMSN83VCW65",
      "amount": 10,
      "type": "percentage",
      "maxDuration": 6,
      "provider": "custom"
    }
  }
}
```

</ResponseExample>
