Getting started
Languages and SDKs
Call the isent API from cURL, Node.js, Python, Go, Ruby and PHP with the HTTP client you already use.
Official isent SDK packages are not published yet. Every example in these docs uses the HTTP client that comes with each language (Python uses the requests library), so there is nothing isent-specific to install. This page will list the packages when they ship.
The API is plain JSON over HTTPS at https://isent.dev/api/v1, so any HTTP client works. Read the key from an environment variable (ISENT_API_KEY in these examples) and send it as a bearer token.
| Language | Client | Needs |
|---|---|---|
| cURL | curl | Any shell |
| Node.js | fetch | Node.js 18 or later, Bun or Deno |
| Python | requests | pip install requests |
| Go | net/http | The standard library |
| Ruby | net/http | The standard library |
| PHP | The curl extension | ext-curl, on by default in most builds |
Send an email
curl -X POST https://isent.dev/api/v1/emails \
-H "Authorization: Bearer $ISENT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Acme <hello@mail.acme.com>",
"to": "amira@acme.com",
"subject": "Your first isent email",
"html": "<p>It works.</p>",
"text": "It works."
}'Handle errors and rate limits
Errors come back as JSON with a stable name. A 429 named rate_limit_exceeded carries a retry-after header in seconds: wait and try again. A 429 named monthly_quota_exceeded will not pass by waiting. The errors table lists every name.
const BASE = "https://isent.dev/api/v1";
export async function isent(path, init = {}, attempt = 0) {
const res = await fetch(`${BASE}${path}`, {
...init,
headers: {
Authorization: `Bearer ${process.env.ISENT_API_KEY}`,
"Content-Type": "application/json",
...init.headers,
},
});
const data = await res.json();
if (res.status === 429 && data.name === "rate_limit_exceeded" && attempt < 3) {
const seconds = Number(res.headers.get("retry-after") ?? 1);
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
return isent(path, init, attempt + 1);
}
if (!res.ok) throw new Error(`${res.status} ${data.name}: ${data.message}`);
return data;
}Page through a list
List endpoints return { "object": "list", "has_more", "data" }, newest first. Pass the last id you received as after to read the next page. See pagination.
let after;
do {
const url = new URL("https://isent.dev/api/v1/contacts");
url.searchParams.set("limit", "100");
if (after) url.searchParams.set("after", after);
const res = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.ISENT_API_KEY}` },
});
const page = await res.json();
for (const contact of page.data) console.log(contact.email);
after = page.has_more ? page.data.at(-1).id : undefined;
} while (after);