Skip to main content

Create First time Shopper's Coupon Code

A first time shopper is a shopper who has not completed any purchases or authorized orders with the store.

note
  • Orders without payment transactions do not count as completed purchases.
  • Canceling or refunding an order does not reinstate first-time shopper status.
  • A first-time shopper coupon code cannot have limited uses or be assigned to specific users, meaning the code cannot be restricted by the number of times it can be used or tied to a specific customer ID.

POST Create First-time Shopper's Coupon Code

https://useast.api.elasticpath.com/v2/rule-promotions/:promotionID/codes

Parameters

Path parameters

NameRequiredTypeDescription
promotionIDRequiredstringThe unique identifier of the promotion.

Headers

NameRequiredTypeDescription
AuthorizationRequiredstringThe Bearer token required to get access to the API.

Body

NameRequiredTypeDescription
typeRequiredstringSpecifies the type of the resource. The type of resource for promotions is promotion_codes.
codesRequiredarraySpecifies the code details in an array of objects.
codes[].codeRequiredstringSpecifies the string to use as a code for the promotion.
is_for_new_shopperOptionalbooleanIndicates whether the coupon is for first-time shoppers. If set to true, the discount applies only if the shopper has never made a payment for an order in the store. If false or not provided, the discount applies to all shoppers.

Request Example

curl -X POST https://useast.api.elasticpath.com/v2/rule-promotions/:promotionID/codes \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $ {
"data":{
"type": "promotion_codes",
"codes": [
{
"code": "first_time",
"is_for_new_shopper": true
}
]
}
}

Response Example

201 Created

{
"data": [
{
"id": "7ba5cd3d-a6dc-4745-97e6-3957f8c050df",
"code": "first_time",
"is_for_new_shopper": true
}
]
}

Errors

For first time shoppers, the following error is returned when you attempt to create a code with uses or user parameters:

{
"errors": [
{
"status": 400,
"source": "",
"title": "Invalid Code",
"detail": "Code - first_time_uses can't have limited uses or assigned to users since it's for first time shoppers."
}
]
}