# Add Loyalty Discount v2.0Beta

The Add Loyalty Discount endpoint adds a discount to a cart and submitted to our loyalty provider. A discount is simply an entity that tracks the redemption of one or more loyalty vouchers.

The vouchers will be redeemed at the loyalty provider and the discount will be applied to the cart. The value of the discount will be the sum of the values of the voucher selected. This value is especially important in the case of percentage based vouchers where the value can only be determined when the voucher is redeemed.

Vouchers will be redeemed in a predetermined order based on business rules configured at the loyalty provider. Voucher redeems may fail for a number of reasons. The ''. In this case, the discount will have a status of Processed.

# Request

POST /v2.0/customers/{profileKey}/carts/{cartId}/discounts/loyalty

# Authorization

An OAuth 2.0 Bearer token with the Cart.Write and Loyalty.Write scopes is required. For more information, see Authentication.

# Path Parameters

A list of the supported path parameters is described below.

Name Required Type Description
profileKey true guid The profile key for the customer.
cartId true guid The cart id for the cart.

# Request Body

The request body takes an AddLoyaltyDiscount object which is described below.

# AddLoyaltyDiscount

Name Required Type Description
voucherCodes true string[] An array of vouchers codes that the customer selected to redeem. Should be the value of the code property from the selected voucher from the Discover Loyalty Vouchers endpoint.

# Sample

{
    "voucherCodes": [
		"1234567890000",
		"1234567891111"
	]
}

# Response

200
OK
Returns an ApiResponse envelope.

# Response Body

The endpoint returns our ApiResponse envelope. The data property of the response will contain a discountId that can be used to check the status of the discount using the Discount Status endpoint.

Name Required Type Description
discountId true string The unique identifier for the discount that was created.

# Sample

{
    "message": "The operation succeeded!",
    "notifications": [
        {
            "severity": "Success",
            "text": "The discount was applied to the cart.",
            "code": null,
            "additionalData": null
        }
    ],
    "data": {
        "discountId": "e5c627e3-c5bc-447a-83f1-75f0e210e313"
    }
}

# Errors

The standard error responses apply.

400
Bad Request
When the request fails validation.
401
Unauthorized
When authentication fails.
403
Forbidden
When authorisation fails.
404
Not Found
When the cart cannot be found.