Gifts
A gift is a code that grants premium to the account that redeems it. Create gift checkout buys one. On a self-hosted instance, the routes on this page work only while its premium mode is mirror.
A gift bought on web or in a store app by a client that sends gift_links: true with the purchase starts held, and its own code works only for the account that bought it. Other people claim it through a gift link, and the gift’s claim rules decide who can. A gift bought without gift_links, made by the Admin API or a staff payment link, or bought before gift links existed, has a code anyone can redeem until its owner makes a link for it.
Gift object
Заголовок раздела «Gift object»A gift grants premium for a set duration.
Structure
Заголовок раздела «Structure»| Field | Type | Description |
|---|---|---|
| code1 | string | The code from the request, a link code or the gift’s own code |
| duration_type | string | The duration unit of duration_quantity |
| duration_quantity2 | integer | The number of units the gift grants |
| redeemed | boolean | Whether the code has been redeemed |
| created_by?3 | ?partial user object | The account that created the gift |
| rules | gift claim rules object | Who can claim the gift |
| expired | boolean | Whether the link in the request has expired |
1 32 case-sensitive letters and digits
2 A value of 0 grants lifetime premium
3 For a gift from the Admin API, created_by is the instance admin who created it
Example
Заголовок раздела «Example»{ "code": "aZ3kQ9mR2tX7bN4vC8wL5yH1sD6gF0pJ", "duration_type": "months", "duration_quantity": 1, "redeemed": false, "created_by": { "id": "1501314428688998182", "username": "quill", "discriminator": "0001", "global_name": "Quill", "avatar": null, "avatar_color": null, "flags": 0 }, "rules": { "recipient": null, "guild": { "id": "1501314428688998190", "name": "Quill's Corner", "icon": null }, "non_premium_only": true }, "expired": false}Gift claim rules object
Заголовок раздела «Gift claim rules object»A gift is for one person, for members of one community or for anyone with the link. non_premium_only can be on with any of the three. The owner sets the rules with Modify gift claim rules until someone claims the gift.
Structure
Заголовок раздела «Structure»| Field | Type | Description |
|---|---|---|
| recipient | ?partial user object | The only account that can claim the gift, or null |
| guild | ?gift community object | The community whose members can claim the gift, or null |
| non_premium_only1 | boolean | Whether accounts that already have premium are refused |
At most one of recipient and guild is set. When both are null, anyone with the link can claim the gift.
1 Premium here is any premium the account has, including gift time, store subscriptions and a subscription set to end
Gift community object
Заголовок раздела «Gift community object»Structure
Заголовок раздела «Structure»| Field | Type | Description |
|---|---|---|
| id | snowflake | The ID of the community |
| name | string | The name of the community |
| icon | ?string | The hash of the community icon |
Gift duration units
Заголовок раздела «Gift duration units»Bought gifts use months or years, and only Admin API gifts use days or weeks.
| Value | Description |
|---|---|
| days | Periods of 24 hours |
| weeks | Periods of seven 24-hour days |
| months | Calendar months, clamped to the last day of the target month |
| years | 12 calendar months |
Get gift
Заголовок раздела «Get gift»/v1/gifts/{code}Returns a gift. code is a link code or the code of a gift anyone can redeem. A held gift’s own code returns UNKNOWN_GIFT_CODE, even for its owner.
Response
Заголовок раздела «Response»| Status | Body | Condition |
|---|---|---|
| 200 | gift object | The gift was returned |
| 404 | error response | UNKNOWN_GIFT_CODE when the code does not exist, was revoked after a refund or by an instance admin, is a link that was replaced or stopped, or is a held gift’s own code |
The rate limit is 60 requests per 10 seconds, on the gift:get bucket.
Redeem gift
Заголовок раздела «Redeem gift»/v1/gifts/{code}/redeemRedeems a gift for the current user and sends a User Update Gateway event. You need a claimed account.
code is a link code or a gift’s own code. A held gift’s own code works only for its owner. The owner can always redeem their own gift, and the claim rules and link expiry don’t apply to them. For anyone else Squad checks the link expiry and then the rules, in the order of the response table below. A refused claim leaves the gift unredeemed.
A gift adds its duration after any premium the account already has and pushes back the next charge of an active subscription. A lifetime gift (duration_quantity of 0) cancels an active subscription.
Request headers
Заголовок раздела «Request headers»| Field | Type | Description |
|---|---|---|
| X-Captcha-Token? | string | The solved ALTCHA challenge |
Response
Заголовок раздела «Response»| Status | Body | Condition |
|---|---|---|
| 204 | empty | The gift was redeemed |
| 400 | error response | GIFT_CODE_ALREADY_REDEEMED when the code was already redeemed |
| 400 | error response | STRIPE_GIFT_REDEMPTION_IN_PROGRESS when the same code is being redeemed at the same time |
| 400 | error response | STRIPE_ERROR when the payment provider rejects the change to an active subscription. The code stays unredeemed |
| 400 | error response | GIFT_LINK_EXPIRED when the link has expired |
| 400 | error response | GIFT_CODE_RECIPIENT_ONLY when the gift is for another account |
| 400 | error response | GIFT_CODE_COMMUNITY_MEMBERS_ONLY when the account isn’t a member of the gift’s community |
| 400 | error response | GIFT_CODE_NON_PREMIUM_ONLY when non_premium_only is on and the account has premium |
| 400 | error response | CANNOT_REDEEM_PLUTONIUM_WITH_VISIONARY when the account has lifetime premium |
| 403 | error response | ACCOUNT_VERIFICATION_REQUIRED for an unclaimed account |
| 404 | error response | UNKNOWN_GIFT_CODE when the code does not exist or was revoked, is a link that was replaced or stopped, or is another account’s held gift |
The rate limit is 10 requests per minute, on the gift:redeem bucket.