What it does
Register a recurring subscription for one of your users. Plan details ride inline on the body — there is no plan catalog to pre-register; your backend is the source of truth for the amount and interval. Requires subscriptions_enabled on the mini app.
The subscription is created in incomplete — no money is taken here. The user activates it in-app by picking a saved card (the host handles that step); the first charge then moves it to active. Dedup key is provider_subscription_ref: send the same one twice and you get the first subscription back with replayed: true.
Body
user_idRequired
SG user id — the same id you get from
POST /s2s/v1/identity/verify.provider_subscription_refRequired
Your own subscription id, 1–128 printable-ASCII chars, no whitespace. Idempotency key, and the handle you address every later call with.
amountRequired
Recurring amount per cycle, as a number. The platform adds commission on top at billing time — this is the amount the user pays.
intervalRequired
Billing cadence unit —
day, week, month, or year.interval_count
Number of units per cycle (default
1). e.g. interval=month, interval_count=3 bills quarterly.currency
ISO-4217 3-letter code. Defaults to the mini app's currency.
plan_code, plan_name_en, plan_name_ar
Display + reconciliation metadata.
plan_name_* show on the in-app subscription card; plan_code (≤ 64) is filterable on the list endpoint.auto_renew
Whether the subscription renews at period end (default
true). false lets it run one cycle then move to expired.plan_metadata, metadata
Free-form JSON objects stored verbatim and echoed back. Use them for your own reconciliation keys.
Request schema
{
"user_id": <number>, // required
"provider_subscription_ref": <string, 1..128 printable ASCII>, // required — dedup key + handle
"amount": <number, ≥ 0>, // required — per-cycle amount
"interval": <string, enum>, // required — "day" | "week" | "month" | "year"
"interval_count": <number, ≥ 1>, // optional — default 1
"currency": <string, ISO 4217>, // optional — defaults to mini-app currency
"plan_code": <string, ≤64>, // optional
"plan_name_en": <string, ≤120>, // optional
"plan_name_ar": <string, ≤120>, // optional
"auto_renew": <boolean>, // optional — default true
"plan_metadata": <object> | null, // optional — free-form JSON
"metadata": <object> | null // optional — free-form JSON
}Response
replayedboolean
true when the same provider_subscription_ref was seen before — the original subscription is returned and no duplicate is created. Keeps your retries idempotent.data.subscription_uuidstring, UUID
SG's stable id. You never need to send it — address every later call by
provider_subscription_ref — but it matches the subscription_uuid on webhook payloads.data.statusstring
Starts at
incomplete. Moves to active once the user activates in-app and the first charge succeeds — you learn that from the subscription.activated webhook, not this response.data.payment_methodstring | null
null until the user binds a card at activation; then card (the only method subscriptions bill on).data.next_charge_atstring, ISO 8601 UTC | null
When the next automatic charge runs.
null while incomplete; set on activation.error_code (on 4xx)string
SUBSCRIPTIONS_NOT_ENABLED / MINI_APP_SUSPENDED (403), PROVIDER_REF_IN_USE (409), USER_NOT_FOUND / INVALID_AMOUNT / INVALID_INTERVAL / INVALID_INTERVAL_COUNT (422). Branch on this, not the message.Response schema
// 201 Created — new subscription (replayed = false), status "incomplete"
// 200 OK — same provider_subscription_ref re-sent (replayed = true)
{
"status": true,
"replayed": <boolean>,
"data": {
"subscription_uuid": "0193c7f0-2a1b-7de4-9c0a-6b5f1e2d3c44",
"provider_subscription_ref": "SUB-GOLD-9b3f12",
"user_id": 6093,
"status": "active", // incomplete | active | past_due | cancelled | expired
"plan_code": "gold_monthly",
"plan_name_en": "Gold — Monthly",
"plan_name_ar": "الذهبية — شهري",
"amount": "29.00",
"currency": "SAR",
"interval": "month", // day | week | month | year
"interval_count": 1,
"auto_renew": true,
"cancel_at_period_end": false,
"payment_method": "card", // null until the user activates
"current_period_start": "2026-11-09T12:00:00.000Z",
"current_period_end": "2026-12-09T12:00:00.000Z",
"next_charge_at": "2026-12-09T12:00:00.000Z",
"started_at": "2026-11-09T12:00:00.000Z",
"activated_at": "2026-11-09T12:00:30.000Z",
"cancelled_at": null,
"plan_metadata": { "tier": "gold" },
"metadata": { "crm_id": "C-4471" },
"created_at": "2026-11-09T11:59:40.000Z",
"updated_at": "2026-11-09T12:00:30.000Z"
},
"message": "Subscription created"
}
// 403 SUBSCRIPTIONS_NOT_ENABLED — not enabled for this mini app
// 403 MINI_APP_SUSPENDED — the mini app is suspended
// 409 PROVIDER_REF_IN_USE — ref already used (only when the dedup body differs)
// 422 USER_NOT_FOUND / INVALID_AMOUNT / INVALID_INTERVAL
{
"status": false,
"error_code": "SUBSCRIPTIONS_NOT_ENABLED",
"message": "subscriptions are not enabled for this mini-app"
}Try it
Base URL
https://microservices.shoppinggate.app/mini-app-core/