Coupons resource (Data API 23.2)

Summary

Http Method Resource Description
GET /sites/{site_id}/coupons Action to get all the coupons with no filtering.
GET /sites/{site_id}/coupons/{coupon_id} Action to get coupon information.
The following fields are returned in the Coupon document when specifying the stats expand:
  • exported_code_count
  • redemption_count
  • total_codes_count
If the role to which the user belongs does not have View_Coupon_Codes permission, then the coupon codes returned will be masked.
PATCH /sites/{site_id}/coupons/{coupon_id} Updates the coupon with the specified information.
DELETE /sites/{site_id}/coupons/{coupon_id} Delete a coupon by id.
PUT /sites/{site_id}/coupons/{coupon_id} Creates a coupon using the information provided. If a coupon exists with the same unique identifier, the coupon is replaced completely.
GET /sites/{site_id}/coupons/{coupon_id}/campaigns Get the campaigns that have a coupon assigned to them either directly or through promotions
GET /sites/{site_id}/coupons/{coupon_id}/campaigns/{campaign_id}/promotions Get the promotions for a campaign that have a coupon assigned to them either directly or through campaigns.
GET /sites/{site_id}/coupons/{coupon_id}/codes Get the coupon codes for the given coupon. If the role to which the user belongs does not have View_Coupon_Codes permission, then the coupon codes returned will be masked.
POST /sites/{site_id}/coupons/{coupon_id}/multiple_codes Add or delete (modify) multiple codes to/from the supplied coupon.
GET /sites/{site_id}/coupons/{coupon_id}/promotions Get the promotions that have a coupon assigned to them either directly or through campaigns.

Get Coupons

Action to get all the coupons with no filtering.

Url

GET https://hostname:port/dw/data/v23_2/sites/{site_id}/coupons?start={Integer}&count={Integer}&select={String}&expand={String}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Response Document

Coupons

Path Parameters

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

Query Parameters

Parameter Type Description Constraints
count Integer Optional count for retrieving only a subset of the codes (default is 25).  
expand String    
select String The property selector.  
start Integer Optional start index for retrieving the codes from a given index (default 0).  

Sample

REQUEST:
GET  /s/-/dw/data/v23_2/sites/site-one/coupons HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
Content-Type: application/json; charset=UTF-8

# in case of success:

RESPONSE:
HTTP/1.1 200 OK
Content-Length: 67
Content-Type: application/json; charset=UTF-8
{
  "_v" : "23.2",
  "count" : 2,
  "data" : [
    {
        "_v" : "23.2",
        "_type" : "coupon",
        "_resource_state":"c2309jd239jdrifj3ui4fn",
        "coupon_id" : "my-coupon",
        "description" : "system generated coupon code.",
        "enabled" : true,
        "link" : "https://example.com/s/-/dw/data/v23_2/sites/SiteGenesis/coupons/my-coupon",
        "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" : "sys",
            "number_of_codes" : 100
        },
        "redemption_count": 2,
        "type" : "system_codes"
    },
    {
        "_v" : "23.2",
        "_type" : "coupon",
        "_resource_state":"nmd39c8jasdn2983djs9js",
        "coupon_id" : "single-coupon",
        "description" : "single coupon code",
        "enabled" : true,
        "link" : "https://example.com/s/-/dw/data/v23_2/sites/SiteGenesis/coupons/single-coupon",
        "redemption_count": 0,
        "single_code": "xmas2015",
        "type" : "single_code"
    }
  ],
  "select": "**",
  "start" : 0,
  "total" : 2
}

Get Coupon

Action to get coupon information.
The following fields are returned in the Coupon document when specifying the stats expand:
  • exported_code_count
  • redemption_count
  • total_codes_count
If the role to which the user belongs does not have View_Coupon_Codes permission, then the coupon codes returned will be masked.

Url

GET https://hostname:port/dw/data/v23_2/sites/{site_id}/coupons/{coupon_id}?select={String}&expand={String}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Response Document

