vouchers Query
Description
Retrieves a paginated list of vouchers with comprehensive filtering and sorting options. Supports filtering by status, expiration, type, user, voucher ID, and search terms. You can request a specific page size, and it will be used if it does not exceed the server-enforced maximum. If your requested size exceeds the maximum, the server will enforce the maximum limit.
query vouchers(
$sort: String
$sortBy: String
$sortOrder: Int
$limit: Int
$status: String
$expired: String
$term: String
$voucherId: String
$userRef: ID
$type: String
$page: Int
) {
vouchers(
sort: $sort
sortBy: $sortBy
sortOrder: $sortOrder
limit: $limit
status: $status
expired: $expired
term: $term
voucherId: $voucherId
userRef: $userRef
type: $type
page: $page
) {
pagination {
limit
count
page
pages
hasMore
}
vouchers {
_id
type
id
value
originalValue
redeemType
redeemed
isInRange
singleSpending
unlimited
spendingLimit
startDate
expires
resourcePath
created
pdf
}
}
}
Variables
{
"sort": "sort",
"sortBy": "sortBy",
"sortOrder": 42,
"limit": 20,
"status": "status",
"expired": "expired",
"term": "term",
"voucherId": "voucherId",
"userRef": "fa7ed23e79251541416d714c",
"type": "type",
"page": 1
}
Response
{
"vouchers": {
"pagination": {
"limit": 20,
"count": 10,
"page": 1,
"pages": 1,
"hasMore": true
},
"vouchers": [
{
"_id": "a479bd6341dc24f4fe071888",
"type": "coupon",
"id": "example",
"value": 1.23,
"originalValue": 1.23,
"redeemType": "value",
"redeemed": true,
"isInRange": true,
"singleSpending": true,
"unlimited": true,
"spendingLimit": 42,
"startDate": 1725899337995,
"expires": 1705760952201,
"resourcePath": "example",
"created": 1753547918538,
"pdf": "example"
}
]
}
}
Arguments
| Name | Type | Description |
|---|---|---|
sort | String | — |
sortBy | String | Field name to sort results by. Valid values include "value", "originalValue", "created", "expires", or "spendings" (sorts by number of spendings). If not specified, defaults to sorting by creation date. |
sortOrder | Int | Sort order: 1 for ascending, -1 for descending. |
limit | Int | Number of vouchers per page. You can request a specific page size, and it will be used if it does not exceed the server-enforced maximum. If your requested size exceeds the maximum, the server will enforce the maximum limit. |
status | String | Status filter. Valid values include "redeemed" to show only redeemed vouchers, or "active" to show only non-redeemed vouchers. |
expired | String | Expiration filter. Valid values include "expired" to show only expired vouchers, or "nonexpired" to show only non-expired vouchers (including vouchers without an expiration date). |
term | String | Search term to filter vouchers by. Performs a case-insensitive search on voucher ID, user name, and note content. |
voucherId | String | Exact voucher ID to filter by. Searches for vouchers with this exact ID. |
userRef | ID | Reference ID of a specific user to filter vouchers by buyer. |
type | String | Voucher type filter. Valid values include "coupon" to show only coupons, "giftCard" to show only gift cards, or "All" to show all types. If not specified, shows all types. |
page | Int | The requested page number. Defaults to 1 if not specified. |