TypeScript SDK
Install the publishable npm SDK for team-scoped REST calls with envelope handling built in.
Loading article…
Use the TypeScript SDK when you want typed methods against /api/v1 without hand-rolling fetch, auth headers, or envelope parsing. The package is generated from the same OpenAPI spec as this API reference and ships at version 1.0.0.
npm install [email protected]The package name is emailguard-sdk. Pin the semver above in production; all published clients share 1.0.0.
Set credentials in your environment (or pass them explicitly to loadConfig):
| Variable | Required | Description |
|---|---|---|
EMAILGUARD_API_KEY | Yes | Team-scoped live key (egsk_live_...) |
API_KEY is accepted as an alias in most clients.
The SDK reads EMAILGUARD_API_BASE_URL when set; otherwise it uses the API origin baked in at build time (https://api.emailguard.co).
This example calls the same operation shown in the API reference quickstart:
import { createPublicClient, loadConfig } from "emailguard-sdk";
const client = createPublicClient(loadConfig());
const result = await client.getTeam();Successful JSON responses use { "code", "data", "message" }. The TypeScript SDK unwraps data automatically — you work with the typed payload directly.
All JSON responses follow a consistent shape:
{
"code": "SUCCESS",
"data": { "..." : "..." },
"message": "OK"
}Error responses use the same envelope with a non-SUCCESS code and a human-readable message. The TypeScript client surfaces these as thrown errors with the API message when possible.
The generated client exposes 20 operations. Each method maps to an endpoint in the sidebar:
cancelPendingInvite() — Cancel a pending invitecreateNotificationChannel() — Create notification channelcreateNotificationRule() — Create notification ruledeleteNotificationChannel() — Delete notification channeldeleteNotificationRule() — Delete notification ruledetectEmailCharacteristics() — Detect email characteristicsgetBillingUsage() — Get billing usagegetTeam() — Get teaminviteTeamMember() — Invite a team memberlistNotificationChannels() — List notification channelslistNotificationEvents() — List notification eventslistNotificationRules() — List notification ruleslistPendingTeamInvites() — List pending team inviteslistTeamMembers() — List team membersremoveTeamMember() — Remove a team membertestNotificationChannel() — Test notification channelupdateNotificationChannel() — Update notification channelupdateNotificationRule() — Update notification ruleupdateTeam() — Update teamupdateTeamMemberRole() — Update a team member roleBrowse by resource group:
Every API reference page includes a TypeScript SDK tab with a copy-paste sample for that route.
| HTTP | Meaning | What to do |
|---|---|---|
401 | Missing or invalid API key | Verify EMAILGUARD_API_KEY and Bearer prefix |
403 | Key lacks scope | Add the scope listed on the endpoint in API reference |
429 | Rate limit or quota | Honor Retry-After; see API rate limiting |