Coupon

Path Parameters

Parameter Type Description Constraints
coupon_id String The id of the requested coupon. minLength=1
site_id String The site context. minLength=1

Query Parameters

Parameter Type Description Constraints
expand String The expand parameter. A comma separated list with the allowed values (stats).  
select String The property selector.  

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
404 CouponNotFoundException

couponId (String)

siteId (String)

Thrown in case the coupon does not exist matching the given id

Sample

REQUEST:
GET /s/-/dw/data/v23_2/sites/SiteGenesis/coupons/my-coupon HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
Content-Type: application/json; charset=UTF-8

# in case of success:
 
RESPONSE:
HTTP/1.1 200 OK
Expires: Thu, 01-Aug-2014 00:00:00 GMT

{
   "_v" : "23.2",
   "_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
  "_type" : "coupon",
   "coupon_id" : "my-coupon",
   "description" : "sytem generated coupon code.",
   "enabled" : true,
   "link" : "https://example.com/s/-/dw/data/v23_2/sites/SiteGenesis/coupons/my-coupon",
   "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" : "sys",
      "number_of_codes" : 100
   },
   "redemption_count": 2,
   "type" : "system_codes"
}

# in case of failure:
 
RESPONSE:
HTTP/1.1 400 BAD REQUEST
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
  "_v" : "23.2",
   "_type":"fault",
  "fault":{
    "type":"CouponNotFoundException",
    "message":"No coupon with ID 'my-coupon' for site 'SiteGenesis' was found."
  }
}

Update Coupon

Updates the coupon with the specified information.

Url

PATCH https://hostname:port/dw/data/v23_2/sites/{site_id}/coupons/{coupon_id}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Request Document

Coupon

Response Document

Coupon

Path Parameters

Parameter Type Description Constraints
coupon_id String The id of the requested coupon. minLength=1
site_id String The site context. minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 CouponUpdateReadOnlyException

couponId (String)

field (String)

Thrown if you try to update certain fields in a coupon after redeeming or exporting it.
400 CouponCodeDuplicateException

couponId (String)

couponCode (String)

Thrown if the code provided is in use by another coupon.
400 SystemGeneratedCouponQuotaException

couponId (String)

reason (String)

count (String)

maxCount (String)

Thrown whenever a quota regarding system-generated coupons is violated
403 CouponUpdateForbiddenException

couponId (String)

Thrown when trying to update a broken coupon, that should be deleted and re-created.
403 CouponLegacyUpdateForbiddenException

couponId (String)

Thrown when trying to update a legacy coupon.
404 CouponNotFoundException

couponId (String)

siteId (String)

Thrown if the coupon does not exist matching the given id.

Sample

REQUEST:
PATCH /s/-/dw/data/v23_2/sites/SiteGenesis/coupons/my-coupon HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
{
   "_resource_state" : "847f9c3c5867f641470b3046aeec31f07757991b792d722e10079926f7a289fb",
   "redemption_limits":
   { "_delete": 0,
     "limit_per_customer" : "3"
   }
  "description":"My coupon 1 as example"
}
# in case of success:

RESPONSE:
HTTP/1.1 200 OK
Content-Length: 67
Content-Type: application/json; charset=UTF-8
{
   "_v" : "23.2",
   "_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
  "_type" : "coupon",
   "coupon_id" : "my-coupon",
   "description" : "sytem generated coupon code.",
   "enabled" : true,
   "link" : "https://example.com/s/-/dw/data/v23_2/sites/SiteGenesis/coupons/my-coupon",
   "redemption_limits" : {
      "limit_per_customer" : 3,
      "limit_per_time_frame" : {
         "lmit" : 0,
         "redemption_time_frame" : 0
      }
   },
   "system_codes_config" : {
      "code_prefix" : "xmas2014-",
      "max_number_of_codes" : 100
   },
   "type" : "system_codes"
}

