Check Coupon Code API
Validate coupon codes and retrieve discount information before applying
Check Coupon Code API
Validate coupon codes before applying them to purchases. Check validity, discount amount, and any applicable restrictions.
Instant Validation
Verify codes in real-time.
Discount Preview
See discount before purchase.
Error Prevention
Catch invalid codes early.
Endpoint Overview
/graphqlValidate a coupon code and retrieve its discount information, validity status, and any usage restrictions.
Request Parameters
codeString!RequiredThe coupon code to validate.
planIdIntPlan ID to check if coupon is applicable.
amountFloatPurchase amount to calculate discount.
GraphQL Mutation
mutation checkCouponCode($code: String!, $planId: Int, $amount: Float) {
checkCouponCode(code: $code, planId: $planId, amount: $amount) {
valid
code
discountType
discountValue
calculatedDiscount
message
restrictions {
validUntil
remainingUses
applicablePlans
}
}
}Variables:
{
"code": "SUMMER2024",
"planId": 5,
"amount": 99.99
}HTTP Request:
curl -X POST https://api.orbnet.com/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"query": "mutation checkCouponCode($code: String!) { checkCouponCode(code: $code) { valid discountType discountValue message } }",
"variables": {
"code": "SUMMER2024"
}
}'Response
{
"data": {
"checkCouponCode": {
"valid": true,
"code": "SUMMER2024",
"discountType": "PERCENTAGE",
"discountValue": 25,
"calculatedDiscount": 24.99,
"message": "Coupon valid for 25% off",
"restrictions": {
"validUntil": "2024-08-31T23:59:59Z",
"remainingUses": 850,
"applicablePlans": [1, 2, 3, 5]
}
}
}
}{
"data": {
"checkCouponCode": {
"valid": false,
"code": "OLDCODE",
"discountType": null,
"discountValue": null,
"calculatedDiscount": null,
"message": "Coupon has expired",
"restrictions": null
}
}
}{
"data": {
"checkCouponCode": {
"valid": false,
"code": "PROONLY",
"discountType": "PERCENTAGE",
"discountValue": 20,
"calculatedDiscount": null,
"message": "Coupon not valid for selected plan",
"restrictions": {
"applicablePlans": [10, 11, 12]
}
}
}
}Validation Checks
Code Exists
Verifies the code exists in the system.
Not Expired
Checks validFrom and validUntil dates.
Usage Limit
Confirms available redemptions remain.
Plan Compatibility
Verifies coupon applies to selected plan.
Use Cases
Checkout Preview
Show discount before final purchase.
Form Validation
Validate as user types coupon code.
Customer Support
Verify codes for support tickets.
API Integration
Validate before external processing.
Best Practices
Validate Early
Check coupons before checkout process.
Show Feedback
Display clear valid/invalid messages.
Handle Errors
Gracefully handle invalid codes.
Include Plan
Pass planId for accurate validation.
Related Endpoints
Real-time Validation
Implement real-time validation as users type coupon codes to provide instant feedback.
Apply Valid Coupons
Once validated, use the Use Coupon Code API to apply the discount to a purchase.