EmailGuard SDK Guide: TypeScript, Go, Python, PHP, and Ruby
by EmailGuard Engineering
Share this article
Enjoyed this article?
More notes on building products, infrastructure, and teams.
by EmailGuard Engineering
More notes on building products, infrastructure, and teams.
EmailGuard ships official SDKs for TypeScript/JavaScript, Go, Python, PHP, and Ruby—generated from the public OpenAPI spec so every client stays aligned with /api/v1. This walkthrough installs each SDK, authenticates with a team API key, and runs the same email detect call you would use at signup.
Deeper per-language pages live under the API reference:
For product context (what to block and why), see the email validation API checklist and disposable blocking at signup.
email:detect scope (scopes explained).Authorization: Bearer egsk_live_... (SDKs set this from EMAILGUARD_API_KEY).Endpoint used below: Detect email characteristics (GET /api/v1/emails/detect).
The TypeScript client unwraps the JSON envelope and returns data directly. The OpenAPI-generated Go, Python, PHP, and Ruby clients return the full envelope (code / data / message)—read data before branching.
@emailguard/sdk)npm install @emailguard/sdk
# or: pnpm add @emailguard/sdkimport { createPublicClient, loadConfig } from "@emailguard/sdk";
const client = createPublicClient(loadConfig()); // reads EMAILGUARD_API_KEY
const data = await client.detectEmailCharacteristics({
email: "user@example.com",
});
if (!data?.syntax_validation) {
throw new Error("Invalid email syntax");
}
if (data.disposable) {
throw new Error("Disposable email addresses are not allowed");
}
// Optional policy: data.relay_domain, data.public_domain, data.detection_sourceFull guide: TypeScript SDK.
github.com/EmailGuard/emailguard-go)go get github.com/EmailGuard/emailguard-gopackage main
import (
"context"
"fmt"
"os"
openapiclient "github.com/EmailGuard/emailguard-go"
)
func main() {
ctx := context.Background()
configuration := openapiclient.NewConfiguration()
configuration.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("EMAILGUARD_API_KEY"))
apiClient := openapiclient.NewAPIClient(configuration)
result, _, err := apiClient.EmailAPI.ApiV1EmailsDetectGet(ctx).
Email("user@example.com").
Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "request failed: %v\n", err)
os.Exit(1)
}
data := result.GetData()
if data.GetDisposable() {
fmt.Println("reject: disposable")
}
}Full guide: Go SDK.
emailguard_sdk)pip install emailguard_sdkimport os
import emailguard_sdk
from emailguard_sdk.rest import ApiException
configuration = emailguard_sdk.Configuration(
host="https://api.emailguard.co",
)
configuration.api_key["Authorization"] = os.environ["EMAILGUARD_API_KEY"]
configuration.api_key_prefix["Authorization"] = "Bearer"
with emailguard_sdk.ApiClient(configuration) as api_client:
api = emailguard_sdk.EmailApi(api_client)
try:
result = api.api_v1_emails_detect_get(email="user@example.com")
except ApiException as e:
raise SystemExit(e) from e
data = result.data
if data and data.disposable:
raise SystemExit("Disposable email addresses are not allowed")Full guide: Python SDK.
emailguard/emailguard-sdk)composer require emailguard/emailguard-sdk<?php
use emailguardSdk\Api\EmailApi;
use emailguardSdk\ApiException;
use emailguardSdk\Configuration;
require __DIR__ . '/vendor/autoload.php';
Configuration::getDefaultConfiguration()
->setHost('https://api.emailguard.co')
->setApiKey('Authorization', getenv('EMAILGUARD_API_KEY'))
->setApiKeyPrefix('Authorization', 'Bearer');
$api = new EmailApi();
try {
$result = $api->apiV1EmailsDetectGet('user@example.com');
} catch (ApiException $e) {
throw new RuntimeException($e->getResponseBody() ?: $e->getMessage(), $e->getCode(), $e);
}
$data = $result->getData();
if ($data && $data->getDisposable()) {
throw new RuntimeException('Disposable email addresses are not allowed');
}Full guide: PHP SDK.
emailguard_sdk)gem install emailguard_sdk
# or add to Gemfile: gem "emailguard_sdk"require "emailguard_sdk"
Emailguard.configure do |config|
config.host = "https://api.emailguard.co"
config.api_key["Authorization"] = ENV.fetch("EMAILGUARD_API_KEY")
config.api_key_prefix["Authorization"] = "Bearer"
end
api = Emailguard::EmailApi.new
result = api.api_v1_emails_detect_get("user@example.com")
data = result.data
if data&.disposable
raise "Disposable email addresses are not allowed"
endFull guide: Ruby SDK.
| Field | Typical signup use |
|---|---|
syntax_validation | Reject garbage early |
disposable | Hard block throwaways (why lists alone fail) |
detection_source | Log precomputed vs live_dns |
relay_domain / relay_provider | Allow by default; step-up if needed (relays vs disposables) |
public_domain | Analytics / corporate-only policies |
normalized | Deduplicate aliases when you enable normalize |
Field reference: disposable detection, relay detection, email detection overview.
If you wire EmailGuard into an MCP-capable agent (Cursor, Claude Desktop, custom hosts), use the MCP integration guide instead of pasting curl into tool definitions. Package: @emailguard/mcp. Same API surface; agent-friendly tool schemas.
Zapier and other automation hosts can call the HTTP API with your key when you do not want a language SDK. Prefer an official SDK in app backends for typed errors and OpenAPI alignment. Overview: getting started.
email:detect scope.Retry-After (API rate limiting).