SDKs
The official SDKs for Node.js, Python and PHP have no dependencies, retry errors correctly, send idempotency keys by themselves and verify webhook signatures.
| Node.js | Python | PHP | |
|---|---|---|---|
| Installation | npm install sendtide |
pip install sendtide |
composer require sendtide/sendtide-php |
| Requirements | Node 18 or newer, ESM with TypeScript types | Python 3.9 or newer, standard library only, fully typed | PHP 8.1 or newer with ext-curl and ext-json |
| Client | new Sendtide({ apiKey }) |
Sendtide(api_key) |
new Client($apiKey) |
All three read the key from the environment variable SENDTIDE_API_KEY otherwise. For Laravel, Symfony Mailer, Django and Next.js there are framework packages, for the command line the CLI. For another language use SMTP or the REST API directly, see Java and .NET; the OpenAPI specification loads into any generator.
Sending
import { Sendtide } from "sendtide";
const sendtide = new Sendtide({ apiKey: process.env.SENDTIDE_API_KEY });
const { id, status } = await sendtide.emails.send({
from: "Acme <hello@example.com>",
to: "anna@example.org",
template: "welcome",
locale: "en",
data: { name: "Anna" },
});
from sendtide import Sendtide
client = Sendtide() # reads SENDTIDE_API_KEY
res = client.emails.send({
"from": "Acme <hello@example.com>",
"to": "anna@example.org",
"template": "welcome",
"locale": "en",
"data": {"name": "Anna"},
})
print(res["id"], res["status"])
<?php
use Sendtide\Client;
$sendtide = new Client(getenv('SENDTIDE_API_KEY'));
$res = $sendtide->emails->send([
'from' => 'Acme <hello@example.com>',
'to' => 'anna@example.org',
'template' => 'welcome',
'locale' => 'en',
'data' => ['name' => 'Anna'],
]);
Options
| Option | Node.js | Python | PHP |
|---|---|---|---|
| Base URL | baseUrl |
base_url |
baseUrl |
| Timeout per attempt | timeout (ms, default 30,000) |
timeout (s, default 30) |
timeout (s, default 30) |
| Retries | maxRetries (2) |
max_retries (2) |
maxRetries (2) |
| API version | apiVersion |
api_version |
apiVersion |
Retries and idempotency
Calls that create email (send, batch, sendMime) always send an Idempotency-Key: a random UUID, or your own that you pass per call. The key stays the same across retries. Network errors, 429 (honoring Retry-After) and 5xx are retried with exponential backoff and jitter. A POST without an idempotency key is only retried on 429.
await sendtide.emails.send(params, { idempotencyKey: "order-42" });
client.emails.send(params, idempotency_key="order-42")
$sendtide->emails->send($params, idempotencyKey: 'order-42');
Batch, attachments, scheduling
import { attachmentFromFile } from "sendtide";
await sendtide.emails.batch({
defaults: { from: "hello@example.com", template: "invoice", locale: "en" },
emails: [
{ to: "anna@example.org", data: { amount: "120.00" } },
{ to: "ben@example.org", data: { amount: "80.00" } },
],
});
await sendtide.emails.send({
from: "hello@example.com",
to: "anna@example.org",
subject: "Your invoice",
html: "<p>Hello</p>",
attachments: [await attachmentFromFile("./invoice.pdf")],
send_at: "2026-12-01T08:00:00Z",
});
await sendtide.emails.cancel(id); // while the email is queued
from sendtide import attachment_from_path
client.emails.batch(
[
{"to": "anna@example.org", "data": {"amount": "120.00"}},
{"to": "ben@example.org", "data": {"amount": "80.00"}},
],
defaults={"from": "hello@example.com", "template": "invoice", "locale": "en"},
)
res = client.emails.send({
"from": "hello@example.com",
"to": "anna@example.org",
"subject": "Your invoice",
"html": "<p>Hello</p>",
"attachments": [attachment_from_path("invoice.pdf")],
"send_at": "2026-12-01T08:00:00Z",
})
client.emails.cancel(res["id"]) # while the email is queued
use Sendtide\Attachment;
$sendtide->emails->batch(
[
['to' => 'anna@example.org', 'data' => ['amount' => '120.00']],
['to' => 'ben@example.org', 'data' => ['amount' => '80.00']],
],
defaults: ['from' => 'hello@example.com', 'template' => 'invoice', 'locale' => 'en'],
);
$res = $sendtide->emails->send([
'from' => 'hello@example.com',
'to' => 'anna@example.org',
'subject' => 'Your invoice',
'html' => '<p>Hello</p>',
'attachments' => [Attachment::fromPath('/tmp/invoice.pdf')],
'send_at' => '2026-12-01T08:00:00Z',
]);
$sendtide->emails->cancel($res['id']); // while the email is queued
The limits for attachments are in Sending email.
Verify webhooks
Always use the raw body, not the parsed JSON. Signatures older than 300 seconds are rejected.
import express from "express";
import { verifyWebhook } from "sendtide";
app.post("/webhooks/sendtide", express.raw({ type: "application/json" }), (req, res) => {
try {
const event = verifyWebhook(req.body, req.get("Sendtide-Signature"), process.env.SENDTIDE_WEBHOOK_SECRET);
console.log(event.type, event.data);
res.sendStatus(200);
} catch {
res.sendStatus(400);
}
});
from flask import Flask, request
from sendtide import SendtideError, verify_webhook
app = Flask(__name__)
@app.post("/webhooks/sendtide")
def sendtide_webhook():
try:
event = verify_webhook(request.get_data(), request.headers.get("Sendtide-Signature"), WEBHOOK_SECRET)
except SendtideError:
return "", 400
print(event["type"], event["data"])
return "", 200
use Sendtide\SendtideError;
use Sendtide\Webhook;
try {
$event = Webhook::verify(
file_get_contents('php://input'),
$_SERVER['HTTP_SENDTIDE_SIGNATURE'] ?? null,
getenv('SENDTIDE_WEBHOOK_SECRET'),
);
} catch (SendtideError $e) {
http_response_code(400);
exit;
}
http_response_code(200);
For tests you build a header with signWebhook(secret, unixSeconds, body) (Node.js), sign_webhook(...) (Python) or Webhook::sign(...) (PHP). How the signature works without an SDK is described in Webhooks.
Pagination
Lists return {data, next_cursor}. The …All functions page by themselves:
for await (const mail of sendtide.emails.searchAll({ q: "status:bounced" })) console.log(mail.id);
for mail in client.emails.search_all("status:bounced"):
print(mail["id"])
foreach ($sendtide->emails->searchAll(['q' => 'status:bounced']) as $mail) { echo $mail['id']; }
Errors
Every failure is raised as a SendtideError. It carries status (0 if no HTTP answer arrived), code, message, field and the request id of the answer (requestId, in Python request_id).
import { SendtideError } from "sendtide";
try {
await sendtide.emails.send({ from: "hello@example.com", to: "not-an-address", subject: "Hi", text: "Hi" });
} catch (err) {
if (err instanceof SendtideError) console.error(err.status, err.code, err.field, err.requestId);
// 422 validation_error to[0] req_…
}
from sendtide import SendtideError
try:
client.emails.send({"from": "hello@example.com", "to": "not-an-address", "subject": "Hi", "text": "Hi"})
except SendtideError as e:
print(e.status, e.code, e.field, e.request_id) # 422 validation_error to[0] req_…
use Sendtide\SendtideError;
try {
$sendtide->emails->send(['from' => 'hello@example.com', 'to' => 'not-an-address', 'subject' => 'Hi', 'text' => 'Hi']);
} catch (SendtideError $e) {
echo $e->status, ' ', $e->code, ' ', $e->field, ' ', $e->requestId;
}
Resources
All groups of the API exist as resources, such as emails, batches, templates, domains, webhooks, inbound, suppressions, tenants, streams, keys, exports and stats. The exact methods are in the README of each SDK, the endpoints in the API reference.