Перейти к содержимому

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.

A gift grants premium for a set duration.

FieldTypeDescription
code1stringThe code from the request, a link code or the gift’s own code
duration_typestringThe duration unit of duration_quantity
duration_quantity2integerThe number of units the gift grants
redeemedbooleanWhether the code has been redeemed
created_by?3?partial user objectThe account that created the gift
rulesgift claim rules objectWho can claim the gift
expiredbooleanWhether 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

{
"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
}

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.

FieldTypeDescription
recipient?partial user objectThe only account that can claim the gift, or null
guild?gift community objectThe community whose members can claim the gift, or null
non_premium_only1booleanWhether 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

FieldTypeDescription
idsnowflakeThe ID of the community
namestringThe name of the community
icon?stringThe hash of the community icon

Bought gifts use months or years, and only Admin API gifts use days or weeks.

ValueDescription
daysPeriods of 24 hours
weeksPeriods of seven 24-hour days
monthsCalendar months, clamped to the last day of the target month
years12 calendar months
GET /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.

StatusBodyCondition
200gift objectThe gift was returned
404error responseUNKNOWN_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.

POST /v1/gifts/{code}/redeem

Redeems 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.

FieldTypeDescription
X-Captcha-Token?stringThe solved ALTCHA challenge
StatusBodyCondition
204emptyThe gift was redeemed
400error responseGIFT_CODE_ALREADY_REDEEMED when the code was already redeemed
400error responseSTRIPE_GIFT_REDEMPTION_IN_PROGRESS when the same code is being redeemed at the same time
400error responseSTRIPE_ERROR when the payment provider rejects the change to an active subscription. The code stays unredeemed
400error responseGIFT_LINK_EXPIRED when the link has expired
400error responseGIFT_CODE_RECIPIENT_ONLY when the gift is for another account
400error responseGIFT_CODE_COMMUNITY_MEMBERS_ONLY when the account isn’t a member of the gift’s community
400error responseGIFT_CODE_NON_PREMIUM_ONLY when non_premium_only is on and the account has premium
400error responseCANNOT_REDEEM_PLUTONIUM_WITH_VISIONARY when the account has lifetime premium
403error responseACCOUNT_VERIFICATION_REQUIRED for an unclaimed account
404error responseUNKNOWN_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.