# 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](/docs/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](https://github.com/emailit).

| Language | Package | Install | Requires | Source |
| --- | --- | --- | --- | --- |
| Node.js | `@emailit/node` | `npm install @emailit/node` | Node.js 18+ | [emailit-node](https://github.com/emailit/emailit-node) |
| PHP | `emailit/emailit-php` | `composer require emailit/emailit-php` | PHP 8.1+ | [emailit-php](https://github.com/emailit/emailit-php) |
| Laravel | `emailit/emailit-laravel` | `composer require emailit/emailit-laravel` | Laravel 10, 11 or 12 | [emailit-laravel](https://github.com/emailit/emailit-laravel) |
| Python | `emailit` | `pip install emailit` | Python 3.7+ | [emailit-python](https://github.com/emailit/emailit-python) |
| Ruby | `emailit` | `bundle add emailit` | Ruby 3.0+ | [emailit-ruby](https://github.com/emailit/emailit-ruby) |
| Go | `github.com/emailit/emailit-go/v2` | `go get github.com/emailit/emailit-go/v2` | Go 1.21+ | [emailit-go](https://github.com/emailit/emailit-go) |
| Java | `com.emailit:emailit-java` | Maven or Gradle, see below | Java 11+ | [emailit-java](https://github.com/emailit/emailit-java) |
| .NET | `Emailit` | `dotnet add package Emailit` | .NET 8+ | [emailit-dotnet](https://github.com/emailit/emailit-dotnet) |
| Rust | `emailit` | `cargo add emailit` | Rust 1.85+ and Tokio | [emailit-rust](https://github.com/emailit/emailit-rust) |

For Java, add the dependency with the latest version listed in the repository:

```xml title="pom.xml"
<dependency>
  <groupId>com.emailit</groupId>
  <artifactId>emailit-java</artifactId>
  <version>VERSION</version>
</dependency>
```

```groovy title="build.gradle"
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.

**Node.js**

```javascript
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);
```

**PHP**

```php
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;
```

**Laravel**

```php
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>',
]);
```

**Python**

```python
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)
```

**Ruby**

```ruby
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.id
```

**Go**

```go
package 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)
}
```

**Java**

```java
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"));
```

**.NET**

```csharp
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);
```

**Rust**

```rust
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**

```bash
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](/docs/domains/add-a-domain/). Until your workspace has [production access](/docs/workspaces/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](/docs/frameworks/nodejs/), [Next.js](/docs/frameworks/nextjs/), [Nuxt](/docs/frameworks/nuxt/), [Laravel](/docs/frameworks/laravel/), [PHP](/docs/frameworks/php/), [Python](/docs/frameworks/python/), [Ruby on Rails](/docs/frameworks/rails/), [Go](/docs/frameworks/go/), [Java](/docs/frameworks/java/), [.NET](/docs/frameworks/dotnet/) and [WordPress](/docs/frameworks/wordpress/).

## MCP server package

The open-source [`@emailit/emailit-mcp`](https://github.com/emailit/emailit-mcp) package runs an MCP server on your machine so AI assistants can call Emailit with your API key:

```bash
npx -y @emailit/emailit-mcp
```

Most people don't need it: the hosted server at `https://api.emailit.com/mcp` needs no install. Compare the two in [Local MCP server](/docs/mcp/local-server/).

`@emailit/js` is a different package: it's the browser script that shows [Emailit forms](/docs/forms/install/) 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>` and `Content-Type: application/json`
- Bodies and responses: JSON

For example, to forward an email with an idempotency key from Node.js without the SDK:

```javascript
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](/docs/api-reference/errors/) and [Rate limits](/docs/api-reference/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](/docs/smtp/settings/).

## 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](https://discord.emailit.com) if you'd like it mentioned here.

## Related

  - [Developer overview](/docs/developers/): Base URL, IDs, errors, pagination and rate limits.
  - [API keys](/docs/developers/api-keys/): Create the key your library needs.
  - [Send email with the API](/docs/email-api/send-email/): Templates, attachments, scheduling and tracking.
  - [Webhook signatures](/docs/webhooks/request-signature/): Verify that webhook requests come from Emailit.

---
Source: https://emailit.com/docs/sdks/
