Skip to main content

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": "d3be7158497ca3ddf0cffe0c",
"type": "type",
"page": 1
}

Response

{
"vouchers": {
"pagination": {
"limit": 20,
"count": 10,
"page": 1,
"pages": 1,
"hasMore": true
},
"vouchers": [
{
"_id": "dd8b16bd111883f89a7984ed",
"type": "coupon",
"id": "example",
"value": 1.23,
"originalValue": 1.23,
"redeemType": "value",
"redeemed": true,
"isInRange": true,
"singleSpending": true,
"unlimited": true,
"spendingLimit": 42,
"startDate": 1748563792696,
"expires": 1750787371705,
"resourcePath": "example",
"created": 1727808755611,
"pdf": "example"
}
]
}
}

Arguments

NameTypeDescription
sortString
sortByStringField 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.
sortOrderIntSort order: 1 for ascending, -1 for descending.
limitIntNumber 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.
statusStringStatus filter. Valid values include "redeemed" to show only redeemed vouchers, or "active" to show only non-redeemed vouchers.
expiredStringExpiration filter. Valid values include "expired" to show only expired vouchers, or "nonexpired" to show only non-expired vouchers (including vouchers without an expiration date).
termStringSearch term to filter vouchers by. Performs a case-insensitive search on voucher ID, user name, and note content.
voucherIdStringExact voucher ID to filter by. Searches for vouchers with this exact ID.
userRefIDReference ID of a specific user to filter vouchers by buyer.
typeStringVoucher 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.
pageIntThe requested page number. Defaults to 1 if not specified.

Returns

VouchersConnection!