const response = await fetch('https://api.emailit.com/v2/emails', {
method: 'POST',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
body: JSON.stringify({
from: 'Your Company <hello@yourdomain.com>',
to: ['recipient1@example.com', 'recipient2@example.com'],
subject: 'Hello World',
html: '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
tracking: {
loads: true,
clicks: true
}
})
});
const result = await response.json();
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.emailit.com/v2/emails',
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([
'from' => 'Your Company <hello@yourdomain.com>',
'to' => ['recipient1@example.com', 'recipient2@example.com'],
'subject' => 'Hello World',
'html' => '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
'tracking' => [
'loads' => true,
'clicks' => true
]
]),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type: application/json'
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
$result = json_decode($response, true);
print_r($result);
}
import requests
response = requests.post(
'https://api.emailit.com/v2/emails',
headers={
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
json={
'from': 'Your Company <hello@yourdomain.com>',
'to': ['recipient1@example.com', 'recipient2@example.com'],
'subject': 'Hello World',
'html': '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
'tracking': {
'loads': True,
'clicks': True
}
}
)
result = response.json()
print(result)
require 'net/http'
require 'json'
uri = URI('https://api.emailit.com/v2/emails')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer em_test_51RxCWJ...vS00p61e0qRE'
request['Content-Type'] = 'application/json'
request.body = {
from: 'Your Company <hello@yourdomain.com>',
to: ['recipient1@example.com', 'recipient2@example.com'],
subject: 'Hello World',
html: '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
tracking: {
loads: true,
clicks: true
}
}.to_json
response = http.request(request)
result = JSON.parse(response.body)
puts result
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.emailit.com/v2/emails"
data := map[string]interface{}{
"from": "Your Company <hello@yourdomain.com>",
"to": []string{"recipient1@example.com", "recipient2@example.com"},
"subject": "Hello World",
"html": "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
"tracking": map[string]bool{
"loads": true,
"clicks": true,
},
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
use reqwest;
use serde_json::{json, Value};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let response = client
.post("https://api.emailit.com/v2/emails")
.header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
.header("Content-Type", "application/json")
.json(&json!({
"from": "Your Company <hello@yourdomain.com>",
"to": ["recipient1@example.com", "recipient2@example.com"],
"subject": "Hello World",
"html": "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
"tracking": {
"loads": true,
"clicks": true
}
}))
.send()
.await?;
let result: Value = response.json().await?;
println!("{:?}", result);
Ok(())
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.http.HttpRequest.BodyPublishers;
public class SendEmail {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
String jsonBody = """
{
"from": "Your Company <hello@yourdomain.com>",
"to": ["recipient1@example.com", "recipient2@example.com"],
"subject": "Hello World",
"html": "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
"tracking": {"loads": true, "clicks": true}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.emailit.com/v2/emails"))
.header("Authorization", "Bearer em_test_51RxCWJ...vS00p61e0qRE")
.header("Content-Type", "application/json")
.POST(BodyPublishers.ofString(jsonBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class SendEmail
{
public static async Task Main()
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization",
"Bearer em_test_51RxCWJ...vS00p61e0qRE");
var data = new {
from = "Your Company <hello@yourdomain.com>",
to = new[] { "recipient1@example.com", "recipient2@example.com" },
subject = "Hello World",
html = "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
tracking = new { loads = true, clicks = true }
};
var json = JsonConvert.SerializeObject(data);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://api.emailit.com/v2/emails", content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
}
curl -X POST https://api.emailit.com/v2/emails \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json" \
-d '{
"from": "Your Company <hello@yourdomain.com>",
"to": ["recipient1@example.com", "recipient2@example.com"],
"subject": "Hello World",
"html": "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
"tracking": {
"loads": true,
"clicks": true
}
}'
Send email
const response = await fetch('https://api.emailit.com/v2/emails', {
method: 'POST',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
body: JSON.stringify({
from: 'Your Company <hello@yourdomain.com>',
to: ['recipient1@example.com', 'recipient2@example.com'],
subject: 'Hello World',
html: '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
tracking: {
loads: true,
clicks: true
}
})
});
const result = await response.json();
const response = await fetch('https://api.emailit.com/v2/emails', {
method: 'POST',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
body: JSON.stringify({
from: 'hello@yourdomain.com',
to: 'user@example.com',
template: 'welcome_email',
variables: {
name: 'John Doe',
company: 'Acme Inc',
activation_url: 'https://example.com/activate?token=abc123'
}
})
});
const result = await response.json();
curl -X POST https://api.emailit.com/v2/emails \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json" \
-d '{
"from": "hello@yourdomain.com",
"to": "user@example.com",
"template": "welcome_email",
"variables": {
"name": "John Doe",
"company": "Acme Inc",
"activation_url": "https://example.com/activate?token=abc123"
}
}'
Send with template
const response = await fetch('https://api.emailit.com/v2/emails', {
method: 'POST',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
body: JSON.stringify({
from: 'hello@yourdomain.com',
to: 'user@example.com',
template: 'welcome_email',
variables: {
name: 'John Doe',
company: 'Acme Inc',
activation_url: 'https://example.com/activate?token=abc123'
}
})
});
const result = await response.json();
const response = await fetch('https://api.emailit.com/v2/emails', {
method: 'POST',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
body: JSON.stringify({
from: 'invoices@yourdomain.com',
to: 'customer@example.com',
subject: 'Your Invoice #12345',
html: '<p>Please find your invoice attached.</p>',
attachments: [
{
filename: 'invoice-12345.pdf',
content: 'JVBERi0xLjQKJcOkw7zDqc...', // base64 encoded
content_type: 'application/pdf'
}
]
})
});
const result = await response.json();
curl -X POST https://api.emailit.com/v2/emails \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json" \
-d '{
"from": "invoices@yourdomain.com",
"to": "customer@example.com",
"subject": "Your Invoice #12345",
"html": "<p>Please find your invoice attached.</p>",
"attachments": [
{
"filename": "invoice-12345.pdf",
"content": "JVBERi0xLjQKJcOkw7zDqc...",
"content_type": "application/pdf"
}
]
}'
Send with attachment
const response = await fetch('https://api.emailit.com/v2/emails', {
method: 'POST',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
body: JSON.stringify({
from: 'invoices@yourdomain.com',
to: 'customer@example.com',
subject: 'Your Invoice #12345',
html: '<p>Please find your invoice attached.</p>',
attachments: [
{
filename: 'invoice-12345.pdf',
content: 'JVBERi0xLjQKJcOkw7zDqc...', // base64 encoded
content_type: 'application/pdf'
}
]
})
});
const result = await response.json();
const response = await fetch('https://api.emailit.com/v2/emails', {
method: 'POST',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
body: JSON.stringify({
from: 'reminders@yourdomain.com',
to: 'user@example.com',
subject: 'Appointment Reminder',
html: '<p>Your appointment is tomorrow at 2 PM.</p>',
scheduled_at: 'tomorrow at 9am'
})
});
const result = await response.json();
curl -X POST https://api.emailit.com/v2/emails \
-H "Authorization: Bearer em_test_51RxCWJ...vS00p61e0qRE" \
-H "Content-Type: application/json" \
-d '{
"from": "reminders@yourdomain.com",
"to": "user@example.com",
"subject": "Appointment Reminder",
"html": "<p>Your appointment is tomorrow at 2 PM.</p>",
"scheduled_at": "2026-01-10T09:00:00Z"
}'
Schedule email
const response = await fetch('https://api.emailit.com/v2/emails', {
method: 'POST',
headers: {
'Authorization': 'Bearer em_test_51RxCWJ...vS00p61e0qRE',
'Content-Type': 'application/json'
},
body: JSON.stringify({
from: 'reminders@yourdomain.com',
to: 'user@example.com',
subject: 'Appointment Reminder',
html: '<p>Your appointment is tomorrow at 2 PM.</p>',
scheduled_at: 'tomorrow at 9am'
})
});
const result = await response.json();
{
"object": "email",
"id": "em_abc123xyz789def456ghi012jkl345",
"ids": {
"recipient1@example.com": "em_abc123xyz789def456ghi012jkl345",
"recipient2@example.com": "em_def456abc789ghi012jkl345mno678"
},
"token": "abc123xyz789",
"message_id": "<abc123xyz789@yourdomain.com>",
"from": "hello@yourdomain.com",
"to": ["recipient1@example.com", "recipient2@example.com"],
"cc": ["cc@example.com"],
"bcc": ["bcc@example.com"],
"subject": "Hello World",
"status": "pending",
"scheduled_at": null,
"created_at": "2026-01-08T12:00:00.123456Z",
"tracking": {
"loads": true,
"clicks": true
}
}
{
"object": "email",
"id": "em_abc123xyz789def456ghi012jkl345",
"token": "abc123xyz789",
"message_id": "<abc123xyz789@yourdomain.com>",
"from": "hello@yourdomain.com",
"to": ["user@example.com"],
"subject": "Appointment Reminder",
"status": "scheduled",
"scheduled_at": "2026-01-10T09:00:00.000Z",
"created_at": "2026-01-08T12:00:00.123456Z",
"tracking": {
"loads": true,
"clicks": true
}
}
{
"error": "Validation failed",
"validation_errors": [
"Missing required field: from",
"Invalid to email address at index 0: invalid-email"
]
}
{
"error": "Template not found",
"details": "Template 'welcome_email' not found or not published"
}
{
"error": "Message too large",
"details": "Message size (45MB) exceeds maximum allowed size of 40MB"
}
{
"error": "From/Sender domain is not valid or not verified",
"details": "The domain from email address 'sender@unverified.com' is not verified in your workspace"
}
{
"error": "Rate limit exceeded",
"message": "Too many requests. Maximum 10 messages per second allowed.",
"limit": 10,
"current": 11,
"retry_after": 1
}
Responses
{
"object": "email",
"id": "em_abc123xyz789def456ghi012jkl345",
"ids": {
"recipient1@example.com": "em_abc123xyz789def456ghi012jkl345",
"recipient2@example.com": "em_def456abc789ghi012jkl345mno678"
},
"token": "abc123xyz789",
"message_id": "<abc123xyz789@yourdomain.com>",
"from": "hello@yourdomain.com",
"to": ["recipient1@example.com", "recipient2@example.com"],
"cc": ["cc@example.com"],
"bcc": ["bcc@example.com"],
"subject": "Hello World",
"status": "pending",
"scheduled_at": null,
"created_at": "2026-01-08T12:00:00.123456Z",
"tracking": {
"loads": true,
"clicks": true
}
}