Send Email Using Template
Interface Description
Send emails using created email templates, supporting batch sending to multiple recipients. Each recipient can use different template variable parameters.
Request Information
- Request Method:
POST - Request Path:
/api/v1/email/SendEmailTemplate - Content-Type:
application/json
Request Parameters
| Parameter Name | Type | Required | Description | Example Value |
|---|---|---|---|---|
| SendEmail | string | Yes | Sender email address | "sender@example.com" |
| TemplateId | string | Yes | Email template ID | "template_123" |
| EmailContent | array | Yes | Email content array, each element contains recipient information and template variables | See description below |
| FromName | string | No | Sender nickname | "USpeedo" |
EmailContent Array Element Description
Each element contains the following fields:
| Parameter Name | Type | Required | Description | Example Value |
|---|---|---|---|---|
| EmailAddress | string | Yes | Recipient email address | "recipient@example.com" |
| TemplateVariableParams | array | No | Template variable parameter list, format: variableName{##}variableValue | ["name{##}John", "code{##}123456"] |
Notes
- Variable format in
TemplateVariableParams:variableName{##}variableValue, multiple variables are separated by array elements.
Request Example
curl -X POST "https://api.uspeedo.com/api/v1/email/SendEmailTemplate" \
-H "Content-Type: application/json" \
-H "Authorization: Basic $(echo -n 'ACCESSKEY_ID:ACCESSKEY_SECRET' | base64)" \
-d '{
"SendEmail": "sender@example.com",
"TemplateId": "template_123",
"FromName": "USpeedo",
"EmailContent": [
{
"EmailAddress": "recipient@example.com",
"TemplateVariableParams": [
"name{##}John",
"code{##}123456"
]
}
]
}'
Response Format
Success Response
{
"RetCode": 0,
"Message": "success",
"SessionNo": "session_1234567890",
"FailedTargetEmails": []
}
Response Field Description
| Field Name | Type | Description |
|---|---|---|
| RetCode | int | Return code, 0 indicates success |
| Message | string | Return message |
| SessionNo | string | Session number, used to query sending status |
| FailedTargetEmails | array | List of failed recipients, each element contains: EmailAddress (email address), TemplateVariableParams (template variable parameters), FailureReason (failure reason) |
Error Response
{
"RetCode": 215392,
"Message": "Invalid parameter [SendEmail]"
}
Common Error Codes
| Error Code | Description |
|---|---|
| 0 | Success |
| 215392 | Parameter error |
| 215397 | Missing required parameter |
| 215400 | Server error |