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

Gift inventory

The gift inventory has the premium gift codes the current account bought.

A new code sets has_unread_gift_inventory on the user object and adds one to unread_gift_inventory_count. To clear both, send has_unread_gift_inventory: false to Modify current user. Listing gifts doesn’t clear them.

One gift code the current account bought. A held gift has no link, and only its owner can redeem it. Other people claim a shared gift through its link.

FieldTypeDescription
codestringThe gift’s own code, used in the routes on this page
duration_typestringThe duration unit of duration_quantity
duration_quantityintegerThe number of duration_type units the code grants
created_atISO8601 timestampWhen the code was created
created_bypartial user objectThe account that bought the code
redeemed_at??ISO8601 timestampWhen the code was redeemed, or null if it is unredeemed
redeemed_by??partial user objectThe account that redeemed the code, or null if it is unredeemed
statestringThe gift share state
share_code1?stringThe code to put in the gift URL, or null when the gift has no working link
link_expires_at?ISO8601 timestampWhen the current link stops working, or null when it never does
rulesgift claim rules objectWho can claim the gift

1 Build gift URLs from share_code only. For a held gift code works for nobody but its owner

ValueDescription
heldThe gift has no link and nobody else can claim it
sharedThe gift has a working link, or it is an older gift whose own code anyone can redeem
expiredThe link has expired. The gift is held again and keeps its claim rules
redeemedSomeone redeemed the gift
GET /v1/users/@me/gifts

Returns the gift codes the current account bought, newest first, with no pagination. The list leaves out revoked codes and codes redeemed more than seven days ago.

HeaderDescription
X-Fluxer-Capabilities?Comma-separated client capabilities. Include gift_links to get each gift as it is

A client made before gift links builds gift URLs from code. So that such a client never shares a code that works only for its owner, a request without gift_links changes the list:

  • Each unredeemed gift that is held or expired gets a new link that never expires, and keeps its claim rules. The owner’s other clients see it as shared.
  • code holds the gift’s share_code for every unredeemed gift that has one. The owner can still redeem a gift through its link, and the claim rules don’t apply to them.
StatusBodyCondition
200array[gift inventory object]The gift codes were returned
404error responseNOT_FOUND when a self-hosted instance’s premium mode isn’t mirror

The rate limit is 40 requests per 10 seconds, on the gifts:list bucket.

PATCH /v1/users/@me/gifts/{code}

Sets who can claim a gift the current account owns and returns the updated gift inventory object. A field you leave out keeps its value, and null clears it. The link stays the same.

FieldTypeDescription
recipient_user_id??snowflakeThe only account that can claim the gift
guild_id??snowflakeThe community whose members can claim the gift. You must be a member
non_premium_only??booleanWhether accounts that already have premium are refused

Setting both recipient_user_id and guild_id fails validation. The recipient can’t be a bot, a deleted account or you.

StatusBodyCondition
200gift inventory objectThe rules were saved
400error responseINVALID_FORM_BODY for a recipient and a community together, an unknown recipient or a community you aren’t in
400error responseGIFT_CODE_ALREADY_REDEEMED when the gift was redeemed
400error responseSTRIPE_GIFT_REDEMPTION_IN_PROGRESS when someone is redeeming the gift at the same time
404error responseUNKNOWN_GIFT_CODE when the gift does not exist, was revoked or belongs to another account

The rate limit is 20 requests per 10 seconds, on the gifts:manage bucket.

POST /v1/users/@me/gifts/{code}/link

Makes a new link for a gift the current account owns and returns the updated gift inventory object. The old link stops working at once. The gift’s own code never changes, and after this call it works only for you.

FieldTypeDescription
expires_in??integerSeconds until the link stops working, one of 3600, 86400, 604800 and 2592000, or null for never (default null)

A link code has the same length and characters as a gift code, and gift URLs and gift embeds work with either. When a link expires, the gift is held again. The gift itself never expires.

StatusBodyCondition
200gift inventory objectThe link was made
400error responseGIFT_CODE_ALREADY_REDEEMED when the gift was redeemed
400error responseSTRIPE_GIFT_REDEMPTION_IN_PROGRESS when someone is redeeming the gift at the same time
404error responseUNKNOWN_GIFT_CODE when the gift does not exist, was revoked or belongs to another account

The rate limit is 20 requests per 10 seconds, on the gifts:manage bucket.

DELETE /v1/users/@me/gifts/{code}/link

Stops the link of a gift the current account owns and returns the updated gift inventory object. The gift is held again and keeps its claim rules.

StatusBodyCondition
200gift inventory objectThe link was stopped
400error responseGIFT_CODE_ALREADY_REDEEMED when the gift was redeemed
400error responseSTRIPE_GIFT_REDEMPTION_IN_PROGRESS when someone is redeeming the gift at the same time
404error responseUNKNOWN_GIFT_CODE when the gift does not exist, was revoked or belongs to another account

The rate limit is 20 requests per 10 seconds, on the gifts:manage bucket.