# in case of failure:

RESPONSE:
HTTP/1.1 404 Not Found
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
  "_v" : "23.2",
   "_type":"fault",
  "fault":{
    "type":"CouponNotFoundException",
    "message":"No coupon with ID 'my-coupon' was found."
  }
}

Delete Coupon

Delete a coupon by id.

Url

DELETE https://hostname:port/dw/data/v23_2/sites/{site_id}/coupons/{coupon_id}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Path Parameters

Parameter Type Description Constraints
coupon_id String Id of the coupon to delete from the site. minLength=1, nullable=false
site_id String The site context. minLength=1

Sample

REQUEST:
DELETE /s/-/dw/data/v23_2/sites/site-one/coupons/my-coupon HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
x-dw-resource-state: 860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5

# in case of success:

RESPONSE:
HTTP/1.1 204 No Content

Create Coupon

Creates a coupon using the information provided. If a coupon exists with the same unique identifier, the coupon is replaced completely.

Url

PUT https://hostname:port/dw/data/v23_2/sites/{site_id}/coupons/{coupon_id}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Request Document

Coupon

Response Document

Coupon

Path Parameters

Parameter Type Description Constraints
coupon_id String The id of the coupon to create. minLength=1, nullable=false
site_id String The site context. minLength=1

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 CouponInvalidException

couponId (String)

fieldId (String)

Thrown if the coupon passed in is not valid (the argument indicates the field that was invalid).
400 CouponCodeDuplicateException

couponId (String)

couponCode (String)

Thrown if the code provided is in use by another coupon.
400 CouponCreateSingleCodeException

couponId (String)

code (String)

Thrown if a single code coupon does not set the coupon code properly.
400 IdConflictException

bodyID (String)

urlID (String)

if the Id in request is not the same as the ID in document.
400 SystemGeneratedCouponQuotaException

couponId (String)

reason (String)

count (String)

maxCount (String)

Thrown whenever a quota regarding system-generated coupons is violated
403 SiteAccessForbiddenException

siteId (String)

Thrown if the resource requires global instead of site-specific context.

Sample

REQUEST:
PUT /s/-/dw/data/v23_2/sites/SiteGenesis/coupons/ccc HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
{
   "coupon_id" : "ccc",
   "description" : "sytem generated coupon code.",
   "enabled" : true,
   "link" : "https://example.com/s/-/dw/data/v23_2/sites/SiteGenesis/coupons/ccc",
   "redemption_limits" : {
      "limit_per_code" : 1,
      "limit_per_customer" : 0,
      "limit_per_time_frame" : {
         "lmit" : 0,
         "redemption_time_frame" : 0
      }
   },
   "system_codes_config" : {
      "code_prefix" : "xmas2014-",
      "max_number_of_codes" : 100
   },
   "type" : "system_codes"
}

# in case of success:

RESPONSE:
HTTP/1.1 201 CREATED
Content-Length: 42
Location: https://example.com/s/-/dw/data/v23_2/sites/SiteGenesis/coupons/ccc
Content-Type: application/json; charset=UTF-8
{
   "_v" : "23.2",
   "_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
   "_type" : "coupon",
   "coupon_id" : "ccc",
   "description" : "sytem generated coupon code.",
   "enabled" : true,
   "link" : "https://example.com/s/-/dw/data/v23_2/sites/SiteGenesis/coupons/ccc",
   "redemption_limits" : {
      "limit_per_code" : 1,
      "limit_per_customer" : 0,
      "limit_per_time_frame" : {
         "lmit" : 0,
         "redemption_time_frame" : 0
      }
   },
   "system_codes_config" : {
      "code_prefix" : "xmas2014-",
      "max_number_of_codes" : 100
   },
   "type" : "system_codes"
}

# in case of failure:

RESPONSE:
HTTP/1.1 404 Not Found
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
  "_v" : "23.2",
   "_type":"fault",
  "fault":{
    "type":"CouponAlreadyInUseException",
    "message":"The coupon with ID 'my-coupon' is already in use."
  }
}

