🛒

coupons

Promotional coupon code that customers can apply for discounts. Tracks coupon code, discount rules, usage limits, validity period, and redemption statistics.

🎯 Request Builder

https://api.mockly.codes/coupons?page=1&limit=10&count=10
📡

Configure your request and click Send Request to see the response here.

Endpoints

GET/coupons

Get a collection of coupons

Alternative: /commerce/coupons
GET/coupons/:id

Get a single coupon by ID

Alternative: /commerce/coupons/:id
GET/coupons/meta

Get resource metadata and schema

Alternative: /commerce/coupons/meta
🔍

How to Use Search

The search feature allows you to filter results by searching for text across all or specific fields. Choose between ?q= or ?search= parameter names.

1. Basic Search

Search across all text fields:

Basic Search
GET https://api.mockly.codes/coupons?q=laptop

2. Search Specific Fields

Field-Specific Search
GET https://api.mockly.codes/coupons?q=laptop&search_fields=name,description

💡 Pro Tips

  • Search is case-insensitive and performs partial matching
  • Without search_fields, all text fields are searched
  • Combine with pagination to handle large result sets efficiently

Code Examples

JavaScript

Fetch Collection
// Get 10 coupons
fetch('https://api.mockly.codes/coupons?count=10')
  .then(res => res.json())
  .then(data => console.log(data));

Python

Fetch with Requests
import requests

response = requests.get(
    'https://api.mockly.codes/coupons?count=10'
)
data = response.json()

cURL

Command Line
curl "https://api.mockly.codes/coupons?count=10"

Bypass Cache

Get Fresh Data
fetch('https://api.mockly.codes/coupons?nocache=true')

Schema Properties

idinteger

Unique identifier for the coupon

Gen:random_int
codestring

Unique alphanumeric coupon code that customers enter at checkout (e.g., SAVE20, WELCOME10)

Gen:coupon_code
descriptionstring

Marketing description explaining what the coupon offers

Gen:sentence
discount_typestring

Type of discount (e.g., percentage, fixed_amount, free_shipping)

Gen:discount_type
discount_valuenumber

Discount amount - percentage (e.g., 20) or fixed amount depending on discount_type

Gen:price
min_purchasenumber

Minimum purchase amount required to use this coupon

Gen:price
max_discountnumber

Maximum discount amount that can be applied, used to cap percentage discounts

Gen:price
currencystring

ISO currency code for monetary values (e.g., USD, EUR, GBP)

Gen:currency
usage_limitinteger

Maximum number of times this coupon can be used across all customers

Gen:random_int
used_countinteger

Number of times this coupon has been successfully applied

Gen:random_int
valid_fromstring

Date when the coupon becomes active and can be used

Gen:past_datedate
valid_untilstring

Expiration date after which the coupon is no longer valid

Gen:future_datedate
activeboolean

Whether the coupon is currently active and available for use

Gen:boolean

Query Parameters

countinteger

Number of items to return (default: 10, max: 100)

seedinteger

Seed for reproducible data generation

nocacheboolean

Bypass cache and generate fresh data on every request