> For the complete documentation index, see [llms.txt](https://vauchar.gitbook.io/vauchar/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vauchar.gitbook.io/vauchar/api-references/coupons/coupon-validations.md).

# Coupon Validations

Operations for validating coupons.

## Validate a Coupon by Code

> Checks if a coupon is valid based on the provided code, user ID, and transaction value.

```json
{"openapi":"3.0.0","info":{"title":"Vauchar API","version":"1.0.0"},"tags":[{"name":"Coupon Validations","description":"Operations for validating coupons."}],"servers":[{"url":"https://api.vauchar.com","description":"Production Server"}],"security":[{"basicAuth":[]}],"components":{"securitySchemes":{"basicAuth":{"type":"http","scheme":"basic","description":"HTTP Basic Authentication. The username is your Merchant ID and the password is your API Key. The combined string `Merchant_Id:Api_Key` should be Base64 encoded."}},"schemas":{"ValidationStatus":{"type":"object","properties":{"status":{"type":"integer","description":"A status code indicating the result of the validation."},"message":{"type":"string","description":"A human-readable message describing the validation status."}}},"Coupon":{"type":"object","properties":{"href":{"type":"string","description":"The direct URL to this specific coupon resource."},"type":{"type":"string","description":"The type of the object, in this case, \"coupon\"."},"id":{"type":"string","description":"The unique identifier for the coupon."},"coupon_code":{"type":"string","description":"The code that customers use to redeem the coupon."},"created":{"type":"integer","format":"int64","description":"The timestamp when the coupon was created (Unix timestamp)."},"start_time":{"type":"integer","format":"int64","description":"The timestamp when the coupon becomes valid (Unix timestamp)."},"expiry_time":{"type":"integer","format":"int64","description":"The timestamp when the coupon expires (Unix timestamp). A value of 0 means it never expires."},"allowed_users":{"type":"integer","description":"The number of specific users allowed to use this coupon. 0 means unlimited."},"redemptions_limit_total":{"type":"integer","description":"The total number of times this coupon can be redeemed across all users. 0 means unlimited."},"redemptions_limit_per_user":{"type":"integer","description":"The number of times a single user can redeem this coupon. 0 means unlimited."},"value":{"type":"string","description":"The discount value of the coupon."},"value_unit":{"type":"string","description":"The unit of the discount value (e.g., 'value' for fixed amount, 'percent')."},"currency":{"type":"string","description":"The currency of the coupon's value (e.g., 'USD')."},"active_status":{"type":"integer","description":"The status of the coupon. 1 for active, 0 for inactive."}}}}},"paths":{"/coupons/validate":{"get":{"summary":"Validate a Coupon by Code","description":"Checks if a coupon is valid based on the provided code, user ID, and transaction value.","operationId":"validateCouponByCode","tags":["Coupon Validations"],"parameters":[{"name":"coupon_code","in":"query","description":"The coupon code to validate.","required":true,"schema":{"type":"string"}},{"name":"user_id","in":"query","description":"The ID of the user attempting to use the coupon.","required":true,"schema":{"type":"string"}},{"name":"transaction_value","in":"query","description":"The total value of the transaction.","required":true,"schema":{"type":"number"}}],"responses":{"200":{"description":"The coupon is valid. The response includes the validation status and coupon details.","content":{"application/json":{"schema":{"type":"object","properties":{"validation_status":{"$ref":"#/components/schemas/ValidationStatus"},"data":{"$ref":"#/components/schemas/Coupon"}}}}}},"400":{"description":"Bad Request. The coupon is invalid or does not meet the criteria (e.g., expired, invalid code, does not apply to the transaction value). The response will contain a specific validation message."},"401":{"description":"Unauthorized. The API Key or Merchant ID is missing or invalid."},"404":{"description":"Not Found. The coupon with the specified code does not exist."},"500":{"description":"Internal Server Error."}}}}}}
```

## Validate by Coupon ID

> Checks if a coupon is valid for a specific user by providing the coupon ID and user ID.

```json
{"openapi":"3.0.0","info":{"title":"Vauchar API","version":"1.0.0"},"tags":[{"name":"Coupon Validations","description":"Operations for validating coupons."}],"servers":[{"url":"https://api.vauchar.com","description":"Production Server"}],"security":[{"basicAuth":[]}],"components":{"securitySchemes":{"basicAuth":{"type":"http","scheme":"basic","description":"HTTP Basic Authentication. The username is your Merchant ID and the password is your API Key. The combined string `Merchant_Id:Api_Key` should be Base64 encoded."}},"schemas":{"ValidationStatus":{"type":"object","properties":{"status":{"type":"integer","description":"A status code indicating the result of the validation."},"message":{"type":"string","description":"A human-readable message describing the validation status."}}},"Coupon":{"type":"object","properties":{"href":{"type":"string","description":"The direct URL to this specific coupon resource."},"type":{"type":"string","description":"The type of the object, in this case, \"coupon\"."},"id":{"type":"string","description":"The unique identifier for the coupon."},"coupon_code":{"type":"string","description":"The code that customers use to redeem the coupon."},"created":{"type":"integer","format":"int64","description":"The timestamp when the coupon was created (Unix timestamp)."},"start_time":{"type":"integer","format":"int64","description":"The timestamp when the coupon becomes valid (Unix timestamp)."},"expiry_time":{"type":"integer","format":"int64","description":"The timestamp when the coupon expires (Unix timestamp). A value of 0 means it never expires."},"allowed_users":{"type":"integer","description":"The number of specific users allowed to use this coupon. 0 means unlimited."},"redemptions_limit_total":{"type":"integer","description":"The total number of times this coupon can be redeemed across all users. 0 means unlimited."},"redemptions_limit_per_user":{"type":"integer","description":"The number of times a single user can redeem this coupon. 0 means unlimited."},"value":{"type":"string","description":"The discount value of the coupon."},"value_unit":{"type":"string","description":"The unit of the discount value (e.g., 'value' for fixed amount, 'percent')."},"currency":{"type":"string","description":"The currency of the coupon's value (e.g., 'USD')."},"active_status":{"type":"integer","description":"The status of the coupon. 1 for active, 0 for inactive."}}}}},"paths":{"/coupons/{couponId}/validate":{"get":{"summary":"Validate by Coupon ID","description":"Checks if a coupon is valid for a specific user by providing the coupon ID and user ID.","operationId":"validateCouponById","tags":["Coupon Validations"],"parameters":[{"name":"couponId","in":"path","description":"The ID of the coupon to validate.","required":true,"schema":{"type":"string"}},{"name":"user_id","in":"query","description":"The ID of the user attempting to use the coupon.","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The coupon is valid. The response includes the validation status and coupon details.","content":{"application/json":{"schema":{"type":"object","properties":{"validation_status":{"$ref":"#/components/schemas/ValidationStatus"},"data":{"$ref":"#/components/schemas/Coupon"}}}}}},"400":{"description":"Bad Request. The coupon is invalid for the user."},"401":{"description":"Unauthorized. The API Key or Merchant ID is missing or invalid."},"404":{"description":"Not Found. The coupon with the specified ID does not exist."},"500":{"description":"Internal Server Error."}}}}}}
```
