Skip to main content
POST
Ruby
The partner’s group must already have a discount assigned, and each referral link can only have one discount code. If you omit code, Dub generates one from the partner’s name.

Authorizations

Authorization
string
header
required

Default authentication mechanism

Body

application/json
partnerId
string
required

The ID of the partner to create a discount code for.

The ID of the partner's referral link to associate this discount code with. Each link can only have one discount code.

code
string

The discount code to create. If omitted, a unique code will be generated automatically from the partner's name.

Maximum string length: 100
Pattern: ^[a-zA-Z0-9\-_]+$

Response

The created discount code.

id
string
required

The unique ID of the discount code.

Example:

"dcode_1JVR7XRCSR0EDBAF39FZ4PMYE"

code
string
required

The alphanumeric discount code that customers can apply at checkout.

Example:

"PARTNER10OFF"

discountId
string | null
required

The ID of the discount this code belongs to.

partnerId
string
required

The ID of the partner this discount code is assigned to.

The ID of the partner's referral link this discount code is associated with.

disabledAt
string | null

When this discount code was disabled, which happens when a partner is banned or deactivated. We don't delete the discount code to avoid another partner claiming a banned/deactivated code (abuse vector).