Skip to main content
Offer codes (also called discount codes) allow you to provide discounts to customers. You can create both percentage-based and fixed-amount discounts, and make them universal (apply to all products) or product-specific.

List Offer Codes

Retrieve all offer codes for a product, including universal offer codes.
GET /v2/products/:product_id/offer_codes

Path Parameters

product_id
string
required
The unique identifier of the product

Response

success
boolean
Whether the request was successful
offer_codes
array
Array of offer code objects
curl https://api.gumroad.com/v2/products/product_id/offer_codes \
  -H "Authorization: Bearer <access_token>"

Get Offer Code

Retrieve details for a specific offer code.
GET /v2/products/:product_id/offer_codes/:id

Path Parameters

product_id
string
required
The unique identifier of the product
id
string
required
The unique identifier of the offer code

Response

success
boolean
Whether the request was successful
offer_code
object
The offer code object
curl https://api.gumroad.com/v2/products/product_id/offer_codes/offer_abc123 \
  -H "Authorization: Bearer <access_token>"

Create Offer Code

Create a new offer code for a product.
POST /v2/products/:product_id/offer_codes

Path Parameters

product_id
string
required
The unique identifier of the product

Body Parameters

name
string
required
The discount code that customers will use (letters, numbers, dashes, and underscores only)
offer_type
string
required
Type of discount: percent for percentage-based or fixed for fixed-amount
amount_off
integer
required
For percentage discounts: the percentage (0-100) For fixed discounts: can be used instead of amount_cents
amount_cents
integer
For fixed discounts: the discount amount in cents (alternative to amount_off)
universal
boolean
default:"false"
Whether the code applies to all of your products. Pass "true" or "false" as a string.
max_purchase_count
integer
Maximum number of times this code can be used (omit for unlimited)
You must provide either amount_off or amount_cents when creating an offer code. For percentage discounts, use amount_off. For fixed-amount discounts, use either parameter.

Response

success
boolean
Whether the request was successful
offer_code
object
The created offer code object
curl -X POST https://api.gumroad.com/v2/products/product_id/offer_codes \
  -H "Authorization: Bearer <access_token>" \
  -d "name=SAVE20" \
  -d "offer_type=percent" \
  -d "amount_off=20" \
  -d "max_purchase_count=100"

Update Offer Code

Update an existing offer code’s maximum purchase count.
PUT /v2/products/:product_id/offer_codes/:id

Path Parameters

product_id
string
required
The unique identifier of the product
id
string
required
The unique identifier of the offer code

Body Parameters

max_purchase_count
integer
Maximum number of times this code can be used

Response

success
boolean
Whether the request was successful
offer_code
object
The updated offer code object
curl -X PUT https://api.gumroad.com/v2/products/product_id/offer_codes/offer_abc123 \
  -H "Authorization: Bearer <access_token>" \
  -d "max_purchase_count=200"

Delete Offer Code

Soft delete an offer code (marks it as deleted but preserves data).
DELETE /v2/products/:product_id/offer_codes/:id

Path Parameters

product_id
string
required
The unique identifier of the product
id
string
required
The unique identifier of the offer code

Response

success
boolean
Whether the request was successful
curl -X DELETE https://api.gumroad.com/v2/products/product_id/offer_codes/offer_abc123 \
  -H "Authorization: Bearer <access_token>"

Error Codes

400
Bad Request - Missing required offer code parameters (amount_off or amount_cents)
401
Unauthorized - Invalid or missing access token
403
Forbidden - Insufficient permissions (requires edit_products scope for create/update/delete)
404
Not Found - Product or offer code not found
422
Unprocessable Entity - Invalid offer code parameters (e.g., discount exceeds product price)

Build docs developers (and LLMs) love