import type { EmailOutboundEmail, EmailMarketingSenderProfile, EmailTrackingEvent, EmailUnsubscriber, EmailRecipient, EmailInclusion, EmailInboundAddress, EmailInboundEmail } from "../_internal/types.gen"; import type { RequestOptions } from "../base-client"; import { RequestBuilder } from "../request-builder"; /** Context reference type — links an email to a domain entity for history tracking. */ export type ContextRefType = "custom" | "deal" | "session" | "ticket"; /** Inclusion content category. */ export type InclusionType = "chart" | "custom" | "goal" | "metric" | "resource" | "supplement"; /** Recipient role on an outbound email. */ export type RecipientType = "to" | "cc" | "bcc"; /** Inbound email routing target. */ export type InboundRoutingTarget = "extraction" | "agent" | "invoices" | "crm"; /** * A file attachment on an outbound email. * * Upload the file to platform storage first, then reference its * `storage_key` here. Maximum 10 attachments per email. */ export interface EmailAttachment { /** Platform storage key returned by the upload API. */ storage_key: string; /** Display filename shown to the recipient. */ filename: string; /** MIME type (e.g. `"application/pdf"`). */ content_type: string; } /** Daily send quota record for a workspace. */ export interface EmailSendLimit { id: string; date: string; workspace_id: string; limit_with_unsubscribe: number; limit_without_unsubscribe: number; sent_with_unsubscribe: number; sent_without_unsubscribe: number; remaining_with_unsubscribe?: number; remaining_without_unsubscribe?: number; inserted_at: string; updated_at: string; } /** * Attributes for creating an outbound email draft. * * Workspace is resolved from the authenticated actor — do not pass * `workspace_id`. */ export interface CreateOutboundEmailAttributes { /** Email subject line. Required. */ subject: string; /** HTML body content. */ body_html?: string; /** Plain-text body (fallback for non-HTML clients). */ body_text?: string; /** Sender profile to use. Falls back to workspace default if omitted. */ sender_profile_id?: string; /** CRM contact reference for tracking. */ contact_ref_id?: string; /** ID of the linked domain entity. */ context_ref_id?: string; /** Type of the linked domain entity. */ context_ref_type?: ContextRefType; /** Append a CAN-SPAM unsubscribe link to the email footer. */ include_unsubscribe_link?: boolean; /** File attachments (max 10). */ attachments?: EmailAttachment[]; } /** * Attributes for updating an outbound email (PATCH semantics). * * Only emails in `draft` status can be updated. */ export interface UpdateOutboundEmailAttributes { /** Updated subject line. */ subject?: string; /** Updated HTML body. */ body_html?: string; /** Updated plain-text body. */ body_text?: string; /** Change the sender profile. */ sender_profile_id?: string; /** Toggle unsubscribe link. */ include_unsubscribe_link?: boolean; /** Replace the attachment list. */ attachments?: EmailAttachment[]; } /** * Attributes for creating a sender profile. * * Workspace is resolved from the authenticated actor — do not pass * `workspace_id`. */ export interface CreateSenderProfileAttributes { /** Sender email address. Must be unique per workspace. */ email: string; /** Display name shown in the From header. */ name: string; /** Physical mailing address (CAN-SPAM compliance). */ address?: string; /** Company name for the email footer. */ company?: string; /** Set as the workspace default on creation. */ is_default?: boolean; /** Contact phone number. */ phone?: string; /** HTML signature block. */ signature?: string; } /** Attributes for updating a sender profile (PATCH semantics). */ export interface UpdateSenderProfileAttributes { /** Updated display name. */ name?: string; /** Updated mailing address. */ address?: string; /** Updated company name. */ company?: string; /** DKIM selector override. */ dkim_selector?: string; /** Change default status. */ is_default?: boolean; /** Updated phone number. */ phone?: string; /** Updated HTML signature. */ signature?: string; } /** Attributes for adding a recipient to an outbound email. */ export interface CreateRecipientAttributes { /** ID of the outbound email. */ outbound_email_id: string; /** Recipient email address. */ email: string; /** Recipient display name. */ name?: string; /** Role: primary (`to`), carbon copy (`cc`), or blind copy (`bcc`). */ recipient_type?: RecipientType; } /** Attributes for attaching a structured data inclusion to a draft email. */ export interface CreateInclusionAttributes { /** ID of the outbound email. */ outbound_email_id: string; /** Content category. */ inclusion_type: InclusionType; /** Platform object ID referenced by this inclusion. */ ref_id?: string; /** Display title. */ title?: string; /** Structured payload (shape depends on `inclusion_type`). */ data?: Record; /** Ordering position (0-indexed). */ position?: number; } /** Attributes for updating an inclusion (PATCH semantics). */ export interface UpdateInclusionAttributes { /** Updated display title. */ title?: string; /** Pre-rendered HTML. */ rendered_html?: string; /** Updated structured payload. */ data?: Record; /** Updated ordering position. */ position?: number; } /** * Attributes for creating an inbound address. * * Unlike outbound resources, `workspace_id` is an explicit argument here. */ export interface CreateInboundAddressAttributes { /** Workspace to create the address in. */ workspace_id: string; /** Human-readable label. */ name: string; /** Where received emails are routed. */ routing_target: InboundRoutingTarget; /** Routing-target-specific configuration. */ handler_config?: Record; /** Max attachment size in MB (1–100, default 25). */ max_attachment_size_mb?: number; /** Restrict accepted MIME types. `null` allows all. */ allowed_mime_types?: string[] | null; /** Max emails per day (1–10,000, default 100). */ daily_receive_limit?: number; } /** Attributes for updating an inbound address (PATCH semantics). */ export interface UpdateInboundAddressAttributes { /** Updated label. */ name?: string; /** Change routing target. */ routing_target?: InboundRoutingTarget; /** Updated routing configuration. */ handler_config?: Record; /** Updated max attachment size in MB. */ max_attachment_size_mb?: number; /** Updated MIME type restrictions. */ allowed_mime_types?: string[] | null; /** Updated daily receive limit. */ daily_receive_limit?: number; } /** * Parameters for AI-assisted email composition. * * Workspace is resolved from the authenticated actor — do not pass it. */ export interface ComposeWithAiAttributes { /** Email addresses of primary recipients. */ to: string[]; /** AI drafting instructions. */ prompt: string; /** Structured context data passed to the AI. */ context?: Record; /** Sender profile ID — uses workspace default if omitted. */ sender_profile_id?: string; /** CRM contact reference. */ contact_ref_id?: string; /** Link the composed email to a domain entity. */ context_ref_type?: ContextRefType; /** ID of the linked domain entity. */ context_ref_id?: string; /** Include a CAN-SPAM unsubscribe link. */ include_unsubscribe_link?: boolean; } /** * Admin-level email namespace — full cross-workspace email management. * * Provides ISV administrators with complete outbound email lifecycle, * sender profile management, recipient/inclusion CRUD, inbound address * routing, and tracking event visibility across all workspaces. */ export declare function createEmailNamespace(rb: RequestBuilder): { /** * Outbound Emails — full lifecycle management. */ outboundEmails: { /** * Get an outbound email by ID. * * @param id - The outbound email ID. * @param options - Optional request-level overrides. * @returns The requested {@link EmailOutboundEmail}. */ get: (id: string, options?: RequestOptions) => Promise; /** * List outbound emails for a workspace. * * @param workspaceId - The workspace ID. * @param options - Pagination and request-level overrides. * @returns An array of {@link EmailOutboundEmail} records. */ listByWorkspace: (workspaceId: string, options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** * List emails sent to a specific contact within a workspace. * * @param workspaceId - The workspace ID. * @param contactRefId - The CRM contact reference ID. * @param options - Pagination and request-level overrides. * @returns An array of {@link EmailOutboundEmail} records. */ listByContact: (workspaceId: string, contactRefId: string, options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** * Create an outbound email draft. * * Workspace is resolved from the authenticated actor. * * @param attributes - Email attributes. `subject` is required. * @param options - Optional request-level overrides. * @returns The newly created {@link EmailOutboundEmail} draft. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * const draft = await admin.email.outboundEmails.create({ * subject: 'Admin notification', * body_html: '

Hello

', * sender_profile_id: 'sp_noreply', * }); * ``` */ create: (attributes: CreateOutboundEmailAttributes, options?: RequestOptions) => Promise; /** * AI-draft an email from a prompt and structured context. * * @param attributes - AI composition parameters. `to` and `prompt` are required. * @param options - Optional request-level overrides. * @returns The AI-generated {@link EmailOutboundEmail} draft. */ composeWithAi: (attributes: ComposeWithAiAttributes, options?: RequestOptions) => Promise; /** * Update a draft outbound email (PATCH semantics). * * Only emails in `draft` status can be updated. * * @param id - The outbound email ID. * @param attributes - Fields to update. * @param options - Optional request-level overrides. * @returns The updated {@link EmailOutboundEmail}. */ update: (id: string, attributes: UpdateOutboundEmailAttributes, options?: RequestOptions) => Promise; /** * Delete a draft outbound email. * * @param id - The outbound email ID. * @param options - Optional request-level overrides. * @returns `true` on successful deletion. */ delete: (id: string, options?: RequestOptions) => Promise; /** * Send a draft email immediately. * * @param id - The outbound email ID. * @param options - Optional request-level overrides. * @returns The email in `ready` status. */ send: (id: string, options?: RequestOptions) => Promise; /** * Schedule a draft for future delivery. * * @param id - The outbound email ID. * @param attributes - Must include `scheduled_for` as ISO 8601 datetime. * @param options - Optional request-level overrides. * @returns The email in `scheduled` status. */ schedule: (id: string, attributes: { scheduled_for: string; }, options?: RequestOptions) => Promise; /** * Cancel a scheduled email (returns to `draft` status). * * @param id - The outbound email ID. * @param options - Optional request-level overrides. * @returns The email back in `draft` status. */ cancelSchedule: (id: string, options?: RequestOptions) => Promise; }; /** * Sender Profiles — verified from-address identities. */ senderProfiles: { /** * Get a sender profile by ID. * * @param id - The sender profile ID. * @param options - Optional request-level overrides. * @returns The requested {@link EmailMarketingSenderProfile}. */ get: (id: string, options?: RequestOptions) => Promise; /** * List sender profiles for a workspace. * * @param workspaceId - The workspace ID. * @param options - Pagination and request-level overrides. * @returns An array of {@link EmailMarketingSenderProfile} records. */ listByWorkspace: (workspaceId: string, options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** * Create a new sender profile. * * Workspace is resolved from the authenticated actor. * * @param attributes - Profile attributes. `email` and `name` are required. * @param options - Optional request-level overrides. * @returns The newly created {@link EmailMarketingSenderProfile}. */ create: (attributes: CreateSenderProfileAttributes, options?: RequestOptions) => Promise; /** * Update a sender profile (PATCH semantics). * * @param id - The sender profile ID. * @param attributes - Fields to update. * @param options - Optional request-level overrides. * @returns The updated {@link EmailMarketingSenderProfile}. */ update: (id: string, attributes: UpdateSenderProfileAttributes, options?: RequestOptions) => Promise; /** * Delete a sender profile. * * @param id - The sender profile ID. * @param options - Optional request-level overrides. * @returns `true` on successful deletion. */ delete: (id: string, options?: RequestOptions) => Promise; /** * Trigger DNS validation (SPF/DKIM/DMARC). * * @param id - The sender profile ID. * @param options - Optional request-level overrides. * @returns The profile (DNS status may still be pending). */ validateDns: (id: string, options?: RequestOptions) => Promise; /** * Set a sender profile as the workspace default. * * @param id - The sender profile ID. * @param options - Optional request-level overrides. * @returns The profile with `is_default` set to `true`. */ setDefault: (id: string, options?: RequestOptions) => Promise; }; /** * Recipients — to/cc/bcc addresses on an outbound email. */ recipients: { /** * Get a recipient by ID. * * @param id - The recipient record ID. * @param options - Optional request-level overrides. * @returns The requested {@link EmailRecipient}. */ get: (id: string, options?: RequestOptions) => Promise; /** * Add a recipient to an outbound email. * * @param attributes - Recipient details. `outbound_email_id` and `email` are required. * @param options - Optional request-level overrides. * @returns The newly created {@link EmailRecipient}. */ create: (attributes: CreateRecipientAttributes, options?: RequestOptions) => Promise; /** * Remove a recipient from an outbound email. * * @param id - The recipient record ID. * @param options - Optional request-level overrides. * @returns `true` on successful deletion. */ delete: (id: string, options?: RequestOptions) => Promise; /** * List all recipients for an outbound email. * * @param outboundEmailId - The outbound email ID. * @param options - Optional request-level overrides. * @returns An array of {@link EmailRecipient} records. */ listByEmail: (outboundEmailId: string, options?: RequestOptions) => Promise; }; /** * Inclusions — structured data embedded in email bodies. */ inclusions: { /** * Get an inclusion by ID. * * @param id - The inclusion ID. * @param options - Optional request-level overrides. * @returns The requested {@link EmailInclusion}. */ get: (id: string, options?: RequestOptions) => Promise; /** * Attach a structured data inclusion to a draft email. * * @param attributes - Inclusion details. `outbound_email_id` and `inclusion_type` are required. * @param options - Optional request-level overrides. * @returns The newly created {@link EmailInclusion}. */ create: (attributes: CreateInclusionAttributes, options?: RequestOptions) => Promise; /** * Update an inclusion (PATCH semantics). * * @param id - The inclusion ID. * @param attributes - Fields to update. * @param options - Optional request-level overrides. * @returns The updated {@link EmailInclusion}. */ update: (id: string, attributes: UpdateInclusionAttributes, options?: RequestOptions) => Promise; /** * Remove an inclusion from a draft email. * * @param id - The inclusion ID. * @param options - Optional request-level overrides. * @returns `true` on successful deletion. */ delete: (id: string, options?: RequestOptions) => Promise; /** * List all inclusions for an outbound email. * * @param outboundEmailId - The outbound email ID. * @param options - Optional request-level overrides. * @returns An array of {@link EmailInclusion} records. */ listByEmail: (outboundEmailId: string, options?: RequestOptions) => Promise; }; /** * Tracking Events — open/click/bounce event history. Read-only. */ trackingEvents: { /** * Get a tracking event by ID. * * @param id - The tracking event ID. * @param options - Optional request-level overrides. * @returns The requested {@link EmailTrackingEvent}. */ get: (id: string, options?: RequestOptions) => Promise; /** * List tracking events for a workspace. * * @param workspaceId - The workspace ID. * @param options - Pagination and request-level overrides. * @returns An array of {@link EmailTrackingEvent} records. */ listByWorkspace: (workspaceId: string, options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; }; /** * Unsubscribers — CAN-SPAM global unsubscribe registry. Read-only. */ unsubscribers: { /** * Get an unsubscribe record by ID. * * @param id - The unsubscriber record ID. * @param options - Optional request-level overrides. * @returns The requested {@link EmailUnsubscriber}. */ get: (id: string, options?: RequestOptions) => Promise; /** * List unsubscriber records for a workspace. * * @param workspaceId - The workspace ID. * @param options - Pagination and request-level overrides. * @returns An array of {@link EmailUnsubscriber} records. */ listByWorkspace: (workspaceId: string, options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; }; /** * Send Limits — daily send quota records. */ sendLimits: { /** * Get a send limit record by ID. * * @param id - The send limit record ID. * @param options - Optional request-level overrides. * @returns The requested {@link EmailSendLimit} record. */ get: (id: string, options?: RequestOptions) => Promise; /** * List send limit records for a workspace (historical). * * @param workspaceId - The workspace ID. * @param options - Pagination and request-level overrides. * @returns An array of {@link EmailSendLimit} records. */ listByWorkspace: (workspaceId: string, options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; }; /** * Inbound Addresses — workspace-scoped email addresses for receiving mail. */ inbound: { addresses: { /** * Get an inbound address by ID. * * @param id - The inbound address ID. * @param options - Optional request-level overrides. * @returns The requested {@link EmailInboundAddress}. */ get: (id: string, options?: RequestOptions) => Promise; /** * Create a new inbound address. * * `workspace_id` is an explicit required parameter. * * @param attributes - Address configuration. * @param options - Optional request-level overrides. * @returns The newly created {@link EmailInboundAddress}. */ create: (attributes: CreateInboundAddressAttributes, options?: RequestOptions) => Promise; /** * Update an inbound address (PATCH semantics). * * @param id - The inbound address ID. * @param attributes - Fields to update. * @param options - Optional request-level overrides. * @returns The updated {@link EmailInboundAddress}. */ update: (id: string, attributes: UpdateInboundAddressAttributes, options?: RequestOptions) => Promise; /** * Delete an inbound address. * * @param id - The inbound address ID. * @param options - Optional request-level overrides. * @returns `true` on successful deletion. */ delete: (id: string, options?: RequestOptions) => Promise; /** * Rotate the inbound address token (invalidates the old token). * * @param id - The inbound address ID. * @param options - Optional request-level overrides. * @returns The address with the new token. */ rotateToken: (id: string, options?: RequestOptions) => Promise; /** * Disable an inbound address. * * @param id - The inbound address ID. * @param options - Optional request-level overrides. * @returns The address with `is_active` set to `false`. */ disable: (id: string, options?: RequestOptions) => Promise; /** * Re-enable a disabled inbound address. * * @param id - The inbound address ID. * @param options - Optional request-level overrides. * @returns The address with `is_active` set to `true`. */ enable: (id: string, options?: RequestOptions) => Promise; /** * List all inbound addresses in a workspace. * * @param workspaceId - The workspace ID. * @param options - Pagination and request-level overrides. * @returns An array of {@link EmailInboundAddress} records. */ listByWorkspace: (workspaceId: string, options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; }; /** Received — read-only log of received inbound emails. */ received: { /** * Get a received inbound email by ID. * * @param id - The inbound email ID. * @param options - Optional request-level overrides. * @returns The requested {@link EmailInboundEmail}. */ get: (id: string, options?: RequestOptions) => Promise; /** * List received emails by inbound address. * * @param addressId - The inbound address ID. * @param options - Pagination and request-level overrides. * @returns An array of {@link EmailInboundEmail} records. */ listByAddress: (addressId: string, options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** * List all received emails in a workspace. * * @param workspaceId - The workspace ID. * @param options - Pagination and request-level overrides. * @returns An array of {@link EmailInboundEmail} records. */ listByWorkspace: (workspaceId: string, options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; }; }; }; //# sourceMappingURL=email.d.ts.map