Orders

Pre-flight the recipient, quote the price, and create an order in awaiting_payment. The response payment block tells you exactly how much to send, to which address, and with which memo (the order id). An ineligible recipient returns 422 recipient_ineligible and creates no order (you are never charged for an undeliverable recipient). The check also opens the order at Fragment (since 2.3.0): it checks the order's own quantity or months and payment_currency, so an order Fragment refuses only at that point (for example "You can buy a minimum of 12,500 stars") is also 422 recipient_ineligible with Fragment's text in telegram_message, before any order exists. If eligibility cannot be verified right now (a transient upstream blip), the call returns a retryable 503 and creates no order — retry shortly with the same Idempotency-Key. Where USDT payments are not offered, usdt_ton returns 422 currency_not_available and creates no order; so does an idempotent replay of a usdt_ton order once USDT payments are no longer offered.

A retry with the same Idempotency-Key and body answers 200 with the existing order without running the daily caps or the recipient check again; its payment is null once that order is no longer awaiting_payment. Any create can answer 429 from the order-lifecycle bucket; a new order can also meet the daily intake cap (every order accepted today, cancelled and expired ones included), the daily order cap (today's orders, cancelled and expired ones excluded) or the guard on unfinished orders to one recipient. A 429 creates no order.

Daily budget of ineligible-recipient refusals. Each tenant may collect a limited number of 422 recipient_ineligible refusals per UTC day (by default 200). Once today's budget is used up, a new create answers 429 rate_limited before the recipient is checked, until 00:00 UTC: the message reads today's budget of ineligible-recipient refusals is used up; new orders are accepted again after 00:00 UTC, and the answer carries Retry-After and error.retry_after, both the seconds left until 00:00 UTC. Do not retry before then. It shares the rate_limited code with the other 429s: tell it apart by error.retry_after (absent on the others), never by the message. Like the caps, it carries the RateLimit-* headers of the order bucket the request passed, often with RateLimit-Remaining above zero. Only a 422 recipient_ineligible from this route counts; an eligible recipient, a 503 and any other refusal do not, and neither does POST /v1/recipients/check — check doubtful handles there first. A create whose recipient check is still running holds a place in the budget until that check answers. While every place left is held by your own checks still running, a create answers a short 429 rate_limited instead: a Retry-After of a few seconds and no error.retry_after, with the message too many of your order checks are still in flight against the daily budget of ineligible-recipient refusals; retry in a few seconds. Retry it after Retry-After, with the same Idempotency-Key if you like (a 429 creates no order). A retry with the key of an order that already exists still answers 200.

post/v1/orders

Request

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

Headers

Idempotency-Keystring required

A unique key for this create attempt, at most 255 characters (surrounding spaces are trimmed), scoped to your tenant. Derive it from your own order id. Retrying with the same key and an identical body returns the original order with 200; the same key with a different body is 409 conflict. The key stays bound to its order for as long as the order exists: reusing it later never creates a second order. A missing, empty or longer key is 400 bad_request, and so is a key starting with campaign: (any case): that prefix is reserved for the orders a campaign creates.

Request body

type'stars' | 'premium' required
quantityinteger

Number of Stars. Required when type=stars. Must be in [50, 1000000].

months3 | 6 | 12

Premium subscription length in months. Required when type=premium. Must be 3, 6, or 12.

payment_currency'ton' | 'usdt_ton' required

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.

callback_urlstring uri

Optional HTTPS URL for the signed order-status webhook. Must be a publicly reachable https:// URL — loopback addresses, private-network and other special-purpose hosts, and non-HTTPS schemes are rejected with 400 bad_request. A hostname that resolves to such an address is refused again when the callback is sent, and that callback is not delivered.

Example request

{
  "recipient": {
    "username": "durov"
  }
}

Response

Idempotent replay — the same key + body returns the original order.

order_idstring uuid required
status'received' | 'awaiting_payment' | 'paid' | 'reserved' | 'swapping' | 'funding' | 'purchasing' | 'fulfilling' | 'completed' | 'delivered' | 'failed' | 'reversed' | 'expired' | 'held' | 'cancelled' required

Lifecycle status. A new order starts in awaiting_payment. The normal path is awaiting_payment → paid → reserved → funding → purchasing → delivered.

Terminal (nothing moves the order on; stop polling). The callback named on each goes to the order's callback_url, when you set one:

  • delivered — the item was delivered to the recipient. Callback order.delivered.
  • completed — the same as delivered, on older orders. No callback.
  • reversed — the item could not be delivered and your payment was reversed to you (failure_reason: undeliverable). Callback order.reversed.
  • failed — the payment named this order but could not be applied: an amount outside the tolerance, or the other asset; it is reversed to the sender. Only an awaiting_payment order can end here. Callback order.failed.
  • expired — no payment arrived before expires_at. Callback order.expired.
  • cancelled — you cancelled it with POST /v1/orders/{id}/cancel while it was awaiting_payment. No callback: the cancel answer is the confirmation.

In progress (no action needed; keep polling or wait for the callback):

  • awaiting_payment — waiting for your payment, until expires_at. The only cancellable status.
  • paid — the payment was matched; delivery is about to start.
  • reserved, funding, purchasing — delivery steps. An order may step back to paid or an earlier step and run again; that is a retry, not a failure.
  • held — delivery or a reversal is being retried, or is under manual review; failure_reason says which. Do not re-create the order. It ends delivered or reversed.
  • received, swapping, fulfilling — kept for older orders; no new order enters them.

Branch on the terminal set above, and treat any status you do not recognise as in progress.

type'stars' | 'premium' required

The product this order is for — echoed back from your request.

quantityinteger nullable required

The number of Stars ordered (when type=stars); null for Premium.

monthsinteger nullable required

The Premium subscription length in months ordered (when type=premium); null for Stars.

expires_atstring date-time nullable required

After this, an unpaid order expires. Set while the order is awaiting_payment; null on a 200 replay of an order that has moved on.

Example response

{
  "quantity": 500,
  "payment": {
    "chain": "ton",
    "amount": "5.757",
    "amount_smallest_unit": "5757000000",
    "fee": {
      "subtotal": "13.18",
      "processing_fee": "0.92",
      "total": "14.1",
      "description": "1% swap + 0.5 GRAM gas",
      "kind": "swap"
    }
  }
}

Changes

    • breaking

      the response property expires_at became nullable for the status

    • breaking

      the response property expires_at became nullable for the status

    • breaking

      added subschema #2 to the payment response property oneOf list for the response status

    283 more changes in this revision