This document describes the minimum Admin API surface for external payment systems (for example, sub2apipay) to complete balance top-up and reconciliation.
## 中文
## Base URL
### 概述
本文档描述外部支付系统(例如 sub2apipay)对接 Sub2API 时的最小 Admin API 集合,用于完成充值发放与对账。
### 基础地址
- 生产环境:`https://<your-domain>`
- Beta 环境:`http://<your-server-ip>:8084`
### 认证方式
以下接口均建议使用:
- 请求头:`x-api-key: admin-<64hex>`(服务间调用推荐)
- 请求头:`Content-Type: application/json`
说明:管理员 JWT 也可访问 admin 路由,但机器对机器调用建议使用 Admin API Key。
This document defines the minimum Admin API surface for integrating external payment systems (for example, sub2apipay) with Sub2API for recharge fulfillment and reconciliation.
### Base URL
- Production: `https://<your-domain>`
- Beta: `http://<your-server-ip>:8084`
All endpoints below use:
### Authentication
- Header: `x-api-key: admin-<64hex>` (recommended for server-to-server)
- Header: `Content-Type: application/json`
Recommended headers:
Note: Admin JWT is also accepted by admin routes, but machine-to-machine integration should use admin API key.
-`x-api-key: admin-<64hex>` (recommended for server-to-server calls)
-`Content-Type: application/json`
## 1) Create + Redeem in One Step
Note: Admin JWT is also accepted by admin routes, but Admin API key is recommended for machine integrations.
-Existing reusable admin interface for manual correction.
-Reuse existing admin endpoint for manual reconciliation.
- Supports `set`, `add`, `subtract`.
Request body example (`subtract`):
...
...
@@ -117,18 +279,35 @@ curl -X POST "${BASE}/api/v1/admin/users/123/balance" \
}'
```
## 4) Error Handling Recommendations
### 4) Purchase URL Query Parameters (Iframe + New Tab)
When Sub2API frontend opens `purchase_subscription_url`, it appends the same query parameters for both iframe and “open in new tab” to keep context consistent.