17. API Redeem Voucher

This API is served by the Background Service via the API Ring router.


Endpoint

  • Base Path: {API_PREFIX}/history-coupon-code

  • Method: GET

  • Headers: apikey: <your-api-key>


Query Parameters

Param
Description

code(optional)

Exact coupon code to search.

coupon(optional)

Coupon program ID (coupon._id).

createdAtRangeFrom(optional)

Inclusive start time in epoch milliseconds.

createdAtRangeTo(optional)

Inclusive end time in epoch milliseconds.

If no date range is provided, the API returns all history records for the organization.


Response

Returns a list of history entries belonging to the caller's organization. All relational fields are populated.

Response Fields

Field
Description

id

History entry ID

code

Coupon code string

coupon

Populated coupon document (id, name, …)

contact

Populated contact document

createdBy

Populated user who sent the coupon

createdAt

Timestamp in milliseconds

coupon_code

Reference to the coupon code document

phoneSend

Phone number used to send the coupon

org

Organization ID


Example Request

Example Response


Notes

  • Requires a valid API Ring token; results are scoped to the org from apiRingSetting.

  • Use pagination at the HTTP gateway if needed; the route currently returns all matched records.



GET /coupons

Endpoint

  • Method: GET

  • URL: /coupons

  • Headers: apikey: <your-api-key>


Query Parameters

Param
Type
Required
Description

text

string

No

Search by name (supports regex + Vietnamese normalization).

dateNow

number

No

Filter coupons whose endTime is in the future or not set.

status

string

No

Time-based status filter: NOT_STARTED, IN_PROGRESS, ENDED.

status Rules

  • NOT_STARTEDstartTime not reached or not set

  • IN_PROGRESS → active period (startTime ≤ now and endTime not passed)

  • ENDEDendTime has passed


Example Response



GET /coupon-codes

Returns the list of actual coupon codes under a specific coupon program.


🔗 Endpoint

  • Method: GET

  • URL: /coupon-codes

  • Headers: apikey: <your-api-key>


Query Parameters

Param
Type
Required
Description

coupon

string

Yes

Coupon program ID.

status

number

No

Filter by voucher status:

0 – unused

1 – used but still valid

2 – exceeded limit / invalid


Example Response

Last updated