Skip to content

Update Coupon

PATCH
/api/v1/admin/coupons/{coupon_id}

Update a coupon’s active / expires_at / max_redemptions.

Uses exclude_unset=True so an omitted field is left alone while an explicit null is applied: expires_at: null means “never expires” and max_redemptions: null means “unlimited”, both of which a truthiness filter would silently discard.

Args: coupon_id: The coupon to update. body: Partial update payload. user: The authenticated platform operator (injected). session: Database session.

Returns: The updated coupon.

Raises: HTTPException 404: No coupon with that id.

Authorizations

Parameters

Path Parameters

coupon_id
required
string format: uuid

Request Body required

PATCH /api/v1/admin/coupons/{id} request body.

Every field is optional and nullable, and None is a meaningful value for two of them (expires_at=None means “never expires”, max_redemptions=None means “unlimited”). Callers must therefore distinguish “absent” from “explicitly null”, which the route does via model_dump(exclude_unset=True) — never a truthiness check.

object
active
Any of:
boolean
expires_at
Any of:
string format: date-time
max_redemptions
Any of:
integer
>= 1

Responses

200

Successful Response

The canonical coupon JSON shape returned by every coupon endpoint.

object
active
required
boolean
bonus_credits
required
integer
code
required
string
created_at
required
string format: date-time
created_by
required
Any of:
string
description
required
Any of:
string
discount_type
required
string
discount_value
required
integer
duration
required
string
duration_months
required
Any of:
integer
expires_at
required
Any of:
string format: date-time
id
required
string format: uuid
max_redemptions
required
Any of:
integer
plan_grant
required
Any of:
string
times_redeemed
required
integer

422

Validation Error

object
detail
Array<object>
object
ctx
object
input
loc
required
Array
msg
required
string
type
required
string