### Create Webhook - Ruby Source: https://emailit.com/docs/api-reference/webhooks/delete This Ruby example shows how to create a webhook. Ensure the emailit gem is installed and use your API key to initialize the client. ```ruby require "emailit" client = Emailit::EmailitClient.new("your_api_key") webhook = client.webhooks.create( name: "My Webhook", url: "https://example.com/webhook", events: ["email.delivered"] ) ``` -------------------------------- ### Template Response Example Source: https://emailit.com/docs/api-reference/templates/delete This is an example of a successful response when retrieving a template. It includes details about the template's content, publishing status, and version history. ```JSON { "data": { "id": "tem_47TaFwzJx6mD7NeJYvLjFxVwbgT", "name": "Welcome Email v1", "alias": "welcome-email", "from": "Support ", "subject": "Welcome!", "reply_to": ["support@company.com"], "html": "

Welcome!

", "text": "Welcome!", "editor": "html", "published_at": "2025-12-24T10:30:00.000000Z", "preview_url": "https://cdn.company.com/previews/welcome.png", "created_at": "2025-12-24T09:00:00.000000Z", "updated_at": "2025-12-24T10:30:00.000000Z", "versions": [ { "id": "tem_anotherOidHere123456789", "name": "Welcome Email v2", "published_at": null, "created_at": "2025-12-24T11:00:00.000000Z", "updated_at": "2025-12-24T11:00:00.000000Z" } ] } } ``` -------------------------------- ### API Key Response Examples Source: https://emailit.com/docs/api-reference/api-keys/get Examples of successful and error responses when updating an API key. ```JSON { "object": "api_key", "id": 1234567890, "name": "Updated API Key Name", "scope": "sending", "sending_domain_id": 1234567890, "last_used_at": "2021-01-01T12:00:00Z", "created_at": "2021-01-01T00:00:00Z", "updated_at": "2021-01-01T12:00:00Z" } ``` ```JSON { "error": { "code": 400, "message": "Bad Request" } } ``` ```JSON { "error": { "code": 404, "message": "API key not found" } } ``` ```JSON { "error": { "code": 409, "message": "API key name already exists" } } ``` -------------------------------- ### Webhook Response Example Source: https://emailit.com/docs/api-reference/webhooks/delete This is an example of a successful webhook creation response. It includes details about the created webhook, such as its ID, name, and associated events. ```json { "object": "webhook", "id": "wh_2BxFg7KNqr5M...", "name": "Production Webhook", "url": "https://example.com/webhook", "all_events": false, "enabled": true, "events": ["email.accepted", "email.delivered", "email.bounced"], "last_used_at": null, "created_at": "2026-02-10T10:00:00.000000+00:00", "updated_at": "2026-02-10T10:00:00.000000+00:00" } ``` -------------------------------- ### Template Update Response Examples Source: https://emailit.com/docs/api-reference/templates/publish Examples of responses when updating a template. Includes successful update, validation error due to existing alias, and template not found. ```JSON { "data": { "id": "tem_47TaFwzJx6mD7NeJYvLjFxVwbgT", "name": "Welcome Email - Updated", "alias": "welcome-email", "from": "Support ", "subject": "Welcome! We are glad you are here", "reply_to": ["support@company.com"], "html": "

Welcome!

