Skip to content

Update Coupon

PATCH
/api/v1/admin/coupons/{coupon_id}
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.

coupon_id
required
Coupon Id
string format: uuid
Media typeapplication/json
UpdateCouponRequest

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
Examplegenerated
{
"active": true,
"expires_at": "2026-04-15T12:00:00Z",
"max_redemptions": 1
}

Successful Response

Media typeapplication/json
CouponOut

The canonical coupon JSON shape returned by every coupon endpoint.

object
active
required
Active
boolean
bonus_credits
required
Bonus Credits
integer
code
required
Code
string
created_at
required
Created At
string format: date-time
created_by
required
Any of:
string
description
required
Any of:
string
discount_type
required
Discount Type
string
discount_value
required
Discount Value
integer
duration
required
Duration
string
duration_months
required
Any of:
integer
expires_at
required
Any of:
string format: date-time
id
required
Id
string format: uuid
max_redemptions
required
Any of:
integer
plan_grant
required
Any of:
string
times_redeemed
required
Times Redeemed
integer
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

Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
ctx
Context
object
input
Input
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
Examplegenerated
{
"detail": [
{
"ctx": {},
"input": "example",
"loc": [
"example"
],
"msg": "example",
"type": "example"
}
]
}