Giveaway series

Create a recurring series

Changed on

Schedule a giveaway that repeats every every × interval from starts_at (UTC), for count occurrences or until a date — exactly one of the two. template is exactly the body of POST /v1/giveaways (conditions and anti-bot policy included) and is checked like a create, live chat checks included, before the series is accepted: a refusal names its field under template. (for example template.title — at most 80 characters once whitespace runs are collapsed — template.gift.comment, template.gift.gift_id or template.winner_count, with details.code when it has one), and answers with the create's statuses (404 for an unknown condition chat, 422 channel_checks_failed with checks, 503 when Telegram could not be asked). Each slot spawns an ordinary giveaway (series.occurrence_created), opens its funding order at once (giveaway.awaiting_funding) and is paid on its own through its one-time deposit address; attest partner conditions against each occurrence's own giveaway id.

Bounds. At most 52 occurrences, the last no more than one year after starts_at: past either bound the answer is 422 schedule_out_of_bounds with field, bound (max_occurrences or max_span) and limit. starts_at may not be in the past (one minute of grace) and must fall within the coming year, and every is at most 365 for day, 52 for week and 12 for month (each 400). Occurrences never overlap: template.duration_sec plus the funding window (7,200 s) plus the spawn grace (900 s) must be shorter than every × interval, a month counted as 28 days (400 on template.duration_sec) — for a daily series, duration_sec is at most 78,299.

Missed slots. A slot not spawned within 15 minutes of its time is skipped, never made up. An unfunded occurrence counts as a miss: on_unfunded: pause pauses after the first miss, skip after three in a row. Series per tenant are capped (409 limit_reached).

Idempotency-Key is required and behaves like a giveaway create. Recurring series are enabled on request (503 series_unavailable until then — not retryable).

post/v1/giveaways/series

Request

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

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

interval'day' | 'week' | 'month' required
everyinteger

Slots are every intervals apart — at most 365 for day, 52 for week and 12 for month (400 above).

starts_atstring date-time required

The first slot (UTC). A month step keeps the day, clamped to the month's end.

countinteger

The number of occurrences. More than 52, or a last slot more than a year after starts_at, is 422 schedule_out_of_bounds (with bound and limit), not a 400.

untilstring date-time

The last slot is the last one at or before this time. until must be after starts_at (400). An until more than a year after starts_at, or one that would make more than 52 slots, is 422 schedule_out_of_bounds (with bound and limit).

currency'ton' | 'usdt_ton'

The asset every occurrence's funding order is opened in: ton = GRAM, usdt_ton = USDT (TON) — 422 currency_not_available while USDT funding is not offered.

on_unfunded'skip' | 'pause'

Response

Idempotent replay — the series this key created.

idstring uuid required
status'active' | 'paused' | 'cancelled' | 'completed' required

active ⇄ paused — paused by you (paused_reason: requested) or automatically (spawn_failures, lost_admin, unfunded), active again only by a resume. From either: cancelled (by you) or completed (the last slot passed, also when a resume finds no slot left). Pause applies to active, resume to paused, cancel to both; asking for the status a series already has returns it unchanged, anything else is 409 invalid_state with status. Terminal: cancelled, completed.

paused_reason'requested' | 'spawn_failures' | 'lost_admin' | 'unfunded' | 'null' nullable
interval'day' | 'week' | 'month' required
everyinteger required
starts_atstring date-time required
countinteger nullable
untilstring date-time nullable
last_indexinteger

The slot the series ends with.

on_unfunded'skip' | 'pause'
currency'ton' | 'usdt_ton'

The asset the order is paid in. ton = the native coin GRAM (ex TON), sent as a plain transfer — it is not USDT on TON. usdt_ton = USDT (TON), sent as a jetton transfer. Required on every create and pricing request: a request without it is rejected with 400 bad_request.

next_indexinteger nullable
next_occurrence_atstring date-time nullable
occurrences_createdinteger
consecutive_failuresinteger
consecutive_missesinteger
created_atstring date-time required
updated_atstring date-time nullable
paused_atstring date-time nullable
ended_atstring date-time nullable

Changes