TgPay Crypto Subscriptions API
Recurring billing — plans and subscriptions.
Recurring billing — plans and subscriptions.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/tgpaycrypto-com:tgpaycrypto-com-subscriptions-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: TgPay Crypto Merchant Subscriptions API
version: '2026-11-16'
summary: Merchant payments API of the TgPay Crypto wallet (@tgpaycryptobot).
description: 'The Merchant API of TgPay Crypto (@tgpaycryptobot): create
invoices, refund them, send payouts and checks, withdraw the app
balance on-chain, exchange it between assets, issue withdrawal links,
manage recurring subscriptions, and receive signed webhooks. Human-readable documentation: https://docs.tgpaycrypto.com/crypto-pay-api-reference/
## Conventions
- **Authentication** — send your token in `TgPayCrypto-API-Token`. `TgCryptoPay-API-Token` and `Crypto-Pay-API-Token` are accepted aliases,
in that order. The first non-empty header wins. Full-access primary
tokens have every scope except `withdraw`; restricted tokens need the
operation''s scope, and only a restricted token can hold `withdraw`. - **Envelope** — application success is HTTP 200 with `{ok: true, result}`;
application errors are `{ok: false, error: {code, name}}`, with `code`
equal to the HTTP status. Branch on `error.name`. Transport/framework
rejections, such as malformed typed query parameters, may lack this envelope. - **Amounts** — requests use decimal strings in whole-coin or fiat units,
never JSON numbers. Crypto input is rounded to the asset''s minor unit,
with midpoint rounding away from zero; the result must be positive. Fiat input must represent a positive exact number of cents, at most
10^13 whole fiat units. Responses use fixed-point strings; balance and
fee amounts can be zero. `*_minor` values are integer strings. `getCurrencies` supplies asset decimals. Send exact asset precision. - **POST parameters** — JSON object, form-urlencoded body, or URL query
parameters; body values override query values, including null. Repeated
form/query keys use the last value. Multipart is rejected. Money-moving
methods have no GET aliases. Nested `items` and `recipients` must be
JSON arrays in a JSON body; JSON-encoded strings do not work for them. Required fields must be present after merging query and body. Optional null values generally behave as omitted; per-field rules apply. Integers accept integer strings; booleans also accept 1/0 and the strings
true/false, 1/0, yes/no, on/off (case-insensitive, surrounding whitespace ignored). Text limits are measured in UTF-16 code units by the server. - **Idempotency** — `spend_id` is required for transfers, batch items,
withdraw and exchange, optional for checks and refunds. Empty/null
optional keys disable replay. Keys are scoped per app and operation;
transfer, transferBatch and withdraw share a namespace, exchange has its
own. After validation and access gates, the same parsed request
replays its stored success. Different input returns `409 idempotency_conflict`;
an unfinished claim returns `409 idempotency_in_progress`. Amount strings
and recipient spelling are not normalized for the request hash: keep them
identical on retries. Replays are snapshots, not refreshed objects; use
list methods to obtain current status. createInvoice and plan creation
have no spend_id idempotency; createInvoice''s retry key is
`client_invoice_id`. - **Per-operation webhook and payload** — createInvoice, createCheck,
transfer, each transferBatch item and withdraw accept `webhook_url`
(a public HTTPS URL, up to 256 characters): every update of that
operation goes there instead of the app''s URL, regardless of the app''s
event selection. It is not returned in objects. createCheck, transfer,
transferBatch items and withdraw also accept `payload` (up to 4096
characters), echoed in the object and its webhooks. - **Pagination** — invoices, checks, transfers, withdrawals, exchanges and
withdrawal links default to offset 0, count 100; the server clamps
offset to at least 0 and count to 1..1000. Subscriptions clamp count to 1..500. These lists return `{items: [...]}`,
newest first. getSubscriptionPlans returns all plans without pagination. - **Timestamps** — ISO-8601 strings; nullable timestamps are explicitly null.'
servers:
- url: https://app.tgpaycrypto.com/pay/api
description: Production
- url: https://testnet.tgpaycrypto.com/pay/api
description: Testnet — coins with no value, its own bot @tgpaycrypto_testnet_bot and its own apps and tokens
security:
- apiToken: []
- apiTokenLegacy: []
- apiTokenCompat: []
tags:
- name: Subscriptions
description: Recurring billing — plans and subscriptions.
paths:
/createSubscriptionPlan:
post:
tags:
- Subscriptions
operationId: createSubscriptionPlan
summary: Create a subscription plan
description: 'Scope: `subscriptions`. Rate limit: 20/min per app.
The plan is an **immutable snapshot** — the mandate a user approves
is exactly this amount per this period; to change the price, create
a new plan and archive the old one. Users approve via the plan''s
`mini_app_subscribe_url`; the first period is charged at approval.
Renewals bill automatically; a failed renewal puts the subscription
into `grace` with retries inside the platform grace window, then
`expired`.
Specific errors: `503 subs_disabled` (feature currently unavailable
platform-side); `400 unknown_asset`; `400 invalid_amount`;
`409 invalid_period` (below the platform minimum),
`409 too_many_plans` (active plan limit reached; archive one first).
Values outside 1..365 return `400 invalid_request` before service validation.
Creation has no spend_id replay protection.'
requestBody:
required: false
content:
application/json:
schema:
$ref: '#/components/schemas/CreatePlanRequest'
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/CreatePlanRequest'
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
required:
- ok
- result
properties:
ok:
const: true
result:
$ref: '#/components/schemas/Plan'
default:
$ref: '#/components/responses/Error'
parameters:
- name: name
in: query
required: false
description: Alternative to this field in the body; body wins. Required-field rules apply after merging.
schema:
$ref: '#/components/schemas/CreatePlanRequest/properties/name'
- name: asset
in: query
required: false
description: Alternative to this field in the body; body wins. Required-field rules apply after merging.
schema:
$ref: '#/components/schemas/CreatePlanRequest/properties/asset'
- name: amount
in: query
required: false
description: Alternative to this field in the body; body wins. Required-field rules apply after merging.
schema:
$ref: '#/components/schemas/CreatePlanRequest/properties/amount'
- name: period_days
in: query
required: false
description: Alternative to this field in the body; body wins. Required-field rules apply after merging.
schema:
$ref: '#/components/schemas/CreatePlanRequest/properties/period_days'
/getSubscriptionPlans:
get:
tags:
- Subscriptions
operationId: getSubscriptionPlans
summary: List subscription plans
description: 'Scope: `read`. Newest first. Each plan carries
`active_subscribers` — the count of live (`active` + `grace`)
subscriptions.
Returns all plans, including archived plans; there are no pagination inputs.'
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
required:
- ok
- result
properties:
ok:
const: true
result:
type: object
required:
- items
properties:
items:
type: array
items:
$ref: '#/components/schemas/PlanWithStats'
default:
$ref: '#/components/responses/Error'
/archiveSubscriptionPlan:
post:
tags:
- Subscriptions
operationId: archiveSubscriptionPlan
summary: Archive a plan
description: 'Scope: `subscriptions`.
Stops **new** approvals; live subscriptions keep renewing on their
own snapshot (end them per-row via `cancelSubscription`). Archiving
is irreversible via the API.
Specific errors: `404 plan_not_found`.'
requestBody:
required: false
content:
application/json:
schema:
type: object
required:
- plan_id
properties:
plan_id:
oneOf:
- type: integer
maximum: 9223372036854775807
minimum: 1
- type: string
pattern: ^\s*\+?0*(?:[1-9][0-9]{0,17}|[1-8][0-9]{18}|9[0-1][0-9]{17}|92[0-1][0-9]{16}|922[0-2][0-9]{15}|9223[0-2][0-9]{14}|92233[0-6][0-9]{13}|922337[0-1][0-9]{12}|92233720[0-2][0-9]{10}|922337203[0-5][0-9]{9}|9223372036[0-7][0-9]{8}|92233720368[0-4][0-9]{7}|922337203685[0-3][0-9]{6}|9223372036854[0-6][0-9]{5}|92233720368547[0-6][0-9]{4}|922337203685477[0-4][0-9]{3}|9223372036854775[0-7][0-9]{2}|922337203685477580[0-6]|9223372036854775807)\s*$
description: Integer or integer string; parsed value must be within 1..9223372036854775807.
application/x-www-form-urlencoded:
schema:
type: object
required:
- plan_id
properties:
plan_id:
oneOf:
- type: integer
maximum: 9223372036854775807
minimum: 1
- type: string
pattern: ^\s*\+?0*(?:[1-9][0-9]{0,17}|[1-8][0-9]{18}|9[0-1][0-9]{17}|92[0-1][0-9]{16}|922[0-2][0-9]{15}|9223[0-2][0-9]{14}|92233[0-6][0-9]{13}|922337[0-1][0-9]{12}|92233720[0-2][0-9]{10}|922337203[0-5][0-9]{9}|9223372036[0-7][0-9]{8}|92233720368[0-4][0-9]{7}|922337203685[0-3][0-9]{6}|9223372036854[0-6][0-9]{5}|92233720368547[0-6][0-9]{4}|922337203685477[0-4][0-9]{3}|9223372036854775[0-7][0-9]{2}|922337203685477580[0-6]|9223372036854775807)\s*$
description: Integer or integer string; parsed value must be within 1..9223372036854775807.
responses:
'200':
description: 'OK — the updated plan (`archived: true`).'
content:
application/json:
schema:
type: object
required:
- ok
- result
properties:
ok:
const: true
result:
$ref: '#/components/schemas/Plan'
default:
$ref: '#/components/responses/Error'
parameters:
- name: plan_id
in: query
required: false
description: Alternative to this field in the body; body wins. Required-field rules apply after merging.
schema:
oneOf:
- type: integer
maximum: 9223372036854775807
minimum: 1
- type: string
pattern: ^\s*\+?0*(?:[1-9][0-9]{0,17}|[1-8][0-9]{18}|9[0-1][0-9]{17}|92[0-1][0-9]{16}|922[0-2][0-9]{15}|9223[0-2][0-9]{14}|92233[0-6][0-9]{13}|922337[0-1][0-9]{12}|92233720[0-2][0-9]{10}|922337203[0-5][0-9]{9}|9223372036[0-7][0-9]{8}|92233720368[0-4][0-9]{7}|922337203685[0-3][0-9]{6}|9223372036854[0-6][0-9]{5}|92233720368547[0-6][0-9]{4}|922337203685477[0-4][0-9]{3}|9223372036854775[0-7][0-9]{2}|922337203685477580[0-6]|9223372036854775807)\s*$
description: Integer or integer string; parsed value must be within 1..9223372036854775807.
/getSubscriptions:
get:
tags:
- Subscriptions
operationId: getSubscriptions
summary: List subscriptions
description: 'Scope: `read`. Newest first. Merchants read `current_period_end` as
the access deadline.'
parameters:
- name: plan_id
in: query
schema:
type: integer
description: Filter by plan.
- name: user_id
in: query
schema:
type: integer
description: Filter by the subscriber's Telegram ID.
- name: status
in: query
schema:
type: string
enum:
- active
- grace
- cancelled
- expired
- name: offset
in: query
schema:
type: integer
default: 0
- name: count
in: query
schema:
type: integer
default: 100
minimum: 1
maximum: 500
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
required:
- ok
- result
properties:
ok:
const: true
result:
type: object
required:
- items
properties:
items:
type: array
items:
$ref: '#/components/schemas/Subscription'
default:
$ref: '#/components/responses/Error'
/cancelSubscription:
post:
tags:
- Subscriptions
operationId: cancelSubscription
summary: Cancel a subscription
description: 'Scope: `subscriptions`.
Stops renewals (`cancelled_by: "merchant"`). Access continues
until `current_period_end`; the status flips to
`cancelled` immediately. The subscriber is notified; the opt-in
`subscription_cancelled` webhook fires. After cancellation, the subscriber may
re-approve later via the plan link.
Specific errors: `404 sub_not_found` (unknown id / another app''s
subscription); `409 sub_not_active` (already cancelled or expired).'
requestBody:
required: false
content:
application/json:
schema:
type: object
required:
- subscription_id
properties:
subscription_id:
oneOf:
- type: integer
maximum: 9223372036854775807
minimum: 1
- type: string
pattern: ^\s*\+?0*(?:[1-9][0-9]{0,17}|[1-8][0-9]{18}|9[0-1][0-9]{17}|92[0-1][0-9]{16}|922[0-2][0-9]{15}|9223[0-2][0-9]{14}|92233[0-6][0-9]{13}|922337[0-1][0-9]{12}|92233720[0-2][0-9]{10}|922337203[0-5][0-9]{9}|9223372036[0-7][0-9]{8}|92233720368[0-4][0-9]{7}|922337203685[0-3][0-9]{6}|9223372036854[0-6][0-9]{5}|92233720368547[0-6][0-9]{4}|922337203685477[0-4][0-9]{3}|9223372036854775[0-7][0-9]{2}|922337203685477580[0-6]|9223372036854775807)\s*$
description: Integer or integer string; parsed value must be within 1..9223372036854775807.
application/x-www-form-urlencoded:
schema:
type: object
required:
- subscription_id
properties:
subscription_id:
oneOf:
- type: integer
maximum: 9223372036854775807
minimum: 1
- type: string
pattern: ^\s*\+?0*(?:[1-9][0-9]{0,17}|[1-8][0-9]{18}|9[0-1][0-9]{17}|92[0-1][0-9]{16}|922[0-2][0-9]{15}|9223[0-2][0-9]{14}|92233[0-6][0-9]{13}|922337[0-1][0-9]{12}|92233720[0-2][0-9]{10}|922337203[0-5][0-9]{9}|9223372036[0-7][0-9]{8}|92233720368[0-4][0-9]{7}|922337203685[0-3][0-9]{6}|9223372036854[0-6][0-9]{5}|92233720368547[0-6][0-9]{4}|922337203685477[0-4][0-9]{3}|9223372036854775[0-7][0-9]{2}|922337203685477580[0-6]|9223372036854775807)\s*$
description: Integer or integer string; parsed value must be within 1..9223372036854775807.
responses:
'200':
description: OK — the updated subscription.
content:
application/json:
schema:
type: object
required:
- ok
- result
properties:
ok:
const: true
result:
$ref: '#/components/schemas/Subscription'
default:
$ref: '#/components/responses/Error'
parameters:
- name: subscription_id
in: query
required: false
description: Alternative to this field in the body; body wins. Required-field rules apply after merging.
schema:
oneOf:
- type: integer
maximum: 9223372036854775807
minimum: 1
- type: string
pattern: ^\s*\+?0*(?:[1-9][0-9]{0,17}|[1-8][0-9]{18}|9[0-1][0-9]{17}|92[0-1][0-9]{16}|922[0-2][0-9]{15}|9223[0-2][0-9]{14}|92233[0-6][0-9]{13}|922337[0-1][0-9]{12}|92233720[0-2][0-9]{10}|922337203[0-5][0-9]{9}|9223372036[0-7][0-9]{8}|92233720368[0-4][0-9]{7}|922337203685[0-3][0-9]{6}|9223372036854[0-6][0-9]{5}|92233720368547[0-6][0-9]{4}|922337203685477[0-4][0-9]{3}|9223372036854775[0-7][0-9]{2}|922337203685477580[0-6]|9223372036854775807)\s*$
description: Integer or integer string; parsed value must be within 1..9223372036854775807.
components:
schemas:
AmountInput:
type: string
minLength: 1
maxLength: 40
description: Positive amount as a decimal string (not a JSON number). Surrounding whitespace and exponent notation are accepted. Crypto rounds to asset precision, midpoint away from zero, and must remain positive; fiat requires exact positive cents. Values must fit the server decimal parser and scaling arithmetic.
pattern: ^\s*\+?(?=[0-9.]*[1-9])(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?\s*$
Amount:
type: string
description: Non-negative fixed-point decimal string in whole-coin (or fiat) units, including zero balances and fees. Never a JSON number.
examples:
- '10.5'
pattern: ^[0-9]+(?:\.[0-9]+)?$
PlanWithStats:
allOf:
- $ref: '#/components/schemas/Plan'
- type: object
properties:
active_subscribers:
type: integer
description: Count of live (active + grace) subscriptions on the plan.
required:
- active_subscribers
ErrorEnvelope:
type: object
required:
- ok
- error
properties:
ok:
const: false
error:
type: object
required:
- code
- name
properties:
code:
type: integer
description: Duplicates the HTTP status (400/401/403/404/409/429/503/500).
name:
type: string
description: Machine-readable error name to branch on, e.g. "insufficient_funds".
CreatePlanRequest:
type: object
required:
- name
- asset
- amount
- period_days
properties:
name:
type: string
minLength: 1
maxLength: 64
asset:
type: string
maxLength: 16
amount:
$ref: '#/components/schemas/AmountInput'
description: The per-period charge.
period_days:
oneOf:
- type: integer
maximum: 365
minimum: 1
- type: string
pattern: ^\s*\+?0*(?:[1-9][0-9]{0,1}|[1-2][0-9]{2}|3[0-5][0-9]{1}|36[0-4]|365)\s*$
description: Also checked server-side against the platform minimum — a value outside the bounds returns 409 invalid_period.
Plan:
type: object
properties:
plan_id:
type: integer
name:
type: string
asset:
type: string
amount:
$ref: '#/components/schemas/Amount'
amount_minor:
$ref: '#/components/schemas/AmountMinor'
period_days:
type: integer
archived:
type: boolean
description: Archived plans accept no new approvals.
mini_app_subscribe_url:
type: string
description: t.me deep link users open to approve.
created_at:
type: string
format: date-time
required:
- plan_id
- name
- asset
- amount
- amount_minor
- period_days
- archived
- mini_app_subscribe_url
- created_at
Subscription:
type: object
properties:
subscription_id:
type: integer
plan_id:
type: integer
user_id:
type: integer
description: Subscriber's Telegram ID.
asset:
type: string
description: Plan snapshot.
amount:
allOf:
- $ref: '#/components/schemas/Amount'
description: Snapshot per-period amount.
amount_minor:
$ref: '#/components/schemas/AmountMinor'
period_days:
type: integer
status:
type: string
enum:
- active
- grace
- cancelled
- expired
description: grace = renewal failed, retrying inside the grace window.
auto_renew:
type: boolean
period_no:
type: integer
description: Number of paid periods so far.
current_period_start:
type: string
format: date-time
current_period_end:
type: string
format: date-time
description: The paid-through deadline — read this as the access deadline.
created_at:
type: string
format: date-time
cancelled_at:
type:
- string
- 'null'
format: date-time
cancelled_by:
type:
- string
- 'null'
enum:
- user
- merchant
- null
expired_at:
type:
- string
- 'null'
format: date-time
required:
- subscription_id
- plan_id
- user_id
- asset
- amount
- amount_minor
- period_days
- status
- auto_renew
- period_no
- current_period_start
- current_period_end
- created_at
- cancelled_at
- cancelled_by
- expired_at
AmountMinor:
type: string
description: The integer minor-unit amount as a string (wei-scale values overflow the JS Number type).
examples:
- '10500000'
pattern: ^[0-9]+$
responses:
Error:
description: 'Error — `{"ok": false, "error": {"code": <HTTP status>, "name":
"<machine_name>"}}` with the same HTTP status on the wire. See the
operation description for its specific error names and the API
description for the common ones.
'
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorEnvelope'
securitySchemes:
apiToken:
type: apiKey
in: header
name: TgPayCrypto-API-Token
description: The canonical token header. The token is shown once, at app creation or rotation.
apiTokenLegacy:
type: apiKey
in: header
name: TgCryptoPay-API-Token
description: The canonical header's name before 2026-09-07 — still accepted, so integrations built earlier keep working unchanged.
apiTokenCompat:
type: apiKey
in: header
name: Crypto-Pay-API-Token
description: Accepted token header alias. The first non-empty canonical/legacy/compatibility header wins, in that order.
externalDocs:
description: Merchant API reference (developer docs)
url: https://docs.tgpaycrypto.com/crypto-pay-api-reference/