Get Campaigns

Get the campaigns that have a coupon assigned to them either directly or through promotions

Url

GET https://hostname:port/dw/data/v23_2/sites/{site_id}/coupons/{coupon_id}/campaigns?start={Integer}&count={Integer}&select={String}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Response Document

Campaigns

Path Parameters

Parameter Type Description Constraints
coupon_id String The id of the coupon that is assigned to campaigns directly or through promotions.  
site_id String The site context. minLength=1

Query Parameters

Parameter Type Description Constraints
count Integer Optional count for retrieving the campaigns (default is 25).  
select String    
start Integer Optional start index for retrieving the campaigns (default 0).  

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
404 CouponNotFoundException

couponId (String)

siteId (String)

Thrown if the coupon does not exist matching the given id.

Sample

REQUEST:
GET /s/-/dw/data/v23_2/sites/SiteGenesis/coupons/my-coupon/campaigns HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367

# in case of success:

RESPONSE:
HTTP/1.1 200 OK
Content-Length: 767
Content-Type: application/json; charset=UTF-8
x-dw-resource-state: 860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5
{
   "_v" : "23.2",
   "_type" : "coupon_campaign_result",
   "count" : 3,
   "data" : 
   [
      
      {
         "_type" : "campaign",
         "campaign_id" : "my-coupon-campaign1",
         "link" : "https://example.com/s/-/dw/data/v23_2/sites/SiteGenesis/campaigns/my-coupon-campaign1"
      },
      
      {
         "_type" : "campaign",
         "campaign_id" : "my-coupon-campaign2",
         "link" : "https://example.com/s/-/dw/data/v23_2/sites/SiteGenesis/campaigns/my-coupon-campaign2"
      },
      
      {
         "_type" : "campaign",
         "campaign_id" : "my-coupon-campaign3",
         "link" : "https://example.com/s/-/dw/data/v23_2/sites/SiteGenesis/campaigns/my-coupon-campaign3"
      }
   ],
   "start" : 0,
   "total" : 3
}

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 NOT FOUND
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
  "_v" : "23.2",
   "_type":"fault",
  "fault":{
    "type":"CouponNotFoundException",
    "message":"No coupon with ID 'my-coupon' for site 'SiteGenesis' was found."
  }
}

Get Promotions for Campaign

Get the promotions for a campaign that have a coupon assigned to them either directly or through campaigns.

Url

GET https://hostname:port/dw/data/v23_2/sites/{site_id}/coupons/{coupon_id}/campaigns/{campaign_id}/promotions?start={Integer}&count={Integer}&select={String}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Response Document

Promotions

Path Parameters

Parameter Type Description Constraints
campaign_id String The id of the campaign that we want to restrict the set of promotions for.  
coupon_id String The id of the coupon that is assigned to promotions directly or through campaigns.  
site_id String The site context. minLength=1

Query Parameters

Parameter Type Description Constraints
count Integer Optional count for retrieving the promotions (default is 25).  
select String    
start Integer Optional start index for retrieving the promotions (default 0).  

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
404 CouponNotFoundException

couponId (String)

siteId (String)

Thrown if the coupon does not exist matching the given id.
404 CampaignNotFoundException

campaignId (String)

siteId (String)

Thrown if the campaign does not exist matching the given id.

Sample

REQUEST:
GET /s/-/dw/data/v23_2/sites/SiteGenesis/coupons/my-coupon/campaigns/my-campaign/promotions HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367

# in case of success:

