Sub2API Admin
Use the bundled CLI instead of ad hoc curl. Run examples from this skill directory.
export SUB2API_BASE_URL='https://your-sub2api-host'
export SUB2_EXPANSION_BASE_URL='https://your-sub2-expansion-host'
export SUB2API_ADMIN_API_KEY='admin-...'
node scripts/sub2api-admin.js accounts list --page-size 20
Use separate expansion-admin credentials for invitation records and statistics:
export SUB2_EXPANSION_ADMIN_USERNAME='admin'
export SUB2_EXPANSION_ADMIN_PASSWORD='...'
If no Admin API Key is available, the CLI can log in with an admin account for the current process:
export SUB2API_ADMIN_EMAIL='admin@example.com'
export SUB2API_ADMIN_PASSWORD='...'
node scripts/sub2api-admin.js redeem-codes list --page-size 20
For full commands and payload examples, read references/admin-cli.md.
Workflow
- Confirm
SUB2API_BASE_URL and credentials are available from environment variables. Never ask the user to paste secrets into chat if they can set env vars locally.
- Prefer read-only commands first:
accounts list, accounts get <id>, groups all, proxies all, redeem-codes list, or api GET ....
- Before destructive or bulk writes, print the target names and IDs, plus the exact command or payload.
- Use
--idempotency-key for payment, recharge, or redeem-code create/redeem workflows.
- After a write, run a follow-up read command to verify the final state.
Invitations
For a new-user invitation, have the inviter provide their own invitation code. Request the binding link with checkins social --invite-code; if the response contains SOCIAL_ACCOUNT_NOT_BOUND, give the returned bindingUrl only to that social-platform user. The user must sign in through that link to bind the platform account and invitation code. Do not attempt to bind an invitation on their behalf or disclose the link to another user.
The expansion backend validates the invite code, account creation-time threshold, self-invites, existing bindings, and reward delivery. Treat REWARDED as the only successful reward state. Read references/admin-cli.md for commands, statuses, and endpoint details.
Common Commands
node scripts/sub2api-admin.js accounts list --page-size 20
node scripts/sub2api-admin.js accounts get 40
node scripts/sub2api-admin.js accounts usage 40
node scripts/sub2api-admin.js accounts set-schedulable 40 true
node scripts/sub2api-admin.js accounts bulk-update --ids 40,39 --json '{"concurrency":10}'
node scripts/sub2api-admin.js groups all
node scripts/sub2api-admin.js proxies all
node scripts/sub2api-admin.js redeem-codes list --page-size 20
node scripts/sub2api-admin.js redeem-codes generate --json '{"count":1,"type":"balance","value":10}' --idempotency-key redeem-123
node scripts/sub2api-admin.js redeem-codes create-and-redeem --json '{"code":"order_123","type":"balance","value":10,"user_id":123}' --idempotency-key order-123
node scripts/sub2api-admin.js checkins social --platform telegram --user-id 12345
node scripts/sub2api-admin.js checkins social --platform qq --user-id 12345 --invite-code 6A2W7FQC
node scripts/sub2api-admin.js invitations list --status REWARDED --page-size 20
node scripts/sub2api-admin.js invitations stats
node scripts/sub2api-admin.js error-rules list
node scripts/sub2api-admin.js tls-profiles list
node scripts/sub2api-admin.js api GET /admin/settings/admin-api-key
Safety Notes
- Authentication uses
x-api-key from SUB2API_ADMIN_API_KEY first. If absent, the CLI logs in with SUB2API_ADMIN_EMAIL and SUB2API_ADMIN_PASSWORD and sends a process-local bearer token.
- If the API returns
INVALID_ADMIN_KEY, ask the user to regenerate the Admin API Key in Sub2API settings.
accounts export may include credentials and tokens. Prefer --file and avoid printing exports in chat.
- Delete, batch-delete, bulk-update, credential import, CRS sync, and account refresh can affect production state. Verify target IDs first.
- For new backend APIs not yet wrapped by the CLI, use
api <METHOD> <admin-path> after a read-only check.
1---2name: sub2api-admin3description: Manage Sub2API admin and Sub2 Expansion check-in APIs through a bundled CLI and reference guide. Use when the user mentions Sub2API admin API, Admin API Key, account management, redeem codes, recharge codes, invitation codes, inviting new users, invitation rewards or records, groups, proxies, error passthrough rules, TLS fingerprint profiles, imports, exports, batch account updates, CRS sync, social account binding, direct check-in, social check-in, or asks to inspect or change Sub2API/Sub2 Expansion backend state.4metadata:5 source: https://skillmd.com/skills/hepingan11/sub2api-admin6---78# Sub2API Admin910Use the bundled CLI instead of ad hoc `curl`. Run examples from this skill directory.1112```bash13export SUB2API_BASE_URL='https://your-sub2api-host'14export SUB2_EXPANSION_BASE_URL='https://your-sub2-expansion-host'15export SUB2API_ADMIN_API_KEY='admin-...'16node scripts/sub2api-admin.js accounts list --page-size 2017```1819Use separate expansion-admin credentials for invitation records and statistics:2021```bash22export SUB2_EXPANSION_ADMIN_USERNAME='admin'23export SUB2_EXPANSION_ADMIN_PASSWORD='...'24```2526If no Admin API Key is available, the CLI can log in with an admin account for the current process:2728```bash29export SUB2API_ADMIN_EMAIL='admin@example.com'30export SUB2API_ADMIN_PASSWORD='...'31node scripts/sub2api-admin.js redeem-codes list --page-size 2032```3334For full commands and payload examples, read [references/admin-cli.md](references/admin-cli.md).3536## Workflow37381. Confirm `SUB2API_BASE_URL` and credentials are available from environment variables. Never ask the user to paste secrets into chat if they can set env vars locally.392. Prefer read-only commands first: `accounts list`, `accounts get <id>`, `groups all`, `proxies all`, `redeem-codes list`, or `api GET ...`.403. Before destructive or bulk writes, print the target names and IDs, plus the exact command or payload.414. Use `--idempotency-key` for payment, recharge, or redeem-code create/redeem workflows.425. After a write, run a follow-up read command to verify the final state.4344## Invitations4546For a new-user invitation, have the inviter provide their own invitation code. Request the binding link with `checkins social --invite-code`; if the response contains `SOCIAL_ACCOUNT_NOT_BOUND`, give the returned `bindingUrl` only to that social-platform user. The user must sign in through that link to bind the platform account and invitation code. Do not attempt to bind an invitation on their behalf or disclose the link to another user.4748The expansion backend validates the invite code, account creation-time threshold, self-invites, existing bindings, and reward delivery. Treat `REWARDED` as the only successful reward state. Read [references/admin-cli.md](references/admin-cli.md) for commands, statuses, and endpoint details.4950## Common Commands5152```bash53node scripts/sub2api-admin.js accounts list --page-size 2054node scripts/sub2api-admin.js accounts get 4055node scripts/sub2api-admin.js accounts usage 4056node scripts/sub2api-admin.js accounts set-schedulable 40 true57node scripts/sub2api-admin.js accounts bulk-update --ids 40,39 --json '{"concurrency":10}'58node scripts/sub2api-admin.js groups all59node scripts/sub2api-admin.js proxies all60node scripts/sub2api-admin.js redeem-codes list --page-size 2061node scripts/sub2api-admin.js redeem-codes generate --json '{"count":1,"type":"balance","value":10}' --idempotency-key redeem-12362node scripts/sub2api-admin.js redeem-codes create-and-redeem --json '{"code":"order_123","type":"balance","value":10,"user_id":123}' --idempotency-key order-12363node scripts/sub2api-admin.js checkins social --platform telegram --user-id 1234564node scripts/sub2api-admin.js checkins social --platform qq --user-id 12345 --invite-code 6A2W7FQC65node scripts/sub2api-admin.js invitations list --status REWARDED --page-size 2066node scripts/sub2api-admin.js invitations stats67node scripts/sub2api-admin.js error-rules list68node scripts/sub2api-admin.js tls-profiles list69node scripts/sub2api-admin.js api GET /admin/settings/admin-api-key70```7172## Safety Notes7374- Authentication uses `x-api-key` from `SUB2API_ADMIN_API_KEY` first. If absent, the CLI logs in with `SUB2API_ADMIN_EMAIL` and `SUB2API_ADMIN_PASSWORD` and sends a process-local bearer token.75- If the API returns `INVALID_ADMIN_KEY`, ask the user to regenerate the Admin API Key in Sub2API settings.76- `accounts export` may include credentials and tokens. Prefer `--file` and avoid printing exports in chat.77- Delete, batch-delete, bulk-update, credential import, CRS sync, and account refresh can affect production state. Verify target IDs first.78- For new backend APIs not yet wrapped by the CLI, use `api <METHOD> <admin-path>` after a read-only check.