---
title: "Create a campaign"
method: POST
path: "/v1/campaigns"
tags: ["Campaigns"]
---

# Create a campaign

`POST /v1/campaigns`

## Request

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

Create an outreach campaign as a `draft`: one product (`stars`,
`premium` or `star_gift`) delivered to every recipient on a list of
Telegram usernames, paid with ONE on-chain transfer after you confirm.
Every submitted entry is stored in submission order and validated in the
background: read the verdicts with `GET /v1/campaigns/{id}/recipients`
or wait for the `campaign.validated` event. Malformed and duplicate
entries are kept as rejected rows (`invalid_format`, `duplicate`), so the
counts always add up.

**Availability.** Campaigns are enabled per tenant on request: a tenant
without access receives `403 forbidden` on create, append, validate,
confirm, resume and `GET /v1/capacity`. If access is withdrawn later, you
can still read your campaigns (list, get, recipients, stats) and pause or
cancel them, but nothing is sent: a paid campaign waits until access
returns, or you cancel it to have the undelivered value returned.
`star_gift` answers `422 product_not_available` where gift campaigns are
not offered, and `usdt_ton` answers `422 currency_not_available` where
USDT payments are not offered.

**Star gifts.** A `star_gift` create checks `gift_id` against the
catalog `GET /v1/gifts` lists: an unknown, sold-out or unsendable gift
answers `422 product_not_available` (a `gift_id` that is not a string of
1–20 digits is a `400`), and a catalog that cannot be read right now
answers `503 gift_catalog_unavailable` — retry later. Confirm checks the
gift again.

**Limits.** Up to 5,000 recipients per request (append more with
`POST /v1/campaigns/{id}/recipients`) and 10,000 per campaign. Live
(non-terminal) campaigns per tenant are capped — over the cap the create
answers `429 rate_limited`.

**Idempotency.** `Idempotency-Key` is required. The same key with the
same body returns the original campaign with `200`; the same key with a
different body is `409 idempotency_conflict`.

Campaign events go to your tenant webhook endpoint, never to a per-order
callback, so `callback_url` is refused with `400`.

## Headers

- `Idempotency-Key` string, required

## Request body

- CreateCampaignRequest
  - `product` 'stars' | 'premium' | 'star_gift', required: What every recipient receives: `stars` (`quantity` Stars), `premium` (`months` of Premium) or `star_gift` (one Telegram star gift, `gift_id`).
  - `quantity` integer: Stars per recipient. Required for `stars`; not allowed otherwise.
  - `months` 3 | 6 | 12: Premium months per recipient. Required for `premium`; not allowed otherwise.
  - `gift_id` string: The star gift to send (from `GET /v1/gifts`), as a string of 1–20 digits. Required for `star_gift`.
  - `comment` string, nullable: `star_gift` only: the text attached to each gift, trimmed (an empty comment means none), at most `comment_max_length` characters (`GET /v1/gifts`, counted in UTF-16 code units). Refused with `400`: control characters other than a line feed `\n` (including the carriage return `\r`, so send `\n` line breaks, not `\r\n`; DEL, the C1 range, line and paragraph separators, bidirectional marks, embeddings, overrides and isolates, the zero-width space, word joiner and byte-order mark); links — any URL, `t.me` or `tg://` link and any domain-like word in any script (`example.com`, `пример.рф`); and @mentions. Links and mentions are tested after folding fullwidth forms to ASCII and removing invisible formatting characters, so `＠name` or `example．com` is refused too. The control, link and mention rules are checked before the gift catalog is read, so a comment within the length limit that breaks one is a `400` even while the catalog is unavailable.
  - `hide_name` boolean: `star_gift` only: hide the sender's name on the gift.
  - `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`.
  - `recipients` string[], required: Telegram usernames (a leading `@` is optional). Malformed or repeated entries are stored as rejected rows. Each entry is stored trimmed, without its leading `@`, with ASCII letters lowercased, a NUL or unpaired surrogate replaced by U+FFFD, and cut to at most 64 UTF-16 code units. Entries are compared as stored, so two entries that become equal only once stored make the later one a `duplicate`. The same applies to appended recipients.

## Response `200`

Idempotent replay — the campaign the first request created.

