Create an email template
curl --request POST \
--url https://app.alvahq.com/api/v1/email-templates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Cold outreach — signal line",
"subject": "Quick thought for {{company.name}}",
"body": "Hi {{contact.firstName}},\n\n{{company.custom.signal_line}}\n\nWould you have 15 minutes next week?",
"usageGuidance": "Use when the company custom field signal_line has been populated."
}
'import requests
url = "https://app.alvahq.com/api/v1/email-templates"
payload = {
"name": "Cold outreach — signal line",
"subject": "Quick thought for {{company.name}}",
"body": "Hi {{contact.firstName}},
{{company.custom.signal_line}}
Would you have 15 minutes next week?",
"usageGuidance": "Use when the company custom field signal_line has been populated."
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Cold outreach — signal line',
subject: 'Quick thought for {{company.name}}',
body: JSON.stringify('Hi {{contact.firstName}},\n\n{{company.custom.signal_line}}\n\nWould you have 15 minutes next week?'),
usageGuidance: 'Use when the company custom field signal_line has been populated.'
})
};
fetch('https://app.alvahq.com/api/v1/email-templates', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.alvahq.com/api/v1/email-templates",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Cold outreach — signal line',
'subject' => 'Quick thought for {{company.name}}',
'body' => 'Hi {{contact.firstName}},
{{company.custom.signal_line}}
Would you have 15 minutes next week?',
'usageGuidance' => 'Use when the company custom field signal_line has been populated.'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.alvahq.com/api/v1/email-templates"
payload := strings.NewReader("{\n \"name\": \"Cold outreach — signal line\",\n \"subject\": \"Quick thought for {{company.name}}\",\n \"body\": \"Hi {{contact.firstName}},\\n\\n{{company.custom.signal_line}}\\n\\nWould you have 15 minutes next week?\",\n \"usageGuidance\": \"Use when the company custom field signal_line has been populated.\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.alvahq.com/api/v1/email-templates")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Cold outreach — signal line\",\n \"subject\": \"Quick thought for {{company.name}}\",\n \"body\": \"Hi {{contact.firstName}},\\n\\n{{company.custom.signal_line}}\\n\\nWould you have 15 minutes next week?\",\n \"usageGuidance\": \"Use when the company custom field signal_line has been populated.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.alvahq.com/api/v1/email-templates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Cold outreach — signal line\",\n \"subject\": \"Quick thought for {{company.name}}\",\n \"body\": \"Hi {{contact.firstName}},\\n\\n{{company.custom.signal_line}}\\n\\nWould you have 15 minutes next week?\",\n \"usageGuidance\": \"Use when the company custom field signal_line has been populated.\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Cold outreach — signal line",
"subject": "Quick thought for {{company.name}}",
"body": "Hi {{contact.firstName}},\n\n{{company.custom.signal_line}}\n\nWould you have 15 minutes next week?",
"groupId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"usageGuidance": "<string>",
"mergeFieldsUsed": [
"<string>"
],
"parentTemplateId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"rootTemplateId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"aiGenerated": true,
"usageCount": 123,
"lastUsedAt": "2023-11-07T05:31:56Z",
"sentCount": 123,
"openCount": 123,
"replyCount": 123,
"clickCount": 123,
"bounceCount": 123,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
},
"resource": "<string>"
}{
"error": "Unauthorised",
"message": "Invalid or revoked API key"
}{
"error": "Unprocessable Entity",
"message": "Validation failed",
"details": {
"name": [
"Name is required"
]
}
}Email Templates
Create an email template
Create an email template. Put merge tags such as {{contact.firstName}} or {{company.custom.signal_line}} in subject and body. mergeFieldsUsed is computed server-side. Available custom-field keys come from GET /api/v1/custom-fields.
POST
/
api
/
v1
/
email-templates
Create an email template
curl --request POST \
--url https://app.alvahq.com/api/v1/email-templates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Cold outreach — signal line",
"subject": "Quick thought for {{company.name}}",
"body": "Hi {{contact.firstName}},\n\n{{company.custom.signal_line}}\n\nWould you have 15 minutes next week?",
"usageGuidance": "Use when the company custom field signal_line has been populated."
}
'import requests
url = "https://app.alvahq.com/api/v1/email-templates"
payload = {
"name": "Cold outreach — signal line",
"subject": "Quick thought for {{company.name}}",
"body": "Hi {{contact.firstName}},
{{company.custom.signal_line}}
Would you have 15 minutes next week?",
"usageGuidance": "Use when the company custom field signal_line has been populated."
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Cold outreach — signal line',
subject: 'Quick thought for {{company.name}}',
body: JSON.stringify('Hi {{contact.firstName}},\n\n{{company.custom.signal_line}}\n\nWould you have 15 minutes next week?'),
usageGuidance: 'Use when the company custom field signal_line has been populated.'
})
};
fetch('https://app.alvahq.com/api/v1/email-templates', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.alvahq.com/api/v1/email-templates",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Cold outreach — signal line',
'subject' => 'Quick thought for {{company.name}}',
'body' => 'Hi {{contact.firstName}},
{{company.custom.signal_line}}
Would you have 15 minutes next week?',
'usageGuidance' => 'Use when the company custom field signal_line has been populated.'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.alvahq.com/api/v1/email-templates"
payload := strings.NewReader("{\n \"name\": \"Cold outreach — signal line\",\n \"subject\": \"Quick thought for {{company.name}}\",\n \"body\": \"Hi {{contact.firstName}},\\n\\n{{company.custom.signal_line}}\\n\\nWould you have 15 minutes next week?\",\n \"usageGuidance\": \"Use when the company custom field signal_line has been populated.\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.alvahq.com/api/v1/email-templates")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Cold outreach — signal line\",\n \"subject\": \"Quick thought for {{company.name}}\",\n \"body\": \"Hi {{contact.firstName}},\\n\\n{{company.custom.signal_line}}\\n\\nWould you have 15 minutes next week?\",\n \"usageGuidance\": \"Use when the company custom field signal_line has been populated.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.alvahq.com/api/v1/email-templates")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Cold outreach — signal line\",\n \"subject\": \"Quick thought for {{company.name}}\",\n \"body\": \"Hi {{contact.firstName}},\\n\\n{{company.custom.signal_line}}\\n\\nWould you have 15 minutes next week?\",\n \"usageGuidance\": \"Use when the company custom field signal_line has been populated.\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Cold outreach — signal line",
"subject": "Quick thought for {{company.name}}",
"body": "Hi {{contact.firstName}},\n\n{{company.custom.signal_line}}\n\nWould you have 15 minutes next week?",
"groupId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"usageGuidance": "<string>",
"mergeFieldsUsed": [
"<string>"
],
"parentTemplateId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"rootTemplateId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"aiGenerated": true,
"usageCount": 123,
"lastUsedAt": "2023-11-07T05:31:56Z",
"sentCount": 123,
"openCount": 123,
"replyCount": 123,
"clickCount": 123,
"bounceCount": 123,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
},
"resource": "<string>"
}{
"error": "Unauthorised",
"message": "Invalid or revoked API key"
}{
"error": "Unprocessable Entity",
"message": "Validation failed",
"details": {
"name": [
"Name is required"
]
}
}Authorizations
API key from Settings > Developer. Format: alva_sk_...
Body
application/json