Delete Coupon From Purchase

This function is used to delete a coupon from a Purchase before it is finalized.

URL Parameters

purchaseIdIntegerThis is the Id value of the Purchase you want to delete the Coupon from.Yes
couponCodeStringThis is the Coupon code that you want to remove from the specified Purchase.Yes
deleteAllDiscountsBooleanThis determines if the Discount applied by the Coupon should also be deleted. If True, the Discount is removed along with the Coupon. If False, the Coupon is removed but the Discount it applied remains in effect.Yes
curl -X DELETE "{PurchaseId}&couponCode={CouponCode}&deleteAllDiscounts=true" \
	-H "Content-Type: application/json" \
	-H "Authorization: Basic {APIKey}"
//path parameter
int purchaseId = {PurchaseId};
string couponCode = {CouponCode};
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://"+purchaseId+"&couponCode="+couponCode+"&deleteAllDiscounts=true" );
//Set content length
request.ContentLength = 0;
//Add Content type
request.ContentType = "application/json";
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic " + apiKey);
//Set request method
request.Method = "DELETE";
//Perform the request
var httpResponse = (HttpWebResponse)request.GetResponse();
//Record the response from our request
var result = "";
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
  result = streamReader.ReadToEnd();
#Import library Requests
import requests
#Pass in a dictionary to the Headers parameter
headers = {'Authorization' : 'Basic {APIKey}', 'Content-Type' : 'application/json'}
#Pass in your URI and Headers
r = requests.delete('{id}&couponCode=fixed10&deleteAllDiscounts=true', headers=headers)
Upon success a 204 No Content response is returned
    "ErrorId": 0,
    "HttpStatusCode": 404,
    "Errors": [
            "Key": "Api Error",
            "Value": "PurchaseCouponCode with id 123 not found."