API ReferenceView as MarkdownOpenAPI

Coupons & vouchers

View as Markdown

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.

Retrieve the coupon capture

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

Public - no token needed.

Status codes

200

GET/coupon_capture
curl -X GET 'http://djotex.com/coupon_capture?ionic=true'

Retrieve the coupon code

Returns if a coupon is valid.

Optional user

Works without a token; with a user token the answer is personal.

Parameters
coupon_codestring

The coupon code's coupon code.

Status codes

200 404 500

GET/coupon_code
curl -X GET 'http://djotex.com/coupon_code?ionic=true'
Response
{
  "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
  }
}

List all coupon codes

Returns if a coupon is valid.

Optional user

Works without a token; with a user token the answer is personal.

Path parameters
codestringRequired

The coupon code's code.

Status codes

200 404 500

GET/coupon_code/:code
curl -X GET 'http://djotex.com/coupon_code/{code}?ionic=true'
Response
{
  "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
  }
}

List all coupon infos

Returns public coupon details by code without incrementing uses.

Public

Public - no token needed.

Path parameters
codestringRequired

The coupon info's code.

Status codes

200 404 500

GET/coupon_info/:code
curl -X GET 'http://djotex.com/coupon_info/{code}?ionic=true'
Response
{
  "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
  }
}

List all coupons

Returns the site's coupons, newest first unless a sort is given.

Public

Public - no token needed.

Returns

Returns a list of Coupon objects.

Status codes

200 500

GET/coupons
curl -X GET 'http://djotex.com/coupons?ionic=true'
Response
[
  {
    "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 a coupon

Create new coupon.

Admin token

Needs a site admin token.

Returns

Returns the Coupon object.

Status codes

201 400 401 500

POST/coupons
curl -X POST 'http://djotex.com/coupons?ionic=true' \
  -H 'Authorization: Bearer <TOKEN>'
Response
{
  "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
  }
}

Retrieve a coupon

Returns one coupon, found by its ID.

Public

Public - no token needed.

Path parameters
idstringRequired

The ID of the coupon.

Returns

Returns the Coupon object.

Status codes

200 404 500

GET/coupons/:id
curl -X GET 'http://djotex.com/coupons/{id}?ionic=true'
Response
{
  "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 a coupon

Update Coupon by id.

Admin token

Needs a site admin token.

Path parameters
idstringRequired

The ID of the coupon.

Returns

Returns the Coupon object.

Status codes

200 400 401 404 500

PATCH/coupons/:id
curl -X PATCH 'http://djotex.com/coupons/{id}?ionic=true' \
  -H 'Authorization: Bearer <TOKEN>'
Response
{
  "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 a coupon

Delete Coupon record by id.

Admin token

Needs a site admin token.

Path parameters
idstringRequired

The ID of the coupon.

Returns

Returns an empty answer on success.

Status codes

200 401 404 500

DELETE/coupons/:id
curl -X DELETE 'http://djotex.com/coupons/{id}?ionic=true' \
  -H 'Authorization: Bearer <TOKEN>'

List all vouchers

Returns the site's vouchers, newest first unless a sort is given.

Public

Public - no token needed.

Query parameters
authenticatedstring

Only vouchers with this authenticated.

Returns

Returns a list of Voucher objects.

Status codes

200 500

GET/vouchers
curl -X GET 'http://djotex.com/vouchers?ionic=true&authenticated=...'
Response
[
  {
    "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"
  }
]

Retrieve a voucher

Returns one voucher, found by its ID.

Admin token

Needs a site admin token.

Path parameters
idstringRequired

The ID of the voucher.

Returns

Returns the Voucher object.

Status codes

200 401 404 500

GET/vouchers/:id
curl -X GET 'http://djotex.com/vouchers/{id}?ionic=true' \
  -H 'Authorization: Bearer <TOKEN>'
Response
{
  "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 with AI

Create a coupon from a prompt, written by the AI builder.

User token

Needs the token of a signed-in user.

Parameters
promptstring

What the AI should do with the coupon, in plain words - any language.

chatIdstring

The AI chat this request belongs to; its history and language carry over. Leave it out to start a new chat.

aiVersionstring

Which version of the AI builder to use; leave it out for the current one.

item_idstring

The ID of the coupon to change.

Status codes

200 401 500

POST/create-new-coupon
curl -X POST 'http://djotex.com/create-new-coupon?ionic=true' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{ "prompt": "...", "chatId": "...", "aiVersion": "...", "item_id": "..." }'
Response
{
  "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"
  }
}

Generate a coupon with AI

Use it to create a new discount coupon or promo code.

User token

Needs the token of a signed-in user.

Parameters
promptstring

What the AI should do with the coupon, in plain words - any language.

chatIdstring

The AI chat this request belongs to; its history and language carry over. Leave it out to start a new chat.

Status codes

200 401 500

POST/generate-coupon
curl -X POST 'http://djotex.com/generate-coupon?ionic=true' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{ "prompt": "...", "chatId": "..." }'
↑↓ Navigate↵ GoEsc Close