CouponSearch resource (Data API 19.3)

Summary

Http Method Resource Description
POST /sites/{site_id}/coupon_search

Searches for coupons.

The Coupon Search document contains a search object that allows filtering on various attributes.

The query attribute specifies a complex query that can be used to narrow down the search. These are the list of searchable attributes:

  • coupon_id - String
  • description - String
  • type - one of {"single_code", "multiple_codes", "system_codes"}
  • enabled - boolean

Note that only searchable attributes can be used in sorting.

The stats expand value is required to return the following fields in the Coupon document:

  • exported_code_count
  • redemption_count
  • total_codes_count

Search Coupons

Searches for coupons.

The Coupon Search document contains a search object that allows filtering on various attributes.

The query attribute specifies a complex query that can be used to narrow down the search. These are the list of searchable attributes:

Note that only searchable attributes can be used in sorting.

The stats expand value is required to return the following fields in the Coupon document:

Url

POST https://hostname:port/dw/data/v19_3/sites/{site_id}/coupon_search

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Request Document

SearchRequest

Response Document

CouponSearchResult

Path Parameters

Parameter Type Description Constraints
site_id String The site context. minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 MalformedSearchParameterException   Thrown if the query is ill-formed.

Sample

REQUEST:
POST /s/-/dw/data/v19_3/sites/SiteGenesis/coupon_search HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
Accept: application/json
{
    "query" : {
        "text_query": {
            "field": ["id", "description"],
            "search_phrase": "my"
        }
    },
    "select" : "(**)"
}

RESPONSE:
HTTP/1.1 200 OK
Content-Length: 67
Content-Type: application/json; charset=UTF-8

{
  "_v" : "19.3",
  "_type" : "coupon_search_result",
  "count" : 2,
  "hits" : [{
   "_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
   "coupon_id" : "my-coupon1",
   "description" : "system generated coupon code.",
   "enabled" : true,
   "link" : "https://example.com/s/-/dw/data/v19_3/sites/SiteGenesis/coupons/my-coupon1",
   "redemption_limits" : {
      "limit_per_code" : 1,
      "limit_per_customer" : 0,
      "limit_per_time_frame" : {
         "limit" : 0,
         "redemption_time_frame" : 0
      }
   },
   "system_codes_config" : {
      "code_prefix" : "xmas2014-",
      "max_number_of_codes" : 100
   },
   "redemption_count": 5,
   "type" : "system_codes"
},
{
   "_resource_state" : "y4ad025da50d1af6cac62e86de2b13def45ead81ffb01c407dad2dc4bfd438kl",
   "coupon_id" : "my-coupon2",
   "description" : "single coupon code.",
   "enabled" : true,
   "link" : "https://example.com/s/-/dw/data/v19_3/sites/SiteGenesis/coupons/my-coupon2",
   "redemption_limits" : {
      "limit_per_code" : 3,
      "limit_per_customer" : 3,
      "limit_per_time_frame" : {
         "limit" : 3,
         "redemption_time_frame" : 7
      }
   },
  "redemption_count": 0,
  "type" : "single_code",
  "single_code": "50OFF"
}],

  "query" : { "text_query": { "fields": ["id", "description"], "search_phrase": "my" } },
  "select": "**",
  "start" : 0,
  "total" : 2
}