---
title: "Create an order"
method: POST
path: "/v1/orders"
tags: ["Orders"]
---

# Create an order

`POST /v1/orders`

## Request

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

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 `429`s: 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`.

## Headers

- `Idempotency-Key` string, required

## Request body

- CreateOrderRequest
  - `type` 'stars' | 'premium', required
  - `recipient` Recipient, required
    - `username` string, required: Telegram @username (the leading `@` is optional, case-insensitive). After canonicalisation (strip `@`, lowercase) must match `[a-z0-9_]{1,32}` — invalid or oversized handles return 400.
  - `quantity` integer: Number of Stars. Required when `type=stars`. Must be in [50, 1000000].
  - `months` 3 | 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_url` string, 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.

## Response `200`

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

- CreatedOrder
  - `order_id` string, 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.
  - `quantity` integer, nullable, required: The number of Stars ordered (when `type=stars`); `null` for Premium.
  - `months` integer, nullable, required: The Premium subscription length in months ordered (when `type=premium`); `null` for Stars.
  - `payment` PaymentInstruction, nullable, required: How to pay for the order. Send EXACTLY `amount` of `asset` with `memo`, as a `transfer` of that kind. A payment in the other asset is not applied to the order: it is reversed to the sender in the asset received. The order is normally marked `failed` with `wrong_currency` once the payment has been returned. If that step cannot complete, the order expires and the payment is still returned.
    - `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`.
    - `chain` string, required
    - `pay_to_address` string, required: The treasury wallet to pay. The SAME address is returned for both `ton` and `usdt_ton` — a USDT jetton transfer routes by owner, so its destination is this (owner) address, not a derived jetton-wallet address.
    - `memo` string, required: The required transfer memo (equals the order id).
    - `amount` string, required: Exact amount to send, as a decimal string.
    - `amount_units` 'ton' | 'usdt', required: Legacy unit label of `amount` (`ton` means GRAM). Frozen for wire compatibility — read `asset` instead.
    - `amount_smallest_unit` string, required: The same amount as an integer string in the smallest unit of `asset` (`amount` × 10^`decimals`) — nano-GRAM for GRAM, micro-USDT for USDT. Build the on-chain transfer from this, never from a re-scaled `amount`.
    - `asset` 'GRAM' | 'USDT', required: The asset to send: `GRAM` on a `ton` order, `USDT` on a `usdt_ton` order.
    - `decimals` 9 | 6, required: Decimal places of `asset` — 9 for GRAM, 6 for USDT.
    - `transfer` 'native' | 'jetton', required: How to send it. `native` — a plain GRAM transfer to `pay_to_address` with `memo` as the comment. `jetton` — a TEP-74 transfer of the `jetton_master` jetton whose destination is `pay_to_address`, with `memo` as the forward-payload comment.
    - `jetton_master` string, nullable, required: The USDT jetton master address for a `jetton` transfer — send only this jetton. `null` for a `native` transfer.
    - `fee` FeeBreakdown, nullable, required: Itemisation of the `usdt_ton` processing fee that is ALREADY part of the all-in amount. `subtotal + processing_fee == total == amount`. Pass-through network cost only — it does not reveal our cost basis or markup. It takes one of two forms, named by `kind`: a swap-backed fee (the 1% DEX swap fee plus GRAM swap gas) or, for an order settled without a swap, network gas alone. Only `total` (= `amount`) is binding — the `subtotal`/`processing_fee` split is informational and may shift by a cent with the live FX rate.
      - `subtotal` string, required: The item price before the processing fee, as a decimal string (USDT).
      - `processing_fee` string, required: The pass-through network cost, rounded up to the cent, as a decimal string (USDT) — the 1% DEX swap fee plus GRAM swap gas for a swap-backed order, or network gas alone for an order settled without a swap.
      - `total` string, required: subtotal + processing_fee — equals `amount`. Decimal string (USDT).
      - `description` string, required: Human-readable label for the fee components — for example "1% swap + 0.5 GRAM gas" for a swap-backed fee, or "TON network gas" for a fee that is network gas alone. A label for display; do not parse it — branch on `kind`.
      - `kind` 'swap' | 'network', required: Machine-readable fee form. `swap` — a swap-backed fee (the 1% DEX swap fee plus GRAM swap gas); `network` — network gas alone, for an order settled without a swap. Use it to choose your own wording for the fee.
      - `currency` 'usdt', required: The unit of the fee amounts (always `usdt`).
  - `expires_at` string, 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.

## Other responses

