SDKs & Code Examples
No SDK installation required. Use any HTTP client in any language. All examples use the REST API with your API key.
Replace
qle_your_api_key and mail.yourdomain.com with your
real values throughout these examples.
JavaScript / TypeScript
Using fetch (no dependencies)
const AVIANISE_KEY = process.env.AVIANISE_API_KEY!;
async function sendEmail(params: {
to: string;
subject: string;
html: string;
}): Promise<{ id: string }> {
const res = await fetch("https://api.quolle.com/v1/emails/send", {
method: "POST",
headers: {
Authorization: `Bearer ${AVIANISE_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
from: "hello@mail.yourdomain.com",
to: params.to,
subject: params.subject,
html: params.html,
}),
});
if (!res.ok) {
const err = await res.json();
throw new Error(err.error ?? "Failed to send email");
}
return res.json();
}
// Usage
const { id } = await sendEmail({
to: "customer@example.com",
subject: "Your account is ready",
html: "<h1>Welcome aboard!</h1>",
});
console.log("Sent:", id);
Using axios
import axios from "axios";
const client = axios.create({
baseURL: "https://api.quolle.com/v1",
headers: { Authorization: `Bearer ${process.env.AVIANISE_API_KEY}` },
});
const { data } = await client.post("/emails/send", {
from: "hello@mail.yourdomain.com",
to: "customer@example.com",
subject: "Welcome!",
html: "<h1>Welcome!</h1>",
});
console.log(data.id);
Python
Using requests
import os
import requests
AVIANISE_KEY = os.environ["AVIANISE_API_KEY"]
def send_email(to: str, subject: str, html: str) -> dict:
response = requests.post(
"https://api.quolle.com/v1/emails/send",
headers={
"Authorization": f"Bearer {AVIANISE_KEY}",
"Content-Type": "application/json",
},
json={
"from": "hello@mail.yourdomain.com",
"to": to,
"subject": subject,
"html": html,
},
timeout=15,
)
response.raise_for_status()
return response.json()
result = send_email(
to="customer@example.com",
subject="Welcome to Acme",
html="<h1>Welcome!</h1><p>Your account is ready.</p>",
)
print(f"Email queued: {result['id']}")
Using httpx (async)
import os
import httpx
async def send_email_async(to: str, subject: str, html: str) -> dict:
async with httpx.AsyncClient() as client:
response = await client.post(
"https://api.quolle.com/v1/emails/send",
headers={"Authorization": f"Bearer {os.environ['AVIANISE_API_KEY']}"},
json={"from": "hello@mail.yourdomain.com", "to": to,
"subject": subject, "html": html},
)
response.raise_for_status()
return response.json()
PHP
Using Guzzle
<?php
use GuzzleHttp\Client;
$client = new Client([
'base_uri' => 'https://api.quolle.com/v1/',
'headers' => [
'Authorization' => 'Bearer ' . getenv('AVIANISE_API_KEY'),
'Content-Type' => 'application/json',
],
]);
$response = $client->post('emails/send', [
'json' => [
'from' => 'hello@mail.yourdomain.com',
'to' => 'customer@example.com',
'subject' => 'Welcome!',
'html' => '<h1>Welcome!</h1>',
],
]);
$data = json_decode($response->getBody(), true);
echo "Queued: " . $data['id'];
Using cURL (plain PHP)
<?php
function avianise_send(string $to, string $subject, string $html): array {
$ch = curl_init('https://api.quolle.com/v1/emails/send');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('AVIANISE_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'from' => 'hello@mail.yourdomain.com',
'to' => $to,
'subject' => $subject,
'html' => $html,
]),
]);
$body = curl_exec($ch);
curl_close($ch);
return json_decode($body, true);
}
$result = avianise_send('customer@example.com', 'Welcome!', '<h1>Hi!</h1>');
echo $result['id'];
Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
type SendRequest struct {
From string `json:"from"`
To string `json:"to"`
Subject string `json:"subject"`
HTML string `json:"html"`
}
type SendResponse struct {
ID string `json:"id"`
Status string `json:"status"`
Message string `json:"message"`
}
func sendEmail(to, subject, html string) (*SendResponse, error) {
payload, _ := json.Marshal(SendRequest{
From: "hello@mail.yourdomain.com",
To: to,
Subject: subject,
HTML: html,
})
req, _ := http.NewRequest("POST",
"https://api.quolle.com/v1/emails/send",
bytes.NewReader(payload),
)
req.Header.Set("Authorization", "Bearer "+os.Getenv("AVIANISE_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var result SendResponse
json.NewDecoder(resp.Body).Decode(&result)
return &result, nil
}
func main() {
result, err := sendEmail("customer@example.com", "Welcome!", "<h1>Welcome!</h1>")
if err != nil {
panic(err)
}
fmt.Println("Queued:", result.ID)
}
Ruby
require 'net/http'
require 'json'
require 'uri'
def send_email(to:, subject:, html:)
uri = URI('https://api.quolle.com/v1/emails/send')
req = Net::HTTP::Post.new(uri)
req['Authorization'] = "Bearer #{ENV['AVIANISE_API_KEY']}"
req['Content-Type'] = 'application/json'
req.body = {
from: 'hello@mail.yourdomain.com',
to: to,
subject: subject,
html: html
}.to_json
Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
end
response = send_email(
to: 'customer@example.com',
subject: 'Welcome!',
html: '<h1>Welcome to Acme</h1>'
)
puts JSON.parse(response.body)['id']
React Email
Use React Email to build beautiful transactional email templates as React components, then pass the rendered HTML to Avianise.
npm install @react-email/render @react-email/components
WelcomeEmail.tsx
import { Html, Body, Heading, Text, Button } from "@react-email/components";
export function WelcomeEmail({ name }: { name: string }) {
return (
<Html>
<Body style={{ fontFamily: "Inter, sans-serif", background: "#fff" }}>
<Heading>Welcome, {name}!</Heading>
<Text>Thanks for joining. Get started below.</Text>
<Button href="https://yourapp.com/dashboard"
style={{ background: "#7c3aed", color: "#fff", padding: "12px 24px" }}>
Go to Dashboard
</Button>
</Body>
</Html>
);
}
send.ts
import { render } from "@react-email/render";
import { WelcomeEmail } from "./WelcomeEmail";
const html = await render(<WelcomeEmail name="Tosin" />);
const res = await fetch("https://api.quolle.com/v1/emails/send", {
method: "POST",
headers: {
"Authorization": "Bearer qle_your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
from: "hello@mail.yourdomain.com",
to: "tosin@example.com",
subject: "Welcome to our app!",
html, // pass the pre-rendered HTML
}),
});
const { id } = await res.json();
console.log("Sent:", id);
Client-side rendering. React Email renders on your server or build machine
using
@react-email/render. The resulting HTML is plain string — pass it
to Avianise as the html field. No special API support needed.
Batch sending
Send multiple emails in one API call (max 50 per batch):
const users = [
{ email: "alice@example.com", name: "Alice" },
{ email: "bob@example.com", name: "Bob" },
];
const { data } = await client.post("/emails/batch", {
emails: users.map(u => ({
from: "hello@mail.yourdomain.com",
to: u.email,
subject: `Hi ${u.name}, welcome!`,
html: `<p>Hi ${u.name}, thanks for signing up!</p>`,
})),
});
console.log(`Queued ${data.queued} emails:`, data.ids);
Check delivery status
// After sending, poll the email status
async function waitForDelivery(emailId: string, maxAttempts = 5): Promise<string> {
for (let i = 0; i < maxAttempts; i++) {
await new Promise(r => setTimeout(r, 2000)); // wait 2s between checks
const { data } = await client.get(`/emails/${emailId}`);
if (data.status === "delivered" || data.status === "failed") {
return data.status;
}
}
return "unknown";
}
Prefer webhooks over polling. For production, set up
webhooks to receive delivery notifications instantly
rather than polling the status endpoint.