mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6354] [Feature]: Add webhook event for successful client Auto Renew #4309
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4309
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Lemirda on GitHub (Aug 28, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6354
Is your feature request related to a problem?
3X-UI currently supports automatic client renewal, but there is no way to receive an external notification when an auto-renewal is successfully performed.
This makes it difficult to synchronize 3X-UI with external systems such as billing systems, subscription management services, statistics dashboards, CRM systems, or custom APIs.
For example, when a client's subscription is automatically renewed, an external service may need to know that:
the renewal was successfully completed;
the client's expiration date has changed;
the traffic quota has been reset;
the client is active again.
At the moment, this requires periodically polling the 3X-UI API or implementing custom scripts that independently monitor client expiration dates.
Describe the solution you'd like
Add a configurable third-party webhook that can be triggered when a client's Auto Renew operation is successfully completed.
The panel should send an HTTP POST request to the configured webhook URL after the renewal has actually been completed successfully.
For example:
{
"event": "client_auto_renew",
"timestamp": 1756422000,
"client": {
"email": "user@example.com",
"uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"inbound_id": 1,
"inbound_tag": "inbound-443"
},
"renewal": {
"auto_renew_days": 30,
"previous_expiry_time": 1756422000000,
"new_expiry_time": 1759014000000
}
}
The exact payload structure can be discussed, but it would be useful to provide at least:
event type;
timestamp;
client email/identifier;
inbound identifier;
previous expiration time;
new expiration time;
Auto Renew period;
optionally, whether traffic was reset and the client was re-enabled.
Ideally, the webhook system should support:
configurable webhook URL;
HTTP POST;
JSON payload;
optional secret/token for authentication;
configurable events;
retry on temporary delivery failures;
logging of webhook delivery status.
The webhook should only be triggered after a successful Auto Renew operation, not merely when the renewal process is attempted.
Alternatives you've considered
The current alternatives are:
Periodically polling the 3X-UI API and comparing client expiration dates.
Running an external cron job that monitors clients and tries to determine when Auto Renew occurred.
Modifying or wrapping the existing Auto Renew logic with a custom script.
All of these approaches are less reliable than having 3X-UI emit an event directly when the renewal actually happens.
A native webhook would also avoid unnecessary API polling and make integration with external billing and subscription systems much easier.
Concrete use case
No response
Mockups, screenshots, or examples
This feature would complement the existing Auto Renew functionality and the broader request for third-party webhooks.
It could also be implemented as part of a general event-based webhook system, for example:
client_created
client_deleted
client_updated
client_auto_renew
client_expired
client_disabled
client_enabled
traffic_limit_reached
For this feature request, however, the main requirement is the client_auto_renew event.
The most important requirement is that the webhook is sent only after the Auto Renew operation has been successfully applied to the client.
Which parts of the panel would this affect?
Backend (API endpoints, login, settings)
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Aug 28, 2026):
Valid feature request — nothing in the panel covers it today. There is no webhook or HTTP-callback mechanism for any client lifecycle event, and auto-renew in particular emits nothing outside the panel: not to the event bus, not to Telegram, not to e-mail. A case-insensitive
webhooksearch over the Go tree returns zero hits (thewebhookinfrontend/src/schemas/routing.ts:8isRuleWebhookSchema, Xray-core's routing failover webhook, unrelated to panel notifications).What exists today, and why none of it substitutes
1. The event bus has a fixed set of eight types, all infrastructure-level —
internal/eventbus/events.go:8-26:No client lifecycle event exists at all, so
client_auto_renew— and the rest of the list in your last section — would be new event types, not just a new sink.2. Its only two sinks are Telegram and e-mail.
internal/web/service/tgbot/tgbot_event.goandinternal/web/service/email/subscriber.go:33, each filtered by a comma-separated setting (tgEnabledEvents/smtpEnabledEvents, defaults atinternal/web/service/setting.go:159-160). There is no HTTP sink.3. The one outbound POST the panel already makes cannot express a renewal. That is the traffic-inform hook —
externalTrafficInformEnable+externalTrafficInformURI(internal/web/service/setting.go:933-947), fired frominternal/web/job/xray_traffic_job.go:103-104. Its body is built atxray_traffic_job.go:241:and those
clientTrafficsare the raw Xray gRPC deltas, constructed ininternal/xray/api.go:881astraffic = &ClientTraffic{Email: email}with onlyUp/Downfilled in afterwards.expiryTime,resetandresetCountare always zero in that payload, so it cannot be used to detect an auto-renew either.Where the event would have to come from
InboundService.autoRenewClients(internal/web/service/inbound_traffic.go:330) already computes every field you asked for, and already separates the renewals that succeeded from the candidates that were merely considered:traffic.ExpiryTimeas read at:434, before the new value is computed:459-461(c["expiryTime"] = newExpiryTime,traffic.ResetCount += renewals):471-472(if !traffic.Enable { traffic.Enable = true)renewedEmails = append(renewedEmails, email)at:470— reached only after the quota reset at:468, and deliberately skipped for a client whose prepaid cap ran out mid-catch-up (:462-467)Two constraints for whoever implements it, both visible in the same file:
autoRenewClientswould not satisfy your "only after a successful renew" requirement: it runs inside a transaction (:62) that can still roll back afterwards —:94-97logstraffic lifecycle maintenance failed after traffic commitand swallows the whole batch. The established pattern for post-commit side effects here istrafficMutationBatch→applyTrafficMutationBatch(:98,internal/web/service/inbound_traffic_apply.go:60).Where("i.node_id IS NULL")(:350), so a master panel renews only its own local clients. A node's clients are renewed by that node's panel, which is where its webhook would fire.A configurable URL should reuse the existing SSRF guard
service.SanitizePublicHTTPURL(internal/web/service/url_safety.go:44), the way the traffic-inform URI does atxray_traffic_job.go:236.Relationship to #5727
#5727 ("Supports third-party webhooks") is the open umbrella request for the generic HTTP sink, still unimplemented. I am not closing this as a duplicate: #5727 asks for new subscriptions / online alerts / traffic usage, none of which is
client_auto_renew, and that event does not exist on the bus at all — so this request adds a piece #5727 does not cover. A maintainer may still choose to fold the two together.A more reliable poll than comparing expiry dates, until then
resetCountis a monotonic counter incremented by exactly the number of renewal periods applied (inbound_traffic.go:461). It therefore distinguishes an auto-renew from a manual expiry edit, and it survives a missed poll — an expiry-date comparison does neither.GET /panel/api/clients/traffic/{email}returns the full traffic row (internal/web/controller/client.go:597-605), withresetCount,expiryTime,up,down,uuidandsubIdGET /panel/api/clients/list/pagedembeds that same row per client undertraffic(internal/web/service/client_paging.go:34and:466)Treat "
resetCountincreased" as the renewal signal, and read the newexpiryTimefrom the same response.Verdict: Feature request
This reply was generated automatically by an AI agent. A maintainer may follow up.
@Lemirda commented on GitHub (Aug 28, 2026):
I would also like to propose an additional option for this feature: a pre-renewal webhook that allows an external service to approve or reject the Auto Renew operation before it is actually performed.
The flow could be:
client_auto_renew_before.allow: true, 3X-UI proceeds with the Auto Renew operation.allow: false, the Auto Renew operation is cancelled.client_auto_renewwebhook with the result of the operation.For example:
This would be particularly useful for external billing/subscription systems. The external service could verify whether the user is actually eligible for renewal before 3X-UI extends the client's expiration time.
For security/reliability, the pre-renewal webhook could have a configurable timeout. If the external service does not respond within the timeout, the renewal could be denied by default.
The authorization response could initially be kept very simple (
allow: true/false), without allowing the external service to modify the renewal parameters.This would make the webhook system useful not only for notifications, but also for external authorization of Auto Renew.