CouponCraft registers REST API endpoints under the couponcraft/v1 namespace.
POST /couponcraft/v1/resolve
Public endpoint. Resolves a URL token to a coupon and applies it to the session.
Request body:
json
{ "token": "abc123..." }
Success response:
json
{
"success": true,
"coupon_id": 42,
"applied": true,
"message": "Coupon applied successfully."
}
Error response (404):
json
{
"code": "couponcraft_invalid_token",
"message": "This coupon link is invalid or has expired."
}
GET /couponcraft/v1/token/{coupon_id}
Admin only (manage_woocommerce). Returns all tokens for a coupon.
Response:
json
[
{
"id": 1,
"token": "abc123...",
"url": "https://yoursite.com/?coupon=abc123...",
"expires_at": null,
"usage_limit": 10,
"usage_count": 3,
"created_at": "2026-04-08 12:00:00"
}
]
POST /couponcraft/v1/token/{coupon_id}
Admin only. Creates a new token for a coupon.
Request body (optional):
json
{ "usage_limit": 100 }
Response:
json
{
"success": true,
"token": "abc123...",
"url": "https://yoursite.com/?coupon=abc123..."
}
DELETE /couponcraft/v1/token/{coupon_id}
Admin only. Deletes all tokens for a coupon.
POST /couponcraft/v1/token/revoke
Admin only. Revokes a single token.
Request body:
json
{ "token": "abc123..." }
POST /couponcraft/v1/token/{coupon_id}/revoke-all
Admin only. Revokes all tokens for a coupon.