Skip to main content
PATCH
/
coupons
/
{id}
curl -X PATCH https://api.example.com/coupons/1 \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "percentage": 30
  }'
{
  "id": 1,
  "name": "SUMMER2026",
  "percentage": 30,
  "expirationDate": "2026-09-30"
}
This endpoint requires admin authentication. Include a valid admin JWT token in the Authorization header.

Path Parameters

id
number
required
The unique identifier of the coupon to update. Must be a valid positive integer.

Request Body

All fields are optional. Only include the fields you want to update.
name
string
The unique name/code for the coupon (max 30 characters)
percentage
number
The discount percentage. Must be an integer between 1 and 100
expirationDate
string
The expiration date in ISO 8601 date string format (e.g., “2026-12-31”)

Response

Returns the updated coupon object.
id
number
The unique identifier for the coupon
name
string
The coupon name/code
percentage
number
The discount percentage
expirationDate
string
The expiration date
curl -X PATCH https://api.example.com/coupons/1 \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "percentage": 30
  }'
{
  "id": 1,
  "name": "SUMMER2026",
  "percentage": 30,
  "expirationDate": "2026-09-30"
}

Validation Rules

When provided, each field follows the same validation rules as creation:
  • name: Maximum 30 characters
  • percentage: Must be an integer between 1 and 100 (inclusive)
  • expirationDate: Must be a valid ISO 8601 date string format

Behavior

  • Only the fields included in the request body will be updated
  • The coupon must exist (returns 404 if not found)
  • All validation rules apply to the fields being updated
  • The ID parameter is validated using IdValidationPipe

Build docs developers (and LLMs) love