Coupons — API
Base URL: http://localhost:8765/api/v1 (local) · https://dev.api.nexgate.co/api/v1 (staging)
Short Description: Discounts with conditions. NexGate coupons are paid from a NexGate pot (the seller still gets the
full price); shop coupons are paid by the shop (its order is cheaper); event coupons are paid by the event's
organiser (the ticket is cheaper). Buyers collect a coupon or type its code, and use it at checkout. Design and the 19
coupon rules: COUPON_SPEC.md; build decisions: COUPON_BUILD_PLAN.md §0a.
Hints:
- Every call uses the person's normal login:
Authorization: Bearer <access token>. - The feature has a switch. While coupons are off, every endpoint here answers 404 and checkouts ignore coupon
fields. Hide the coupon screens when
GET /coupons/mineanswers 404. - Every rule is checked by the server when a coupon is collected or typed, when a checkout is made or changed, and again at payment. The app only shows what the server says.
- Amounts are TZS. A percent coupon always has a cap. Codes are letters and numbers, any case:
yoyo-10=YOYO10. - Refusals are HTTP 409 with
data.codeanddata.reason(show the reason as it is). Full list in Part 9.
Contents
- Part 1 — How it works (diagrams, money, examples)
- Part 2 — Buyer: find, collect, type a code, My coupons (1–5)
- Part 3 — Buyer: coupons at checkout (changes to existing endpoints)
- Part 4 — Shop owner: shop coupons (6–16)
- Part 5 — Event organiser: event coupons (17–24)
- Part 6 — NexGate admin: NexGate coupons (25–37)
- Part 7 — Admin support (38–40)
- Part 8 — Notifications
- Part 9 — Refusal codes
- Part 10 — Screens checklist
Part 1 — How it works
1.1 Three creators
| NexGate coupon | Shop coupon | Event coupon | |
|---|---|---|---|
| Made by | super admin | the shop owner, or staff whose role can make price offers | the event's organiser |
| Paid by | the coupon's pot (from COUPONS-CAMPAIGNS) |
the shop: its order is cheaper | the organiser: the ticket is cheaper |
| Seller / organiser gets | full price | price − discount (commission on that) | price − discount |
| Works on | shop orders; chat offers, group buys, event tickets where its switches say | shop orders only | paid tickets of that event (its ticket types), not group prices |
| Stops when | the pot is empty, total uses, end date | spending limit, total uses, end date | spending limit, total uses in tickets, end date, the event starts / is cancelled / completes |
| Never on | instalments, gifts, delivery | chat offers, group buys, instalments, gifts, delivery | free or donation tickets, group prices |
At most one NexGate coupon + one coupon per shop on an order (rule 6).
1.2 From a coupon to a discount
NexGate / shop / organiser BUYER (Juma)
────────────────────────── ────────────
creates coupon, code YOYO10,
"Show in app" on or off
│
├── shown on: shop page / product page ─► GET /coupons/shown?shopId= ─► [Collect] POST /coupons/{id}/collect
│ event page ─► GET /coupons/shown-for-event
├── a code anywhere (Instagram, sticker, ─► types it: POST /coupons/redeem { code } (also what nexgate.co/<code> opens)
│ influencer, private coupons)
└── given to people (sorry, thank-you, ─► lands straight in My coupons (COUPON_RECEIVED)
referral)
My coupons GET /coupons/mine ─► ACTIVE · USED · EXPIRED
│
▼
checkout: nexgateCouponId / shopCouponIds / eventCouponId ─► discount shown, checked again at payment
│
▼
paid ─► the coupon is USED for this person (even if the order is later refunded: rule 18)
A held coupon belongs to that account: a screenshot is useless to anyone else (rule 13).
1.3 Where the money goes
NexGate coupon (shoes 30,000; NexGate 5,000 off; gift balance 8,000):
┌───────────────┐ 5,000 ┌─────────────────────────┐
│ coupon's pot │ ────────► │ │
├───────────────┤ 8,000 │ order escrow 30,000 │ ──► seller gets 30,000 − commission
│ gift balance │ ────────► │ (the FULL price) │
├───────────────┤ 17,000 │ │
│ wallet │ ────────► │ │
└───────────────┘ └─────────────────────────┘
Juma pays 25,000: gift first, then wallet. Payment answer: amountPaid 30,000 · couponDiscount 5,000 · giftPaid 8,000 · walletPaid 17,000
Shop coupon (Mama Yoyo's 10% off, at most 5,000; shoes 30,000):
checkout total 27,000 (pricing.shopDiscount 3,000) ──► order escrow 27,000 ──► the shop gets 27,000 − commission
No money moves for the coupon: the order is simply cheaper. The order shows discount 3,000.
Both on one order: the shop's coupon comes off first, the NexGate coupon is worked out on what is left, then gift balance, then the wallet (rule 17).
shoes 30,000 ─► shop coupon −3,000 = 27,000 ─► NexGate 10% (cap 5,000) on 27,000 = −2,700 ─► Juma pays 24,300
A cart over two shops shares a NexGate coupon by the size of each shop's covered items (rule 19): dress 30,000 (Mama Yoyo) + earphones 10,000 (Tech Shop), coupon 8,000 → 6,000 + 2,000. A shop coupon stays inside its own shop.
1.4 Refunds (rule 18)
| Juma's order | Back to Juma | Back to the coupon | The coupon |
|---|---|---|---|
| Whole order cancelled, paid 5,000 coupon + 8,000 gift + 17,000 wallet | 8,000 gift + 17,000 wallet | 5,000 to the pot (to COUPONS-CAMPAIGNS if it has ended) |
stays used |
| One of two items returned (half) | his half, in the same gift / wallet mix | half of the coupon to the pot | stays used |
| A shop-coupon order refunded | what he paid | the shop's spending limit comes back | stays used |
The refund notice says: "… · The TZS 5,000 coupon used on this order is not returned".
1.5 Codes (rule 16)
- Unique among live coupons across NexGate (scheduled, running, paused, ran out).
- After a coupon ends its code stays reserved for its owner for 90 days, then anyone may take it.
- Letters and numbers, 4–20; any case; spaces and dashes ignored. Shops can't start a code with
NEXGATE. - Empty code → made automatically from the shop / event name:
MAMAYO7K2P. - A code can't change after the coupon is made. 5 wrong codes → 60-minute pause.
1.6 Editing after someone holds it
| Can change | Can't change once anyone collected or used it |
|---|---|
| title · a later end date · higher limits (per buyer, total uses, spending limit) · the show switch | discount · cap · minimum · audience · what it covers · switches · start (once started) |
To change those: stop it and make a new one (COUPON_TERMS_LOCKED).
Standard Response Format
Success
{ "success": true, "httpStatus": "OK", "message": "Coupon collected", "action_time": "2026-11-21T10:30:45", "data": { } }
Coded refusal (HTTP 409)
{
"success": false, "httpStatus": "CONFLICT", "message": "Add 5000 TZS more to use this coupon", "action_time": "2026-11-21T10:30:45",
"data": { "code": "COUPON_MIN_ORDER", "reason": "Add 5000 TZS more to use this coupon" }
}
| Status | When |
|---|---|
401 |
missing or expired token |
403 |
admin endpoint without the right role |
404 |
coupons are switched off; or the coupon / shop / event isn't found or isn't yours |
409 |
a coded refusal (Part 9) |
422 |
a field fails validation |
Shared objects
CouponCard (what a buyer sees)
{
"couponId": "7c1e…", "creator": "SHOP",
"shop": { "shopId": "cfb6…", "name": "Mama Yoyo",
"logo": { "fileId": "1d2e…", "status": "READY", "thumbUrl": "https://…/thumb.webp", "mimeType": "image/webp" } },
"title": "10% off for followers", "code": "YOYO10", "kind": "PERCENT", "value": 10, "cap": 5000, "minOrder": 20000,
"startsAt": "2026-11-21T00:00:00", "endsAt": "2026-11-30T23:59:00", "audience": "FOLLOWERS",
"covers": { "shops": 0, "categories": 0, "products": 3, "notOnSale": true, "chatOffers": false, "groupBuys": false, "events": false },
"held": true, "state": "ACTIVE", "usesLeft": 1, "canCollect": false, "whyNot": null
}
| Field | Description |
|---|---|
creator |
NEXGATE, SHOP, ORGANISER |
shop |
For shop coupons: the shop and its logo (media standard: ShopLogoPrimaryMedia); null otherwise |
code |
Only for coupons shown in the app. A private code is never sent: whoever has it already knows it |
kind / value / cap |
FIXED: value TZS off. PERCENT: value %, at most cap |
minOrder |
Counted on the covered items only |
audience |
EVERYONE, NEW_TO_NEXGATE, NEW_TO_SHOP, FOLLOWERS, PAST_BUYERS, CHOSEN |
covers |
How many shops / categories / products it is limited to (0 = all), and which other payments a NexGate coupon also works on |
endsAt |
When the coupon ends for you. Usually the coupon's own end. A coupon you grabbed in a live drop lasts as long as the shop chose (1 hour to 7 days from the grab) and a referral welcome coupon 14 days: then endsAt is that earlier time. Never later than the coupon's own end |
held / state / usesLeft |
In My coupons: ACTIVE, USED (no uses left for you), EXPIRED (the coupon ended, or your own endsAt passed) |
canCollect / whyNot |
On shop, product and event pages: show Collect, or the reason it isn't for you |
Show the discount as "5,000 off" or "10% off, up to 5,000"; "Min. order 20,000"; "Ends 30 Nov".
CouponResponse (what its creator sees)
{
"couponId": "7c1e…", "creator": "NEXGATE", "shopId": null, "eventId": null, "title": "Welcome: 5,000 off", "code": "WELCOME5",
"showInApp": true, "kind": "FIXED", "value": 5000, "cap": null, "minOrder": 20000,
"startsAt": "2026-11-21T00:00:00", "endsAt": "2026-12-31T23:59:00", "audience": "NEW_TO_NEXGATE", "followedBefore": false,
"shopIds": [], "categoryIds": [], "productIds": [], "excludedProductIds": [], "notOnSale": false,
"allowChatOffers": false, "allowGroupBuys": true, "allowEvents": false, "perBuyerLimit": 1, "totalUses": 1000,
"state": "RUNNING", "termsLocked": true,
"numbers": { "holders": 340, "orders": 120, "buyers": 118, "discountGiven": 595000, "returned": 5000 },
"pot": { "accountNumber": "CPOT-7c1e…", "funded": 2000000, "used": 600000, "returned": 5000, "left": 1405000 },
"limit": null, "createdAt": "2026-11-21T09:00:00", "endedAt": null
}
| Field | Description |
|---|---|
state |
SCHEDULED, RUNNING, PAUSED, RAN_OUT (pot empty, limit or uses reached), ENDED, CANCELLED |
termsLocked |
Someone holds or used it: only the fields in 1.6 can change |
numbers |
orders = payments that used it (a refund doesn't lower it); discountGiven is net of refunds |
pot |
NexGate coupons only |
limit |
Shop / event coupons: { limit, used } (the spending limit) |
ticketTypeIds |
Event coupons (in the request; the response carries the event in eventId) |
CouponRequest (create and edit)
| Field | Type | Required | Description | Validation |
|---|---|---|---|---|
| title | string | Yes | Shown to buyers | max 80 |
| code | string | No | Empty = made automatically | 4–20 letters/numbers; shops: not NEXGATE…; can't change later |
| showInApp | boolean | No | Shown on shop / product / event pages (default true); off = a private code |
|
| kind | string | Yes | FIXED or PERCENT |
|
| value | number | Yes | TZS off, or the % | whole numbers; % from 1 to 100 |
| cap | number | PERCENT | The most it takes off | required for PERCENT |
| minOrder | number | No | Minimum of the covered items | ≥ 0 |
| startsAt | datetime | No | Default now | |
| endsAt | datetime | Yes | after start and in the future; event coupons: by the event start / ticket sales end | |
| audience | string | No | Default EVERYONE |
NexGate: EVERYONE, NEW_TO_NEXGATE, CHOSEN; shop: EVERYONE, NEW_TO_SHOP, FOLLOWERS, PAST_BUYERS, CHOSEN; event: EVERYONE |
| followedBefore | boolean | No | Followers only: only people who followed before it started | only with FOLLOWERS |
| shopIds | UUID[] | No | NexGate: only these shops (empty = all) | must exist |
| categoryIds | UUID[] | No | Only these product categories | must exist |
| productIds / excludedProductIds | UUID[] | No | Shop: only / never these products | the shop's own |
| notOnSale | boolean | No | Shop: not on items already on sale | |
| allowChatOffers / allowGroupBuys / allowEvents | boolean | No | NexGate only: also on chat offers / a member's own group-buy share / paid event tickets | |
| perBuyerLimit | integer | No | Uses per person (default 1) | ≥ 1 |
| totalUses | integer | No | Total uses (event coupons: tickets) | ≥ 1 |
| spendLimit | number | shop / event | The most given in discounts in total | required for shops and events; never for NexGate |
| budget | number | NexGate create | Moved from COUPONS-CAMPAIGNS into the pot |
required on NexGate create |
| reason | string | No | For the admin audit log | max 300 |
| ticketTypeIds | UUID[] | No | Event coupons: only these ticket types | the event's own |
Part 2 — Buyer
1. Coupons on a shop or product page
Purpose: Public coupons a buyer can collect here: the shop's own and NexGate's that cover it.
Endpoint: GET {base_url}/coupons/shown?shopId={shopId} or ?productId={productId}
Access Level: 🔒 Protected
| Parameter | Type | Required | Description |
|---|---|---|---|
| shopId | UUID | one of the two | Shop page: every coupon for this shop |
| productId | UUID | one of the two | Product page: only coupons that cover this product |
Success Response: data = list of CouponCard. Show Collect when canCollect, else whyNot
("Only for people who follow this shop"). Running coupons only; ones that ran out are left out.
2. Coupons on an event page
Endpoint: GET {base_url}/coupons/shown-for-event?eventId={eventId}
Access Level: 🔒 Protected
Success Response: list of CouponCard: the organiser's own coupons for this event and NexGate coupons that work on event tickets.
3. Collect
Purpose: Put a shown coupon into My coupons.
Endpoint: POST {base_url}/coupons/{couponId}/collect
Access Level: 🔒 Protected
No body. Collecting twice is safe (the same card comes back). Private coupons can't be collected (404): they are typed.
Success Response: the CouponCard with held: true.
Errors (409): COUPON_ENDED, COUPON_NOT_STARTED, COUPON_RAN_OUT, COUPON_NOT_FOR_YOU (audience, or you are the shop's
own team / the organiser), COUPON_USED_UP.
4. Type a code
Purpose: Add a coupon by its code (public or private). The nexgate.co/<code> link opens the app and calls this.
Endpoint: POST {base_url}/coupons/redeem
Access Level: 🔒 Protected
Request JSON Sample:
{ "code": "yoyo-10" }
| Parameter | Type | Required | Validation |
|---|---|---|---|
| code | string | Yes | max 40; any case, spaces / dashes ignored |
Success Response: the CouponCard, held: true.
Errors (409): COUPON_CODE_NOT_FOUND (counts as a wrong try), COUPON_CODE_TRIES_PAUSED (5 wrong in 60 minutes), and
the errors of endpoint 3.
5. My coupons
Endpoint: GET {base_url}/coupons/mine?state=ACTIVE
Access Level: 🔒 Protected
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
| state | string | No | ACTIVE, USED, EXPIRED |
all |
Success Response: list of CouponCard (newest first), each with held: true, state, usesLeft.
What is in the list: coupons you collected, typed, were given (by a shop, the referral welcome / thank-you), and
coupons you grabbed in a live or meeting coupon drop (POST /live/streams/{streamId}/drops/{dropId}/grab, live doc; POST /meetings/{meetingId}/drops/{dropId}/grab,
calls & meetings doc).
A grabbed coupon works like any shop coupon at checkout until its endsAt; while it can be used, your orders in that
shop also count for the live or meeting.
Part 3 — Coupons at checkout (changes to existing endpoints)
Also in commerce_logistics_changes.md §16. With coupons off, these fields are ignored and nothing new appears.
3.1 Shop checkouts
POST {base_url}/e-commerce/checkout-sessions ·
PATCH {base_url}/e-commerce/checkout-sessions/{sessionId}
New request fields:
| Field | Type | On | Description |
|---|---|---|---|
| nexgateCouponId | UUID | create, update | One NexGate coupon from My coupons |
| removeCoupon | boolean | update | true takes the NexGate coupon off |
| shopCouponIds | UUID[] | create, update | At most one per shop (shop orders only: buy now, cart). On update the list replaces the shop coupons; [] takes them off |
{ "sessionType": "REGULAR_CART", "nexgateCouponId": "7c1e…", "shopCouponIds": ["a4b2…"], "useGiftBalance": true }
New response fields:
{
"pricing": { "subtotal": 30000, "shopDiscount": 3000, "shippingCost": 0, "tax": 0, "total": 27000, "currency": "TZS" },
"shopCoupons": [ { "couponId": "a4b2…", "shopId": "cfb6…", "discount": 3000, "byPart": { "cfb6…": 3000 } } ],
"nexgateCouponId": "7c1e…", "couponDiscount": 2700, "amountToPay": 24300
}
| Field | Description |
|---|---|
pricing.shopDiscount |
New. Shop coupons, already taken off pricing.total |
shopCoupons |
New. Each shop coupon and its discount per order group |
nexgateCouponId, couponDiscount |
New. The NexGate coupon and its discount (paid by NexGate; pricing.total stays the price before it) |
amountToPay |
New. pricing.total − couponDiscount: what gift balance and wallet pay |
Where they work: NexGate coupons on buy now and cart; on chat offers and group buys only when that coupon allows it; never on instalments. Shop coupons on buy now and cart only.
Flash prices (from a live or meeting) take no coupon on top:
- A shop coupon is refused with
NO_COUPON_ON_FLASHwhen that shop's items in this order include a flash price. Other shops' coupons in the same cart still work. - A NexGate coupon comes off the items without a flash price. It is refused with
NO_COUPON_ON_FLASHonly when every item has a flash price.
3.2 Event checkout
POST {base_url}/e-events/checkout
| New field | Description |
|---|---|
| nexgateCouponId | A NexGate coupon that allows event tickets |
| eventCouponId | The organiser's coupon for this event (paid tickets, not group prices) |
The organiser's coupon lowers pricing.total; a NexGate coupon is then worked out on what is left.
3.3 Balance check and payment
GET /wallet/checkout-balance-check gains couponDiscount (the NexGate coupon); giftPart and shortfall count it.
POST …/process-payment (shop) and POST /e-events/checkout/{id}/payment gain couponDiscount:
{ "status": "COMPLETED", "amountPaid": 30000, "couponDiscount": 5000, "giftPaid": 8000, "walletPaid": 17000 }
amountPaid = the price held for the seller; the buyer paid giftPaid + walletPaid.
At payment every coupon is checked again. If one no longer applies (ended, ran out, unfollowed the shop, someone took
the last use) the payment is refused with its code (COUPON_RAN_OUT, COUPON_ENDED, COUPON_NOT_FOR_YOU,
COUPON_CHANGED, …) and nothing is taken. Show the reason, take the coupon off (PATCH with removeCoupon / a new
shopCouponIds), show the new price.
3.4 Order detail and refund notice
GET /e-commerce/orders/{orderId} gains:
| Field | Description |
|---|---|
discount |
The shop coupon's discount on this order (the shop paid it) |
coupon |
The NexGate coupon: { couponId, code, title, discount, returnedToCoupon }. Show "Coupon WELCOME5 −5,000"; after a refund "(not returned)" |
ESCROW_REFUNDED data: refund.body ends with "· The TZS 5,000 coupon used on this order is not returned";
refund.coupon carries the amount.
Part 4 — Shop owner: shop coupons
Base: {base_url}/shops/{shopId}/coupons. Who: the shop owner, or staff whose shop role has price offers. A
coupon of another shop answers 404.
6. Create
POST {base_url}/shops/{shopId}/coupons
{
"title": "Followers: 10% off", "code": "YOYO10", "showInApp": true, "kind": "PERCENT", "value": 10, "cap": 5000, "minOrder": 20000,
"endsAt": "2026-11-30T23:59:00", "audience": "FOLLOWERS", "followedBefore": false,
"productIds": [], "categoryIds": [], "excludedProductIds": ["d1c0…"], "notOnSale": true,
"perBuyerLimit": 1, "totalUses": 100, "spendLimit": 200000
}
Body: CouponRequest (spendLimit required, no budget, no shopIds or switches).
Response: CouponResponse with limit. A followers-only coupon that starts
now tells the shop's followers (once a day per shop).
Errors: NOT_YOUR_SHOP, COUPON_CODE_TAKEN, COUPON_CODE_RESERVED, COUPON_CODE_INVALID, COUPON_CAP_REQUIRED,
COUPON_VALUE_INVALID, COUPON_DATES_INVALID, COUPON_AUDIENCE_NOT_ALLOWED, COUPON_FIELD_NOT_ALLOWED,
COUPON_LIMIT_REQUIRED, PRODUCT_NOT_IN_SHOP, CATEGORY_NOT_FOUND.
7. My coupons (list) · 8. Side by side
GET {base_url}/shops/{shopId}/coupons → list of CouponResponse.
GET {base_url}/shops/{shopId}/coupons/compare
[ { "couponId": "…", "code": "INSTA10", "title": "Instagram 10%", "state": "RUNNING", "orders": 40, "newCustomers": 25,
"discountGiven": 120000, "salesCompleted": 1200000 },
{ "couponId": "…", "code": "RADIO10", "title": "Radio 10%", "state": "ENDED", "orders": 3, "newCustomers": 1,
"discountGiven": 9000, "salesCompleted": 90000 } ]
9. One coupon
GET {base_url}/shops/{shopId}/coupons/{couponId} → CouponResponse.
10. Report (the coupon's impact)
GET {base_url}/shops/{shopId}/coupons/{couponId}/report
{
"couponId": "…", "code": "YOYO10", "title": "Followers: 10% off", "state": "RUNNING",
"people": { "newCustomers": 31, "returning": 13, "newFollowers": 85 },
"money": { "salesCompleted": 1320000, "discountGiven": 132000, "costPerOrder": 3000, "averageOrder": 30000, "usualOrder": 22000 },
"funnel": { "holders": 120, "orders": 48, "completed": 44, "cancelled": 4, "takeUpPercent": 40.0 },
"perDay": [ { "day": "2026-11-21", "orders": 9, "discount": 27000 } ],
"topProducts": [ { "productName": "Red dress", "quantity": 18 } ],
"limits": { "spendLimit": 200000, "spent": 132000, "totalUses": 100, "used": 48 }
}
| Section | Meaning |
|---|---|
people |
first: new customers (no earlier order at this shop) vs returning; new followers while it ran |
money |
completed orders' items sales; discount net of refunds; per order; average order with the coupon vs the shop's usual (its average completed order in the 90 days before) |
funnel |
holders → orders → completed / cancelled; take-up = orders ÷ holders |
perDay, topProducts, limits |
for the small chart, best sellers, and how much of the limit is used |
11. Its orders
GET {base_url}/shops/{shopId}/coupons/{couponId}/orders?page=1&size=20
{ "content": [ { "orderId": "…", "orderNumber": "ORD-2026-0042", "shopId": "…", "shopName": "Mama Yoyo", "orderItems": 30000,
"discount": 3000, "status": "COMPLETED", "newCustomer": true, "orderedAt": "2026-11-21T11:02:10" } ],
"totalElements": 48, "number": 0, "size": 20 }
12. Edit
PUT {base_url}/shops/{shopId}/coupons/{couponId} — the whole CouponRequest. Once held, only what 1.6 allows
(COUPON_TERMS_LOCKED); the code never changes (COUPON_CODE_FIXED); an ended coupon can't change (COUPON_CLOSED).
13–15. Pause · resume · stop
POST …/{couponId}/pause · …/resume · …/stop (stop: optional { "reason": "…" }). Calling twice is safe. A stopped
coupon is final: people who hold it see it as expired; its code is reserved for the shop for 90 days.
16. Give to people
POST {base_url}/shops/{shopId}/coupons/{couponId}/give
{ "accountIds": ["3213…", "77c1…"], "reason": "Sorry for the late delivery" }
{ "given": 1, "alreadyHeld": 0, "notFound": [], "notAllowed": ["77c1…"] }
A shop gives only to its followers, past buyers (a completed order) or people it chats with; others come back in
notAllowed. Each person gets COUPON_RECEIVED.
Part 5 — Event organiser: event coupons
Base: {base_url}/events/{eventId}/coupons. Who: the event's organiser.
| # | Method | Endpoint | |
|---|---|---|---|
| 17 | POST | …/coupons |
create |
| 18 | GET | …/coupons |
list |
| 19 | GET | …/coupons/{couponId} |
one |
| 20 | GET | …/coupons/{couponId}/report |
uses and discount |
| 21 | PUT | …/coupons/{couponId} |
edit |
| 22–24 | POST | …/{couponId}/pause · /resume · /stop |
{ "title": "Early bird: 2,000 off", "code": "EARLYBIRD", "kind": "FIXED", "value": 2000, "endsAt": "2026-12-01T18:00:00",
"ticketTypeIds": ["4f19…"], "totalUses": 50, "spendLimit": 100000 }
Rules:
- One event; optionally chosen ticket types (
TICKET_NOT_IN_EVENT). - It ends by the time the event starts or its ticket sales end (
COUPON_DATES_INVALID), and ends by itself when the event starts, is cancelled or completes. - Paid tickets only, never group ticket prices;
totalUsescounts tickets ("first 50 tickets"). - Audience: everyone. The organiser can't use their own coupon. Errors:
NOT_YOUR_EVENT,EVENT_CLOSED, plus Part 4's.
Part 6 — NexGate admin: NexGate coupons
Base: {base_url}/admin/coupons. Who: super admin. Every action is in the admin audit log.
Money first: move money PLATFORM-REVENUE → COUPONS-CAMPAIGNS with the existing finance transfer
(POST /admin/finance/system-accounts/transfer, toAccount: "COUPONS-CAMPAIGNS"). Each coupon's budget then moves into
its own pot.
| # | Method | Endpoint | Body / answer |
|---|---|---|---|
| 25 | POST | /admin/coupons |
CouponRequest with budget → CouponResponse (COUPON_BUDGET_REQUIRED, COUPON_BUDGET_LOW) |
| 26 | GET | /admin/coupons |
all NexGate coupons |
| 27 | GET | /admin/coupons/compare |
side by side |
| 28 | GET | /admin/coupons/{couponId} |
one |
| 29 | GET | /admin/coupons/{couponId}/report |
as 10, plus pot and byShop: [ { shopId, shopName, orders, discount } ] |
| 30 | GET | /admin/coupons/{couponId}/orders |
as 11 |
| 31 | PUT | /admin/coupons/{couponId} |
edit (as 12) |
| 32–34 | POST | …/{couponId}/pause · /resume · /stop |
optional { "reason" }; stopping sends the pot's leftover back to COUPONS-CAMPAIGNS |
| 35 | POST | …/{couponId}/top-up |
{ "amount": 500000, "reason": "…" } |
| 36 | POST | …/{couponId}/give |
{ "accountIds": [...], "reason" } → { given, alreadyHeld, notFound, notAllowed }; NexGate may give to anyone |
A NexGate coupon's pot under 10 % of what was funded tells the admins (COUPON_POT_LOW, once a day). Refunds after the
coupon ended land in its pot and are moved on to the budget by the timer.
Part 7 — Admin support
Who: staff admin and super admin.
| # | Method | Endpoint | |
|---|---|---|---|
| 38 | GET | /admin/coupons/search?code=YOYO10 |
every coupon that ever had this code (any creator), newest first |
| 39 | GET | /admin/coupons/people/{accountId} |
{ accountId, coupons: [CouponCard] } |
| 40 | POST | /admin/coupons/{couponId}/stop-shop-coupon |
{ "reason": "Misleading: price raised first" } (required) → stops a shop's or organiser's coupon; COUPON_NEXGATE_OWN for NexGate's own |
Admins can never edit a shop's coupon or move a shop's money.
Part 8 — Notifications
| Type | To | When | Text | Opens |
|---|---|---|---|---|
COUPON_RECEIVED |
buyer | given a coupon | 🎟️ Mama Yoyo gave you 5,000 off · Use by 30 Dec | My coupons (MY_COUPONS) |
COUPON_EXPIRING |
buyer | 2 days before a held, unused coupon ends (once) | Your 5,000 off from Mama Yoyo ends in 2 days | My coupons |
COUPON_NEW_FOR_FOLLOWERS |
followers | a followers-only shop coupon starts (max one a day per shop) | Mama Yoyo has 10% off for followers · Until 30 Nov | the shop (SHOP, shopId; couponId in data) |
COUPON_RAN_OUT |
shop owner | spending limit or total uses reached | YOYO10 has stopped · Spending limit reached. Raise it to restart. | the coupon (COUPON) |
COUPON_ENDED |
shop owner | the end date came | YOYO10 ended · 40 uses · TZS 120,000 discount · TZS 600,000 in sales | the coupon |
COUPON_POT_LOW |
admins | a NexGate pot under 10 % (once a day) | WELCOME5 pot: TZS 180,000 left of TZS 2,000,000 | admin coupon (ADMIN_COUPON) |
Data for apps that draw their own text: couponId, actor.name, shop.name, coupon.code, coupon.discount
("5,000 off" / "10% off"), coupon.endsOn, and per type coupon.stopReason, coupon.uses, coupon.discountTotal,
coupon.sales, coupon.potLeft, coupon.potTotal.
Part 9 — Refusal codes
All HTTP 409; show data.reason.
| Code | When |
|---|---|
COUPON_NOT_FOUND |
no such coupon (for this kind of use) |
COUPON_NOT_HELD |
collect or type it first |
NO_COUPON_ON_FLASH |
"A flash price takes no coupon on top": a shop coupon on a shop whose items have a flash price, or a NexGate coupon when every item has one (3.1) |
COUPON_NOT_STARTED / COUPON_ENDED / COUPON_CLOSED |
not yet / no longer running, or your own endsAt passed (live drop, referral welcome) / ended (can't be changed) |
COUPON_RAN_OUT |
pot empty, spending limit or total uses reached (event: "Only N tickets are left") |
COUPON_USED_UP |
you have used it as many times as allowed |
COUPON_NOT_FOR_YOU |
audience (new, followers, past buyers, chosen) or the shop's own team / the organiser |
COUPON_NOT_FOR_THIS |
not on this payment (chat offer, group buy, instalment, ticket type, free ticket, another event) or covers nothing here |
COUPON_MIN_ORDER |
"Add X TZS more to use this coupon" |
COUPON_ONE_PER_SHOP |
two coupons of the same shop |
COUPON_SELLER_LIMIT |
the shop's coupon doesn't fit with its delivery offer on this order |
COUPON_CHANGED |
a shop / organiser coupon changed between checkout and payment |
COUPON_CODE_NOT_FOUND / COUPON_CODE_TRIES_PAUSED |
wrong code / 5 wrong codes: paused |
COUPON_CODE_TAKEN / COUPON_CODE_RESERVED / COUPON_CODE_INVALID / COUPON_CODE_FIXED |
creating: code in use or reserved / NEXGATE… / format / can't change |
COUPON_TERMS_LOCKED |
editing what can't change once held |
COUPON_CAP_REQUIRED / COUPON_VALUE_INVALID / COUPON_DATES_INVALID / COUPON_AUDIENCE_NOT_ALLOWED / COUPON_FIELD_NOT_ALLOWED / COUPON_LIMIT_REQUIRED |
creating / editing |
COUPON_BUDGET_REQUIRED / COUPON_BUDGET_LOW / COUPON_HAS_NO_POT |
NexGate money |
COUPON_GIVE_NOT_ALLOWED / COUPON_NEXGATE_OWN |
giving event coupons / admin stop on a NexGate coupon |
NOT_YOUR_SHOP / NOT_YOUR_EVENT / ADMIN_ONLY |
who may manage |
SHOP_NOT_FOUND / CATEGORY_NOT_FOUND / PRODUCT_NOT_IN_SHOP / TICKET_NOT_IN_EVENT / EVENT_CLOSED / EVENT_REQUIRED / SHOP_REQUIRED / COUPON_SHOP_REQUIRED |
lists and scope |
Part 10 — Screens checklist
| Screen | Calls |
|---|---|
| Shop page / product page | coupons strip (1) with Collect (3) |
| Event page | coupons strip (2) with Collect |
| Me → My coupons | tabs Active / Used / Expired (5); Add a code (4) |
nexgate.co/<code> link |
open the app → (4) with the code |
| Checkout | "Use a coupon": My coupons that fit; send nexgateCouponId / shopCouponIds / eventCouponId; show shopDiscount, couponDiscount, amountToPay; on a coupon refusal at payment, take it off and show the new price |
| Receipt / order detail | couponDiscount, giftPaid, walletPaid; order discount and coupon |
| Shop dashboard → Coupons | list (7), side by side (8), create / edit (6, 12), report (10), orders (11), pause / resume / stop (13–15), give (16) |
| Event dashboard → Coupons | 17–24 |
| Admin → Coupons | 25–36; finance transfer to COUPONS-CAMPAIGNS first |
| Admin → Support | 38–40 |
No comments to display
No comments to display