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.

11 endpoints in 2 parts: Coupon, Voucher.

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://cloudoffice-gr.max-media.io/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://cloudoffice-gr.max-media.io/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://cloudoffice-gr.max-media.io/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://cloudoffice-gr.max-media.io/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://cloudoffice-gr.max-media.io/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://cloudoffice-gr.max-media.io/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://cloudoffice-gr.max-media.io/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://cloudoffice-gr.max-media.io/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://cloudoffice-gr.max-media.io/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://cloudoffice-gr.max-media.io/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://cloudoffice-gr.max-media.io/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"
}
↑↓ Navigate↵ GoEsc Close