[GH-ISSUE #5146] [Feature]: Allow custom subscription link pattern in Bulk Add clients #3617

Closed
opened 2026-10-31 20:33:45 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Namso9 on GitHub (Jun 9, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5146

Yes. When using Bulk Add to create multiple clients, the Email field can be generated with a prefix and number range, for example Cus 1 to Cus 10.
However, the subscription link / Sub ID is generated randomly. There is currently no option to generate subscription links with a custom prefix or number range.
Example:
I want to bulk create 10 clients with subscription links like:
https://example.com/api/sub/1
https://example.com/api/sub/2
https://example.com/api/sub/3
...
https://example.com/api/sub/10
But currently, after using Bulk Add, I have to edit each client manually one by one to change the subscription link / Sub ID.
This takes extra time and can cause mistakes when creating many clients.

Describe the solution you'd like

Please add an optional custom subscription link / Sub ID pattern feature in the Bulk Add client form.
Suggested UI placement: inside the Bulk Add client modal/form, near the Email range option.
Suggested options:
Subscription ID mode:
[ ] Auto random subscription ID
[ ] Custom subscription pattern

Prefix: ______
Start number: ____
End number: ____
Suffix: ______
Zero padding: ____
Expected behavior:
If “Auto random subscription ID” is selected, the current behavior should stay the same.
If “Custom subscription pattern” is selected, the panel should generate Sub IDs based on the pattern.
Example 1:
Prefix:
Start number: 1
End number: 10
Suffix:
Zero padding: 0
Expected Sub IDs:
1
2
3
...
10
Expected subscription links:
https://example.com/api/sub/1
https://example.com/api/sub/2
https://example.com/api/sub/3
...
https://example.com/api/sub/10
Example 2:
Prefix: Cus-
Start number: 1
End number: 10
Zero padding: 3
Expected Sub IDs:
Cus-001
Cus-002
Cus-003
...
Cus-010
Possible edge cases:
If a generated Sub ID already exists, the panel should show an error before creating clients.
Sub ID should only allow safe characters for URLs.
If the number of generated Sub IDs does not match the number of clients, the panel should show a validation error.
The current random Sub ID behavior should remain the default option.

Alternatives you've considered

Currently, I prepare the subscription links manually outside the panel, for example using AI or a text generator:
https://example.com/api/sub/1
https://example.com/api/sub/2
...
https://example.com/api/sub/10
But after bulk adding clients, the panel still generates random Sub IDs. So I must open each client and manually edit the subscription ID one by one.
This works, but it is slow, repetitive, and easy to make mistakes.

Concrete use case

I manage many clients and often need to create clients in batches.
For example, I may create 10 clients at once:
Cus 1
Cus 2
Cus 3
...
Cus 10
The Email range works correctly in Bulk Add, but I also need the subscription links to be organized in the same way:
/api/sub/1
/api/sub/2
/api/sub/3
...
/api/sub/10
This feature would help admins and resellers create clean, predictable, and organized subscription links without editing each client manually.

Mockups, screenshots, or examples

Example Bulk Add subscription pattern:
Email prefix: Cus
Email start number: 1
Email end number: 10

Subscription ID mode: Custom pattern
Subscription prefix:
Subscription start number: 1
Subscription end number: 10
Zero padding: 0
Expected result:
Email: Cus 1 Sub ID: 1
Email: Cus 2 Sub ID: 2
Email: Cus 3 Sub ID: 3
...
Email: Cus 10 Sub ID: 10
Another example:
Email: Cus 1 Sub ID: Cus-001
Email: Cus 2 Sub ID: Cus-002
Email: Cus 3 Sub ID: Cus-003
...
Email: Cus 10 Sub ID: Cus-010

Which parts of the panel would this affect?

Subscription (share links / Clash / JSON), Other, Frontend (UI / panel pages)

Are you willing to help?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @Namso9 on GitHub (Jun 9, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5146 ### Is your feature request related to a problem? Yes. When using Bulk Add to create multiple clients, the Email field can be generated with a prefix and number range, for example Cus 1 to Cus 10. However, the subscription link / Sub ID is generated randomly. There is currently no option to generate subscription links with a custom prefix or number range. Example: I want to bulk create 10 clients with subscription links like: https://example.com/api/sub/1 https://example.com/api/sub/2 https://example.com/api/sub/3 ... https://example.com/api/sub/10 But currently, after using Bulk Add, I have to edit each client manually one by one to change the subscription link / Sub ID. This takes extra time and can cause mistakes when creating many clients. ### Describe the solution you'd like Please add an optional custom subscription link / Sub ID pattern feature in the Bulk Add client form. Suggested UI placement: inside the Bulk Add client modal/form, near the Email range option. Suggested options: Subscription ID mode: [ ] Auto random subscription ID [ ] Custom subscription pattern Prefix: ______ Start number: ____ End number: ____ Suffix: ______ Zero padding: ____ Expected behavior: If “Auto random subscription ID” is selected, the current behavior should stay the same. If “Custom subscription pattern” is selected, the panel should generate Sub IDs based on the pattern. Example 1: Prefix: Start number: 1 End number: 10 Suffix: Zero padding: 0 Expected Sub IDs: 1 2 3 ... 10 Expected subscription links: https://example.com/api/sub/1 https://example.com/api/sub/2 https://example.com/api/sub/3 ... https://example.com/api/sub/10 Example 2: Prefix: Cus- Start number: 1 End number: 10 Zero padding: 3 Expected Sub IDs: Cus-001 Cus-002 Cus-003 ... Cus-010 Possible edge cases: If a generated Sub ID already exists, the panel should show an error before creating clients. Sub ID should only allow safe characters for URLs. If the number of generated Sub IDs does not match the number of clients, the panel should show a validation error. The current random Sub ID behavior should remain the default option. ### Alternatives you've considered Currently, I prepare the subscription links manually outside the panel, for example using AI or a text generator: https://example.com/api/sub/1 https://example.com/api/sub/2 ... https://example.com/api/sub/10 But after bulk adding clients, the panel still generates random Sub IDs. So I must open each client and manually edit the subscription ID one by one. This works, but it is slow, repetitive, and easy to make mistakes. ### Concrete use case I manage many clients and often need to create clients in batches. For example, I may create 10 clients at once: Cus 1 Cus 2 Cus 3 ... Cus 10 The Email range works correctly in Bulk Add, but I also need the subscription links to be organized in the same way: /api/sub/1 /api/sub/2 /api/sub/3 ... /api/sub/10 This feature would help admins and resellers create clean, predictable, and organized subscription links without editing each client manually. ### Mockups, screenshots, or examples Example Bulk Add subscription pattern: Email prefix: Cus Email start number: 1 Email end number: 10 Subscription ID mode: Custom pattern Subscription prefix: Subscription start number: 1 Subscription end number: 10 Zero padding: 0 Expected result: Email: Cus 1 Sub ID: 1 Email: Cus 2 Sub ID: 2 Email: Cus 3 Sub ID: 3 ... Email: Cus 10 Sub ID: 10 Another example: Email: Cus 1 Sub ID: Cus-001 Email: Cus 2 Sub ID: Cus-002 Email: Cus 3 Sub ID: Cus-003 ... Email: Cus 10 Sub ID: Cus-010 ### Which parts of the panel would this affect? Subscription (share links / Clash / JSON), Other, Frontend (UI / panel pages) ### Are you willing to help? - [ ] I'd like to implement this feature myself and open a PR. - [x] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
Author
Owner

@github-actions[bot] commented on GitHub (Jun 9, 2026):

Thanks for the detailed and well-structured request, @Namso9.

Current behavior (confirmed in source)

The Bulk Add modal (frontend/src/pages/clients/ClientBulkAddModal.tsx) builds the payload like this:

// line 160-179
const payloads = emails.map((email) => ({
  client: {
    email,
    subId: form.subId || RandomUtil.randomLowerAndNum(16),
    ...
  },
  inboundIds: form.inboundIds,
}));
  • If the Sub ID field is left blank: each client receives a fresh random 16-character subId (the call is inside map(), so it runs once per client). This is the only way to get unique subIds today.
  • If you type a fixed value into the Sub ID field: every client in the batch receives that same value. The backend (web/service/client.go:3309) detects the duplicate within the batch and skips every client after the first with the error "subId already in use".

In short, there is no pattern-based generation at all — only "one random per client" or "one fixed for all (broken for batches)".

What would need to change

This is a frontend-only addition for the most part:

  1. frontend/src/schemas/client.ts — extend ClientBulkAddFormSchema with optional new fields (e.g. subIdMethod, subIdPrefix, subIdStart, subIdEnd, subIdPadding).
  2. frontend/src/pages/clients/ClientBulkAddModal.tsx — add a buildSubIds() function modeled after the existing buildEmails(), and wire it up so each email index maps to the corresponding generated subId in the payload.
  3. No backend changes needed for validation: the backend already enforces uniqueness both within a batch (seenSubID map, client.go:3269) and against existing records (client.go:3342-3378), and it already validates characters (hasForbiddenClientChar, client.go:527: rejects /, \, space, and control chars). The proposed examples (Cus-001, 1, 10, etc.) all pass that check.

Edge cases to keep in mind

  • The number of generated subIds must match the number of generated emails. The simplest enforcement is to derive the count from the same firstNum/lastNum range that drives email generation, or add a check before submit.
  • If a generated subId already exists (e.g. a previous run used the same range), the backend returns "subId already in use" per client; the existing bulkCreatedMixed warning toast will surface this already.
  • The random-subId behavior must remain the default so existing workflows are unaffected.

If anyone picks this up as a PR, the email method selector (emailMethod 0–4 with firstNum/lastNum) is the natural model to follow for the subId side.

<!-- gh-comment-id:4662850920 --> @github-actions[bot] commented on GitHub (Jun 9, 2026): Thanks for the detailed and well-structured request, @Namso9. **Current behavior (confirmed in source)** The Bulk Add modal (`frontend/src/pages/clients/ClientBulkAddModal.tsx`) builds the payload like this: ```js // line 160-179 const payloads = emails.map((email) => ({ client: { email, subId: form.subId || RandomUtil.randomLowerAndNum(16), ... }, inboundIds: form.inboundIds, })); ``` - If the Sub ID field is left **blank**: each client receives a fresh random 16-character subId (the call is inside `map()`, so it runs once per client). This is the only way to get unique subIds today. - If you type a **fixed** value into the Sub ID field: every client in the batch receives that same value. The backend (`web/service/client.go:3309`) detects the duplicate within the batch and skips every client after the first with the error `"subId already in use"`. In short, there is no pattern-based generation at all — only "one random per client" or "one fixed for all (broken for batches)". **What would need to change** This is a frontend-only addition for the most part: 1. **`frontend/src/schemas/client.ts`** — extend `ClientBulkAddFormSchema` with optional new fields (e.g. `subIdMethod`, `subIdPrefix`, `subIdStart`, `subIdEnd`, `subIdPadding`). 2. **`frontend/src/pages/clients/ClientBulkAddModal.tsx`** — add a `buildSubIds()` function modeled after the existing `buildEmails()`, and wire it up so each email index maps to the corresponding generated subId in the payload. 3. **No backend changes needed** for validation: the backend already enforces uniqueness both within a batch (`seenSubID` map, `client.go:3269`) and against existing records (`client.go:3342-3378`), and it already validates characters (`hasForbiddenClientChar`, `client.go:527`: rejects `/`, `\`, space, and control chars). The proposed examples (`Cus-001`, `1`, `10`, etc.) all pass that check. **Edge cases to keep in mind** - The number of generated subIds must match the number of generated emails. The simplest enforcement is to derive the count from the same `firstNum`/`lastNum` range that drives email generation, or add a check before submit. - If a generated subId already exists (e.g. a previous run used the same range), the backend returns `"subId already in use"` per client; the existing `bulkCreatedMixed` warning toast will surface this already. - The random-subId behavior must remain the default so existing workflows are unaffected. If anyone picks this up as a PR, the email method selector (`emailMethod` 0–4 with `firstNum`/`lastNum`) is the natural model to follow for the subId side.
Author
Owner

@Namso9 commented on GitHub (Jun 16, 2026):

anyone? pls

<!-- gh-comment-id:4713773964 --> @Namso9 commented on GitHub (Jun 16, 2026): anyone? pls
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3617
No description provided.