Templates
Create Template
Create a draft template. Variables use {{{NAME}}}.
POST
/templatesBody Parameters
namestringrequiredInternal name.
aliasstringUnique name you can send by instead of the ID.
fromstringDefault sender.
subjectstringDefault subject (can use variables).
htmlstringrequiredHTML with
{{{VARIABLES}}}.textstringPlain-text version.
variables{ key, type, fallback_value? }[]Declared variables. Without a fallback a variable is required when sending.
import { Resend } from 'resend';
const client = new Resend('pw_xxxxxxxxx');
const { data, error } = await client.templates.create({
name: 'Welcome',
alias: 'welcome',
from: 'Acme <hello@yourdomain.com>',
subject: 'Welcome, {{{NAME}}}',
html: '<p>Hi {{{NAME}}}</p>',
variables: [{ key: 'NAME', type: 'string', fallbackValue: 'there' }],
});import requests
res = requests.post(
"https://post-waves.com/templates",
headers={"Authorization": "Bearer pw_xxxxxxxxx"},
json={
"name": "Welcome",
"alias": "welcome",
"from": "Acme <hello@yourdomain.com>",
"subject": "Welcome, {{{NAME}}}",
"html": "<p>Hi {{{NAME}}}</p>",
"variables": [
{
"key": "NAME",
"type": "string",
"fallback_value": "there"
}
]
},
)
print(res.json())<?php
$ch = curl_init('https://post-waves.com/templates');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer pw_xxxxxxxxx',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Welcome',
'alias' => 'welcome',
'from' => 'Acme <hello@yourdomain.com>',
'subject' => 'Welcome, {{{NAME}}}',
'html' => '<p>Hi {{{NAME}}}</p>',
'variables' => [
[
'key' => 'NAME',
'type' => 'string',
'fallback_value' => 'there',
],
],
]),
]);
$response = json_decode(curl_exec($ch), true);require "net/http"
require "json"
uri = URI("https://post-waves.com/templates")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer pw_xxxxxxxxx"
req["Content-Type"] = "application/json"
req.body = {
name: "Welcome",
alias: "welcome",
from: "Acme <hello@yourdomain.com>",
subject: "Welcome, {{{NAME}}}",
html: "<p>Hi {{{NAME}}}</p>",
variables: [
{
key: "NAME",
type: "string",
fallback_value: "there"
}
]
}.to_json
res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts JSON.parse(res.body)package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{"name":"Welcome","alias":"welcome","from":"Acme <hello@yourdomain.com>","subject":"Welcome, {{{NAME}}}","html":"<p>Hi {{{NAME}}}</p>","variables":[{"key":"NAME","type":"string","fallback_value":"there"}]}`)
req, _ := http.NewRequest("POST", "https://post-waves.com/templates", body)
req.Header.Set("Authorization", "Bearer pw_xxxxxxxxx")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(string(out))
}curl -X POST 'https://post-waves.com/templates' \
-H 'Authorization: Bearer pw_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{"name":"Welcome","alias":"welcome","from":"Acme <hello@yourdomain.com>","subject":"Welcome, {{{NAME}}}","html":"<p>Hi {{{NAME}}}</p>","variables":[{"key":"NAME","type":"string","fallback_value":"there"}]}'Try itPOST
/templatesNo key yet? Create one in the dashboard.