Reference
SDKs and libraries
Official Emailit libraries for Node.js, PHP, Laravel, Python, Ruby, Go, Java, .NET and Rust, plus the MCP package and how to call the API over plain HTTP.
Emailit maintains open-source client libraries for nine languages and frameworks. Each one wraps the REST API with typed errors and the same resource names you see in the API reference. If your language isn’t listed, any HTTP client works.
Official libraries
All libraries are MIT-licensed and published from github.com/emailit.
| Language | Package | Install | Requires | Source |
|---|---|---|---|---|
| Node.js | @emailit/node |
npm install @emailit/node |
Node.js 18+ | emailit-node |
| PHP | emailit/emailit-php |
composer require emailit/emailit-php |
PHP 8.1+ | emailit-php |
| Laravel | emailit/emailit-laravel |
composer require emailit/emailit-laravel |
Laravel 10, 11 or 12 | emailit-laravel |
| Python | emailit |
pip install emailit |
Python 3.7+ | emailit-python |
| Ruby | emailit |
bundle add emailit |
Ruby 3.0+ | emailit-ruby |
| Go | github.com/emailit/emailit-go/v2 |
go get github.com/emailit/emailit-go/v2 |
Go 1.21+ | emailit-go |
| Java | com.emailit:emailit-java |
Maven or Gradle, see below | Java 11+ | emailit-java |
| .NET | Emailit |
dotnet add package Emailit |
.NET 8+ | emailit-dotnet |
| Rust | emailit |
cargo add emailit |
Rust 1.85+ and Tokio | emailit-rust |
For Java, add the dependency with the latest version listed in the repository:
<dependency>
<groupId>com.emailit</groupId>
<artifactId>emailit-java</artifactId>
<version>VERSION</version>
</dependency>implementation 'com.emailit:emailit-java:VERSION'Send an email
Every library takes your API key when you create the client. Load it from an environment variable rather than hard-coding it.
import { Emailit } from '@emailit/node';
const emailit = new Emailit(process.env.EMAILIT_API_KEY);
const email = await emailit.emails.send({
from: 'Acme <hello@acme.com>',
to: 'ada@example.com',
subject: 'Welcome to Acme',
html: '<p>Thanks for signing up.</p>',
});
console.log(email.id);require 'vendor/autoload.php';
$emailit = Emailit::client(getenv('EMAILIT_API_KEY'));
$email = $emailit->emails()->send([
'from' => 'Acme <hello@acme.com>',
'to' => 'ada@example.com',
'subject' => 'Welcome to Acme',
'html' => '<p>Thanks for signing up.</p>',
]);
echo $email->id;use Emailit\Laravel\Facades\Emailit;
$email = Emailit::emails()->send([
'from' => 'Acme <hello@acme.com>',
'to' => 'ada@example.com',
'subject' => 'Welcome to Acme',
'html' => '<p>Thanks for signing up.</p>',
]);import os
from emailit import EmailitClient
client = EmailitClient(os.environ["EMAILIT_API_KEY"])
email = client.emails.send({
"from": "Acme <hello@acme.com>",
"to": "ada@example.com",
"subject": "Welcome to Acme",
"html": "<p>Thanks for signing up.</p>",
})
print(email.id)require "emailit"
client = Emailit::EmailitClient.new(ENV.fetch("EMAILIT_API_KEY"))
email = client.emails.send(
from: "Acme <hello@acme.com>",
to: "ada@example.com",
subject: "Welcome to Acme",
html: "<p>Thanks for signing up.</p>"
)
puts email.idpackage main
import (
"fmt"
"os"
"github.com/emailit/emailit-go/v2"
)
func main() {
client := emailit.NewClient(os.Getenv("EMAILIT_API_KEY"))
email, err := client.Emails.Send(&emailit.SendEmailRequest{
From: "Acme <hello@acme.com>",
To: []string{"ada@example.com"},
Subject: "Welcome to Acme",
Html: "<p>Thanks for signing up.</p>",
})
if err != nil {
panic(err)
}
fmt.Println(email.Id)
}import com.emailit.*;
import com.emailit.params.*;
import java.util.List;
EmailitClient emailit = new EmailitClient(System.getenv("EMAILIT_API_KEY"));
EmailitObject email = emailit.emails().send(
EmailSendParams.builder()
.setFrom("Acme <hello@acme.com>")
.setTo(List.of("ada@example.com"))
.setSubject("Welcome to Acme")
.setHtml("<p>Thanks for signing up.</p>")
.build()
);
System.out.println(email.getString("id"));using Emailit;
using Emailit.Options;
using Emailit.Resources;
var emailit = new EmailitClient(Environment.GetEnvironmentVariable("EMAILIT_API_KEY"));
Email email = emailit.Emails.Send(new EmailSendOptions
{
From = "Acme <hello@acme.com>",
To = new[] { "ada@example.com" },
Subject = "Welcome to Acme",
Html = "<p>Thanks for signing up.</p>",
});
Console.WriteLine(email.Id);use emailit::types::CreateEmailBaseOptions;
use emailit::{Emailit, Result};
#[tokio::main]
async fn main() -> Result<()> {
let emailit = Emailit::new(&std::env::var("EMAILIT_API_KEY").expect("EMAILIT_API_KEY is not set"));
let options = CreateEmailBaseOptions::new(
"Acme <hello@acme.com>",
["ada@example.com"],
"Welcome to Acme",
)
.with_html("<p>Thanks for signing up.</p>");
let email = emailit.emails.send(options).await?;
println!("{:?}", email.id);
Ok(())
}curl https://api.emailit.com/v2/emails \
-H "Authorization: Bearer $EMAILIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Acme <hello@acme.com>",
"to": "ada@example.com",
"subject": "Welcome to Acme",
"html": "<p>Thanks for signing up.</p>"
}'The from address must be on a verified sending domain. Until your workspace has production access, you can only send to the account emails of workspace members.
What the libraries cover
Each library exposes the same services: emails, domains, API keys, audiences, subscribers, templates, suppressions, email verifications, email verification lists, webhooks, contacts and events. Errors are raised as typed exceptions or error values, for example an authentication error for 401, a rate-limit error for 429 and a validation error for 422, so you can handle each case separately.
Some newer endpoints aren’t wrapped yet, including forwarding an email, campaigns, automations, forms and DMARC reports. The libraries also don’t set the Idempotency-Key header. For those, call the endpoint over HTTP with the same API key, as shown below.
For framework-specific setup, including mail transports, webhook routes and SMTP configuration, see the framework guides: Node.js, Next.js, Nuxt, Laravel, PHP, Python, Ruby on Rails, Go, Java, .NET and WordPress.
MCP server package
The open-source @emailit/emailit-mcp package runs an MCP server on your machine so AI assistants can call Emailit with your API key:
npx -y @emailit/emailit-mcpMost people don’t need it: the hosted server at https://api.emailit.com/mcp needs no install. Compare the two in Local MCP server.
@emailit/js is a different package: it’s the browser script that shows Emailit forms on your site, not an API client.
Use the API over HTTP
You don’t need a library. Any HTTP client that can send JSON works:
- Base URL:
https://api.emailit.com/v2 - Headers:
Authorization: Bearer <your API key>andContent-Type: application/json - Bodies and responses: JSON
For example, to forward an email with an idempotency key from Node.js without the SDK:
const response = await fetch('https://api.emailit.com/v2/emails/em_4K6oASS7KP9ztzWmSN9ndEu13HW/forward', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.EMAILIT_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': 'forward-order-1042',
},
body: JSON.stringify({ to: 'support@acme.com' }),
});
if (!response.ok) {
throw new Error(`Emailit returned ${response.status}: ${await response.text()}`);
}Read Errors and Rate limits before you build your own client, so you handle 4xx responses and retry-after correctly. If your app already speaks SMTP, you can also skip the API entirely and use the SMTP relay.
Community libraries
Emailit doesn’t maintain libraries outside the list above. If you find or build one for another language or framework, review its code before you give it an API key, and prefer a Sending Only key restricted to one domain. Let us know at support@emailit.com or on Discord if you’d like it mentioned here.