Skip to main content

Send Email

Send a transactional email using a template or direct HTML.

Endpoint

POST /api/v1/send

Authentication: Secret Key (sdk_...)

Request Parameters

FieldTypeRequiredDescription
email or tostringYesRecipient's email.
templatestringYes*Template name (e.g. welcome).
htmlstringYes*HTML content (if not using template).
subjectstringNoOverride the subject.
dataobjectNoVariables to replace in the template.
info

Either template OR html is required.

Examples

Using a Template

curl -X POST https://senddock.dev/api/v1/send \
-H "Authorization: Bearer sdk_..." \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"template": "welcome",
"data": { "name": "Developer" }
}'

Using Direct HTML

curl -X POST https://senddock.dev/api/v1/send \
-H "Authorization: Bearer sdk_..." \
-H "Content-Type: application/json" \
-d '{
"to": "user@example.com",
"html": "<h1>Hello!</h1>",
"subject": "Direct HTML"
}'
await fetch('https://senddock.dev/api/v1/send', {
method: 'POST',
headers: {
'Authorization': 'Bearer sdk_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
to: 'user@example.com',
template: 'welcome',
data: {
name: 'John',
activationLink: 'https://...'
}
})
});

Response

Success (200)

{
"success": true,
"data": {
"message": "Email sent successfully",
"template": "welcome-email",
"to": "user@example.com"
}
}

Error (400)

{
"success": false,
"error": "Missing required field: email"
}

System Templates

If you haven't created a custom template in the dashboard, you can use these built-in templates:

  • verification: For email verification codes.
  • welcome: A generic welcome email.
  • purchase_confirmation: Simple order confirmation.
  • credentials: For sending temporary passwords or credentials.

Template Syntax (Handlebars)

We support full Handlebars syntax:

  • Variables: {{name}}
  • Conditionals: {{#if premium}} ... {{/if}}
  • Loops: {{#each items}} {{this.name}} {{/each}}