Coupons API

Validate, apply, and redeem coupon codes. Use these endpoints to check coupon validity, apply discounts during checkout, and redeem instant coupons for free traffic or subscription time.

Coupon Types: ProxyHat supports two types of coupons. Instant coupons are redeemed immediately via the /coupon/redeem endpoint and grant free traffic or subscription time directly to your account. Payment-based coupons are applied at checkout via the /coupon/apply endpoint and provide a discount on the order total. Use /coupon/validate to check a coupon and determine its type before redeeming or applying it.
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
  }
}
POST /v1/coupon/apply Requires Auth

Apply Coupon

Apply Coupon

Apply a coupon to a pending payment. Used during checkout for payment-based coupons that provide a discount on the order total. The coupon is validated and the discounted amount is returned.

Request Body
Name Type Required Description
code string Required The coupon code to apply.
plan_id string Required The UUID of the plan being purchased.
order_sum number Required The order total before the discount.
currency string Optional The currency code for the order. Defaults to "USD".
curl -X POST https://api.proxyhat.com/v1/coupon/apply \
  -H "Authorization: Bearer __API_KEY__" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "code": "SAVE10",
    "plan_id": "uuid",
    "order_sum": 50.00
  }'
import requests

response = requests.post(
    "https://api.proxyhat.com/v1/coupon/apply",
    headers={
        "Authorization": "Bearer __API_KEY__",
        "Content-Type": "application/json",
        "Accept": "application/json",
    },
    json={
        "code": "SAVE10",
        "plan_id": "uuid",
        "order_sum": 50.00,
    },
)

data = response.json()
coupon = data["coupon"]
print(f"Applied {coupon["code"]}: -${coupon["discount"]}, pay ${coupon["final_amount"]}")
const response = await fetch("https://api.proxyhat.com/v1/coupon/apply", {
  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,
  }),
});

const { coupon } = await response.json();
console.log(`Applied ${coupon.code}: -$${coupon.discount}, pay $${coupon.final_amount}`);
payload := strings.NewReader(`{
  "code": "SAVE10",
  "plan_id": "uuid",
  "order_sum": 50.00
}`)

req, _ := http.NewRequest("POST", "https://api.proxyhat.com/v1/coupon/apply", 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
  }
}
POST /v1/coupon/redeem Requires Auth

Redeem Coupon

Redeem Coupon

Redeem an instant coupon for free traffic or subscription time. Only works for coupons with is_instant=true. The benefit is applied immediately to the authenticated account.

Request Body
Name Type Required Description
code string Required The instant coupon code to redeem.
curl -X POST https://api.proxyhat.com/v1/coupon/redeem \
  -H "Authorization: Bearer __API_KEY__" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "code": "FREETRIAL"
  }'
import requests

response = requests.post(
    "https://api.proxyhat.com/v1/coupon/redeem",
    headers={
        "Authorization": "Bearer __API_KEY__",
        "Content-Type": "application/json",
        "Accept": "application/json",
    },
    json={
        "code": "FREETRIAL",
    },
)

data = response.json()
print(f"{data["message"]}: {data["coupon"]["code"]}")
const response = await fetch("https://api.proxyhat.com/v1/coupon/redeem", {
  method: "POST",
  headers: {
    "Authorization": "Bearer __API_KEY__",
    "Content-Type": "application/json",
    "Accept": "application/json",
  },
  body: JSON.stringify({
    code: "FREETRIAL",
  }),
});

const data = await response.json();
console.log(`${data.message}: ${data.coupon.code}`);
payload := strings.NewReader(`{
  "code": "FREETRIAL"
}`)

req, _ := http.NewRequest("POST", "https://api.proxyhat.com/v1/coupon/redeem", 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["message"])
Response 200
{
  "success": true,
  "message": "Coupon redeemed",
  "coupon": {
    "id": 2,
    "code": "FREETRIAL",
    "type": "instant",
    "data": {
      "free_traffic_gb": 1
    }
  }
}