Coupons are discount codes customers enter at checkout - a fixed amount, a percentage, free shipping or buy X get Y - limited to products, collections, events or a minimum subtotal. Vouchers are app-exclusive offers.
Endpoints that need a token: the site owner creates it in their admin (Developers > API reference). AI assistants: how to ask the user for one.
13 endpoints in 3 parts: Coupon, Voucher, AI builder.
Lightweight endpoint for the ionic app to trigger the couponCapture middleware. The middleware runs before this handler, validates ?coupon= and sets the pending_coupon cookie.
Public - no token needed.
curl -X GET 'http://dunav41.com/coupon_capture?ionic=true'
Returns if a coupon is valid.
Works without a token; with a user token the answer is personal.
The coupon code's coupon code.
curl -X GET 'http://dunav41.com/coupon_code?ionic=true'
{
"code": "example",
"name": "Example",
"fixed_discount": 1,
"percentage_discount": 1,
"shipping_discount": 1,
"sale_discount": 1,
"apply_to_all_orders": false,
"apply_to_all_products": false,
"apply_to_product": "example",
"apply_to_event": "example",
"apply_to_all_events": false,
"apply_to_collection": "example",
"apply_to_minimum_subtotal": 49.9,
"start_date": "2026-11-04T12:00:00.000Z",
"end_date": "2026-11-04T12:00:00.000Z",
"no_end_date": false,
"limit_uses": 1,
"uses": 1,
"_id": "6543210fedcba98765432100",
"quantity_discount": {
"buy": 0,
"get": 0
}
}Returns if a coupon is valid.
Works without a token; with a user token the answer is personal.
The coupon code's code.
curl -X GET 'http://dunav41.com/coupon_code/{code}?ionic=true'{
"code": "example",
"name": "Example",
"fixed_discount": 1,
"percentage_discount": 1,
"shipping_discount": 1,
"sale_discount": 1,
"apply_to_all_orders": false,
"apply_to_all_products": false,
"apply_to_product": "example",
"apply_to_event": "example",
"apply_to_all_events": false,
"apply_to_collection": "example",
"apply_to_minimum_subtotal": 49.9,
"start_date": "2026-11-04T12:00:00.000Z",
"end_date": "2026-11-04T12:00:00.000Z",
"no_end_date": false,
"limit_uses": 1,
"uses": 1,
"_id": "6543210fedcba98765432100",
"quantity_discount": {
"buy": 0,
"get": 0
}
}Returns public coupon details by code without incrementing uses.
Public - no token needed.
The coupon info's code.
curl -X GET 'http://dunav41.com/coupon_info/{code}?ionic=true'{
"code": "example",
"name": "Example",
"fixed_discount": 1,
"percentage_discount": 1,
"shipping_discount": 1,
"sale_discount": 1,
"apply_to_all_orders": false,
"apply_to_all_products": false,
"apply_to_product": "example",
"apply_to_event": "example",
"apply_to_all_events": false,
"apply_to_collection": "example",
"apply_to_minimum_subtotal": 49.9,
"start_date": "2026-11-04T12:00:00.000Z",
"end_date": "2026-11-04T12:00:00.000Z",
"no_end_date": false,
"limit_uses": 1,
"uses": 1,
"_id": "6543210fedcba98765432100",
"quantity_discount": {
"buy": 0,
"get": 0
}
}Returns the site's coupons, newest first unless a sort is given.
Public - no token needed.
Returns a list of Coupon objects.
curl -X GET 'http://dunav41.com/coupons?ionic=true'
[
{
"code": "example",
"name": "Example",
"fixed_discount": 1,
"percentage_discount": 1,
"shipping_discount": 1,
"sale_discount": 1,
"apply_to_all_orders": false,
"apply_to_all_products": false,
"apply_to_product": "example",
"apply_to_event": "example",
"apply_to_all_events": false,
"apply_to_collection": "example",
"apply_to_minimum_subtotal": 49.9,
"start_date": "2026-11-04T12:00:00.000Z",
"end_date": "2026-11-04T12:00:00.000Z",
"no_end_date": false,
"limit_uses": 1,
"uses": 1,
"_id": "6543210fedcba98765432100",
"quantity_discount": {
"buy": 0,
"get": 0
}
}
]Create new coupon.
Needs a site admin token.
Returns the Coupon object.
curl -X POST 'http://dunav41.com/coupons?ionic=true' \ -H 'Authorization: Bearer <TOKEN>'
{
"code": "example",
"name": "Example",
"fixed_discount": 1,
"percentage_discount": 1,
"shipping_discount": 1,
"sale_discount": 1,
"apply_to_all_orders": false,
"apply_to_all_products": false,
"apply_to_product": "example",
"apply_to_event": "example",
"apply_to_all_events": false,
"apply_to_collection": "example",
"apply_to_minimum_subtotal": 49.9,
"start_date": "2026-11-04T12:00:00.000Z",
"end_date": "2026-11-04T12:00:00.000Z",
"no_end_date": false,
"limit_uses": 1,
"uses": 1,
"_id": "6543210fedcba98765432100",
"quantity_discount": {
"buy": 0,
"get": 0
}
}Returns one coupon, found by its ID.
Public - no token needed.
The ID of the coupon.
Returns the Coupon object.
curl -X GET 'http://dunav41.com/coupons/{id}?ionic=true'{
"code": "example",
"name": "Example",
"fixed_discount": 1,
"percentage_discount": 1,
"shipping_discount": 1,
"sale_discount": 1,
"apply_to_all_orders": false,
"apply_to_all_products": false,
"apply_to_product": "example",
"apply_to_event": "example",
"apply_to_all_events": false,
"apply_to_collection": "example",
"apply_to_minimum_subtotal": 49.9,
"start_date": "2026-11-04T12:00:00.000Z",
"end_date": "2026-11-04T12:00:00.000Z",
"no_end_date": false,
"limit_uses": 1,
"uses": 1,
"_id": "6543210fedcba98765432100",
"quantity_discount": {
"buy": 0,
"get": 0
}
}Update Coupon by id.
Needs a site admin token.
The ID of the coupon.
Returns the Coupon object.
curl -X PATCH 'http://dunav41.com/coupons/{id}?ionic=true' \
-H 'Authorization: Bearer <TOKEN>'{
"code": "example",
"name": "Example",
"fixed_discount": 1,
"percentage_discount": 1,
"shipping_discount": 1,
"sale_discount": 1,
"apply_to_all_orders": false,
"apply_to_all_products": false,
"apply_to_product": "example",
"apply_to_event": "example",
"apply_to_all_events": false,
"apply_to_collection": "example",
"apply_to_minimum_subtotal": 49.9,
"start_date": "2026-11-04T12:00:00.000Z",
"end_date": "2026-11-04T12:00:00.000Z",
"no_end_date": false,
"limit_uses": 1,
"uses": 1,
"_id": "6543210fedcba98765432100",
"quantity_discount": {
"buy": 0,
"get": 0
}
}Delete Coupon record by id.
Needs a site admin token.
The ID of the coupon.
Returns an empty answer on success.
curl -X DELETE 'http://dunav41.com/coupons/{id}?ionic=true' \
-H 'Authorization: Bearer <TOKEN>'Returns the site's vouchers, newest first unless a sort is given.
Public - no token needed.
Only vouchers with this authenticated.
Returns a list of Voucher objects.
curl -X GET 'http://dunav41.com/vouchers?ionic=true&authenticated=...'
[
{
"title": "Example",
"body": "Text shown on the site.",
"media": "6543210fedcba98765432100",
"show_to": "0",
"coupon": "6543210fedcba98765432100",
"_id": "6543210fedcba98765432100",
"updatedAt": "2026-11-04T12:00:00.000Z",
"createdAt": "2026-11-04T12:00:00.000Z"
}
]Returns one voucher, found by its ID.
Needs a site admin token.
The ID of the voucher.
Returns the Voucher object.
curl -X GET 'http://dunav41.com/vouchers/{id}?ionic=true' \
-H 'Authorization: Bearer <TOKEN>'{
"title": "Example",
"body": "Text shown on the site.",
"media": "6543210fedcba98765432100",
"show_to": "0",
"coupon": "6543210fedcba98765432100",
"_id": "6543210fedcba98765432100",
"updatedAt": "2026-11-04T12:00:00.000Z",
"createdAt": "2026-11-04T12:00:00.000Z"
}Create a coupon from a prompt, written by the AI builder.
Needs the token of a signed-in user.
What the AI should do with the coupon, in plain words - any language.
The AI chat this request belongs to; its history and language carry over. Leave it out to start a new chat.
Which version of the AI builder to use; leave it out for the current one.
The ID of the coupon to change.
curl -X POST 'http://dunav41.com/create-new-coupon?ionic=true' \
-H 'Authorization: Bearer <TOKEN>' \
-H 'Content-Type: application/json' \
-d '{ "prompt": "...", "chatId": "...", "aiVersion": "...", "item_id": "..." }'{
"chat_id": "6543210fedcba98765432100",
"role": "user",
"text": "Text shown on the site.",
"target_url": "example-item",
"action": "RESPONSE",
"options": [
"example"
],
"medias": [
{
"media": "6543210fedcba98765432100",
"gcs_url": "example-item",
"gemini_uri": "example",
"gemini_interaction_id": "example",
"_id": "6543210fedcba98765432100"
}
],
"products": [
"6543210fedcba98765432101"
],
"services": [
"6543210fedcba98765432101"
],
"blogposts": [
"6543210fedcba98765432101"
],
"programs": [
"6543210fedcba98765432101"
],
"suggestions": [
{
"text": "Text shown on the site.",
"route": "example",
"item_id": "6543210fedcba98765432100",
"medias": [],
"picture": "6543210fedcba98765432100",
"_id": "6543210fedcba98765432100"
}
],
"is_system": false,
"_id": "6543210fedcba98765432100",
"updatedAt": "2026-11-04T12:00:00.000Z",
"createdAt": "2026-11-04T12:00:00.000Z",
"data": {
"object": "example",
"object_type": "example",
"edit_summary": "example",
"edit_diff": "example",
"undo_record": "example",
"hero_animation_offer": "example",
"preview_state": "example",
"pending_credit_cost": 0,
"target_restore": "example",
"media_request": "example",
"item_request": "example",
"reference_request": "example"
}
}Use it to create a new discount coupon or promo code.
Needs the token of a signed-in user.
What the AI should do with the coupon, in plain words - any language.
The AI chat this request belongs to; its history and language carry over. Leave it out to start a new chat.
curl -X POST 'http://dunav41.com/generate-coupon?ionic=true' \
-H 'Authorization: Bearer <TOKEN>' \
-H 'Content-Type: application/json' \
-d '{ "prompt": "...", "chatId": "..." }'