RESPONSE:
HTTP/1.1 200 OK
Content-Length: 767
Content-Type: application/json; charset=UTF-8
x-dw-resource-state: 860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5
{
   "_v" : "23.2",
   "_type" : "promotions",
   "count" : 1,
   "data" : 
   [
      
      {
         "_type" : "promotion",
         "id" : "my-coupon-promotion1",
         "link" : "https://example.com/s/-/dw/data/v23_2/sites/SiteGenesis/promotions/my-coupon-promotion1"
      }

   ],
   "start" : 0,
   "total" : 1
}

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 NOT FOUND
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
  "_v" : "23.2",
   "_type":"fault",
  "fault":{
    "type":"CouponNotFoundException",
    "message":"No coupon with ID 'my-coupon' for site 'SiteGenesis' was found."
  }
}

RESPONSE:
HTTP/1.1 404 NOT FOUND
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
  "_v" : "23.2",
   "_type":"fault",
  "fault":{
    "type":"CampaignNotFoundException",
    "message":"No campaign with ID 'my-campaign' in site 'SiteGenesis' was found."  
  }
}

Get Coupon Codes

Get the coupon codes for the given coupon. If the role to which the user belongs does not have View_Coupon_Codes permission, then the coupon codes returned will be masked.

Url

GET https://hostname:port/dw/data/v23_2/sites/{site_id}/coupons/{coupon_id}/codes?start={Integer}&count={Integer}&select={String}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Response Document

CouponCodes

Path Parameters

Parameter Type Description Constraints
coupon_id String The id of the coupon from which to delete codes (must be a multiple code coupon).  
site_id String The site context. minLength=1

Query Parameters

Parameter Type Description Constraints
count Integer Optional count for retrieving only a subset of the codes (default is 25).  
select String Optional select clause for getting fields from the returned JSON document.  
start Integer Optional start index for retrieving the codes from a given index (default 0).  

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
404 CouponNotFoundException

couponId (String)

siteId (String)

Thrown if the coupon does not exist matching the given id.

Sample

REQUEST:
GET /s/-/dw/data/v23_2/sites/site-one/coupons/my-coupon/codes HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367

# in case of success:

RESPONSE:
HTTP/1.1 200 OK
Content-Length: 767
Content-Type: application/json; charset=UTF-8
{
     "_v" : "23.2",
     "_type" : "coupon_code_result",
     "count" : 25,
     "hits" : [
         {
             "_resource_state" : "860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5",
             "code" : "xmas2014-00001", 
             "redemption_count" : 1, 
             "issued" : true 
         },
         {
             "_resource_state" : "847f9c3c5867f641470b3046aeec31f07757991b792d722e10079926f7a289fb",
             "code" : "xmas2014-00002", 
             "redemption_count" : 0, 
             "issued" : false 
         },
         {
             "_resource_state" : "045f07bb655171dc37d8eb8bf4b0db7ac1fb3a160002eb96fbe6e2f95aa4b6cc", 
             "code" : "xmas2014-00003", 
             "redemption_count" : 5, 
             "issued" : true 
         },
         {
             "_resource_state" : "gv094jt4rfnc983rchj39d",
             "code" : "xmas2014-00004", 
             "redemption_count" : 103, 
             "issued" : true 
         },
     ....
     ]
     "next" : "https://example.com/s/-/dw/data/v23_2/sites/SiteGenesis/coupons/my-coupon/codes?start=25",
     "start" : 0
}

Modify Multiple Codes

Add or delete (modify) multiple codes to/from the supplied coupon.

Url

POST https://hostname:port/dw/data/v23_2/sites/{site_id}/coupons/{coupon_id}/multiple_codes?delete={Boolean}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Request Document

CouponMultiCodesRequest

Path Parameters

Parameter Type Description Constraints
coupon_id String The id of the coupon to modify codes (must be multiple code coupon).  
site_id String The site context. minLength=1

Query Parameters

Parameter Type Description Constraints
delete Boolean Optional parameter for specifying when to delete multiple codes.  

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
400 CouponCodeCreateException

couponCode (String)

Thrown if the coupon code could not be created.
404 CouponNotFoundException

couponId (String)

siteId (String)

Thrown if the coupon does not exist matching the given id.

Sample