- `201`: Order created (or replayed on an idempotent retry → 200).
- `400`: Malformed request (`bad_request`): a missing or invalid field, header or query parameter (the `message` names it), a malformed `cursor`, a body that is not valid JSON, or a body nested deeper than 64 levels. Send integer query parameters as plain decimal digits: the pricing, order, giveaway and series routes refuse any other spelling (a sign, decimal point, exponent, hex prefix or surrounding spaces) with a `400` naming the parameter. Fix the request; retrying it unchanged gets the same answer.
- `401`: Missing or invalid `X-Api-Key`.
- `403`: The API key is valid, but the tenant is suspended (for example after `/api_revoke` — run `/api_rotate` in the bot to restore access) or banned, or the product (campaigns, giveaways) is not enabled for it. Products are enabled per tenant on request. A source address blocked at our edge gets `403 forbidden` with the message `source blocked`, whatever the key.
- `409`: Idempotency-Key reused with a different body (`conflict`).
- `413`: The request body is larger than 256 KB (`bad_request`, `request body too large`).
- `415`: A request body was sent with a `Content-Type` other than `application/json` (a missing one included), or with an unsupported charset or `Content-Encoding` (`bad_request`). A POST without a body needs no `Content-Type`.
- `422`: The request is well-formed but cannot be served: `recipient_ineligible` (order create: the recipient cannot receive the item, and no order is created), `product_not_available`, `currency_not_available` (the currency is not offered on this service; nothing is created), `channel_checks_failed` (with `checks`), `schedule_out_of_bounds` (with `bound` and `limit`) or `unprocessable`.
- `429`: A rate limit was reached (`rate_limited`). See **Rate limits** in the overview. Which `429`s carry headers: - **Per-minute buckets** — the general request budget, the order-lifecycle bucket, the pricing/recipient-check probe cap (60 req/min), the campaign bucket, and your giveaway read, write, quote and attestation buckets. Every answer metered by one carries `RateLimit-Policy`, `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` (seconds); a `429` adds `Retry-After` (seconds). - **Caps, no `Retry-After`** — the daily intake cap and the daily order cap on `POST /v1/orders` (UTC day), the per-recipient guard on unfinished orders to one `@username`, and the cap on live campaigns. These `429`s carry no `Retry-After`, but they do carry the `RateLimit-*` headers of the per-minute bucket the request passed (often with `RateLimit-Remaining` above zero): branch on `Retry-After`, never on `RateLimit-Remaining`. Back off; the daily intake and order caps clear at the next UTC midnight. - **The daily budget of ineligible-recipient refusals** on `POST /v1/orders` — its `429` carries `Retry-After` and `error.retry_after`, both the seconds until 00:00 UTC, when the budget resets, plus the `RateLimit-*` headers of the order bucket it passed. `error.retry_after` is what sets it apart from the other `429`s. While the budget's places are held only by your own checks still running, the create answers a short `429` instead: `Retry-After` of a few seconds and no `error.retry_after` — retry after `Retry-After`. - **The giveaway quote budget shared by all tenants** — its `429` carries `Retry-After` (seconds until the shared budget reopens) and the `RateLimit-*` headers of your own quote bucket, never figures for the shared budget. - **Edge throttle** — a coarse per-IP throttle in front of the API answers the same envelope with `Retry-After: 1` and no `RateLimit-*` headers.
- `503`: A required source was temporarily unavailable (`unavailable`): the price source, recipient eligibility that could not be verified right now, the payment check a cancel runs first, or (order create, rarely) no fulfilment capacity assigned to your tenant right now. The `message` is generic (`internal error`), so it does not say which: treat every `unavailable` as **retryable** — reuse the same `Idempotency-Key` and try again shortly. An app `503 unavailable` creates and cancels nothing and charges nothing. If `503 unavailable` on order create persists, contact support with the `X-Request-ID`. The edge's own `502`, `503` and `504` (the service restarting or timing out) answer the same envelope with `unavailable`, and may follow a request that did land: retry with the same `Idempotency-Key`, and an order create that landed is replayed, never duplicated. On the campaign, gift and giveaway routes a `503` may also be a gift catalog that cannot be read right now (`gift_catalog_unavailable` — retry later) or an option that is not enabled for your tenant yet (`prize_type_unavailable`, `partner_conditions_unavailable`, `antibot_enforce_unavailable`, `autopost_unavailable`, `series_unavailable` — do not retry, ask support); the `code` says which.

## Changes

- **2026-10-31** `9f589c4dd26b`: 30 breaking, 187 warning, 69 info
  - the response property `expires_at` became nullable for the status `200`
  - the response property `expires_at` became nullable for the status `201`
  - added `#/components/schemas/PaymentInstruction, subschema #2` to the `payment` response property `oneOf` list for the response status `200`
  - added `#/components/schemas/PaymentInstruction, subschema #2` to the `payment` response property `oneOf` list for the response status `201`
  - …282 more
- **2026-09-28** `6ebdc05ab41d`: 1 breaking, 15 info
  - the request property `payment_currency` became required
  - the `payment_currency` request property default value `ton` was removed
  - the `currency` response's property default value `ton` was removed for the status `200`
  - the `currency` response's property default value `ton` was removed for the status `201`
  - …12 more

[Operation history](https://skmtc.dev/mystars/apis/mystars-faas-fulfilment-api/changes/v1/orders/post.md)

---

[API](https://skmtc.dev/mystars/apis/mystars-faas-fulfilment-api.md) - [All operations](https://skmtc.dev/mystars/apis/mystars-faas-fulfilment-api/llms.txt) - [OpenAPI document](https://skmtc.dev/mystars/apis/mystars-faas-fulfilment-api/revisions/b6cdc8aff8c2?raw)
