/admin/communication/templates
为当前租户创建消息发送模板。支持短信、邮件、推送三种渠道,模板内容可使用 {{变量}} 或 Go template 语法定义变量占位符(如 {{code}}),后续发送时由传入的变量值替换。模板支持多语言(locale)。参考:ePrivacy Directive 2002/58/EC、CAN-SPAM Act。
Request Body
Schema: dto.CreateTemplateRequest
| Field | Type | Required | Example | Constraints | Description |
|---|---|---|---|---|---|
channel |
string |
Yes | sms |
enum: `sms`, `email`, `push` | |
code |
string |
Yes | verify_code |
||
content |
string |
Yes | 您的验证码是{code},5分钟内有效 |
||
name |
string |
Yes | 验证码模板 |
||
content_type |
string |
No | text |
||
description |
string |
No | 用于发送登录验证码 |
||
format |
string |
No | simple |
||
subject |
string |
No | 验证码通知 |
||
text_content |
string |
No | Your code is {code} |
||
variables |
array of string |
No | ['["code"]'] |
Responses
| Status | Description | Schema |
|---|---|---|
| 201 | 模板创建成功,返回模板详情 | dto.CreateTemplateResponse |
| 400 | 请求参数错误 | dto.SimpleResponse |
| 401 | 未认证或令牌无效 | dto.SimpleResponse |
| 403 | 无权访问该资源 | dto.SimpleResponse |
| 404 | 资源不存在 | dto.SimpleResponse |
| 500 | 服务内部错误 | dto.SimpleResponse |
Referenced Schemas
dto.CreateTemplateResponse
| Field | Type | Required | Example | Constraints | Description |
|---|---|---|---|---|---|
code |
integer |
No | 0 |
||
data |
dto.MessageTemplateResponse |
No | |||
message |
string |
No | success |
dto.MessageTemplateResponse
消息模板数据
| Field | Type | Required | Example | Constraints | Description |
|---|---|---|---|---|---|
channel |
string |
No | sms |
||
code |
string |
No | verify_code |
||
content |
string |
No | 您的验证码是{code},5分钟内有效 |
||
content_type |
string |
No | text |
||
created_at |
string |
No | 2026-04-15T10:00:00Z |
||
description |
string |
No | 用于发送登录验证码 |
||
id |
string |
No | tpl_abc123 |
||
is_active |
boolean |
No | True |
||
name |
string |
No | 验证码模板 |
||
subject |
string |
No | 验证码通知 |
||
tenant_id |
string |
No | tnt_xyz789 |
||
updated_at |
string |
No | 2026-04-15T10:00:00Z |
||
variables |
array of string |
No | ['["code"]'] |
||
version |
integer |
No | 1 |
dto.SimpleResponse
| Field | Type | Required | Example | Constraints | Description |
|---|---|---|---|---|---|
code |
integer |
No | |||
message |
string |
No | |||
timestamp |
string |
No |