From 8fb027d3319618060b60a39449fe829844f70489 Mon Sep 17 00:00:00 2001 From: lyzno1 Date: Wed, 12 Nov 2025 13:08:41 +0800 Subject: [PATCH] feat: add sandbox api rate limit email template --- api/libs/email_i18n.py | 26 ++++ .../api_rate_limit_limit_template_en-US.html | 133 +++++++++++++++++ .../api_rate_limit_limit_template_zh-CN.html | 133 +++++++++++++++++ ...api_rate_limit_warning_template_en-US.html | 134 ++++++++++++++++++ ...api_rate_limit_warning_template_zh-CN.html | 133 +++++++++++++++++ .../api_rate_limit_limit_template_en-US.html | 124 ++++++++++++++++ .../api_rate_limit_limit_template_zh-CN.html | 124 ++++++++++++++++ ...api_rate_limit_warning_template_en-US.html | 125 ++++++++++++++++ ...api_rate_limit_warning_template_zh-CN.html | 124 ++++++++++++++++ 9 files changed, 1056 insertions(+) create mode 100644 api/templates/api_rate_limit_limit_template_en-US.html create mode 100644 api/templates/api_rate_limit_limit_template_zh-CN.html create mode 100644 api/templates/api_rate_limit_warning_template_en-US.html create mode 100644 api/templates/api_rate_limit_warning_template_zh-CN.html create mode 100644 api/templates/without-brand/api_rate_limit_limit_template_en-US.html create mode 100644 api/templates/without-brand/api_rate_limit_limit_template_zh-CN.html create mode 100644 api/templates/without-brand/api_rate_limit_warning_template_en-US.html create mode 100644 api/templates/without-brand/api_rate_limit_warning_template_zh-CN.html diff --git a/api/libs/email_i18n.py b/api/libs/email_i18n.py index 42cf119104..ff74ccbe8e 100644 --- a/api/libs/email_i18n.py +++ b/api/libs/email_i18n.py @@ -42,6 +42,8 @@ class EmailType(StrEnum): TRIGGER_EVENTS_LIMIT_PROFESSIONAL = auto() TRIGGER_EVENTS_USAGE_WARNING_SANDBOX = auto() TRIGGER_EVENTS_USAGE_WARNING_PROFESSIONAL = auto() + API_RATE_LIMIT_LIMIT_SANDBOX = auto() + API_RATE_LIMIT_WARNING_SANDBOX = auto() class EmailLanguage(StrEnum): @@ -497,6 +499,30 @@ def create_default_email_config() -> EmailI18nConfig: branded_template_path="without-brand/trigger_events_usage_warning_template_zh-CN.html", ), }, + EmailType.API_RATE_LIMIT_LIMIT_SANDBOX: { + EmailLanguage.EN_US: EmailTemplate( + subject="You’ve reached your API Rate Limit", + template_path="api_rate_limit_limit_template_en-US.html", + branded_template_path="without-brand/api_rate_limit_limit_template_en-US.html", + ), + EmailLanguage.ZH_HANS: EmailTemplate( + subject="您的 API 速率额度已用尽", + template_path="api_rate_limit_limit_template_zh-CN.html", + branded_template_path="without-brand/api_rate_limit_limit_template_zh-CN.html", + ), + }, + EmailType.API_RATE_LIMIT_WARNING_SANDBOX: { + EmailLanguage.EN_US: EmailTemplate( + subject="You’re nearing your API Rate Limit", + template_path="api_rate_limit_warning_template_en-US.html", + branded_template_path="without-brand/api_rate_limit_warning_template_en-US.html", + ), + EmailLanguage.ZH_HANS: EmailTemplate( + subject="您的 API 速率额度接近上限", + template_path="api_rate_limit_warning_template_zh-CN.html", + branded_template_path="without-brand/api_rate_limit_warning_template_zh-CN.html", + ), + }, EmailType.EMAIL_REGISTER: { EmailLanguage.EN_US: EmailTemplate( subject="Register Your {application_title} Account", diff --git a/api/templates/api_rate_limit_limit_template_en-US.html b/api/templates/api_rate_limit_limit_template_en-US.html new file mode 100644 index 0000000000..c1c129ad0a --- /dev/null +++ b/api/templates/api_rate_limit_limit_template_en-US.html @@ -0,0 +1,133 @@ + + + + + + + + +
+
+ Dify Logo +
+
+

You’ve reached your API Rate Limit

+
+

+ Your workspace {{workspaceName}} has used all available Monthly API Rate Limit for the + {{planName}} Plan (limit: {{planLimit}}). +

+

+ As a result, API access has been temporarily paused. +

+

+ To continue using the Dify API and unlock a higher limit, please upgrade to a paid plan. +

+
+ {{ctaLabel}} +

+ Monthly API Rate Limit for the {{planName}} Plan will reset on {{resetDate}}. +

+
+
+ + + diff --git a/api/templates/api_rate_limit_limit_template_zh-CN.html b/api/templates/api_rate_limit_limit_template_zh-CN.html new file mode 100644 index 0000000000..4cc0d7c6e1 --- /dev/null +++ b/api/templates/api_rate_limit_limit_template_zh-CN.html @@ -0,0 +1,133 @@ + + + + + + + + +
+
+ Dify Logo +
+
+

您的 API 速率额度已用尽

+
+

+ 您的工作区 {{workspaceName}} 已用完 Monthly API Rate Limit,触及 + {{planName}} 计划(上限:{{planLimit}})。 +

+

+ 因此,API 访问已被暂时暂停。 +

+

+ 若要继续使用 Dify API 并解锁更高额度,请升级到付费套餐。 +

+
+ {{ctaLabel}} +

+ {{planName}} 计划的 Monthly API Rate Limit 将于 {{resetDate}} 重置。 +

+
+
+ + + diff --git a/api/templates/api_rate_limit_warning_template_en-US.html b/api/templates/api_rate_limit_warning_template_en-US.html new file mode 100644 index 0000000000..840f257c15 --- /dev/null +++ b/api/templates/api_rate_limit_warning_template_en-US.html @@ -0,0 +1,134 @@ + + + + + + + + +
+
+ Dify Logo +
+
+

You’re nearing your API Rate Limit

+
+

+ Your workspace {{workspaceName}} has used 80% of its Monthly API Rate Limit for the + {{planName}} Plan (limit: {{planLimit}}). +

+

+ Once the limit is reached, API access will be temporarily paused until the next monthly reset. +

+

+ To avoid service interruptions and ensure continued access to the Dify API, please consider upgrading your plan for a higher API + Rate Limit. +

+
+ {{ctaLabel}} +

+ Monthly API Rate Limit for the {{planName}} Plan will reset on {{resetDate}}. +

+
+
+ + + diff --git a/api/templates/api_rate_limit_warning_template_zh-CN.html b/api/templates/api_rate_limit_warning_template_zh-CN.html new file mode 100644 index 0000000000..180388bbb8 --- /dev/null +++ b/api/templates/api_rate_limit_warning_template_zh-CN.html @@ -0,0 +1,133 @@ + + + + + + + + +
+
+ Dify Logo +
+
+

您的 API 速率额度接近上限

+
+

+ 您的工作区 {{workspaceName}} 已使用 80% 的 Monthly API Rate Limit,触及 + {{planName}} 计划(上限:{{planLimit}})。 +

+

+ 一旦达到上限,API 访问将暂停,直至下一个月度重置。 +

+

+ 为避免服务中断并持续访问 Dify API,请考虑升级到额度更高的套餐。 +

+
+ {{ctaLabel}} +

+ {{planName}} 计划的 Monthly API Rate Limit 将于 {{resetDate}} 重置。 +

+
+
+ + + diff --git a/api/templates/without-brand/api_rate_limit_limit_template_en-US.html b/api/templates/without-brand/api_rate_limit_limit_template_en-US.html new file mode 100644 index 0000000000..f59a218489 --- /dev/null +++ b/api/templates/without-brand/api_rate_limit_limit_template_en-US.html @@ -0,0 +1,124 @@ + + + + + + + + +
+
+
+

You’ve reached your API Rate Limit

+
+

+ Your workspace {{workspaceName}} has used all available Monthly API Rate Limit for the + {{planName}} Plan (limit: {{planLimit}}). +

+

+ As a result, API access has been temporarily paused. +

+

+ To continue using the Dify API and unlock a higher limit, please upgrade to a paid plan. +

+
+ {{ctaLabel}} +

+ Monthly API Rate Limit for the {{planName}} Plan will reset on {{resetDate}}. +

+
+
+ + + diff --git a/api/templates/without-brand/api_rate_limit_limit_template_zh-CN.html b/api/templates/without-brand/api_rate_limit_limit_template_zh-CN.html new file mode 100644 index 0000000000..0c7b5538ce --- /dev/null +++ b/api/templates/without-brand/api_rate_limit_limit_template_zh-CN.html @@ -0,0 +1,124 @@ + + + + + + + + +
+
+
+

您的 API 速率额度已用尽

+
+

+ 您的工作区 {{workspaceName}} 已用完 Monthly API Rate Limit,触及 + {{planName}} 计划(上限:{{planLimit}})。 +

+

+ 因此,API 访问已被暂时暂停。 +

+

+ 若要继续使用 Dify API 并解锁更高额度,请升级到付费套餐。 +

+
+ {{ctaLabel}} +

+ {{planName}} 计划的 Monthly API Rate Limit 将于 {{resetDate}} 重置。 +

+
+
+ + + diff --git a/api/templates/without-brand/api_rate_limit_warning_template_en-US.html b/api/templates/without-brand/api_rate_limit_warning_template_en-US.html new file mode 100644 index 0000000000..93ec12dc96 --- /dev/null +++ b/api/templates/without-brand/api_rate_limit_warning_template_en-US.html @@ -0,0 +1,125 @@ + + + + + + + + +
+
+
+

You’re nearing your API Rate Limit

+
+

+ Your workspace {{workspaceName}} has used 80% of its Monthly API Rate Limit for the + {{planName}} Plan (limit: {{planLimit}}). +

+

+ Once the limit is reached, API access will be temporarily paused until the next monthly reset. +

+

+ To avoid service interruptions and ensure continued access to the Dify API, please consider upgrading your plan for a higher API + Rate Limit. +

+
+ {{ctaLabel}} +

+ Monthly API Rate Limit for the {{planName}} Plan will reset on {{resetDate}}. +

+
+
+ + + diff --git a/api/templates/without-brand/api_rate_limit_warning_template_zh-CN.html b/api/templates/without-brand/api_rate_limit_warning_template_zh-CN.html new file mode 100644 index 0000000000..a877ac3ffa --- /dev/null +++ b/api/templates/without-brand/api_rate_limit_warning_template_zh-CN.html @@ -0,0 +1,124 @@ + + + + + + + + +
+
+
+

您的 API 速率额度接近上限

+
+

+ 您的工作区 {{workspaceName}} 已使用 80% 的 Monthly API Rate Limit,触及 + {{planName}} 计划(上限:{{planLimit}})。 +

+

+ 一旦达到上限,API 访问将暂停,直至下一个月度重置。 +

+

+ 为避免服务中断并持续访问 Dify API,请考虑升级到额度更高的套餐。 +

+
+ {{ctaLabel}} +

+ {{planName}} 计划的 Monthly API Rate Limit 将于 {{resetDate}} 重置。 +

+
+
+ + +