- CreatedCampaign
  - `campaign_id` string, uuid, required
  - `status` 'draft' | 'awaiting_payment' | 'paid' | 'running' | 'paused' | 'cancelling' | 'settling' | 'awaiting_approval' | 'completed' | 'cancelled' | 'expired' | 'failed', required: `draft` (recipients can be added and are validated) → `awaiting_payment` (list and price locked by confirm) → `paid` → `running` ⇄ `paused` → `settling` → `completed`. Cancelling after payment goes through `cancelling` → `settling` → `cancelled`. `awaiting_approval` means the settlement owes a reversal that is waiting for review. `expired`: an unpaid campaign whose payment window ended, or a draft not confirmed within 7 days of its creation (`reason: draft_expired`). `failed`: the payment funded no recipient (fully reversed). Terminal: `completed`, `cancelled`, `expired`, `failed`.
  - `product` 'stars' | 'premium' | 'star_gift', required: What every recipient receives: `stars` (`quantity` Stars), `premium` (`months` of Premium) or `star_gift` (one Telegram star gift, `gift_id`).
  - `quantity` integer, nullable: Stars per recipient (`stars`).
  - `months` integer, nullable: Premium months per recipient (`premium`).
  - `gift` CampaignGift, nullable
    - `gift_id` string, required
    - `stars` string, nullable, required: The gift's price in Stars, as locked at confirm (an integer string). A gift is never bought above it: if Telegram asks more Stars (or no readable price) when sending, nothing is charged, the recipient is retried; after three not-charged send failures on the same recipient (a price refusal counts as one) it fails `internal_error` (its value is returned at settlement).
    - `limited` boolean, nullable, required
    - `comment` string, nullable, required
    - `hide_name` boolean, required
    - `comment_suppressed` boolean, required: True once Telegram refused the comment three times and the remaining gifts go without it.
  - `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`.
  - `recipient_count` integer, nullable: Deliverable recipients locked at confirm.
  - `unit_price` string, nullable: Price per recipient locked at confirm, decimal string in `payment_currency`.
  - `amount` string, nullable: The total to pay (`unit_price` × `recipient_count`).
  - `payment` CampaignPaymentInstruction, nullable, required: How to pay a confirmed campaign: send EXACTLY `amount_smallest_unit` of `asset` to `pay_to_address` with `memo` (the campaign id) as the comment (`native`) or the jetton forward-payload comment (`jetton`).
    - `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
    - `memo` string, required: The campaign id.
    - `amount` string, required: Decimal string in `asset`.
    - `amount_smallest_unit` string, required: Integer string — nano-GRAM or micro-USDT.
    - `asset` 'GRAM' | 'USDT', required
    - `decimals` 9 | 6, required
    - `transfer` 'native' | 'jetton', required
    - `jetton_master` string, nullable, required
  - `payment_tx` string, nullable
  - `received_amount` string, nullable
  - `max_deliverable` integer, nullable: Recipients the payment funds — all of them inside the −1% … +2% tolerance, otherwise `floor(received / unit_price)`.
  - `failure_reason` string, nullable: `underpaid` (the payment funded no recipient), `expired` (unpaid in time) or `draft_expired` (never confirmed).
  - `pause_reason` 'tenant' | 'cost_guard' | 'null', nullable
  - `reversal_due` string, nullable: The value owed back at settlement (received − delivered × unit_price), before the reversal fee.
  - `reversal_amount` string, nullable: What the reversal actually sent (due minus the reversal fee — currently 0.01 GRAM, or the USDT value of 0.15 GRAM); `null` until recorded.
  - `reversal_skip_reason` 'dust' | 'null', nullable: `dust` — the amount owed was below the dust threshold (0.1 GRAM or 0.5 USDT) or the fee would consume it, so nothing was sent.
  - `reversal_tx` string, nullable: The transaction hash of the reversal that returned what the campaign owed you; `null` while none has gone out, or when it was confirmed without a reference we can show (contact support). Never a placeholder (since 2.1.3).
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required
  - `confirmed_at` string, date-time, nullable
  - `expires_at` string, date-time, nullable: The payment deadline, only while `awaiting_payment`.
  - `paid_at` string, date-time, nullable
  - `finished_at` string, date-time, nullable
  - `batch` CampaignRecipientBatch, required: What one create or append request did: `submitted` = `accepted` (new rows to validate) + `rejected` (malformed or duplicate).
    - `submitted` integer, required
    - `accepted` integer, required
    - `rejected` integer, required

## Other responses

- `201`: Campaign created as a draft; validation has started.
- `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`: The request conflicts with the resource's state or with an earlier request: `idempotency_conflict`, `idempotency_in_flight` (with `Retry-After`), `conflict` (also an order `Idempotency-Key` reused with a different body, or an order cancel in a status other than `awaiting_payment`), or a giveaway refusal with its own code (`funding_received`, `use_close`, `limit_reached`, `attestations_frozen`, `attestation_limit_reached` with `limit`, `funding_order_open_in_other_currency` with `currency`, …).
- `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`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/mystars/apis/mystars-faas-fulfilment-api/changes/v1/campaigns/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)
