Search for coupons.
Operation ID: couponsSearchThe Coupon Search document contains a search object that allows filtering on various attributes.
The following searchable query attributes can be used to narrow the search:
Attribute | Type |
---|---|
couponId | String |
description | String |
type | one of {"single_code", "multiple_codes", "system_codes"} |
enabled | Boolean |
Note that only searchable attributes can be used in sorting.
curl "https://{shortCode}.api.commercecloud.salesforce.com/pricing/coupons/v1/organizations/{organizationId}/coupons?siteId=RefArch" \
-X POST \
-H "content-type: application/json" \
-d '{
"limit": 10,
"query": {
"filteredQuery": {
"query": {
"textQuery": {
"fields": [
"couponId"
],
"searchPhrase": "disabled"
}
},
"filter": {
"termFilter": {
"field": "enabled",
"operator": "is",
"values": [
false
]
}
}
}
},
"sorts": [
{
"field": {},
"sortOrder": "asc"
}
],
"offset": 0
}'
An identifier for the organization the request is being made by
f_ecom_zzxy_prd
The identifier of the site that a request is being made in the context of. Attributes might have site specific values, and some objects may only be assigned to specific sites
RefArch
{
"limit": 10,
"query": {
"filteredQuery": {
"query": {
"textQuery": {
"fields": [
"couponId"
],
"searchPhrase": "disabled"
}
},
"filter": {
"termFilter": {
"field": "enabled",
"operator": "is",
"values": [
false
]
}
}
}
},
"sorts": [
{
"field": {},
"sortOrder": "asc"
}
],
"offset": 0
}
Maximum records to retrieve per request, not to exceed 200.
10
A set of objects that define criteria used to select records. A query can contain one of the following:
MatchAllQuery
- Matches all documents.
TermQuery
- Matches one or more documents against one or more document fields.
TextQuery
- Matches text against one or more fields.
BoolQuery
- Allows construction of a logical expression of multiple queries.
FilteredQuery
- Allows a filter to be applied to a query.
NestedQuery
- Allows you to query on nested documents.
- Only supported by some Commerce APIs. For more details, see the endpoint descriptions in the API documentation.
{
"filteredQuery": {
"query": {
"textQuery": {
"fields": [
"couponId"
],
"searchPhrase": "disabled"
}
},
"filter": {
"termFilter": {
"field": "enabled",
"operator": "is",
"values": [
false
]
}
}
}
}
The list of sort clauses configured for the search request. Sort clauses are optional. See the description of the search endpoint for details on the default sorting behavior that is used when explicit sorts are not passed.
[{
"field": "couponId",
"sortOrder": "desc"
}]
The zero-based index of the first hit/data to include in the result.
0
Coupon information successfully retrieved.
{
"hits": [
{}
],
"query": {
"filteredQuery": {
"query": {
"textQuery": {
"fields": [
"couponId"
],
"searchPhrase": "disabled"
}
},
"filter": {
"termFilter": {
"field": "enabled",
"operator": "is",
"values": [
false
]
}
}
}
},
"sorts": [
{
"field": {},
"sortOrder": "asc"
}
]
}
The sorted array of coupon search hits. Can be empty.
[{
"couponId": "MyCoupon",
"creationDate": "2019-10-20T12:00:00Z",
"description": "This coupon is used to give 10% off stuff.",
"enabled": false,
"exportedCodeCount": 0,
"lastModified": "2019-10-30T04:23:59Z",
"redemptionCount": 3,
"redemptionLimits": {
"limitPerCode": 0,
"limitPerCustomer": 0,
"limitPerTimeFrame": {
"redemptionTimeFrame": 24,
"limit": 1
}
},
"singleCode": "MyCode",
"systemCodesConfig": {
"codePrefix": "SG",
"numberOfCodes": 50000
},
"totalCodesCount": 50,
"type": "single_code"
}]
Properties inherited from PaginatedSearchResult.
A set of objects that define criteria used to select records. A query can contain one of the following:
MatchAllQuery
- Matches all documents.
TermQuery
- Matches one or more documents against one or more document fields.
TextQuery
- Matches text against one or more fields.
BoolQuery
- Allows construction of a logical expression of multiple queries.
FilteredQuery
- Allows a filter to be applied to a query.
NestedQuery
- Allows you to query on nested documents.
- Only supported by some Commerce APIs. For more details, see the endpoint descriptions in the API documentation.
{
"filteredQuery": {
"query": {
"textQuery": {
"fields": [
"couponId"
],
"searchPhrase": "disabled"
}
},
"filter": {
"termFilter": {
"field": "enabled",
"operator": "is",
"values": [
false
]
}
}
}
}
The sorting that was applied to the result.
[{
"field": "couponId",
"sortOrder": "desc"
}]
The sorted array of search hits. Can be empty.
Properties inherited from PaginatedResultBase.
The zero-based index of the first hit/data to include in the result.
0
Properties inherited from ResultBase.
The total number of hits that match the search's criteria. This can be greater than the number of results returned as search results are pagenated.
10