SDKs & Libraries
Txtly provides a straightforward REST API that works with any HTTP client. Official SDKs are coming soon — in the meantime, here are examples in popular languages to get you started quickly.
Node.js / TypeScript
Use the built-in fetch API (Node 18+) or any HTTP library like Axios:
const response = await fetch("https://api.txtly.com.au/v1/emails", {
method: "POST",
headers: {
"Authorization": "Bearer tx_your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
from: "hello@yourdomain.com",
to: "user@example.com",
subject: "Hello from Txtly",
html: "<p>Your first email!</p>",
}),
});
const email = await response.json();
console.log(email.id); // em_abc123Helper wrapper
Create a thin wrapper for cleaner usage across your project:
class Txtly {
private baseUrl = "https://api.txtly.com.au/v1";
constructor(private apiKey: string) {}
private async request(path: string, options?: RequestInit) {
const res = await fetch(this.baseUrl + path, {
...options,
headers: {
"Authorization": `Bearer ${this.apiKey}`,
"Content-Type": "application/json",
...options?.headers,
},
});
if (!res.ok) throw new Error(await res.text());
return res.json();
}
async sendEmail(params: {
from: string;
to: string;
subject: string;
html?: string;
text?: string;
}) {
return this.request("/emails", {
method: "POST",
body: JSON.stringify(params),
});
}
async getEmail(id: string) {
return this.request(`/emails/${id}`);
}
}
// Usage
const txtly = new Txtly("tx_your_api_key");
const email = await txtly.sendEmail({
from: "hello@yourdomain.com",
to: "user@example.com",
subject: "Hello!",
html: "<p>Welcome aboard.</p>",
});Python
Use the requests or httpx library:
import requests
response = requests.post(
"https://api.txtly.com.au/v1/emails",
headers={
"Authorization": "Bearer tx_your_api_key",
"Content-Type": "application/json",
},
json={
"from": "hello@yourdomain.com",
"to": "user@example.com",
"subject": "Hello from Txtly",
"html": "<p>Your first email!</p>",
},
)
email = response.json()
print(email["id"]) # em_abc123import httpx
async with httpx.AsyncClient() as client:
response = await client.post(
"https://api.txtly.com.au/v1/emails",
headers={
"Authorization": "Bearer tx_your_api_key",
"Content-Type": "application/json",
},
json={
"from": "hello@yourdomain.com",
"to": "user@example.com",
"subject": "Hello from Txtly",
"html": "<p>Your first email!</p>",
},
)
email = response.json()
print(email["id"])cURL
Test the API directly from your terminal:
curl -X POST https://api.txtly.com.au/v1/emails \\
-H "Authorization: Bearer tx_your_api_key" \\
-H "Content-Type: application/json" \\
-d '{
"from": "hello@yourdomain.com",
"to": "user@example.com",
"subject": "Hello from Txtly",
"html": "<p>Your first email!</p>"
}'curl https://api.txtly.com.au/v1/domains \\
-H "Authorization: Bearer tx_your_api_key"curl -X POST https://api.txtly.com.au/v1/domains/dom_abc123/verify \\
-H "Authorization: Bearer tx_your_api_key"SMTP
Use Txtly as an SMTP relay for applications that don't support REST APIs. Configure your application with the following settings:
Host: smtp.txtly.com.au
Port: 587 (STARTTLS) or 465 (TLS)
Username: txtly
Password: tx_your_api_keyOfficial SDKs (coming soon)
We're building official SDKs for Node.js, Python, Go, Ruby, and PHP. These will include full type definitions, automatic retries, pagination helpers, and webhook signature verification utilities. Join the waitlist at txtly.com.au/sdks to be notified when they launch.