Skip to content

Update a coupon

PATCH
/coupons/{id}
Code sample: Shell / cURL
curl --request PATCH \
--url https://example.com/api/v1/coupons/example \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "code": "example", "currency": "example", "discountType": "PERCENTAGE", "duration": "ONCE", "durationInCycles": 1, "expiresAt": "example", "isActive": true, "maxRedemptions": 1, "startsAt": "example", "value": 1 }'

Updates a coupon, including activating or deactivating it via isActive. Lowering maxRedemptions below the current redemption count is valid — it stops future redemptions without being rejected. Changing duration follows the same REPEATING vs durationInCycles rule as creation. Requires the invoices.manage permission.

id
required

Resource identifier (CUID2).

string
>= 1 characters

Resource identifier (CUID2).

Media typeapplication/json
object
code
string
>= 1 characters <= 50 characters
currency
string
>= 3 characters <= 3 characters
discountType
string
Allowed values: PERCENTAGE FIXED_AMOUNT
duration

How many billing cycles a subscription this coupon opened keeps discounting. ONCE (default) applies only to the purchase invoice; REPEATING counts durationInCycles invoices starting with the purchase; FOREVER never stops.

string
Allowed values: ONCE REPEATING FOREVER
durationInCycles

Required and positive when duration is REPEATING; omitted otherwise.

Any of:
integer
> 0 <= 9007199254740991
expiresAt
string | null
isActive

Activate or deactivate the coupon.

boolean
maxRedemptions
Any of:
integer
> 0 <= 9007199254740991
startsAt
string | null
value
number

The updated coupon.

Media typeapplication/json
object
data
required

A workspace discount coupon, redeemable at checkout and on invoices.

object
code
required
string
createdAt
required
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
currency
required
string
discountType
required
string
Allowed values: PERCENTAGE FIXED_AMOUNT
duration
required

How many billing cycles a subscription this coupon opened keeps discounting. ONCE (default) applies only to the purchase invoice; REPEATING counts durationInCycles invoices starting with the purchase; FOREVER never stops.

string
Allowed values: ONCE REPEATING FOREVER
durationInCycles
required

Number of billing cycles discounted. Only set when duration is REPEATING.

Any of:
integer
>= -9007199254740991 <= 9007199254740991
expiresAt
required
Any of:
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
id
required
string
isActive
required
boolean
maxRedemptions
required
Any of:
integer
>= -9007199254740991 <= 9007199254740991
redeemedCount
required
integer
>= -9007199254740991 <= 9007199254740991
startsAt
required
Any of:
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
updatedAt
required
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
value
required

Percentage points or a fixed currency amount.

number

Example

{
"data": {
"discountType": "PERCENTAGE",
"duration": "ONCE"
}
}

Validation error. Parse failures include field paths and expectations.

Media typeapplication/json

Validation error with safe field paths and expected values; submitted values are never returned.

object
error
required
object
code
required

Stable machine-readable error code.

string
issues
Array<object>
object
expected
required
string
message
required
string
path
required
Array<string | number>
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Unauthorized.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Forbidden.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Not found.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Conflict.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Invalid input.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Rate limit exceeded. Wait for Retry-After before retrying.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}
RateLimit-Limit
string
/^\d+$/

Maximum requests in the current quota window.

RateLimit-Policy
string

Quota policy in requests and window seconds, for example 60;w=60.

RateLimit-Remaining
string
/^\d+$/

Requests left in this quota window (zero when blocked).

RateLimit-Reset
string
/^\d+$/

Seconds until the current quota window resets, when available from the rate-limit store.

Retry-After
string
/^\d+$/

Seconds until another request may be attempted.