@gpt-platform/client 0.10.5 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_internal/client/client.gen.d.ts +3 -0
- package/dist/_internal/client/client.gen.d.ts.map +1 -0
- package/dist/_internal/client/index.d.ts +9 -0
- package/dist/_internal/client/index.d.ts.map +1 -0
- package/dist/_internal/client/types.gen.d.ts +118 -0
- package/dist/_internal/client/types.gen.d.ts.map +1 -0
- package/dist/_internal/client/utils.gen.d.ts +34 -0
- package/dist/_internal/client/utils.gen.d.ts.map +1 -0
- package/dist/_internal/client.gen.d.ts +13 -0
- package/dist/_internal/client.gen.d.ts.map +1 -0
- package/dist/_internal/core/auth.gen.d.ts +19 -0
- package/dist/_internal/core/auth.gen.d.ts.map +1 -0
- package/dist/_internal/core/bodySerializer.gen.d.ts +26 -0
- package/dist/_internal/core/bodySerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/params.gen.d.ts +44 -0
- package/dist/_internal/core/params.gen.d.ts.map +1 -0
- package/dist/_internal/core/pathSerializer.gen.d.ts +34 -0
- package/dist/_internal/core/pathSerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/queryKeySerializer.gen.d.ts +19 -0
- package/dist/_internal/core/queryKeySerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/serverSentEvents.gen.d.ts +72 -0
- package/dist/_internal/core/serverSentEvents.gen.d.ts.map +1 -0
- package/dist/_internal/core/types.gen.d.ts +79 -0
- package/dist/_internal/core/types.gen.d.ts.map +1 -0
- package/dist/_internal/core/utils.gen.d.ts +20 -0
- package/dist/_internal/core/utils.gen.d.ts.map +1 -0
- package/dist/_internal/index.d.ts +3 -0
- package/dist/_internal/index.d.ts.map +1 -0
- package/dist/_internal/sdk.gen.d.ts +7053 -0
- package/dist/_internal/sdk.gen.d.ts.map +1 -0
- package/dist/_internal/types.gen.d.ts +146633 -0
- package/dist/_internal/types.gen.d.ts.map +1 -0
- package/dist/base-client.d.ts +199 -0
- package/dist/base-client.d.ts.map +1 -0
- package/dist/errors/index.d.ts +128 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/events.d.ts +69 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/execution-events.d.ts +95 -0
- package/dist/execution-events.d.ts.map +1 -0
- package/dist/gpt-client.d.ts +2175 -0
- package/dist/gpt-client.d.ts.map +1 -0
- package/dist/index.d.ts +51 -30734
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +311 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +311 -4
- package/dist/index.mjs.map +1 -1
- package/dist/json-api.d.ts +26 -0
- package/dist/json-api.d.ts.map +1 -0
- package/dist/logging.d.ts +22 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/namespace-types.d.ts +79 -0
- package/dist/namespace-types.d.ts.map +1 -0
- package/dist/namespaces/access-grants.d.ts +71 -0
- package/dist/namespaces/access-grants.d.ts.map +1 -0
- package/dist/namespaces/agents.d.ts +1406 -0
- package/dist/namespaces/agents.d.ts.map +1 -0
- package/dist/namespaces/ai.d.ts +407 -0
- package/dist/namespaces/ai.d.ts.map +1 -0
- package/dist/namespaces/audit.d.ts +83 -0
- package/dist/namespaces/audit.d.ts.map +1 -0
- package/dist/namespaces/billing.d.ts +854 -0
- package/dist/namespaces/billing.d.ts.map +1 -0
- package/dist/namespaces/campaigns.d.ts +973 -0
- package/dist/namespaces/campaigns.d.ts.map +1 -0
- package/dist/namespaces/catalog.d.ts +964 -0
- package/dist/namespaces/catalog.d.ts.map +1 -0
- package/dist/namespaces/channels.d.ts +162 -0
- package/dist/namespaces/channels.d.ts.map +1 -0
- package/dist/namespaces/clinical.d.ts +2443 -0
- package/dist/namespaces/clinical.d.ts.map +1 -0
- package/dist/namespaces/communication.d.ts +439 -0
- package/dist/namespaces/communication.d.ts.map +1 -0
- package/dist/namespaces/compliance.d.ts +2310 -0
- package/dist/namespaces/compliance.d.ts.map +1 -0
- package/dist/namespaces/connectors.d.ts +1368 -0
- package/dist/namespaces/connectors.d.ts.map +1 -0
- package/dist/namespaces/content.d.ts +188 -0
- package/dist/namespaces/content.d.ts.map +1 -0
- package/dist/namespaces/crawler.d.ts +408 -0
- package/dist/namespaces/crawler.d.ts.map +1 -0
- package/dist/namespaces/crm-clusters.d.ts +31 -0
- package/dist/namespaces/crm-clusters.d.ts.map +1 -0
- package/dist/namespaces/crm.d.ts +1539 -0
- package/dist/namespaces/crm.d.ts.map +1 -0
- package/dist/namespaces/documents.d.ts +136 -0
- package/dist/namespaces/documents.d.ts.map +1 -0
- package/dist/namespaces/email.d.ts +550 -0
- package/dist/namespaces/email.d.ts.map +1 -0
- package/dist/namespaces/extraction.d.ts +1249 -0
- package/dist/namespaces/extraction.d.ts.map +1 -0
- package/dist/namespaces/identity.d.ts +411 -0
- package/dist/namespaces/identity.d.ts.map +1 -0
- package/dist/namespaces/imports.d.ts +177 -0
- package/dist/namespaces/imports.d.ts.map +1 -0
- package/dist/namespaces/index.d.ts +119 -0
- package/dist/namespaces/index.d.ts.map +1 -0
- package/dist/namespaces/memory.d.ts +105 -0
- package/dist/namespaces/memory.d.ts.map +1 -0
- package/dist/namespaces/models.d.ts +75 -0
- package/dist/namespaces/models.d.ts.map +1 -0
- package/dist/namespaces/permissions.d.ts +75 -0
- package/dist/namespaces/permissions.d.ts.map +1 -0
- package/dist/namespaces/pipeline-executions.d.ts +130 -0
- package/dist/namespaces/pipeline-executions.d.ts.map +1 -0
- package/dist/namespaces/pipelines.d.ts +120 -0
- package/dist/namespaces/pipelines.d.ts.map +1 -0
- package/dist/namespaces/platform.d.ts +1430 -0
- package/dist/namespaces/platform.d.ts.map +1 -0
- package/dist/namespaces/portal.d.ts +198 -0
- package/dist/namespaces/portal.d.ts.map +1 -0
- package/dist/namespaces/projects.d.ts +553 -0
- package/dist/namespaces/projects.d.ts.map +1 -0
- package/dist/namespaces/roles.d.ts +65 -0
- package/dist/namespaces/roles.d.ts.map +1 -0
- package/dist/namespaces/scheduling.d.ts +944 -0
- package/dist/namespaces/scheduling.d.ts.map +1 -0
- package/dist/namespaces/search.d.ts +224 -0
- package/dist/namespaces/search.d.ts.map +1 -0
- package/dist/namespaces/session-notes.d.ts +67 -0
- package/dist/namespaces/session-notes.d.ts.map +1 -0
- package/dist/namespaces/social.d.ts +330 -0
- package/dist/namespaces/social.d.ts.map +1 -0
- package/dist/namespaces/storage.d.ts +378 -0
- package/dist/namespaces/storage.d.ts.map +1 -0
- package/dist/namespaces/support.d.ts +427 -0
- package/dist/namespaces/support.d.ts.map +1 -0
- package/dist/namespaces/threads.d.ts +596 -0
- package/dist/namespaces/threads.d.ts.map +1 -0
- package/dist/namespaces/training.d.ts +358 -0
- package/dist/namespaces/training.d.ts.map +1 -0
- package/dist/namespaces/voice.d.ts +752 -0
- package/dist/namespaces/voice.d.ts.map +1 -0
- package/dist/namespaces/watcher.d.ts +425 -0
- package/dist/namespaces/watcher.d.ts.map +1 -0
- package/dist/namespaces/webhooks-ns.d.ts +3 -0
- package/dist/namespaces/webhooks-ns.d.ts.map +1 -0
- package/dist/pagination.d.ts +57 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/request-builder.d.ts +95 -0
- package/dist/request-builder.d.ts.map +1 -0
- package/dist/security.d.ts +32 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/streaming.d.ts +135 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/utils/retry.d.ts +63 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/webhook-signature.d.ts +109 -0
- package/dist/webhook-signature.d.ts.map +1 -0
- package/llms.txt +7 -1
- package/package.json +286 -36
- package/dist/index.d.mts +0 -30734
|
@@ -0,0 +1,973 @@
|
|
|
1
|
+
import type { EmailMarketingTemplate, Campaign, EmailMarketingGeneratedEmail, EmailMarketingSequence, EmailMarketingSenderProfile } from "../_internal/types.gen";
|
|
2
|
+
import type { MjmlCompileResult, TemplateVersion } from "./email";
|
|
3
|
+
import type { RequestOptions } from "../base-client";
|
|
4
|
+
import { RequestBuilder } from "../request-builder";
|
|
5
|
+
/** @public Result of an AI-powered campaign performance analysis. */
|
|
6
|
+
export type CampaignAnalysisResult = Record<string, unknown>;
|
|
7
|
+
/** Attributes accepted when creating a campaign. */
|
|
8
|
+
export type CreateCampaignAttributes = {
|
|
9
|
+
workspace_id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
template_id: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
include_unsubscribe_link?: boolean;
|
|
14
|
+
unsubscribe_message?: string;
|
|
15
|
+
include_tracking_pixel?: boolean;
|
|
16
|
+
sender_profile_id?: string;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
};
|
|
19
|
+
/** Attributes accepted when updating a campaign (PATCH semantics). */
|
|
20
|
+
export type UpdateCampaignAttributes = {
|
|
21
|
+
name?: string;
|
|
22
|
+
scheduled_at?: string;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
/** Attributes accepted when creating a follow-up campaign. */
|
|
26
|
+
export type CreateFollowupCampaignAttributes = {
|
|
27
|
+
name?: string;
|
|
28
|
+
subject?: string;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
};
|
|
31
|
+
/** Attributes accepted when updating a generated email (PATCH semantics). */
|
|
32
|
+
export type UpdateGeneratedEmailAttributes = {
|
|
33
|
+
subject?: string;
|
|
34
|
+
body?: string;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
};
|
|
37
|
+
/** Attributes accepted when updating a sender profile (PATCH semantics). */
|
|
38
|
+
export type UpdateSenderProfileAttributes = {
|
|
39
|
+
name?: string;
|
|
40
|
+
from_email?: string;
|
|
41
|
+
reply_to?: string;
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
};
|
|
44
|
+
/** Attributes accepted when importing recipients from a CSV file. */
|
|
45
|
+
export type ImportRecipientsAttributes = {
|
|
46
|
+
csv_storage_key: string;
|
|
47
|
+
column_mapping?: Record<string, string>;
|
|
48
|
+
workspace_id: string;
|
|
49
|
+
};
|
|
50
|
+
/** Attributes accepted when exporting campaign data. */
|
|
51
|
+
export type ExportCampaignAttributes = {
|
|
52
|
+
workspace_id: string;
|
|
53
|
+
format?: string;
|
|
54
|
+
export_type?: string;
|
|
55
|
+
};
|
|
56
|
+
/** Attributes accepted when optimizing subject lines with AI. */
|
|
57
|
+
export type OptimizeSubjectsAttributes = {
|
|
58
|
+
original_subject: string;
|
|
59
|
+
campaign_description: string;
|
|
60
|
+
audience_description: string;
|
|
61
|
+
};
|
|
62
|
+
/** Attributes accepted when creating a marketing sequence. */
|
|
63
|
+
export type CreateSequenceAttributes = {
|
|
64
|
+
workspace_id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
[key: string]: unknown;
|
|
67
|
+
};
|
|
68
|
+
/** Attributes accepted when updating a marketing sequence. */
|
|
69
|
+
export type UpdateSequenceAttributes = {
|
|
70
|
+
name?: string;
|
|
71
|
+
[key: string]: unknown;
|
|
72
|
+
};
|
|
73
|
+
/** Attributes accepted when creating a sequence step. */
|
|
74
|
+
export type CreateSequenceStepAttributes = {
|
|
75
|
+
sequence_id: string;
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
};
|
|
78
|
+
/** Attributes accepted when updating a sequence step. */
|
|
79
|
+
export type UpdateSequenceStepAttributes = {
|
|
80
|
+
[key: string]: unknown;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Email Marketing namespace for campaigns, templates, and AI-powered email generation.
|
|
84
|
+
*
|
|
85
|
+
* Provides sub-namespaces covering the full email marketing lifecycle:
|
|
86
|
+
* campaigns (one-off or scheduled sends), templates (reusable HTML/text
|
|
87
|
+
* layouts), generated emails (AI-personalised drafts awaiting human review),
|
|
88
|
+
* sender profiles (from-address identities with DNS validation), and
|
|
89
|
+
* sequences (multi-step drip automation).
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
94
|
+
*
|
|
95
|
+
* // Create a campaign, use AI to pick the best send time, then send
|
|
96
|
+
* const campaign = await client.campaigns.campaigns.create({
|
|
97
|
+
* workspace_id: 'ws_abc123',
|
|
98
|
+
* name: 'Spring Sale 2026',
|
|
99
|
+
* subject: 'Up to 40% off this weekend only',
|
|
100
|
+
* template_id: 'tmpl_spring',
|
|
101
|
+
* });
|
|
102
|
+
*
|
|
103
|
+
* await client.campaigns.campaigns.optimizeSendTimes(campaign.id);
|
|
104
|
+
* await client.campaigns.campaigns.send(campaign.id);
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare function createCampaignsNamespace(rb: RequestBuilder): {
|
|
108
|
+
/**
|
|
109
|
+
* Campaigns — email campaign orchestration.
|
|
110
|
+
*
|
|
111
|
+
* A campaign represents a single bulk email send (or a scheduled future
|
|
112
|
+
* send) targeting a list of recipients. Campaigns can be created from
|
|
113
|
+
* templates, analysed with AI for performance insights, have their send
|
|
114
|
+
* times AI-optimised, and spawn follow-up campaigns automatically.
|
|
115
|
+
*/
|
|
116
|
+
campaigns: {
|
|
117
|
+
/**
|
|
118
|
+
* Fetch a single campaign by its unique ID.
|
|
119
|
+
*
|
|
120
|
+
* @param id - The unique identifier of the campaign to retrieve.
|
|
121
|
+
* @param options - Optional request-level overrides.
|
|
122
|
+
* @returns A promise that resolves to the matching {@link Campaign}.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
127
|
+
*
|
|
128
|
+
* const campaign = await client.campaigns.campaigns.get('camp_abc123');
|
|
129
|
+
* console.log(campaign.attributes.name, campaign.attributes.status);
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
get: (id: string, options?: RequestOptions) => Promise<Campaign>;
|
|
133
|
+
/**
|
|
134
|
+
* Create a new email campaign.
|
|
135
|
+
*
|
|
136
|
+
* The campaign starts in `draft` status. Populate all required fields
|
|
137
|
+
* (subject, recipients, template or body content) before calling
|
|
138
|
+
* {@link send} to trigger delivery.
|
|
139
|
+
*
|
|
140
|
+
* @param attributes - Key/value map of campaign attributes. Must include
|
|
141
|
+
* `workspace_id` and `name`. Common fields: `subject`, `template_id`,
|
|
142
|
+
* `sender_profile_id`, `recipient_list_id`, `scheduled_at`.
|
|
143
|
+
* @param options - Optional request-level overrides.
|
|
144
|
+
* @returns A promise that resolves to the newly created {@link Campaign}.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
149
|
+
*
|
|
150
|
+
* const campaign = await client.campaigns.campaigns.create({
|
|
151
|
+
* workspace_id: 'ws_abc123',
|
|
152
|
+
* name: 'Q2 Product Update',
|
|
153
|
+
* subject: 'What\'s new in Q2 2026',
|
|
154
|
+
* template_id: 'tmpl_product_update',
|
|
155
|
+
* sender_profile_id: 'sp_noreply',
|
|
156
|
+
* });
|
|
157
|
+
* console.log(campaign.id); // 'camp_...'
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
create: (attributes: CreateCampaignAttributes, options?: RequestOptions) => Promise<Campaign>;
|
|
161
|
+
/**
|
|
162
|
+
* Update an existing campaign's attributes.
|
|
163
|
+
*
|
|
164
|
+
* Only the fields present in `attributes` are changed (PATCH semantics).
|
|
165
|
+
* Campaigns can only be updated while in `draft` status.
|
|
166
|
+
*
|
|
167
|
+
* @param id - The unique identifier of the campaign to update.
|
|
168
|
+
* @param attributes - Key/value map of attributes to change.
|
|
169
|
+
* @param options - Optional request-level overrides.
|
|
170
|
+
* @returns A promise that resolves to the updated {@link Campaign}.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
175
|
+
*
|
|
176
|
+
* const campaign = await client.campaigns.campaigns.update('camp_abc123', {
|
|
177
|
+
* subject: 'Revised subject line for A/B test',
|
|
178
|
+
* scheduled_at: '2026-04-01T09:00:00Z',
|
|
179
|
+
* });
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
update: (id: string, attributes: UpdateCampaignAttributes, options?: RequestOptions) => Promise<Campaign>;
|
|
183
|
+
/**
|
|
184
|
+
* Permanently delete a campaign.
|
|
185
|
+
*
|
|
186
|
+
* Only `draft` campaigns can be deleted. Campaigns that have been sent
|
|
187
|
+
* or are currently sending cannot be removed.
|
|
188
|
+
*
|
|
189
|
+
* @param id - The unique identifier of the campaign to delete.
|
|
190
|
+
* @param options - Optional request-level overrides.
|
|
191
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
196
|
+
*
|
|
197
|
+
* await client.campaigns.campaigns.delete('camp_abc123');
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
201
|
+
/**
|
|
202
|
+
* List campaigns for a workspace with optional pagination.
|
|
203
|
+
*
|
|
204
|
+
* @param workspaceId - The ID of the workspace whose campaigns to list.
|
|
205
|
+
* @param options - Optional pagination controls (`page`, `pageSize`) and
|
|
206
|
+
* request-level overrides.
|
|
207
|
+
* @returns A promise that resolves to an array of {@link Campaign} records.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
212
|
+
*
|
|
213
|
+
* const campaigns = await client.campaigns.campaigns.listByWorkspace('ws_abc123', {
|
|
214
|
+
* pageSize: 25,
|
|
215
|
+
* });
|
|
216
|
+
* const drafts = campaigns.filter((c) => c.attributes.status === 'draft');
|
|
217
|
+
* console.log(`${drafts.length} drafts awaiting send`);
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
listByWorkspace: (workspaceId: string, options?: {
|
|
221
|
+
page?: number;
|
|
222
|
+
pageSize?: number;
|
|
223
|
+
} & RequestOptions) => Promise<Campaign[]>;
|
|
224
|
+
/**
|
|
225
|
+
* Trigger immediate delivery of a campaign to all recipients.
|
|
226
|
+
*
|
|
227
|
+
* The campaign must be in `draft` or `scheduled` status. Once sent, the
|
|
228
|
+
* campaign transitions to `sending` and then `sent`. This action is
|
|
229
|
+
* irreversible — use with care in production.
|
|
230
|
+
*
|
|
231
|
+
* @param id - The unique identifier of the campaign to send.
|
|
232
|
+
* @param options - Optional request-level overrides.
|
|
233
|
+
* @returns A promise that resolves with the server's acknowledgement payload.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
238
|
+
*
|
|
239
|
+
* await client.campaigns.campaigns.send('camp_abc123');
|
|
240
|
+
* console.log('Campaign queued for delivery');
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
send: (id: string, options?: RequestOptions) => Promise<Campaign>;
|
|
244
|
+
/**
|
|
245
|
+
* Request an AI-powered performance analysis of a sent campaign.
|
|
246
|
+
*
|
|
247
|
+
* The platform's AI reviews open rates, click-through rates, unsubscribes,
|
|
248
|
+
* and engagement patterns to produce a natural-language report with
|
|
249
|
+
* actionable recommendations. Requires the campaign to be in `sent` status.
|
|
250
|
+
*
|
|
251
|
+
* @param id - The unique identifier of the campaign to analyse.
|
|
252
|
+
* @param options - Optional request-level overrides.
|
|
253
|
+
* @returns A promise that resolves to the AI-generated analysis report payload.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
258
|
+
*
|
|
259
|
+
* const report = await client.campaigns.campaigns.analyze('camp_abc123');
|
|
260
|
+
* console.log(report); // AI narrative with metrics breakdown
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
analyze: (id: string, options?: RequestOptions) => Promise<CampaignAnalysisResult>;
|
|
264
|
+
/**
|
|
265
|
+
* Use AI to determine the optimal send time for a campaign.
|
|
266
|
+
*
|
|
267
|
+
* Analyses recipient engagement history and timezone distribution to
|
|
268
|
+
* recommend (and optionally auto-set) a `scheduled_at` timestamp that
|
|
269
|
+
* maximises open rates. Call this before {@link send} to improve
|
|
270
|
+
* deliverability outcomes.
|
|
271
|
+
*
|
|
272
|
+
* @param id - The unique identifier of the campaign to optimise.
|
|
273
|
+
* @param options - Optional request-level overrides.
|
|
274
|
+
* @returns A promise that resolves to the optimisation result payload,
|
|
275
|
+
* which includes the recommended send time.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```typescript
|
|
279
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
280
|
+
*
|
|
281
|
+
* const result = await client.campaigns.campaigns.optimizeSendTimes('camp_abc123');
|
|
282
|
+
* // result contains recommended_send_at and supporting rationale
|
|
283
|
+
* console.log(result);
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
optimizeSendTimes: (id: string, options?: RequestOptions) => Promise<Campaign>;
|
|
287
|
+
/**
|
|
288
|
+
* Create a follow-up campaign targeted at recipients who did not engage
|
|
289
|
+
* with the original campaign.
|
|
290
|
+
*
|
|
291
|
+
* The AI automatically segments non-openers / non-clickers from the
|
|
292
|
+
* parent campaign and creates a new draft campaign with a refined subject
|
|
293
|
+
* line and message. You can then review and send the follow-up via
|
|
294
|
+
* {@link send}.
|
|
295
|
+
*
|
|
296
|
+
* @param id - The ID of the original campaign to follow up on.
|
|
297
|
+
* @param attributes - Additional attributes for the follow-up campaign,
|
|
298
|
+
* such as a custom `subject` or `scheduled_at` override.
|
|
299
|
+
* @param options - Optional request-level overrides.
|
|
300
|
+
* @returns A promise that resolves to the newly created follow-up campaign payload.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```typescript
|
|
304
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
305
|
+
*
|
|
306
|
+
* // Create a follow-up 3 days after the original send
|
|
307
|
+
* const followUp = await client.campaigns.campaigns.createFollowup(
|
|
308
|
+
* 'camp_abc123',
|
|
309
|
+
* {
|
|
310
|
+
* subject: 'Did you miss our Spring Sale?',
|
|
311
|
+
* scheduled_at: '2026-04-04T09:00:00Z',
|
|
312
|
+
* },
|
|
313
|
+
* );
|
|
314
|
+
* console.log('Follow-up campaign:', followUp);
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
createFollowup: (id: string, attributes: CreateFollowupCampaignAttributes, options?: RequestOptions) => Promise<Campaign>;
|
|
318
|
+
/**
|
|
319
|
+
* Import recipients from a CSV file stored in platform storage.
|
|
320
|
+
*
|
|
321
|
+
* @param id - The campaign ID to import recipients into.
|
|
322
|
+
* @param attributes - Import configuration including `csv_storage_key`,
|
|
323
|
+
* optional `column_mapping`, and `workspace_id`.
|
|
324
|
+
* @param options - Optional request-level overrides.
|
|
325
|
+
* @returns A promise resolving to the import job details.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* const result = await client.campaigns.campaigns.importRecipients('camp_abc', {
|
|
330
|
+
* csv_storage_key: 'uploads/recipients.csv',
|
|
331
|
+
* workspace_id: 'ws_abc123',
|
|
332
|
+
* });
|
|
333
|
+
* console.log(result.job_id);
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
importRecipients: (id: string, attributes: ImportRecipientsAttributes, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
337
|
+
/**
|
|
338
|
+
* Trigger AI-powered email generation for all campaign recipients.
|
|
339
|
+
*
|
|
340
|
+
* @param id - The campaign ID to generate emails for.
|
|
341
|
+
* @param workspaceId - The workspace ID.
|
|
342
|
+
* @param options - Optional request-level overrides.
|
|
343
|
+
* @returns A promise resolving to the generation job details.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```typescript
|
|
347
|
+
* const result = await client.campaigns.campaigns.generateEmails('camp_abc', 'ws_abc123');
|
|
348
|
+
* console.log(result.job_id);
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
generateEmails: (id: string, workspaceId: string, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
352
|
+
/**
|
|
353
|
+
* Generate A/B test subject line variants using AI.
|
|
354
|
+
*
|
|
355
|
+
* @param id - The campaign ID to optimize subjects for.
|
|
356
|
+
* @param attributes - Subject optimization parameters including
|
|
357
|
+
* `original_subject`, `campaign_description`, and `audience_description`.
|
|
358
|
+
* @param options - Optional request-level overrides.
|
|
359
|
+
* @returns A promise resolving to the optimization result with variant suggestions.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```typescript
|
|
363
|
+
* const result = await client.campaigns.campaigns.optimizeSubjects('camp_abc', {
|
|
364
|
+
* original_subject: 'Spring Sale!',
|
|
365
|
+
* campaign_description: 'Seasonal discount promotion',
|
|
366
|
+
* audience_description: 'Existing customers aged 25-45',
|
|
367
|
+
* });
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
370
|
+
optimizeSubjects: (id: string, attributes: OptimizeSubjectsAttributes, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
371
|
+
/**
|
|
372
|
+
* Export campaign data (recipients, results, or analytics) as CSV.
|
|
373
|
+
*
|
|
374
|
+
* @param id - The campaign ID to export.
|
|
375
|
+
* @param attributes - Export configuration including `workspace_id`,
|
|
376
|
+
* optional `format` and `export_type`.
|
|
377
|
+
* @param options - Optional request-level overrides.
|
|
378
|
+
* @returns A promise resolving to the export job details.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```typescript
|
|
382
|
+
* const result = await client.campaigns.campaigns.export('camp_abc', {
|
|
383
|
+
* workspace_id: 'ws_abc123',
|
|
384
|
+
* export_type: 'recipients',
|
|
385
|
+
* });
|
|
386
|
+
* console.log(result.job_id);
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
export: (id: string, attributes: ExportCampaignAttributes, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
390
|
+
};
|
|
391
|
+
/**
|
|
392
|
+
* Templates — reusable MJML-based email layout templates with versioning.
|
|
393
|
+
*
|
|
394
|
+
* Templates define the HTML and/or plain-text structure of an email,
|
|
395
|
+
* including header, footer, styling, and placeholder merge tags. Campaigns
|
|
396
|
+
* reference a template to avoid duplicating layout code across sends.
|
|
397
|
+
* Templates support live MJML compilation, publish/unpublish lifecycle,
|
|
398
|
+
* and immutable version snapshots for campaign reproducibility.
|
|
399
|
+
* Templates are scoped to a workspace.
|
|
400
|
+
*/
|
|
401
|
+
templates: {
|
|
402
|
+
/**
|
|
403
|
+
* List all email templates for a workspace.
|
|
404
|
+
*
|
|
405
|
+
* @param workspaceId - The ID of the workspace whose templates to list.
|
|
406
|
+
* @param options - Optional pagination controls (`page`, `pageSize`) and
|
|
407
|
+
* request-level overrides.
|
|
408
|
+
* @returns A promise that resolves to an array of {@link EmailMarketingTemplate} records.
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```typescript
|
|
412
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
413
|
+
*
|
|
414
|
+
* const templates = await client.campaigns.templates.listByWorkspace('ws_abc123');
|
|
415
|
+
* console.log(templates.map((t) => t.attributes.name));
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
listByWorkspace: (workspaceId: string, options?: {
|
|
419
|
+
page?: number;
|
|
420
|
+
pageSize?: number;
|
|
421
|
+
} & RequestOptions) => Promise<EmailMarketingTemplate[]>;
|
|
422
|
+
/**
|
|
423
|
+
* Stateless MJML compilation. Does not save. Use for live preview in builder UI.
|
|
424
|
+
*
|
|
425
|
+
* @param mjml - Raw MJML source string to compile.
|
|
426
|
+
* @param options - Optional request-level overrides.
|
|
427
|
+
* @returns A promise resolving to the compilation result including HTML, variables, and errors.
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```typescript
|
|
431
|
+
* const result = await client.campaigns.templates.compile("<mjml>...</mjml>");
|
|
432
|
+
* console.log(result.html, result.variables);
|
|
433
|
+
* ```
|
|
434
|
+
*/
|
|
435
|
+
compile: (mjml: string, options?: RequestOptions) => Promise<MjmlCompileResult>;
|
|
436
|
+
/**
|
|
437
|
+
* Render a saved template with variable overrides. Returns final HTML for preview.
|
|
438
|
+
*
|
|
439
|
+
* @param templateId - The ID of the template to preview.
|
|
440
|
+
* @param variables - Key/value map of variable substitutions for the preview render.
|
|
441
|
+
* @param options - Optional request-level overrides.
|
|
442
|
+
* @returns A promise resolving to an object containing the rendered `preview_html`.
|
|
443
|
+
*
|
|
444
|
+
* @example
|
|
445
|
+
* ```typescript
|
|
446
|
+
* const { preview_html } = await client.campaigns.templates.preview("tmpl_123", { first_name: "Jane" });
|
|
447
|
+
* ```
|
|
448
|
+
*/
|
|
449
|
+
preview: (templateId: string, variables: Record<string, string>, options?: RequestOptions) => Promise<{
|
|
450
|
+
preview_html: string;
|
|
451
|
+
}>;
|
|
452
|
+
/**
|
|
453
|
+
* Publish a template — compiles MJML, creates an immutable TemplateVersion snapshot,
|
|
454
|
+
* and updates `published_body_html`. Campaigns created after this call use this version.
|
|
455
|
+
*
|
|
456
|
+
* @param templateId - The ID of the template to publish.
|
|
457
|
+
* @param options - Optional request-level overrides.
|
|
458
|
+
* @returns A promise resolving to the updated template with `current_version` incremented.
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* ```typescript
|
|
462
|
+
* const template = await client.campaigns.templates.publish("tmpl_123");
|
|
463
|
+
* console.log(template.current_version); // 1
|
|
464
|
+
* ```
|
|
465
|
+
*/
|
|
466
|
+
publish: (templateId: string, options?: RequestOptions) => Promise<EmailMarketingTemplate>;
|
|
467
|
+
/**
|
|
468
|
+
* Unpublish a template — reverts to draft state.
|
|
469
|
+
*
|
|
470
|
+
* @param templateId - The ID of the template to unpublish.
|
|
471
|
+
* @param options - Optional request-level overrides.
|
|
472
|
+
* @returns A promise resolving to the updated template in draft state.
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* ```typescript
|
|
476
|
+
* await client.campaigns.templates.unpublish("tmpl_123");
|
|
477
|
+
* ```
|
|
478
|
+
*/
|
|
479
|
+
unpublish: (templateId: string, options?: RequestOptions) => Promise<EmailMarketingTemplate>;
|
|
480
|
+
/**
|
|
481
|
+
* Restore a template's MJML source from a previous version snapshot.
|
|
482
|
+
* Does NOT auto-publish — call `publish` after reviewing the restored content.
|
|
483
|
+
*
|
|
484
|
+
* @param templateId - The ID of the template to roll back.
|
|
485
|
+
* @param versionNumber - The version number to restore from.
|
|
486
|
+
* @param options - Optional request-level overrides.
|
|
487
|
+
* @returns A promise resolving to the template with MJML source restored.
|
|
488
|
+
*
|
|
489
|
+
* @example
|
|
490
|
+
* ```typescript
|
|
491
|
+
* const template = await client.campaigns.templates.rollback("tmpl_123", 2);
|
|
492
|
+
* ```
|
|
493
|
+
*/
|
|
494
|
+
rollback: (templateId: string, versionNumber: number, options?: RequestOptions) => Promise<EmailMarketingTemplate>;
|
|
495
|
+
/**
|
|
496
|
+
* List all TemplateVersion snapshots for a template, ordered by version_number descending.
|
|
497
|
+
* Body fields (body_html, body_mjml) are excluded for performance. Use getVersion for full content.
|
|
498
|
+
*
|
|
499
|
+
* @param templateId - The ID of the template whose versions to list.
|
|
500
|
+
* @param options - Optional request-level overrides.
|
|
501
|
+
* @returns A promise resolving to an array of version summaries (without body fields).
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
* ```typescript
|
|
505
|
+
* const versions = await client.campaigns.templates.versions("tmpl_123");
|
|
506
|
+
* ```
|
|
507
|
+
*/
|
|
508
|
+
versions: (templateId: string, options?: RequestOptions) => Promise<Omit<TemplateVersion, "body_html" | "body_mjml">[]>;
|
|
509
|
+
/**
|
|
510
|
+
* Fetch a specific TemplateVersion by template ID and version number.
|
|
511
|
+
*
|
|
512
|
+
* @param templateId - The ID of the template.
|
|
513
|
+
* @param versionNumber - The version number to fetch.
|
|
514
|
+
* @param options - Optional request-level overrides.
|
|
515
|
+
* @returns A promise resolving to the full {@link TemplateVersion} including body fields.
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* ```typescript
|
|
519
|
+
* const v = await client.campaigns.templates.getVersion("tmpl_123", 2);
|
|
520
|
+
* ```
|
|
521
|
+
*/
|
|
522
|
+
getVersion: (templateId: string, versionNumber: number, options?: RequestOptions) => Promise<TemplateVersion>;
|
|
523
|
+
};
|
|
524
|
+
/**
|
|
525
|
+
* Generated Emails — AI-personalised email drafts awaiting human review.
|
|
526
|
+
*
|
|
527
|
+
* When a campaign uses AI personalisation, the platform generates an
|
|
528
|
+
* individual email draft for each recipient. These drafts sit in a review
|
|
529
|
+
* queue until a human approves them. Approved emails are moved to the
|
|
530
|
+
* sending queue and dispatched automatically.
|
|
531
|
+
*/
|
|
532
|
+
generatedEmails: {
|
|
533
|
+
/**
|
|
534
|
+
* Fetch a single AI-generated email draft by its unique ID.
|
|
535
|
+
*
|
|
536
|
+
* @param id - The unique identifier of the generated email to retrieve.
|
|
537
|
+
* @param options - Optional request-level overrides.
|
|
538
|
+
* @returns A promise that resolves to the matching {@link EmailMarketingGeneratedEmail}.
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* ```typescript
|
|
542
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
543
|
+
*
|
|
544
|
+
* const email = await client.campaigns.generatedEmails.get('gen_abc123');
|
|
545
|
+
* console.log(email.attributes.subject, email.attributes.body_html);
|
|
546
|
+
* ```
|
|
547
|
+
*/
|
|
548
|
+
get: (id: string, options?: RequestOptions) => Promise<EmailMarketingGeneratedEmail>;
|
|
549
|
+
/**
|
|
550
|
+
* Update an AI-generated email draft before approval.
|
|
551
|
+
*
|
|
552
|
+
* Use this to correct the AI output — adjust subject lines, body copy,
|
|
553
|
+
* or personalisation tokens — before approving the email for sending.
|
|
554
|
+
*
|
|
555
|
+
* @param id - The unique identifier of the generated email to update.
|
|
556
|
+
* @param attributes - Key/value map of attributes to change (e.g.
|
|
557
|
+
* `subject`, `body_html`, `body_text`).
|
|
558
|
+
* @param options - Optional request-level overrides.
|
|
559
|
+
* @returns A promise that resolves to the updated {@link EmailMarketingGeneratedEmail}.
|
|
560
|
+
*
|
|
561
|
+
* @example
|
|
562
|
+
* ```typescript
|
|
563
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
564
|
+
*
|
|
565
|
+
* const email = await client.campaigns.generatedEmails.update('gen_abc123', {
|
|
566
|
+
* subject: 'Personalised just for you, Jane',
|
|
567
|
+
* body_html: '<p>Hi Jane, ...</p>',
|
|
568
|
+
* });
|
|
569
|
+
* ```
|
|
570
|
+
*/
|
|
571
|
+
update: (id: string, attributes: UpdateGeneratedEmailAttributes, options?: RequestOptions) => Promise<EmailMarketingGeneratedEmail>;
|
|
572
|
+
/**
|
|
573
|
+
* Approve a generated email draft and move it to the sending queue.
|
|
574
|
+
*
|
|
575
|
+
* Once approved, the email is scheduled for delivery to its intended
|
|
576
|
+
* recipient and can no longer be edited. If you need to make changes,
|
|
577
|
+
* call {@link update} first, then approve.
|
|
578
|
+
*
|
|
579
|
+
* @param id - The unique identifier of the generated email to approve.
|
|
580
|
+
* @param options - Optional request-level overrides.
|
|
581
|
+
* @returns A promise that resolves to the updated {@link EmailMarketingGeneratedEmail}
|
|
582
|
+
* with `status` reflecting its new approved/queued state.
|
|
583
|
+
*
|
|
584
|
+
* @example
|
|
585
|
+
* ```typescript
|
|
586
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
587
|
+
*
|
|
588
|
+
* const approved = await client.campaigns.generatedEmails.approve('gen_abc123');
|
|
589
|
+
* console.log(approved.attributes.status); // 'queued'
|
|
590
|
+
* ```
|
|
591
|
+
*/
|
|
592
|
+
approve: (id: string, options?: RequestOptions) => Promise<EmailMarketingGeneratedEmail>;
|
|
593
|
+
/**
|
|
594
|
+
* Reject an AI-generated email draft. The email will not be sent.
|
|
595
|
+
*
|
|
596
|
+
* @param id - The unique identifier of the generated email to reject.
|
|
597
|
+
* @param options - Optional request-level overrides.
|
|
598
|
+
* @returns A promise that resolves to the updated {@link EmailMarketingGeneratedEmail}.
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* ```typescript
|
|
602
|
+
* const rejected = await client.campaigns.generatedEmails.reject('gen_abc123');
|
|
603
|
+
* console.log(rejected.attributes.status); // 'rejected'
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
606
|
+
reject: (id: string, options?: RequestOptions) => Promise<EmailMarketingGeneratedEmail>;
|
|
607
|
+
/**
|
|
608
|
+
* Schedule a generated email for delivery at a specific time.
|
|
609
|
+
*
|
|
610
|
+
* @param id - The unique identifier of the generated email to schedule.
|
|
611
|
+
* @param options - Optional request-level overrides.
|
|
612
|
+
* @returns A promise that resolves to the updated {@link EmailMarketingGeneratedEmail}.
|
|
613
|
+
*
|
|
614
|
+
* @example
|
|
615
|
+
* ```typescript
|
|
616
|
+
* const scheduled = await client.campaigns.generatedEmails.schedule('gen_abc123');
|
|
617
|
+
* ```
|
|
618
|
+
*/
|
|
619
|
+
schedule: (id: string, options?: RequestOptions) => Promise<EmailMarketingGeneratedEmail>;
|
|
620
|
+
/**
|
|
621
|
+
* List all generated emails for a specific campaign.
|
|
622
|
+
*
|
|
623
|
+
* @param campaignId - The ID of the campaign whose generated emails to list.
|
|
624
|
+
* @param options - Optional pagination controls and request-level overrides.
|
|
625
|
+
* @returns A promise resolving to an array of {@link EmailMarketingGeneratedEmail}.
|
|
626
|
+
*
|
|
627
|
+
* @example
|
|
628
|
+
* ```typescript
|
|
629
|
+
* const emails = await client.campaigns.generatedEmails.listByCampaign('camp_abc');
|
|
630
|
+
* console.log(`${emails.length} emails generated`);
|
|
631
|
+
* ```
|
|
632
|
+
*/
|
|
633
|
+
listByCampaign: (campaignId: string, options?: {
|
|
634
|
+
page?: number;
|
|
635
|
+
pageSize?: number;
|
|
636
|
+
} & RequestOptions) => Promise<EmailMarketingGeneratedEmail[]>;
|
|
637
|
+
};
|
|
638
|
+
/**
|
|
639
|
+
* Sender Profiles — verified from-address identities for outgoing email.
|
|
640
|
+
*
|
|
641
|
+
* A sender profile defines the `From` name and email address used when
|
|
642
|
+
* sending campaigns. Before a profile can be used for sending, its domain
|
|
643
|
+
* must be verified via DNS records (SPF, DKIM, DMARC). Use
|
|
644
|
+
* {@link validateDns} to trigger re-verification after DNS changes.
|
|
645
|
+
*/
|
|
646
|
+
senderProfiles: {
|
|
647
|
+
/**
|
|
648
|
+
* Fetch a single sender profile by its unique ID.
|
|
649
|
+
*
|
|
650
|
+
* @param id - The unique identifier of the sender profile to retrieve.
|
|
651
|
+
* @param options - Optional request-level overrides.
|
|
652
|
+
* @returns A promise that resolves to the matching {@link EmailMarketingSenderProfile}.
|
|
653
|
+
*
|
|
654
|
+
* @example
|
|
655
|
+
* ```typescript
|
|
656
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
657
|
+
*
|
|
658
|
+
* const profile = await client.campaigns.senderProfiles.get('sp_abc123');
|
|
659
|
+
* console.log(profile.attributes.from_email, profile.attributes.dns_verified);
|
|
660
|
+
* ```
|
|
661
|
+
*/
|
|
662
|
+
get: (id: string, options?: RequestOptions) => Promise<EmailMarketingSenderProfile>;
|
|
663
|
+
/**
|
|
664
|
+
* Update an existing sender profile's attributes.
|
|
665
|
+
*
|
|
666
|
+
* After updating `from_email` or `from_name`, re-verify DNS with
|
|
667
|
+
* {@link validateDns} to ensure deliverability.
|
|
668
|
+
*
|
|
669
|
+
* @param id - The unique identifier of the sender profile to update.
|
|
670
|
+
* @param attributes - Key/value map of attributes to change (e.g.
|
|
671
|
+
* `from_name`, `reply_to_email`).
|
|
672
|
+
* @param options - Optional request-level overrides.
|
|
673
|
+
* @returns A promise that resolves to the updated {@link EmailMarketingSenderProfile}.
|
|
674
|
+
*
|
|
675
|
+
* @example
|
|
676
|
+
* ```typescript
|
|
677
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
678
|
+
*
|
|
679
|
+
* const profile = await client.campaigns.senderProfiles.update('sp_abc123', {
|
|
680
|
+
* from_name: 'Acme Support Team',
|
|
681
|
+
* reply_to_email: 'support@acme.com',
|
|
682
|
+
* });
|
|
683
|
+
* ```
|
|
684
|
+
*/
|
|
685
|
+
update: (id: string, attributes: UpdateSenderProfileAttributes, options?: RequestOptions) => Promise<EmailMarketingSenderProfile>;
|
|
686
|
+
/**
|
|
687
|
+
* Validate the DNS records (SPF, DKIM, DMARC) for a sender profile.
|
|
688
|
+
*
|
|
689
|
+
* Triggers a re-check of the domain's DNS configuration. The result
|
|
690
|
+
* indicates which records are correctly published and which are missing
|
|
691
|
+
* or misconfigured. Call this after making DNS changes to confirm the
|
|
692
|
+
* domain is ready for sending.
|
|
693
|
+
*
|
|
694
|
+
* @param id - The unique identifier of the sender profile to validate.
|
|
695
|
+
* @param options - Optional request-level overrides.
|
|
696
|
+
* @returns A promise that resolves to the DNS validation result payload,
|
|
697
|
+
* containing per-record status information.
|
|
698
|
+
*
|
|
699
|
+
* @example
|
|
700
|
+
* ```typescript
|
|
701
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
702
|
+
*
|
|
703
|
+
* const result = await client.campaigns.senderProfiles.validateDns('sp_abc123');
|
|
704
|
+
* // result contains spf, dkim, dmarc status fields
|
|
705
|
+
* console.log(result);
|
|
706
|
+
* ```
|
|
707
|
+
*/
|
|
708
|
+
validateDns: (id: string, options?: RequestOptions) => Promise<EmailMarketingSenderProfile>;
|
|
709
|
+
/**
|
|
710
|
+
* Permanently delete a sender profile.
|
|
711
|
+
*
|
|
712
|
+
* Deleting a sender profile that is referenced by existing campaigns will
|
|
713
|
+
* cause those campaigns to require a new profile before they can be sent.
|
|
714
|
+
*
|
|
715
|
+
* @param id - The unique identifier of the sender profile to delete.
|
|
716
|
+
* @param options - Optional request-level overrides.
|
|
717
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
718
|
+
*
|
|
719
|
+
* @example
|
|
720
|
+
* ```typescript
|
|
721
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
722
|
+
*
|
|
723
|
+
* await client.campaigns.senderProfiles.delete('sp_abc123');
|
|
724
|
+
* ```
|
|
725
|
+
*/
|
|
726
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
727
|
+
};
|
|
728
|
+
/**
|
|
729
|
+
* Sequences — multi-step drip campaign automation.
|
|
730
|
+
*
|
|
731
|
+
* A sequence is a timed series of emails automatically sent to enrolled
|
|
732
|
+
* contacts over days or weeks (e.g. a 5-email onboarding drip). Each step
|
|
733
|
+
* in the sequence has a delay and references a template or inline content.
|
|
734
|
+
* Sequences can be paused and resumed without losing enrollee state.
|
|
735
|
+
*/
|
|
736
|
+
sequences: {
|
|
737
|
+
/**
|
|
738
|
+
* Fetch a single sequence by its unique ID.
|
|
739
|
+
*
|
|
740
|
+
* @param id - The unique identifier of the sequence to retrieve.
|
|
741
|
+
* @param options - Optional request-level overrides.
|
|
742
|
+
* @returns A promise that resolves to the matching {@link EmailMarketingSequence}.
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* ```typescript
|
|
746
|
+
* const sequence = await client.campaigns.sequences.get('seq_abc123');
|
|
747
|
+
* console.log(sequence.attributes.name, sequence.attributes.status);
|
|
748
|
+
* ```
|
|
749
|
+
*/
|
|
750
|
+
get: (id: string, options?: RequestOptions) => Promise<EmailMarketingSequence>;
|
|
751
|
+
/**
|
|
752
|
+
* Create a new email sequence.
|
|
753
|
+
*
|
|
754
|
+
* @param attributes - Key/value map of sequence attributes. Must include
|
|
755
|
+
* `workspace_id` and `name`.
|
|
756
|
+
* @param options - Optional request-level overrides.
|
|
757
|
+
* @returns A promise that resolves to the newly created sequence resource.
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```typescript
|
|
761
|
+
* const sequence = await client.campaigns.sequences.create({
|
|
762
|
+
* workspace_id: 'ws_abc123',
|
|
763
|
+
* name: 'New User Onboarding',
|
|
764
|
+
* });
|
|
765
|
+
* ```
|
|
766
|
+
*/
|
|
767
|
+
create: (attributes: CreateSequenceAttributes, options?: RequestOptions) => Promise<EmailMarketingSequence>;
|
|
768
|
+
/**
|
|
769
|
+
* Update an existing sequence's attributes (PATCH semantics).
|
|
770
|
+
*
|
|
771
|
+
* @param id - The unique identifier of the sequence to update.
|
|
772
|
+
* @param attributes - Key/value map of attributes to change.
|
|
773
|
+
* @param options - Optional request-level overrides.
|
|
774
|
+
* @returns A promise that resolves to the updated {@link EmailMarketingSequence}.
|
|
775
|
+
*
|
|
776
|
+
* @example
|
|
777
|
+
* ```typescript
|
|
778
|
+
* const updated = await client.campaigns.sequences.update('seq_abc', { name: 'Revised Drip' });
|
|
779
|
+
* ```
|
|
780
|
+
*/
|
|
781
|
+
update: (id: string, attributes: UpdateSequenceAttributes, options?: RequestOptions) => Promise<EmailMarketingSequence>;
|
|
782
|
+
/**
|
|
783
|
+
* Permanently delete a sequence.
|
|
784
|
+
*
|
|
785
|
+
* @param id - The unique identifier of the sequence to delete.
|
|
786
|
+
* @param options - Optional request-level overrides.
|
|
787
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
788
|
+
*
|
|
789
|
+
* @example
|
|
790
|
+
* ```typescript
|
|
791
|
+
* await client.campaigns.sequences.delete('seq_abc123');
|
|
792
|
+
* ```
|
|
793
|
+
*/
|
|
794
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
795
|
+
/**
|
|
796
|
+
* Activate a sequence to start delivering emails to enrolled contacts.
|
|
797
|
+
*
|
|
798
|
+
* @param id - The unique identifier of the sequence to activate.
|
|
799
|
+
* @param options - Optional request-level overrides.
|
|
800
|
+
* @returns A promise that resolves to the updated {@link EmailMarketingSequence}.
|
|
801
|
+
*
|
|
802
|
+
* @example
|
|
803
|
+
* ```typescript
|
|
804
|
+
* const active = await client.campaigns.sequences.activate('seq_abc123');
|
|
805
|
+
* console.log(active.attributes.status); // 'active'
|
|
806
|
+
* ```
|
|
807
|
+
*/
|
|
808
|
+
activate: (id: string, options?: RequestOptions) => Promise<EmailMarketingSequence>;
|
|
809
|
+
/**
|
|
810
|
+
* Pause a running sequence, suspending all pending deliveries.
|
|
811
|
+
*
|
|
812
|
+
* @param id - The unique identifier of the sequence to pause.
|
|
813
|
+
* @param options - Optional request-level overrides.
|
|
814
|
+
* @returns A promise that resolves to the updated {@link EmailMarketingSequence}.
|
|
815
|
+
*
|
|
816
|
+
* @example
|
|
817
|
+
* ```typescript
|
|
818
|
+
* const paused = await client.campaigns.sequences.pause('seq_abc123');
|
|
819
|
+
* console.log(paused.attributes.status); // 'paused'
|
|
820
|
+
* ```
|
|
821
|
+
*/
|
|
822
|
+
pause: (id: string, options?: RequestOptions) => Promise<EmailMarketingSequence>;
|
|
823
|
+
/**
|
|
824
|
+
* Mark a sequence as complete, finalizing all deliveries.
|
|
825
|
+
*
|
|
826
|
+
* @param id - The unique identifier of the sequence to complete.
|
|
827
|
+
* @param options - Optional request-level overrides.
|
|
828
|
+
* @returns A promise that resolves to the updated {@link EmailMarketingSequence}.
|
|
829
|
+
*
|
|
830
|
+
* @example
|
|
831
|
+
* ```typescript
|
|
832
|
+
* const completed = await client.campaigns.sequences.complete('seq_abc123');
|
|
833
|
+
* ```
|
|
834
|
+
*/
|
|
835
|
+
complete: (id: string, options?: RequestOptions) => Promise<EmailMarketingSequence>;
|
|
836
|
+
/**
|
|
837
|
+
* List all sequences for a workspace with optional pagination.
|
|
838
|
+
*
|
|
839
|
+
* @param workspaceId - The ID of the workspace whose sequences to list.
|
|
840
|
+
* @param options - Optional pagination controls (`page`, `pageSize`) and
|
|
841
|
+
* request-level overrides.
|
|
842
|
+
* @returns A promise that resolves to an array of sequence resource records.
|
|
843
|
+
*
|
|
844
|
+
* @example
|
|
845
|
+
* ```typescript
|
|
846
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
847
|
+
*
|
|
848
|
+
* const sequences = await client.campaigns.sequences.listByWorkspace('ws_abc123');
|
|
849
|
+
* console.log(sequences);
|
|
850
|
+
* ```
|
|
851
|
+
*/
|
|
852
|
+
listByWorkspace: (workspaceId: string, options?: {
|
|
853
|
+
page?: number;
|
|
854
|
+
pageSize?: number;
|
|
855
|
+
} & RequestOptions) => Promise<EmailMarketingSequence[]>;
|
|
856
|
+
/**
|
|
857
|
+
* Resume a paused sequence, re-enabling automatic step delivery for all
|
|
858
|
+
* currently enrolled contacts from where they left off.
|
|
859
|
+
*
|
|
860
|
+
* Sequences may be paused by the platform (e.g. due to a sending limit)
|
|
861
|
+
* or manually by an ISV admin. Resuming does not re-send skipped steps;
|
|
862
|
+
* it continues from the next scheduled step for each enrollee.
|
|
863
|
+
*
|
|
864
|
+
* @param id - The unique identifier of the sequence to resume.
|
|
865
|
+
* @param options - Optional request-level overrides.
|
|
866
|
+
* @returns A promise that resolves to the updated sequence resource.
|
|
867
|
+
*
|
|
868
|
+
* @example
|
|
869
|
+
* ```typescript
|
|
870
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
871
|
+
*
|
|
872
|
+
* const sequence = await client.campaigns.sequences.resume('seq_abc123');
|
|
873
|
+
* console.log(sequence); // sequence with status: 'active'
|
|
874
|
+
* ```
|
|
875
|
+
*/
|
|
876
|
+
resume: (id: string, options?: RequestOptions) => Promise<EmailMarketingSequence>;
|
|
877
|
+
};
|
|
878
|
+
/**
|
|
879
|
+
* Recipients — campaign audience members.
|
|
880
|
+
*
|
|
881
|
+
* Each recipient represents one email address on a campaign's send list,
|
|
882
|
+
* with optional merge fields for personalisation. Recipients are typically
|
|
883
|
+
* imported via CSV.
|
|
884
|
+
*/
|
|
885
|
+
recipients: {
|
|
886
|
+
/**
|
|
887
|
+
* Fetch a single recipient by its unique ID.
|
|
888
|
+
*
|
|
889
|
+
* @param id - The unique identifier of the recipient.
|
|
890
|
+
* @param options - Optional request-level overrides.
|
|
891
|
+
* @returns A promise resolving to the recipient record.
|
|
892
|
+
*
|
|
893
|
+
* @example
|
|
894
|
+
* ```typescript
|
|
895
|
+
* const recipient = await client.campaigns.recipients.get('recip_abc123');
|
|
896
|
+
* console.log(recipient.attributes.email);
|
|
897
|
+
* ```
|
|
898
|
+
*/
|
|
899
|
+
get: (id: string, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
900
|
+
/**
|
|
901
|
+
* List all recipients for a specific campaign.
|
|
902
|
+
*
|
|
903
|
+
* @param campaignId - The ID of the campaign whose recipients to list.
|
|
904
|
+
* @param options - Optional pagination controls and request-level overrides.
|
|
905
|
+
* @returns A promise resolving to an array of recipient records.
|
|
906
|
+
*
|
|
907
|
+
* @example
|
|
908
|
+
* ```typescript
|
|
909
|
+
* const recipients = await client.campaigns.recipients.listByCampaign('camp_abc');
|
|
910
|
+
* console.log(`${recipients.length} recipients`);
|
|
911
|
+
* ```
|
|
912
|
+
*/
|
|
913
|
+
listByCampaign: (campaignId: string, options?: {
|
|
914
|
+
page?: number;
|
|
915
|
+
pageSize?: number;
|
|
916
|
+
} & RequestOptions) => Promise<Record<string, unknown>[]>;
|
|
917
|
+
};
|
|
918
|
+
/**
|
|
919
|
+
* Sequence Steps — individual steps within a drip sequence.
|
|
920
|
+
*
|
|
921
|
+
* Each step defines a timed email delivery within a sequence, with a
|
|
922
|
+
* delay offset and template or inline content.
|
|
923
|
+
*/
|
|
924
|
+
sequenceSteps: {
|
|
925
|
+
/**
|
|
926
|
+
* Fetch a single sequence step by its unique ID.
|
|
927
|
+
*
|
|
928
|
+
* @param id - The unique identifier of the sequence step.
|
|
929
|
+
* @param options - Optional request-level overrides.
|
|
930
|
+
* @returns A promise resolving to the sequence step record.
|
|
931
|
+
*
|
|
932
|
+
* @example
|
|
933
|
+
* ```typescript
|
|
934
|
+
* const step = await client.campaigns.sequenceSteps.get('step_abc123');
|
|
935
|
+
* ```
|
|
936
|
+
*/
|
|
937
|
+
get: (id: string, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
938
|
+
/**
|
|
939
|
+
* Create a new step within a sequence.
|
|
940
|
+
*
|
|
941
|
+
* @param attributes - Step attributes including `sequence_id`.
|
|
942
|
+
* @param options - Optional request-level overrides.
|
|
943
|
+
* @returns A promise resolving to the newly created sequence step.
|
|
944
|
+
*
|
|
945
|
+
* @example
|
|
946
|
+
* ```typescript
|
|
947
|
+
* const step = await client.campaigns.sequenceSteps.create({
|
|
948
|
+
* sequence_id: 'seq_abc123',
|
|
949
|
+
* delay_days: 3,
|
|
950
|
+
* template_id: 'tmpl_reminder',
|
|
951
|
+
* });
|
|
952
|
+
* ```
|
|
953
|
+
*/
|
|
954
|
+
create: (attributes: CreateSequenceStepAttributes, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
955
|
+
/**
|
|
956
|
+
* List all steps in a specific sequence.
|
|
957
|
+
*
|
|
958
|
+
* @param sequenceId - The ID of the sequence whose steps to list.
|
|
959
|
+
* @param options - Optional pagination controls and request-level overrides.
|
|
960
|
+
* @returns A promise resolving to an array of sequence step records.
|
|
961
|
+
*
|
|
962
|
+
* @example
|
|
963
|
+
* ```typescript
|
|
964
|
+
* const steps = await client.campaigns.sequenceSteps.listBySequence('seq_abc123');
|
|
965
|
+
* ```
|
|
966
|
+
*/
|
|
967
|
+
listBySequence: (sequenceId: string, options?: {
|
|
968
|
+
page?: number;
|
|
969
|
+
pageSize?: number;
|
|
970
|
+
} & RequestOptions) => Promise<Record<string, unknown>[]>;
|
|
971
|
+
};
|
|
972
|
+
};
|
|
973
|
+
//# sourceMappingURL=campaigns.d.ts.map
|