Giveaways

Open the giveaway's funding order (201, the giveaway becomes awaiting_funding) or serve the open one again (200), and get the payment instruction. Unlike an order, a giveaway is paid to its OWN one-time deposit address: memo is null and address_kind is one_time_deposit — send exactly amount_smallest_unit of asset to pay_to_address before expires_at, with no comment needed. When the payment arrives the giveaway opens (giveaway.opened). A late, short or excess payment to the deposit address is returned to the sender automatically.

Currency. currency chooses the asset of a NEW funding order: ton pays in GRAM, usdt_ton in USDT on TON; no body means ton. While a payable order is open, a call naming its currency serves it again (200); a call naming the other currency is refused 409 funding_order_open_in_other_currency with currency set to the open order's currency — fund again with that currency (a USDT order is served again only with usdt_ton, never with no body). usdt_ton answers 422 currency_not_available while USDT funding is not offered only where a NEW order would be opened: an open USDT order is still served again with usdt_ton.

Expiry. expires_at is the end of the funding window (2 hours from the moment the order opened; serving it again keeps that deadline). An expired instruction cannot be paid or replaced: /fund answers 409 funding_order_not_payable with the order's status (for example expired, failed, reversed or missing; whatever the value, the order cannot be paid). An expired or reversed funding order then cancels the giveaway (giveaway.cancelled, reason funding_expired), after which /fund answers 409 not_fundable with status: cancelled. To try again, create a new giveaway.

Already paid. Once the payment arrived, /fund answers 409 funding_order_not_payable with status: completed while the giveaway is still opening, then 409 not_fundable with the giveaway's status — as in any status other than draft and awaiting_funding.

Other refusals. A gift prize is re-priced live before a new order opens: a price that moved since the create is 409 gift_price_changed with the new stars (the giveaway's gift.stars is the price it was created with); create a new giveaway at the new price. A gift that sold out since the create is 400 on gift.gift_id, and one with fewer left than winner_count is 400 on winner_count, each with details.code. 503 gift_catalog_unavailable (retry later) and 503 prize_type_unavailable (not enabled — do not retry) apply to gift prizes; 503 unavailable means no deposit address can be issued right now (retry).

Idempotency-Key is required; a retry with the same key returns the same instruction. A refusal keeps no answer, so the corrected call (for example in the open order's currency) may reuse the key.

post/v1/giveaways/{id}/fund

Request

  • Base URL
    https://api.mystars.tg
  • Auth
    API key in header X-Api-Key

Path parameters

idstring uuid required

The giveaway id (UUID).

Headers

Idempotency-Keystring required

A unique key for this write, at most 255 characters, scoped to your tenant. Retrying with the same key and the same request returns the original answer instead of acting twice; the same key with a different request is 409 idempotency_conflict while the key is held (its first request still running, or its answer kept). On the giveaway and series writes, while the first request with the key is still running, a retry is 409 idempotency_in_flight with Retry-After: 1 — retry with the same key. A campaign create or recipient append retry waits for the first one and gets its answer. Derive the key from your own record id to stay safe across process restarts.

How long a key is remembered: a campaign create or recipient append key stays bound to what it created, and so does a giveaway or series create key. On the other giveaway and series writes (chat register and re-check, fund, cancel, close, auto-post, attestations, the series pause, resume and cancel) only a 2xx answer is remembered, for 7 days; after that the same key runs the request again. Within those 7 days a same-key retry of a write that timed out or answered 503 gets the first 2xx the write produced, as it was, normally instead of a second run of the write or a state refusal caused by the first attempt having landed. In the rare case that 2xx could not be recorded, the retry answers 409 idempotency_in_flight for up to 5 minutes and then runs the write again; if the first attempt stopped answering altogether, or its 2xx could not be stored by the API, that wait is up to 10 minutes. A refusal (any 4xx) and a 5xx are never kept: after one, the same key runs the request again against the state at that moment, so once you have fixed the cause you may send the corrected request with the same key.

An answer replayed from the API's stored copy of an earlier 2xx carries Idempotent-Replayed: true; a first answer recovered after the API answered 503 or timed out comes without it. Do not use the header to decide whether the write was applied; read the body.

Request body

currency'ton' | 'usdt_ton'

ton = GRAM; usdt_ton = USDT (TON) where USDT funding is offered. Chooses the asset of a NEW funding order. While an order is open, the same currency serves it again and the other currency is 409 funding_order_open_in_other_currency with currency set to the open order's currency.

Response

The open funding order, served again.

giveaway_idstring uuid required
status'awaiting_funding' required

Example response

{
  "payment": {
    "chain": "ton"
  }
}

Changes