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 install commands for your SDK in your project.
1npm install sendtern
| SDK | Runtime | Distribution |
|---|---|---|
| Node.js / TypeScript | Node.js 18+ | npm |
| Python | Python 3.9+ | GitHub release |
| Ruby | Ruby 3.1+ | GitHub release |
| PHP | PHP 8.1+, cURL, Composer | Packagist |
| Laravel | Laravel 12+, PHP cURL, Composer | Packagist |
| Go | Go 1.21+ | pkg.go.dev |
| Rust | Rust 1.88+ | GitHub source |
| Java | Java 17+ | GitHub release |
| .NET | .NET SDK 8+ | GitHub release |
For Java, save the example as SendExample.java in the same directory as the JAR and run java --class-path sendtern-0.3.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';
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.
List emails with a full-access project key. When the page reports has_more, keep the same filters and pass the last email ID as after.
Call other client endpoints
Use the SDK request method for JSON endpoints in the client OpenAPI specification. The download method returns the original bytes of binary endpoints listed in your deployment’s specification.
1const domains = await client.request('GET', '/domains');
2console.log(domains.data);
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.