lomi.
Payments

Discount Coupons

Create and manage promotional discount codes.

The Discount Coupons API allows you to create and manage promotional codes that customers can apply at checkout.

Create a discount coupon

Request Body

FieldTypeRequiredDescription
codestringYesUnique coupon code (auto-uppercased)
discount_typestringNopercentage or fixed (default: percentage)
discount_percentagenumberIf percentageDiscount percentage (0-100)
discount_fixed_amountnumberIf fixedFixed discount amount
descriptionstringNoCoupon description
is_activebooleanNoActive status (default: true)
max_usesnumberNoMaximum total uses
max_quantity_per_usenumberNoMax quantity per use
valid_fromstringNoStart date (ISO 8601)
expires_atstringNoExpiration date (ISO 8601)
customer_typestringNoall, new, existing
usage_frequency_limitstringNototal, per_customer, per_customer_per_product
usage_limit_valuenumberNoLimit value (if not total)
scope_typestringNoorganization_wide, specific_products, specific_prices
product_idsarrayNoProduct IDs (if scope is specific)
import { LomiSDK } from '@lomi./sdk';

const lomi = new LomiSDK({
  apiKey: process.env.LOMI_API_KEY!,
  environment: 'live',
});

// Percentage discount
const coupon = await lomi.discountCoupons.create({
  code: 'SAVE20',
  discount_type: 'percentage',
  discount_percentage: 20,
  description: '20% off all products',
  max_uses: 100,
  expires_at: '2024-12-31T23:59:59Z',
});

// Fixed amount discount
const fixedCoupon = await lomi.discountCoupons.create({
  code: 'FLAT5000',
  discount_type: 'fixed',
  discount_fixed_amount: 5000,
  description: '5000 XOF off',
  customer_type: 'new',
});

console.log(`Coupon created: ${coupon.code}`);
from lomi import LomiClient
import os

client = LomiClient(
    api_key=os.environ["LOMI_API_KEY"],
    environment="test"
)

coupon = client.discount_coupons.create({
    "code": "SAVE20",
    "discount_type": "percentage",
    "discount_percentage": 20,
    "description": "20% off all products",
    "max_uses": 100,
    "expires_at": "2024-12-31T23:59:59Z"
})

print(f"Coupon created: {coupon['code']}")
curl -X POST "https://api.lomi.africa/discount-coupons" \
  -H "X-API-KEY: $LOMI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "SAVE20",
    "discount_type": "percentage",
    "discount_percentage": 20,
    "description": "20% off all products",
    "max_uses": 100,
    "expires_at": "2024-12-31T23:59:59Z"
  }'

List discount coupons

Retrieve all discount coupons for your organization.

const coupons = await lomi.discountCoupons.list();
coupons = client.discount_coupons.list()
curl -X GET "https://api.lomi.africa/discount-coupons" \
  -H "X-API-KEY: $LOMI_API_KEY"

Get a discount coupon

Retrieve details of a specific coupon.

const coupon = await lomi.discountCoupons.get('dc_abc123...');
coupon = client.discount_coupons.get('dc_abc123...')
curl -X GET "https://api.lomi.africa/discount-coupons/dc_abc123..." \
  -H "X-API-KEY: $LOMI_API_KEY"

Get coupon performance

Retrieve usage statistics and revenue impact for a coupon.

const performance = await lomi.discountCoupons.getPerformance('dc_abc123...');

console.log(`Total uses: ${performance.total_uses}`);
console.log(`Total discounted: ${performance.total_discount_amount}`);
console.log(`Revenue generated: ${performance.total_revenue}`);
console.log(`Avg order value: ${performance.average_order_value}`);
performance = client.discount_coupons.get_performance('dc_abc123...')
print(f"Total uses: {performance['total_uses']}")
curl -X GET "https://api.lomi.africa/discount-coupons/dc_abc123.../performance" \
  -H "X-API-KEY: $LOMI_API_KEY"

Response

{
  "total_uses": 45,
  "total_discount_amount": 25000,
  "total_revenue": 150000,
  "average_order_value": 3333.33
}

Discount Coupon Object

FieldTypeDescription
idstringUnique identifier
codestringCoupon code
discount_typestringpercentage or fixed
discount_percentagenumberPercentage value
discount_fixed_amountnumberFixed amount value
is_activebooleanActive status
max_usesnumberMaximum uses
current_usesnumberCurrent use count
valid_fromstringStart date
expires_atstringExpiration date
scope_typestringApplication scope
created_atstringCreation timestamp

Error Responses

StatusDescription
400Invalid input or duplicate code
401Invalid or missing API key
404Coupon not found

On this page