# add multiple codes
REQUEST:
POST /s/-/dw/data/v23_2/sites/SiteGenesis/coupons/my-coupon/multiple_codes HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
{ 
    codes: ["xyz","pdq","abc"] 
}

# delete multiple codes
REQUEST:
POST /s/-/dw/data/v23_2/sites/site-one/coupons/my-coupon/multiple_codes?delete=true HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367
{
    codes: ["code1","code2","code3"]
}

# in case of success:

RESPONSE:
HTTP/1.1 204 NO CONTENT
Content-Length: 0

# in case of failure:

RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
  "_v" : "23.2",
   "_type":"fault",
  "fault":{
    "type":"NotApplicableOperationException",
    "message":"The operation is not applicable to this object."
  }
}

RESPONSE:
HTTP/1.1 404 Not Found
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
  "_v" : "23.2",
   "_type":"fault",
  "fault":{
    "type":"CouponNotFoundException",
    "message":"No coupon with ID 'my-coupon' for site 'SiteGenesis' was found."
  }
}

RESPONSE:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
  "_v" : "23.2",
   "_type":"fault",
  "fault":{
    "type":"CouponCodeCreateException",
    "message":"Coupon code 'code1' could not be created. Please check to ensure the code is valid."
  }
}

Get Promotions

Get the promotions that have a coupon assigned to them either directly or through campaigns.

Url

GET https://hostname:port/dw/data/v23_2/sites/{site_id}/coupons/{coupon_id}/promotions?start={Integer}&count={Integer}&select={String}

Formats

json, xml

Authentication

Name Description
OAuth Authentication via OAuth token.

Response Document

Promotions

Path Parameters

Parameter Type Description Constraints
coupon_id String The id of the coupon that is assigned to promotions directly or through campaigns.  
site_id String The site context. minLength=1

Query Parameters

Parameter Type Description Constraints
count Integer Optional count for retrieving the promotions (default is 25).  
select String    
start Integer Optional start index for retrieving the promotions (default 0).  

In case of a failure Fault Document is returned.

Faults

Status Type Arguments Description
404 CouponNotFoundException

couponId (String)

siteId (String)

Thrown if the coupon does not exist matching the given id.

Sample

REQUEST:
GET /s/-/dw/data/v23_2/sites/SiteGenesis/coupons/my-coupon/promotions HTTP/1.1
Host: example.com
Authorization: Bearer a5b6eb0d-8312-41a3-88f3-2c53c4507367

# in case of success:

RESPONSE:
HTTP/1.1 200 OK
Content-Length: 767
Content-Type: application/json; charset=UTF-8
x-dw-resource-state: 860cde3040519cce439cd99e209f8a87c3ad0b7e2813edbf6f5501f763b73bd5
{
   "_v" : "23.2",
   "_type" : "promotions",
   "count" : 2,
   "data" : 
   [
      
      {
         "_type" : "promotion",
         "id" : "my-coupon-promotion1",
         "link" : "https://example.com/s/-/dw/data/v23_2/sites/SiteGenesis/promotions/my-coupon-promotion1"
      },
      
      {
         "_type" : "promotion",
         "id" : "my-coupon-promotion2",
         "link" : "https://example.com/s/-/dw/data/v23_2/sites/SiteGenesis/promotions/my-coupon-promotion2"
      }
   ],
   "start" : 0,
   "total" : 2
}

# in case of failure:
 
RESPONSE:
HTTP/1.1 404 NOT FOUND
Expires: Thu, 01-Jan-1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=0,no-cache,no-store,must-revalidate
{
  "_v" : "23.2",
   "_type":"fault",
  "fault":{
    "type":"CouponNotFoundException",
    "message":"No coupon with ID 'my-coupon' for site 'SiteGenesis' was found."
  }
}
X OCAPI versions 15.x and 16.x will be retired on March 31, 2021. For dates and more information, see the OCAPI versioning and deprecation policy and this Knowledge Article.