", "text": "Welcome!", "editor": "html", "published_at": "2025-12-24T10:30:00.000000Z", "preview_url": null, "created_at": "2025-12-24T10:30:00.000000Z", "updated_at": "2025-12-24T12:00:00.000000Z" }, "message": "Template was successfully updated." } ``` ```JSON { "message": "Validation failed", "errors": { "alias": ["Alias already exists"] } } ``` ```JSON { "message": "Template not found" } ``` -------------------------------- ### Create Template - Go Source: https://emailit.com/docs/api-reference/templates/delete Use `emailit.NewClient` to initialize the client and then call `client.Templates.Create` with a `CreateTemplateRequest` struct. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") template, err := client.Templates.Create(&emailit.CreateTemplateRequest{ Name: "Welcome", Subject: "Welcome!", Html: "

Hello {{name}}

", }) ``` -------------------------------- ### Get Event by ID - Ruby Source: https://emailit.com/docs/api-reference/events Use this Ruby snippet to get event details by ID. Ensure the Emailit gem is installed and configured with your API key. ```ruby require "emailit" client = Emailit::EmailitClient.new("your_api_key") event = client.events.get("evt_123") ``` -------------------------------- ### Get Email Attachments (Ruby) Source: https://emailit.com/docs/api-reference/emails/attachments Fetch email attachments using Ruby's Net::HTTP library. This example demonstrates making a GET request with custom headers. ```ruby require "net/http" require "json" uri = URI("https://api.emailit.com/v2/emails/em_abc123/attachments") req = Net::HTTP::Get.new(uri) req["Authorization"] = "Bearer your_api_key" http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true attachments = JSON.parse(http.request(req).body) ``` -------------------------------- ### Create Webhook - Go Source: https://emailit.com/docs/api-reference/webhooks/delete Create a webhook using the Go SDK. Initialize the client with your API key and pass the webhook creation parameters. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") webhook, err := client.Webhooks.Create(&emailit.CreateWebhookRequest{ Name: "My Webhook", Url: "https://example.com/webhook", Events: []string{"email.delivered"}, }) ``` -------------------------------- ### Successful Get Webhook Response Source: https://emailit.com/docs/api-reference/webhooks/get Example of a successful response when retrieving a specific webhook. ```json { "object": "webhook", "id": "wh_2BxFg7KNqr5M...", "name": "My Webhook", "url": "https://example.com/webhook", "all_events": false, "enabled": true, "events": ["email.accepted", "email.delivered"], "last_used_at": "2026-02-11T14:30:00.000000+00:00", "created_at": "2026-02-10T10:00:00.000000+00:00", "updated_at": "2026-02-10T10:00:00.000000+00:00" } ``` -------------------------------- ### Create Domain - Go Source: https://emailit.com/docs/api-reference/domains/delete Create a domain using the Emailit Go SDK. Initialize the client with your API key. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") domain, err := client.Domains.Create(&emailit.CreateDomainRequest{Name: "example.com"}) ``` -------------------------------- ### Create Webhook - .NET Source: https://emailit.com/docs/api-reference/webhooks/delete This .NET example shows how to create a webhook. Initialize the EmailitClient with your API key and configure the webhook options. ```csharp using Emailit; var emailit = new EmailitClient("your_api_key"); var webhook = emailit.Webhooks.Create(new WebhookCreateOptions { Name = "My Webhook", Url = "https://example.com/webhook", Events = new[] { "email.delivered" } }); ``` -------------------------------- ### Get Email Body (Ruby) Source: https://emailit.com/docs/api-reference/emails/retry Retrieve an email's body content using Ruby's Net::HTTP library. This example demonstrates constructing the GET request and parsing the JSON response. ```Ruby require "net/http" require "json" uri = URI("https://api.emailit.com/v2/emails/em_abc123/body") req = Net::HTTP::Get.new(uri) req["Authorization"] = "Bearer your_api_key" http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true attachments = JSON.parse(http.request(req).body) ``` -------------------------------- ### Get Domain by ID (PHP) Source: https://emailit.com/docs/api-reference/domains/update Access domain information by its ID. This example uses the Emailit PHP client. ```php $emailit = Emailit::client('your_api_key'); $domain = $emailit->domains()->get('sd_1234567890'); ``` -------------------------------- ### Create Contact with PHP Source: https://emailit.com/docs/api-reference/contacts/delete This example demonstrates creating a contact using the Emailit PHP client. Initialize the client with your API key before making the request. ```php $emailit = Emailit::client('your_api_key'); $contact = $emailit->contacts()->create([ 'email' => 'user@example.com', 'first_name' => 'John', 'last_name' => 'Doe', ]); ``` -------------------------------- ### Get Email Attachments - Python Source: https://emailit.com/docs/api-reference/emails/raw Use the `EmailitClient` to retrieve the attachment list for an email. This example shows the client initialization. ```python from emailit import EmailitClient client = EmailitClient("your_api_key") ``` -------------------------------- ### Create API Key - Go Source: https://emailit.com/docs/api-reference/api-keys/update Create a new API key with the Emailit Go SDK. Ensure the client is initialized with your API key. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") apiKey, err := client.ApiKeys.Create(&emailit.CreateApiKeyRequest{ Name: "Production Key", Scope: "full_access", }) ``` -------------------------------- ### Get Webhook (Laravel) Source: https://emailit.com/docs/api-reference/webhooks/get Retrieve information about a specific webhook by its ID. Requires full permission. This example uses the Laravel integration. ```php use Emailit\Laravel\Facades\Emailit; $webhook = Emailit::webhooks()->get('wh_123'); ``` -------------------------------- ### Get Webhook (.NET) Source: https://emailit.com/docs/api-reference/webhooks/get Retrieve information about a specific webhook by its ID. Requires full permission. This example uses the .NET SDK. ```csharp using Emailit; var emailit = new EmailitClient("your_api_key"); var webhook = emailit.Webhooks.Get("wh_123"); ``` -------------------------------- ### Create Template - PHP Source: https://emailit.com/docs/api-reference/templates/delete Initialize the Emailit client using `Emailit::client` and then call the `templates()->create` method with template details. ```php $emailit = Emailit::client('your_api_key'); $template = $emailit->templates()->create([ 'name' => 'Welcome', 'subject' => 'Welcome!', 'html' => '

Hello {{name}}

' ]); ``` -------------------------------- ### Get Webhook (Java) Source: https://emailit.com/docs/api-reference/webhooks/get Retrieve information about a specific webhook by its ID. Requires full permission. This example uses the Java SDK. ```java import com.emailit.*; EmailitClient emailit = new EmailitClient("your_api_key"); EmailitObject webhook = emailit.webhooks().get("wh_123"); ``` -------------------------------- ### List Subscribers in Go Source: https://emailit.com/docs/api-reference/audiences/subscribers/delete Initialize the Emailit client with your API key. Call the `Subscribers.List` method, passing the audience ID and `nil` for options if no specific query parameters are needed. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") subscribers, err := client.Subscribers.List("aud_123", nil) ``` -------------------------------- ### Create Domain - Python Source: https://emailit.com/docs/api-reference/domains/delete Create a domain with the Emailit Python client. Initialize the client with your API key. ```python from emailit import EmailitClient client = EmailitClient("your_api_key") domain = client.domains.create({"name": "example.com"}) ``` -------------------------------- ### Get Webhook (Rust) Source: https://emailit.com/docs/api-reference/webhooks/get Retrieve information about a specific webhook by its ID. Requires full permission. This example uses the Rust SDK. ```rust use emailit::Emailit; let emailit = Emailit::new("your_api_key"); let webhook = emailit.webhooks.get("wh_123").await?; ``` -------------------------------- ### Create Contact with Go Source: https://emailit.com/docs/api-reference/contacts/delete This Go snippet shows how to create a contact using the Emailit SDK. Remember to handle potential errors returned by the Create method. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") contact, err := client.Contacts.Create(&emailit.CreateContactRequest{ Email: "user@example.com", FirstName: "John", LastName: "Doe", }) ``` -------------------------------- ### Get Webhook (Go) Source: https://emailit.com/docs/api-reference/webhooks/get Retrieve information about a specific webhook by its ID. Requires full permission. This example uses the Go SDK. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") webhook, err := client.Webhooks.Get("wh_123") ``` -------------------------------- ### List Webhooks (Go) Source: https://emailit.com/docs/api-reference/webhooks/get Retrieve a list of all webhooks in your workspace. Requires full permission. This example uses the Go SDK. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") webhooks, err := client.Webhooks.List(nil) ``` -------------------------------- ### Get Webhook (Ruby) Source: https://emailit.com/docs/api-reference/webhooks/get Retrieve information about a specific webhook by its ID. Requires full permission. This example uses the Ruby SDK. ```ruby require "emailit" client = Emailit::EmailitClient.new("your_api_key") webhook = client.webhooks.get("wh_123") ``` -------------------------------- ### Create Domain - Rust Source: https://emailit.com/docs/api-reference/domains/delete This Rust snippet shows how to create a domain using the Emailit library. Ensure the client is initialized with your API key. ```rust use emailit::Emailit; let emailit = Emailit::new("your_api_key"); let domain = emailit.domains.create(emailit::types::CreateDomainParams::new("example.com")).await?; ``` -------------------------------- ### Get Webhook (PHP) Source: https://emailit.com/docs/api-reference/webhooks/get Retrieve information about a specific webhook by its ID. Requires full permission. This example uses the PHP SDK. ```php $emailit = Emailit::client('your_api_key'); $webhook = $emailit->webhooks()->get('wh_123'); ``` -------------------------------- ### Get Webhook (Python) Source: https://emailit.com/docs/api-reference/webhooks/get Retrieve information about a specific webhook by its ID. Requires full permission. This example uses the Python SDK. ```python from emailit import EmailitClient client = EmailitClient("your_api_key") webhook = client.webhooks.get("wh_123") ``` -------------------------------- ### Create Webhook - PHP Source: https://emailit.com/docs/api-reference/webhooks/delete Create a webhook using the PHP SDK. Instantiate the client with your API key and provide the webhook configuration. ```php $emailit = Emailit::client('your_api_key'); $webhook = $emailit->webhooks()->create([ 'name' => 'My Webhook', 'url' => 'https://example.com/webhook', 'events' => ['email.delivered'] ]); ``` -------------------------------- ### Get Webhook (Node.js) Source: https://emailit.com/docs/api-reference/webhooks/get Retrieve information about a specific webhook by its ID. Requires full permission. This example uses the Node.js SDK. ```javascript import { Emailit } from '@emailit/node'; const emailit = new Emailit('your_api_key'); const webhook = await emailit.webhooks.get('wh_123'); ``` -------------------------------- ### Create Audience - Go Source: https://emailit.com/docs/api-reference/audiences/list This Go code snippet shows how to create an audience. Initialize the Emailit client with your API key and handle potential errors. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") audience, err := client.Audiences.Create(&emailit.CreateAudienceRequest{ Name: "Newsletter", }) ``` -------------------------------- ### List Templates - Go Source: https://emailit.com/docs/api-reference/templates/publish Initialize the Emailit Go client with your API key to fetch a list of published templates. Handles potential errors during the API call. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") templates, err := client.Templates.List(nil) ``` -------------------------------- ### Get Email Body - cURL Source: https://emailit.com/docs/api-reference/emails/attachments A command-line example to fetch the body of a specific email using cURL. Includes the necessary Authorization header. ```Shell curl https://api.emailit.com/v2/emails/em_abc123/body \ -H "Authorization: Bearer your_api_key" ``` -------------------------------- ### List Events (Ruby) Source: https://emailit.com/docs/api-reference/events/get This Ruby example demonstrates how to list events, filtering by the 'email.delivered' type. Make sure the 'emailit' gem is installed. ```ruby require "emailit" client = Emailit::EmailitClient.new("your_api_key") events = client.events.list(type: "email.delivered") ``` -------------------------------- ### Create Email Verification List - Go Source: https://emailit.com/docs/api-reference/email-verifications/lists/export Create an email verification list in Go. This example uses the 'emailit-go/v2' SDK and requires your API key. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") list, err := client.EmailVerificationLists.Create(&emailit.CreateEmailVerificationListRequest{Name: "My List", Emails: []string{"user1@example.com", "user2@example.com"}}) ``` -------------------------------- ### Get Raw Email Content (cURL) Source: https://emailit.com/docs/api-reference/emails/body A command-line example using cURL to fetch the raw content of an email. This demonstrates a direct API call. ```bash curl https://api.emailit.com/v2/emails/em_abc123/raw \ -H "Authorization: Bearer your_api_key" ``` -------------------------------- ### Create Domain - .NET Source: https://emailit.com/docs/api-reference/domains/delete Use this .NET snippet to create a domain with the Emailit client. Initialize the client with your API key. ```csharp using Emailit; var emailit = new EmailitClient("your_api_key"); var domain = emailit.Domains.Create(new DomainCreateOptions { Name = "example.com" }); ``` -------------------------------- ### Get Email Attachments (Laravel) Source: https://emailit.com/docs/api-reference/emails/attachments Retrieve email attachments using Laravel's HTTP client. This example uses `Http::withToken` for authentication. ```php $response = Http::withToken('your_api_key') ->get('https://api.emailit.com/v2/emails/em_abc123/attachments'); $attachments = $response->json(); ``` -------------------------------- ### Verify Email with Go Source: https://emailit.com/docs/api-reference/email-verifications/verify Use the Emailit Go SDK to verify email addresses. Initialize the client with your API key. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") result, err := client.EmailVerifications.Verify(&emailit.VerifyEmailRequest{Email: "user@example.com"}) ``` -------------------------------- ### Create Domain - PHP Source: https://emailit.com/docs/api-reference/domains/delete This PHP snippet demonstrates creating a domain using the Emailit library. Make sure to set up the client with your API key. ```php $emailit = Emailit::client('your_api_key'); $domain = $emailit->domains()->create(['name' => 'example.com']); ``` -------------------------------- ### Get Raw Email Content (Laravel) Source: https://emailit.com/docs/api-reference/emails/body Retrieves the raw content of an email using Laravel's HTTP client. This example demonstrates a direct API call. ```php // This endpoint requires a direct API call $response = Http::withToken('your_api_key') ->get('https://api.emailit.com/v2/emails/em_abc123/raw'); $raw = $response->json(); ``` -------------------------------- ### Get Raw Email Content (Java) Source: https://emailit.com/docs/api-reference/emails/body Retrieves the raw content of an email using Java's built-in HTTP client. This is a direct API call example. ```java import java.net.http.*; import java.net.URI; // This endpoint requires a direct API call HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.emailit.com/v2/emails/em_abc123/raw")) .header("Authorization", "Bearer your_api_key") .GET() .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); ``` -------------------------------- ### List Audiences in Go Source: https://emailit.com/docs/api-reference/audiences/list Initialize the Emailit client with your API key. The `Audiences.List` method accepts optional parameters for pagination and returns the audiences and an error. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") audiences, err := client.Audiences.List(nil) ``` -------------------------------- ### Get Email Meta - Ruby Setup Source: https://emailit.com/docs/api-reference/emails/attachments Boilerplate code for Ruby, including necessary imports for Net::HTTP and JSON, which are often used for direct API calls. ```Ruby require "net/http" require "json" ``` -------------------------------- ### List Subscribers in PHP Source: https://emailit.com/docs/api-reference/audiences/subscribers/delete Initialize the Emailit client using the static `client` method with your API key. Then, access the subscribers service and call the `list` method with the audience ID. ```php $emailit = Emailit::client('your_api_key'); $subscribers = $emailit->subscribers()->list('aud_123'); ``` -------------------------------- ### Get Event by ID - Go Source: https://emailit.com/docs/api-reference/events Retrieve event information by ID in Go. This example requires the 'emailit-go' SDK. Remember to handle potential errors returned by the API call. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") event, err := client.Events.Get("evt_123") ``` -------------------------------- ### Create Webhook - Rust Source: https://emailit.com/docs/api-reference/webhooks/delete This Rust code snippet demonstrates creating a webhook. Initialize the Emailit client with your API key and configure the webhook parameters. ```rust use emailit::Emailit; let emailit = Emailit::new("your_api_key"); let webhook = emailit.webhooks.create( emailit::types::CreateWebhookParams::new( "My Webhook", "https://example.com/webhook" ).with_events(vec!["email.delivered".into()]) ).await?; ``` -------------------------------- ### Add Subscriber using Go Source: https://emailit.com/docs/api-reference/audiences/subscribers/delete Initialize the Emailit client with your API key. Call the `Subscribers.Create` method, passing the audience ID and a `CreateSubscriberRequest` struct containing subscriber details. Email is a required field. ```go import "github.com/emailit/emailit-go/v2" client := emailit.NewClient("your_api_key") subscriber, err := client.Subscribers.Create("aud_123", &emailit.CreateSubscriberRequest{ Email: "user@example.com", FirstName: "John", }) ``` -------------------------------- ### Get Event by ID - PHP Source: https://emailit.com/docs/api-reference/events Fetch event data by its ID in PHP. This example assumes the Emailit PHP SDK is set up. Replace 'your_api_key' with your actual API key. ```php $emailit = Emailit::client('your_api_key'); $event = $emailit->events()->get('evt_123'); ``` -------------------------------- ### Create Template - Rust Source: https://emailit.com/docs/api-reference/templates/delete Initialize the Emailit client and use the `templates.create` method, passing a `CreateTemplateParams` object. ```rust use emailit::Emailit; let emailit = Emailit::new("your_api_key"); let template = emailit.templates.create( emailit::types::CreateTemplateParams::new("Welcome") .with_subject("Welcome!") .with_html("

Hello {{name}}

") ).await?; ```