Gift codes
Each gift code gives premium to the first account that redeems it. People redeem them through Gifts.
Gift duration units
Заголовок раздела «Gift duration units»A gift’s duration_type is one of these units.
| Value | Description |
|---|---|
| days | Days |
| weeks | Weeks |
| months | Calendar months |
| years | Calendar years |
| lifetime | Premium that never ends, and duration_quantity is ignored |
Create gift codes
Заголовок раздела «Create gift codes»/v1/admin/gift-codesGenerates gift codes and returns their redemption links. You need gift_codes:generate, and the instance’s premium mode must be mirror.
JSON body
Заголовок раздела «JSON body»| Field | Type | Description |
|---|---|---|
| count | integer | The number of codes to generate (1-100) |
| duration_type | string | The gift duration unit |
| duration_quantity | integer | The number of units (1-3650), still required but ignored for lifetime |
Response body
Заголовок раздела «Response body»| Field | Type | Description |
|---|---|---|
| codes | array[string] | The redemption links, each in the form {gift URL}/{code} |
Response
Заголовок раздела «Response»| Status | Body | Condition |
|---|---|---|
| 200 | response body | The codes were generated |
| 403 | error response | FEATURE_NOT_AVAILABLE_SELF_HOSTED when the premium mode is everyone |
The request records a generate_gift_codes audit entry without the codes.
The rate limit is 30 requests per minute, on the admin:code:generation bucket.
Revoke a gift code
Заголовок раздела «Revoke a gift code»/v1/admin/gift-codes/{code}Revokes a gift code that nobody has redeemed. You need gift_codes:generate. Pass the code itself, which is the last part of the redemption link.
A redeemed code can’t be revoked, because the premium it gave already belongs to the account that redeemed it. To take that premium back, use Remove user premium on that account. The error message has the ID of that account.
A code a customer bought can’t be revoked here either. Refund the purchase instead, which revokes the code.
Response
Заголовок раздела «Response»| Status | Body | Condition |
|---|---|---|
| 204 | none | The code was revoked |
| 400 | error response | INVALID_FORM_BODY when the code was redeemed or a customer bought it |
| 400 | error response | STRIPE_GIFT_REDEMPTION_IN_PROGRESS when someone is redeeming the code right now |
| 404 | error response | UNKNOWN_GIFT_CODE when the code doesn’t exist or was already revoked |
The request records a revoke_gift_code audit entry with the code and its duration. A revoked code can’t be redeemed, so reading the entry doesn’t give premium to anyone.
The rate limit is 30 requests per minute, on the admin:code:generation bucket.
Look up a gift code
Заголовок раздела «Look up a gift code»/v1/admin/gift-codes/{code}Returns one gift code. You need gift_codes:generate. Pass the gift code or the code at the end of a gift link, and the response always has the gift code itself.
Response body
Заголовок раздела «Response body»| Field | Type | Description |
|---|---|---|
| code | string | The gift code |
| state | string | held, shared, expired or redeemed, as in the gift inventory |
| revoked | boolean | Whether the code was revoked |
| duration_type | string | The gift duration unit |
| duration_quantity | integer | The number of units |
| created_by_user_id | snowflake | The account that bought or created the gift |
| created_at | ISO 8601 timestamp | When the gift was created |
| stripe_payment_intent_id | ?string | The Stripe payment intent that paid for the gift |
| link_only | boolean | Whether the code works only for its owner, and other people claim the gift through a link |
| has_link | boolean | Whether the gift has a link right now |
| link_created_at | ?ISO 8601 timestamp | When the current link was made |
| link_expires_at | ?ISO 8601 timestamp | When the current link stops working, or null for never |
| recipient_user_id | ?snowflake | The only account that can claim the gift |
| recipient_guild_id | ?snowflake | The community whose members can claim the gift |
| non_premium_only | boolean | Whether accounts that already have premium are refused |
| redeemed_by_user_id | ?snowflake | The account that redeemed the gift |
| redeemed_at | ?ISO 8601 timestamp | When the gift was redeemed |
| redeemed_geoip_country_code | ?string | The country of the IP address the gift was redeemed from |
| redeemed_billing_country_code | ?string | The billing country of the newest payment of the account that redeemed the gift |
The response has no link code, so staff can’t claim a gift from it.
Response
Заголовок раздела «Response»| Status | Body | Condition |
|---|---|---|
| 200 | response body | The gift code was found |
| 404 | error response | UNKNOWN_GIFT_CODE when no gift code or link matches |
The request records a view_gift_code audit entry with the gift code.
The rate limit is 30 requests per minute, on the admin:code:generation bucket.
Stop a gift link
Заголовок раздела «Stop a gift link»/v1/admin/gift-codes/{code}/linkStops the link of a gift nobody has redeemed, for example when a link was posted somewhere public by mistake. You need gift_codes:generate. Pass the gift code or the code at the end of its link.
The gift goes back to its owner as ready to send, and the owner can make a new link. For an older gift whose code works for anyone, the code then works only for its owner, the same as when the owner stops the link.
Response
Заголовок раздела «Response»| Status | Body | Condition |
|---|---|---|
| 200 | gift code | The link was stopped |
| 400 | error response | GIFT_CODE_ALREADY_REDEEMED when the gift was redeemed |
| 400 | error response | STRIPE_GIFT_REDEMPTION_IN_PROGRESS when someone is redeeming the gift right now |
| 404 | error response | UNKNOWN_GIFT_CODE when no gift code or link matches, or the code was revoked |
The request records a stop_gift_code_link audit entry with the gift code.
The rate limit is 30 requests per minute, on the admin:code:generation bucket.