POST
/v1/coupon/validate
Requires Auth
Validate Coupon
Validate Coupon
Check if a coupon code is valid and preview the discount without applying it. Use this to display discount details to the user before they proceed with checkout or redemption.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| code | string | Required | The coupon code to validate. |
| plan_id | string | Optional | The UUID of the plan to check the coupon against. Needed for plan-specific discounts. |
| order_sum | number | Optional | The order total in the given currency. Used to calculate the discount amount. |
| currency | string | Optional | The currency code for the order. Defaults to "USD". |
curl -X POST https://api.proxyhat.com/v1/coupon/validate \
-H "Authorization: Bearer __API_KEY__" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"code": "SAVE10",
"plan_id": "uuid",
"order_sum": 50.00,
"currency": "USD"
}'
import requests
response = requests.post(
"https://api.proxyhat.com/v1/coupon/validate",
headers={
"Authorization": "Bearer __API_KEY__",
"Content-Type": "application/json",
"Accept": "application/json",
},
json={
"code": "SAVE10",
"plan_id": "uuid",
"order_sum": 50.00,
"currency": "USD",
},
)
data = response.json()
coupon = data["coupon"]
print(f"Discount: ${coupon["discount"]}, Final: ${coupon["final_amount"]}")
const response = await fetch("https://api.proxyhat.com/v1/coupon/validate", {
method: "POST",
headers: {
"Authorization": "Bearer __API_KEY__",
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({
code: "SAVE10",
plan_id: "uuid",
order_sum: 50.00,
currency: "USD",
}),
});
const { coupon } = await response.json();
console.log(`Discount: $${coupon.discount}, Final: $${coupon.final_amount}`);
payload := strings.NewReader(`{
"code": "SAVE10",
"plan_id": "uuid",
"order_sum": 50.00,
"currency": "USD"
}`)
req, _ := http.NewRequest("POST", "https://api.proxyhat.com/v1/coupon/validate", payload)
req.Header.Set("Authorization", "Bearer __API_KEY__")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result["coupon"])
Response
200
{
"success": true,
"coupon": {
"id": 1,
"code": "SAVE10",
"type": "percent",
"data": {
"percent": 10
},
"discount": 5.00,
"final_amount": 45.00
}
}