Get started

Sendtern SDKs

Install a Sendtern SDK and send an email from your server.

Sendtern has SDKs for Node.js and TypeScript, Python, Ruby, PHP, Laravel, Go, Rust, Java, and .NET. Each supports sending, batch sending, retrieving an email by ID, and capturing a message in Email Playground.

Install the SDK

Run the command in your project. Packages are distributed from the Sendtern SDK release.

1npm install https://github.com/Sendtern/sendtern-sdks/releases/download/v0.2.0/sendtern-sdk-0.2.0.tgz
SDKRuntime
Node.js / TypeScriptNode.js 18+
PythonPython 3.9+
RubyRuby 3.1+
PHPPHP 8.1+, cURL, Composer
LaravelLaravel 12+, PHP cURL, Composer
GoGo 1.21+
RustRust 1.88+
JavaJava 17+
.NET.NET SDK 8+

For Java, save the example as SendExample.java in the same directory as the JAR and run java --class-path sendtern-0.2.0.jar SendExample.java.

For Laravel, add this entry to config/services.php and append the example to routes/console.php. Run php artisan sendtern:example from the project directory.

1'sendtern' => [
2    'key' => env('SENDTERN_API_KEY'),
3    'base_url' => env('SENDTERN_BASE_URL', 'https://sendtern.com'),
4],

Send your first email

Create a sending-only API key and store it on your server as SENDTERN_API_KEY. Replace the sender with an address on your verified domain and use a recipient address you control.

1import { Sendtern } from '@sendtern/sdk';
2
3const client = new Sendtern(process.env.SENDTERN_API_KEY);
4const result = await client.emails.send({
5  "from": "Acme <hello@mail.example.com>",
6  "to": "you@example.com",
7  "subject": "Hello from Sendtern",
8  "text": "This is your first Sendtern email."
9});
10console.log(result.id);

The response contains an email ID. Open Emails to follow delivery. A full-access key is required to fetch an email by ID through the API.

Test without sending

Open the Integration assistant and select your language for a sample that calls capture on the SDK. The message goes to Email Playground, which lets you inspect the HTML and headers before you configure a sending domain.

Batches and delivery status

Batch submission uses strict validation by default. Use permissive validation to accept valid rows and read errors with the original indexes. Email lookup returns last_event and the delivery timeline in events.

Handle errors and retries

SDK errors expose the HTTP status and the API error code when available. If your app retries a send or batch request, reuse the same idempotency key and payload. If a response includes Retry-After, wait for that interval before retrying.

See the API reference for request fields and error codes, or send with cURL from any environment with HTTP access.

Questions sent for AI answers are processed by Google. Leave out credentials and personal data.