Update Coupon
const url = 'https://api.ultimateteam.ai/api/v1/admin/coupons/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0';const options = { method: 'PATCH', headers: {'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json'}, body: '{"active":true,"expires_at":"2026-04-15T12:00:00Z","max_redemptions":1}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url https://api.ultimateteam.ai/api/v1/admin/coupons/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0 \ --header 'Content-Type: application/json' \ --header 'X-API-Key: <X-API-Key>' \ --data '{ "active": true, "expires_at": "2026-04-15T12:00:00Z", "max_redemptions": 1 }'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
Section titled “Authorizations”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”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
Examplegenerated
{ "active": true, "expires_at": "2026-04-15T12:00:00Z", "max_redemptions": 1}Responses
Section titled “ Responses ”Successful Response
The canonical coupon JSON shape returned by every coupon endpoint.
object
Examplegenerated
{ "active": true, "bonus_credits": 1, "code": "example", "created_at": "2026-04-15T12:00:00Z", "created_by": "example", "description": "example", "discount_type": "example", "discount_value": 1, "duration": "example", "duration_months": 1, "expires_at": "2026-04-15T12:00:00Z", "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "max_redemptions": 1, "plan_grant": "example", "times_redeemed": 1}Validation Error
object
object
object
Examplegenerated
{ "detail": [ { "ctx": {}, "input": "example", "loc": [ "example" ], "msg": "example", "type": "example" } ]}