Manage email campaigns, templates, recipients, and tracking.
Send transactional email
/organizations/{organizationId}/projects/{projectId}/apps/email/{appId}/actions/sendSends a single transactional email to a specific recipient using an email template. Used for one-off emails like order confirmations, password resets, etc.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const org = "org_123";const project = "proj_123";const app = "app_123";const data = { to: "user@example.com", subject: "Hello", body: "World" };
const { data: result } = await gc.email.sendTransactionalEmail(org, project, app, data);Contact email timeline
/organizations/{organizationId}/projects/{projectId}/apps/email/{appId}/contacts/{contactId}/timelineReturns the unified email timeline for a contact: past sends + planned sends (including staged sends from a Mind sends draft when present), each with per-send engagement stats (opens, clicks, bounced, complained). Each send carries its `draftId` (non-null only while staged in a ready draft). The response-level `draftId` points at the contact's active sends draft when one exists — use it to render accept/reject UI. Order is COALESCE(sent_at, scheduled_for, created_at) DESC so upcoming planned sends appear at the top, then recent sent, then older.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: emailTimeline } = await gc.email.getContactEmailTimeline({ organizationId: "org_123", projectId: "proj_123", appId: "app_123", contactId: "contact_123"});Get email template
/organizations/{organizationId}/projects/{projectId}/apps/email/{appId}/emails/{emailId}Returns a single email template by ID, including name, subject line, full content blocks, header/footer references, and timestamps.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: email } = await gc.email.getEmail({ organizationId: "org_123", projectId: "proj_123", appId: "app_123", emailId: "email_123"});Get email recipient
/organizations/{organizationId}/projects/{projectId}/apps/email/{appId}/emails/{emailId}/recipients/{recipientId}Returns a single recipient row with subscription state.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: recipient } = await gc.email.getEmailRecipient({ organizationId: "org_123", projectId: "proj_123", appId: "app_123", emailId: "email_123", recipientId: "rec_123"});Unsubscribe a recipient
/organizations/{organizationId}/projects/{projectId}/apps/email/{appId}/emails/{emailId}/recipients/{recipientId}/unsubscribeSoft-unsubscribes a recipient by setting unsubscribed_at and an optional reason. The row is preserved for audit + resubscribe.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const orgId = "org-id";const projectId = "project-id";const appId = "app-id";const emailId = "email-id";const recipientId = "recipient-id";const data = {};
const { data: result } = await gc.email.unsubscribeEmailRecipient(orgId, projectId, appId, emailId, recipientId, data);List email recipients
/organizations/{organizationId}/projects/{projectId}/apps/email/{appId}/emails/{emailId}/recipientsReturns the subscribers for a specific email template. Includes currently subscribed and previously unsubscribed contacts.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: recipients } = await gc.email.getEmailRecipients({ organizationId: "org-id", projectId: "project-id", appId: "app-id", emailId: "email-id"});Subscribe a contact
/organizations/{organizationId}/projects/{projectId}/apps/email/{appId}/emails/{emailId}/recipientsAdds a contact as a recipient of this email. If the contact was previously unsubscribed, the row is resurrected (unsubscribed_at cleared).
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const organizationId = "org_123";const projectId = "proj_123";const appId = "app_123";const emailId = "email_123";const data = { email: "user@example.com" };
const { data: subscription } = await gc.email.subscribeEmailRecipient({ organizationId, projectId, appId, emailId, data});Get email templates
/organizations/{organizationId}/projects/{projectId}/apps/email/{appId}/emailsReturns a list of all email templates for the specified app. Each template includes its name, subject line, content blocks, and associated header/footer references.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: emails } = await gc.email.getEmails({ organizationId: "org_123", projectId: "proj_123", appId: "app_123"});Get email header
/organizations/{organizationId}/projects/{projectId}/apps/email/{appId}/headers/{headerId}Returns a single email header by ID, including its name, content blocks, and timestamps.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: emailHeader } = await gc.email.getEmailHeader({ organizationId: "org-id", projectId: "project-id", appId: "app-id", headerId: "header-id"});Get email headers
/organizations/{organizationId}/projects/{projectId}/apps/email/{appId}/headersReturns a list of all email headers for the specified app. Headers contain branding and navigation elements prepended to emails.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: emailHeaders } = await gc.email.listEmailHeaders({ organizationId: "org_123", projectId: "proj_123", appId: "app_123"});Get email send with events
/organizations/{organizationId}/projects/{projectId}/apps/email/{appId}/sends/{sendId}Returns a single send row and its full event log (delivered/open/click/bounce/complaint/unsubscribe).
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: emailSend } = await gc.email.getEmailSend({ organizationId: "org-id", projectId: "project-id", appId: "app-id", sendId: "send-id"});Update send
/organizations/{organizationId}/projects/{projectId}/apps/email/{appId}/sends/{sendId}Reschedule, cancel, or adjust metadata on a send row. Cannot modify rows with status='sent' or status='failed'.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: emailSend } = await gc.email.updateEmailSend({ organizationId: "org_123", projectId: "proj_123", appId: "app_123", sendId: "send_123", data: { status: "sent" }});List email sends
/organizations/{organizationId}/projects/{projectId}/apps/email/{appId}/sendsReturns the log of sends (past + planned + queued) for this email app. Filter by email, contact, or status. Sorted by effective time (sent_at, then scheduled_for, then created_at) descending.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: emailSends } = await gc.email.getEmailSends({ organizationId: "org_123", projectId: "proj_123", appId: "app_123"});Create a planned send
/organizations/{organizationId}/projects/{projectId}/apps/email/{appId}/sendsCreates a send row. Mind writes status='planned' rows that it reorders as new CRM activity lands. When Mind commits to firing, it transitions to status='queued' with scheduled_for set; a worker picks it up.
import { createGiantContext } from "@giantcontext/sdk-typescript";
const gc = createGiantContext({ apiKey: process.env.GIANTCONTEXT_API_KEY! });
const { data: emailSend } = await gc.email.createEmailSend({ organizationId: "org_123", projectId: "proj_123", appId: "app_123", data: {}});