@synterai/sdk-js 0.1.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/README.md +133 -0
- package/dist/index.d.mts +1260 -0
- package/dist/index.d.ts +1260 -0
- package/dist/index.js +1461 -0
- package/dist/index.mjs +1408 -0
- package/package.json +67 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared enums for the typed tool methods, matching catalog.json's
|
|
3
|
+
* `platforms` list and the `date_range` enum used by `get_performance`.
|
|
4
|
+
*
|
|
5
|
+
* Kept distinct from the legacy `Platform` type in `../types` (which only
|
|
6
|
+
* covers google/reddit/x for click-ID/UTM macro purposes and is used by
|
|
7
|
+
* `../utils/*`) to avoid narrowing that unrelated, pre-existing surface.
|
|
8
|
+
*/
|
|
9
|
+
type AdPlatform = 'google' | 'meta' | 'linkedin' | 'microsoft' | 'reddit' | 'tiktok' | 'x';
|
|
10
|
+
type DateRange = 'TODAY' | 'YESTERDAY' | 'LAST_7_DAYS' | 'LAST_30_DAYS' | 'THIS_MONTH' | 'LAST_MONTH';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* `campaigns` category — catalog.json tools: list_campaigns,
|
|
14
|
+
* create_search_campaign, create_display_campaign, create_pmax_campaign,
|
|
15
|
+
* pause_campaign, update_campaign_budget.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
interface ListCampaignsInput {
|
|
19
|
+
/**
|
|
20
|
+
* Filter by platform (optional - lists all if not specified).
|
|
21
|
+
*
|
|
22
|
+
* NOTE (preserved per SPEC.md/catalog.json dispatch note): an omitted
|
|
23
|
+
* platform only queries Google, not all connected platforms, despite
|
|
24
|
+
* the tool's description — this mirrors confirmed production behavior.
|
|
25
|
+
*/
|
|
26
|
+
platform?: AdPlatform;
|
|
27
|
+
/** Filter by campaign status. */
|
|
28
|
+
status?: 'ENABLED' | 'PAUSED' | 'REMOVED';
|
|
29
|
+
/** Maximum number of campaigns to return (default: 50). */
|
|
30
|
+
limit?: number;
|
|
31
|
+
}
|
|
32
|
+
interface CreateSearchCampaignInput {
|
|
33
|
+
/** Name for the campaign. */
|
|
34
|
+
campaign_name: string;
|
|
35
|
+
/** Daily budget in USD. */
|
|
36
|
+
daily_budget: number;
|
|
37
|
+
/** Keywords to target (phrase match). Minimum 1. */
|
|
38
|
+
keywords: string[];
|
|
39
|
+
/** Headlines, 3-15, max 30 chars each. */
|
|
40
|
+
headlines: string[];
|
|
41
|
+
/** Descriptions, 2-4, max 90 chars each. */
|
|
42
|
+
descriptions: string[];
|
|
43
|
+
/** Landing page URL. */
|
|
44
|
+
final_url: string;
|
|
45
|
+
/** Geo target codes (e.g. '2840' for US). */
|
|
46
|
+
geo_targets?: string[];
|
|
47
|
+
}
|
|
48
|
+
interface CreateDisplayCampaignInput {
|
|
49
|
+
campaign_name: string;
|
|
50
|
+
/** Daily budget in USD. */
|
|
51
|
+
daily_budget: number;
|
|
52
|
+
/** Headlines (1-5, max 30 chars each). */
|
|
53
|
+
headlines: string[];
|
|
54
|
+
/** Descriptions (1-5, max 90 chars each). */
|
|
55
|
+
descriptions: string[];
|
|
56
|
+
/** Business name (max 25 chars). */
|
|
57
|
+
business_name: string;
|
|
58
|
+
/** Landing page URL. */
|
|
59
|
+
final_url: string;
|
|
60
|
+
/**
|
|
61
|
+
* URL to 1200x628 landscape image.
|
|
62
|
+
*
|
|
63
|
+
* KNOWN ISSUE (SPEC.md "Known issues" #3): Display and PMax use
|
|
64
|
+
* inconsistent flag names for the same concept — this sends
|
|
65
|
+
* `--landscape-image`, while `create_pmax_campaign` sends
|
|
66
|
+
* `--landscape-image-url` for the equivalent field. Preserved verbatim
|
|
67
|
+
* so calls actually work against the real backend scripts.
|
|
68
|
+
*/
|
|
69
|
+
landscape_image_url?: string;
|
|
70
|
+
/** URL to 1200x1200 square image. See known-issue note above (`--square-image`, not `-url`). */
|
|
71
|
+
square_image_url?: string;
|
|
72
|
+
geo_targets?: string[];
|
|
73
|
+
}
|
|
74
|
+
interface CreatePmaxCampaignInput {
|
|
75
|
+
campaign_name: string;
|
|
76
|
+
daily_budget: number;
|
|
77
|
+
/** Headlines (3-15, max 30 chars each). */
|
|
78
|
+
headlines: string[];
|
|
79
|
+
/** Long headline (max 90 chars). */
|
|
80
|
+
long_headline: string;
|
|
81
|
+
/** Descriptions (2-5, max 90 chars each). */
|
|
82
|
+
descriptions: string[];
|
|
83
|
+
/** Business name (max 25 chars). */
|
|
84
|
+
business_name: string;
|
|
85
|
+
final_url: string;
|
|
86
|
+
/** See known-issue note on {@link CreateDisplayCampaignInput.landscape_image_url} — this uses `--landscape-image-url`. */
|
|
87
|
+
landscape_image_url?: string;
|
|
88
|
+
square_image_url?: string;
|
|
89
|
+
/** URL to square logo (min 128x128). */
|
|
90
|
+
logo_url?: string;
|
|
91
|
+
geo_targets?: string[];
|
|
92
|
+
/** Target CPA in USD (optional). */
|
|
93
|
+
target_cpa?: number;
|
|
94
|
+
}
|
|
95
|
+
interface PauseCampaignInput {
|
|
96
|
+
/** Campaign ID (platform-specific format). */
|
|
97
|
+
campaign_id: string;
|
|
98
|
+
/**
|
|
99
|
+
* KNOWN ISSUE (SPEC.md "Known issues" #1, catalog.json `knownIssues`):
|
|
100
|
+
* the schema requires/accepts this field for all 7 platforms and the
|
|
101
|
+
* tool description claims cross-platform support, but live dispatch
|
|
102
|
+
* hardcodes `platform=google` regardless of what's passed here.
|
|
103
|
+
* Preserved verbatim — flagged to Joel as a product bug, not "fixed"
|
|
104
|
+
* in the SDK.
|
|
105
|
+
*/
|
|
106
|
+
platform: AdPlatform;
|
|
107
|
+
}
|
|
108
|
+
interface UpdateCampaignBudgetInput {
|
|
109
|
+
campaign_id: string;
|
|
110
|
+
/** See {@link PauseCampaignInput.platform} — same known issue: ignored, live dispatch always sends `platform=google`. */
|
|
111
|
+
platform: AdPlatform;
|
|
112
|
+
/** New daily budget in USD. */
|
|
113
|
+
daily_budget: number;
|
|
114
|
+
}
|
|
115
|
+
declare class CampaignsResource {
|
|
116
|
+
private readonly client;
|
|
117
|
+
constructor(client: Synter);
|
|
118
|
+
/**
|
|
119
|
+
* List all campaigns across connected ad platforms. Returns campaign
|
|
120
|
+
* name, status, budget, and performance metrics.
|
|
121
|
+
*
|
|
122
|
+
* Custom-dispatch tool (platform-routed script name) — see SPEC.md's
|
|
123
|
+
* "Platform resolution" rule 2 and the note on {@link ListCampaignsInput.platform}.
|
|
124
|
+
*/
|
|
125
|
+
list(input?: ListCampaignsInput): Promise<Record<string, unknown>>;
|
|
126
|
+
/**
|
|
127
|
+
* Create a Google Ads Search campaign with an ad group, responsive
|
|
128
|
+
* search ad, and keywords — all in one atomic request. Requires at
|
|
129
|
+
* least 3 headlines (max 30 chars) and 2 descriptions (max 90 chars).
|
|
130
|
+
*/
|
|
131
|
+
createSearch(input: CreateSearchCampaignInput): Promise<Record<string, unknown>>;
|
|
132
|
+
/**
|
|
133
|
+
* Create a Google Ads Display campaign with responsive display ads.
|
|
134
|
+
* Supports image uploads from URLs.
|
|
135
|
+
*/
|
|
136
|
+
createDisplay(input: CreateDisplayCampaignInput): Promise<Record<string, unknown>>;
|
|
137
|
+
/**
|
|
138
|
+
* Create a Google Ads Performance Max campaign. Requires images,
|
|
139
|
+
* headlines, descriptions, and a business name.
|
|
140
|
+
*/
|
|
141
|
+
createPmax(input: CreatePmaxCampaignInput): Promise<Record<string, unknown>>;
|
|
142
|
+
/**
|
|
143
|
+
* Pause a campaign by ID.
|
|
144
|
+
*
|
|
145
|
+
* KNOWN ISSUE: see {@link PauseCampaignInput.platform} — always
|
|
146
|
+
* dispatches with `platform=google` regardless of input.
|
|
147
|
+
*/
|
|
148
|
+
pause(input: PauseCampaignInput): Promise<Record<string, unknown>>;
|
|
149
|
+
/**
|
|
150
|
+
* Update the daily budget for a campaign.
|
|
151
|
+
*
|
|
152
|
+
* KNOWN ISSUE: see {@link UpdateCampaignBudgetInput.platform} — always
|
|
153
|
+
* dispatches with `platform=google` regardless of input.
|
|
154
|
+
*/
|
|
155
|
+
updateBudget(input: UpdateCampaignBudgetInput): Promise<Record<string, unknown>>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* `analytics` category — catalog.json tools: get_performance, get_daily_spend.
|
|
160
|
+
*
|
|
161
|
+
* Both are custom-dispatch per SPEC.md's testing bar (not forced through
|
|
162
|
+
* the generic argMapping-only path): get_performance has a platform-scoped
|
|
163
|
+
* `onlyForPlatform` flag and a `dateRangeToDays` transform; get_daily_spend
|
|
164
|
+
* has a fixed script name but still resolves/sends a platform, and (unlike
|
|
165
|
+
* any other tool) also re-emits that resolved platform as an uppercased
|
|
166
|
+
* CLI flag.
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
interface GetPerformanceInput {
|
|
170
|
+
/** Filter by platform (optional). */
|
|
171
|
+
platform?: AdPlatform;
|
|
172
|
+
/** Filter by specific campaign ID (optional). Only forwarded when the resolved platform is `google` — see known-supported note above. */
|
|
173
|
+
campaign_id?: string;
|
|
174
|
+
/** Date range for metrics (default: LAST_7_DAYS). */
|
|
175
|
+
date_range?: DateRange;
|
|
176
|
+
}
|
|
177
|
+
interface GetDailySpendInput {
|
|
178
|
+
/** Number of days to look back (default: 7). */
|
|
179
|
+
days?: number;
|
|
180
|
+
platform?: AdPlatform;
|
|
181
|
+
}
|
|
182
|
+
declare class AnalyticsResource {
|
|
183
|
+
private readonly client;
|
|
184
|
+
constructor(client: Synter);
|
|
185
|
+
/**
|
|
186
|
+
* Get performance metrics (impressions, clicks, spend, conversions,
|
|
187
|
+
* ROAS) for campaigns.
|
|
188
|
+
*/
|
|
189
|
+
getPerformance(input?: GetPerformanceInput): Promise<Record<string, unknown>>;
|
|
190
|
+
/** Get daily spend breakdown across all connected ad accounts. */
|
|
191
|
+
getDailySpend(input?: GetDailySpendInput): Promise<Record<string, unknown>>;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* `keywords` category — catalog.json tools: add_keywords, add_negative_keywords.
|
|
196
|
+
* Both fixed to `platform: "google"` (no cross-platform keyword scripts exist yet).
|
|
197
|
+
*/
|
|
198
|
+
|
|
199
|
+
interface AddKeywordsInput {
|
|
200
|
+
ad_group_id: string;
|
|
201
|
+
keywords: string[];
|
|
202
|
+
/** default: PHRASE */
|
|
203
|
+
match_type?: 'EXACT' | 'PHRASE' | 'BROAD';
|
|
204
|
+
}
|
|
205
|
+
interface AddNegativeKeywordsInput {
|
|
206
|
+
campaign_id: string;
|
|
207
|
+
keywords: string[];
|
|
208
|
+
/** default: CAMPAIGN */
|
|
209
|
+
level?: 'CAMPAIGN' | 'AD_GROUP';
|
|
210
|
+
}
|
|
211
|
+
declare class KeywordsResource {
|
|
212
|
+
private readonly client;
|
|
213
|
+
constructor(client: Synter);
|
|
214
|
+
/** Add keywords to a Google Ads campaign or ad group. */
|
|
215
|
+
add(input: AddKeywordsInput): Promise<Record<string, unknown>>;
|
|
216
|
+
/** Add negative keywords to block unwanted search terms. */
|
|
217
|
+
addNegative(input: AddNegativeKeywordsInput): Promise<Record<string, unknown>>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* `conversions` category — catalog.json tools: create_conversion,
|
|
222
|
+
* list_conversions, diagnose_tracking.
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
interface CreateConversionInput {
|
|
226
|
+
/** e.g. 'Signup', 'Purchase' */
|
|
227
|
+
name: string;
|
|
228
|
+
/** Default conversion value in USD (optional). */
|
|
229
|
+
value?: number;
|
|
230
|
+
/** default: LEAD */
|
|
231
|
+
category?: 'PURCHASE' | 'SIGNUP' | 'LEAD' | 'PAGE_VIEW' | 'ADD_TO_CART' | 'DOWNLOAD' | 'OTHER';
|
|
232
|
+
}
|
|
233
|
+
interface DiagnoseTrackingInput {
|
|
234
|
+
/** Website URL to check. */
|
|
235
|
+
url: string;
|
|
236
|
+
}
|
|
237
|
+
declare class ConversionsResource {
|
|
238
|
+
private readonly client;
|
|
239
|
+
constructor(client: Synter);
|
|
240
|
+
/**
|
|
241
|
+
* Create a conversion action in Google Ads. Returns the conversion ID
|
|
242
|
+
* and label for GTM setup.
|
|
243
|
+
*/
|
|
244
|
+
create(input: CreateConversionInput): Promise<Record<string, unknown>>;
|
|
245
|
+
/** List all conversion actions configured in Google Ads. */
|
|
246
|
+
list(): Promise<Record<string, unknown>>;
|
|
247
|
+
/**
|
|
248
|
+
* Check if conversion tracking is properly set up on a website.
|
|
249
|
+
* Verifies gtag.js, GTM, and pixel installation.
|
|
250
|
+
*
|
|
251
|
+
* No platform is sent for this tool — it isn't tied to ad-account
|
|
252
|
+
* credentials (SPEC.md's "Platform resolution" rule 3).
|
|
253
|
+
*/
|
|
254
|
+
diagnoseTracking(input: DiagnoseTrackingInput): Promise<Record<string, unknown>>;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* `creative` category — catalog.json tools: generate_image, generate_video.
|
|
259
|
+
* Neither is tied to a platform's OAuth credentials (SPEC.md's "Platform
|
|
260
|
+
* resolution" rule 3 — no `platform` key at all).
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
interface GenerateImageInput {
|
|
264
|
+
/** Be specific about style, layout, colors. */
|
|
265
|
+
prompt: string;
|
|
266
|
+
/** default: 1200x628 */
|
|
267
|
+
size?: '1200x628' | '1200x1200' | '1080x1080' | '1920x1080';
|
|
268
|
+
/** default: imagen */
|
|
269
|
+
provider?: 'imagen' | 'flux' | 'sdxl';
|
|
270
|
+
/** Asset name for organization. */
|
|
271
|
+
name?: string;
|
|
272
|
+
}
|
|
273
|
+
interface GenerateVideoInput {
|
|
274
|
+
product_name: string;
|
|
275
|
+
/** Main value proposition. */
|
|
276
|
+
key_benefit: string;
|
|
277
|
+
/** default: pas */
|
|
278
|
+
concept?: 'pas' | 'aida' | 'before_after' | 'testimonial' | 'demo' | 'execute';
|
|
279
|
+
target_audience?: string;
|
|
280
|
+
/** default: 8 */
|
|
281
|
+
duration?: 6 | 8 | 15 | 30;
|
|
282
|
+
/** default: veo */
|
|
283
|
+
provider?: 'veo' | 'runway' | 'luma' | 'creatify';
|
|
284
|
+
}
|
|
285
|
+
declare class CreativeResource {
|
|
286
|
+
private readonly client;
|
|
287
|
+
constructor(client: Synter);
|
|
288
|
+
/** Generate an AI image for ad creatives using Imagen 4, Flux, or Stable Diffusion. */
|
|
289
|
+
generateImage(input: GenerateImageInput): Promise<Record<string, unknown>>;
|
|
290
|
+
/** Generate an AI video ad using Veo, Runway, or Luma. Great for YouTube and social ads. */
|
|
291
|
+
generateVideo(input: GenerateVideoInput): Promise<Record<string, unknown>>;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* `meta` category — catalog.json tool: create_meta_campaign.
|
|
296
|
+
* One method today; kept in its own namespace so more can be added later
|
|
297
|
+
* without renaming, per SPEC.md's naming table.
|
|
298
|
+
*/
|
|
299
|
+
|
|
300
|
+
interface CreateMetaCampaignInput {
|
|
301
|
+
name: string;
|
|
302
|
+
objective: 'CONVERSIONS' | 'TRAFFIC' | 'LEADS' | 'AWARENESS' | 'ENGAGEMENT';
|
|
303
|
+
daily_budget: number;
|
|
304
|
+
}
|
|
305
|
+
declare class MetaResource {
|
|
306
|
+
private readonly client;
|
|
307
|
+
constructor(client: Synter);
|
|
308
|
+
/** Create a Meta (Facebook/Instagram) advertising campaign. */
|
|
309
|
+
createCampaign(input: CreateMetaCampaignInput): Promise<Record<string, unknown>>;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* `linkedin` category — catalog.json tool: create_linkedin_campaign.
|
|
314
|
+
* One method today; kept in its own namespace so more can be added later
|
|
315
|
+
* without renaming, per SPEC.md's naming table.
|
|
316
|
+
*/
|
|
317
|
+
|
|
318
|
+
interface CreateLinkedInCampaignInput {
|
|
319
|
+
name: string;
|
|
320
|
+
objective: 'WEBSITE_VISIT' | 'LEAD_GENERATION' | 'ENGAGEMENT' | 'VIDEO_VIEW' | 'BRAND_AWARENESS';
|
|
321
|
+
daily_budget: number;
|
|
322
|
+
target_company_sizes?: ('1-10' | '11-50' | '51-200' | '201-500' | '501-1000' | '1001-5000' | '5001-10000' | '10001+')[];
|
|
323
|
+
target_industries?: string[];
|
|
324
|
+
target_job_functions?: string[];
|
|
325
|
+
}
|
|
326
|
+
declare class LinkedInResource {
|
|
327
|
+
private readonly client;
|
|
328
|
+
constructor(client: Synter);
|
|
329
|
+
/** Create a LinkedIn Ads campaign for B2B advertising. */
|
|
330
|
+
createCampaign(input: CreateLinkedInCampaignInput): Promise<Record<string, unknown>>;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* `reddit` category — catalog.json tool: create_reddit_campaign.
|
|
335
|
+
* One method today; kept in its own namespace so more can be added later
|
|
336
|
+
* without renaming, per SPEC.md's naming table.
|
|
337
|
+
*/
|
|
338
|
+
|
|
339
|
+
interface CreateRedditCampaignInput {
|
|
340
|
+
name: string;
|
|
341
|
+
objective: 'TRAFFIC' | 'CONVERSIONS' | 'VIDEO_VIEWS' | 'APP_INSTALLS' | 'REACH';
|
|
342
|
+
daily_budget: number;
|
|
343
|
+
/** Optional - omit for interest-based targeting. */
|
|
344
|
+
subreddits?: string[];
|
|
345
|
+
interests?: string[];
|
|
346
|
+
}
|
|
347
|
+
declare class RedditResource {
|
|
348
|
+
private readonly client;
|
|
349
|
+
constructor(client: Synter);
|
|
350
|
+
/** Create a Reddit Ads campaign for community-based advertising. */
|
|
351
|
+
createCampaign(input: CreateRedditCampaignInput): Promise<Record<string, unknown>>;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* `audiences` category — catalog.json tools: stage_audience_artifact
|
|
356
|
+
* (custom handler, special endpoint), sync_audience (custom handler,
|
|
357
|
+
* argBuildingRules), manage_audience (generic argMapping).
|
|
358
|
+
*/
|
|
359
|
+
|
|
360
|
+
interface StageAudienceArtifactInput {
|
|
361
|
+
/** Newline-delimited identifiers. SHA-256 hex for emails/phones; raw uppercase UUIDs for MAIDs. */
|
|
362
|
+
body: string;
|
|
363
|
+
/** Which script will consume this artifact. Default 'meta_ads_create_audience'. */
|
|
364
|
+
script_name?: string;
|
|
365
|
+
/** Default 3600 (1 hour). */
|
|
366
|
+
ttl_seconds?: number;
|
|
367
|
+
/** Confirm lawful basis under GDPR/CCPA + platform terms for every identifier. Omitting logs a warning (soft-launch). */
|
|
368
|
+
i_have_consent?: boolean;
|
|
369
|
+
}
|
|
370
|
+
interface StageAudienceArtifactResult {
|
|
371
|
+
artifact_id: string;
|
|
372
|
+
[key: string]: unknown;
|
|
373
|
+
}
|
|
374
|
+
interface SyncAudienceInput {
|
|
375
|
+
platform: AdPlatform;
|
|
376
|
+
audience_name?: string;
|
|
377
|
+
/** Optional — defaults to the user's primary account on that platform. */
|
|
378
|
+
account_id?: string;
|
|
379
|
+
/** Comma-separated SHA-256 hashed emails, lowercase hex. */
|
|
380
|
+
hashed_emails?: string;
|
|
381
|
+
hashed_emails_artifact_id?: string;
|
|
382
|
+
/** Comma-separated SHA-256 hashed phones (E.164 pre-hash). */
|
|
383
|
+
hashed_phones?: string;
|
|
384
|
+
/** Meta + most platforms; not supported by Google's customer match script today. */
|
|
385
|
+
hashed_phones_artifact_id?: string;
|
|
386
|
+
/** Comma-separated raw IDFA/GAID, uppercase UUID. Meta and TikTok only. NOT hashed. */
|
|
387
|
+
mobile_ids?: string;
|
|
388
|
+
/** Meta only. */
|
|
389
|
+
mobile_ids_artifact_id?: string;
|
|
390
|
+
/** B2B account targeting (Google + LinkedIn). */
|
|
391
|
+
company_domains?: string;
|
|
392
|
+
csv_url?: string;
|
|
393
|
+
/** Meta only: USER_PROVIDED_ONLY (default), PARTNER_PROVIDED_ONLY, or BOTH_USER_AND_PARTNER_PROVIDED. */
|
|
394
|
+
customer_file_source?: 'USER_PROVIDED_ONLY' | 'PARTNER_PROVIDED_ONLY' | 'BOTH_USER_AND_PARTNER_PROVIDED';
|
|
395
|
+
i_have_consent?: boolean;
|
|
396
|
+
}
|
|
397
|
+
interface ManageAudienceInput {
|
|
398
|
+
action: 'create' | 'upload' | 'list' | 'status' | 'list-sources';
|
|
399
|
+
/** Required for action=create. Required for action=upload unless audience_id is provided. */
|
|
400
|
+
name?: string;
|
|
401
|
+
/** Comma-separated, hashed client-side before upload. */
|
|
402
|
+
emails?: string;
|
|
403
|
+
/** Comma-separated, E.164 format. */
|
|
404
|
+
phones?: string;
|
|
405
|
+
company_domains?: string;
|
|
406
|
+
/** Alternative to name for action=upload. */
|
|
407
|
+
audience_id?: string;
|
|
408
|
+
/** Days to keep members; default 540, max 540. */
|
|
409
|
+
membership_lifespan?: number;
|
|
410
|
+
/** Required for action=status. */
|
|
411
|
+
job_resource_name?: string;
|
|
412
|
+
}
|
|
413
|
+
declare class AudiencesResource {
|
|
414
|
+
private readonly client;
|
|
415
|
+
constructor(client: Synter);
|
|
416
|
+
/**
|
|
417
|
+
* Stage a hashed-PII payload (newline-delimited identifiers — SHA-256
|
|
418
|
+
* emails, phones, or raw MAIDs) in Synter's private artifact store and
|
|
419
|
+
* return an opaque `artifact_id`. Pass that id to `sync()` via
|
|
420
|
+
* `*_artifact_id` parameters. FREE. Use instead of pasting hashed
|
|
421
|
+
* identifiers inline when over ~500 entries.
|
|
422
|
+
*
|
|
423
|
+
* Bypasses the primary `tools/run` dispatcher: different host
|
|
424
|
+
* (`https://api.syntermedia.ai`) and a different auth header
|
|
425
|
+
* (`X-Synter-Key`, not `Authorization: Bearer`) — see SPEC.md/catalog.json
|
|
426
|
+
* `transport.special`.
|
|
427
|
+
*/
|
|
428
|
+
stageArtifact(input: StageAudienceArtifactInput): Promise<StageAudienceArtifactResult>;
|
|
429
|
+
/**
|
|
430
|
+
* Upload an audience to an ad platform. Accepts inline hashed
|
|
431
|
+
* identifiers, raw mobile_ids, company_domains, a public csv_url, or
|
|
432
|
+
* `*_artifact_id` references staged via `stageArtifact()`. Costs 10
|
|
433
|
+
* credits on success.
|
|
434
|
+
*
|
|
435
|
+
* Custom handler per catalog.json's `dispatch.argBuildingRules` — does
|
|
436
|
+
* not go through the generic argMapping path.
|
|
437
|
+
*/
|
|
438
|
+
sync(input: SyncAudienceInput): Promise<Record<string, unknown>>;
|
|
439
|
+
/**
|
|
440
|
+
* Create, upload to, or list first-party audiences in Google Ads via
|
|
441
|
+
* the Data Manager API. Supports Customer Match lists from emails,
|
|
442
|
+
* phone numbers, and company domains.
|
|
443
|
+
*/
|
|
444
|
+
manage(input: ManageAudienceInput): Promise<Record<string, unknown>>;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Amp Custom Advertising Toolbox
|
|
449
|
+
*
|
|
450
|
+
* A collection of AI-powered advertising tools specifically designed for
|
|
451
|
+
* Amp integration, providing intelligent campaign management, creative
|
|
452
|
+
* generation, and optimization capabilities.
|
|
453
|
+
*/
|
|
454
|
+
|
|
455
|
+
interface AmpToolboxConfig {
|
|
456
|
+
/**
|
|
457
|
+
* AI model to use for creative generation
|
|
458
|
+
* @default 'gpt-4'
|
|
459
|
+
*/
|
|
460
|
+
aiModel?: 'gpt-4' | 'gpt-4-turbo' | 'gpt-3.5-turbo';
|
|
461
|
+
/**
|
|
462
|
+
* Enable auto-optimization
|
|
463
|
+
* @default true
|
|
464
|
+
*/
|
|
465
|
+
autoOptimize?: boolean;
|
|
466
|
+
/**
|
|
467
|
+
* Optimization interval in hours
|
|
468
|
+
* @default 24
|
|
469
|
+
*/
|
|
470
|
+
optimizeInterval?: number;
|
|
471
|
+
/**
|
|
472
|
+
* Enable A/B testing
|
|
473
|
+
* @default true
|
|
474
|
+
*/
|
|
475
|
+
enableABTesting?: boolean;
|
|
476
|
+
}
|
|
477
|
+
interface CampaignBriefInput {
|
|
478
|
+
/**
|
|
479
|
+
* Business/product description
|
|
480
|
+
*/
|
|
481
|
+
product: string;
|
|
482
|
+
/**
|
|
483
|
+
* Target audience description
|
|
484
|
+
*/
|
|
485
|
+
audience: string;
|
|
486
|
+
/**
|
|
487
|
+
* Campaign goals (awareness, conversions, engagement)
|
|
488
|
+
*/
|
|
489
|
+
goals: string[];
|
|
490
|
+
/**
|
|
491
|
+
* Budget constraints
|
|
492
|
+
*/
|
|
493
|
+
budget: {
|
|
494
|
+
total: number;
|
|
495
|
+
currency: string;
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* Preferred platforms
|
|
499
|
+
*/
|
|
500
|
+
platforms?: ('google' | 'reddit' | 'x' | 'linkedin')[];
|
|
501
|
+
/**
|
|
502
|
+
* Brand voice/tone
|
|
503
|
+
*/
|
|
504
|
+
brandVoice?: string;
|
|
505
|
+
/**
|
|
506
|
+
* Competitive context
|
|
507
|
+
*/
|
|
508
|
+
competitors?: string[];
|
|
509
|
+
}
|
|
510
|
+
interface GeneratedCampaign {
|
|
511
|
+
/**
|
|
512
|
+
* Campaign strategy overview
|
|
513
|
+
*/
|
|
514
|
+
strategy: string;
|
|
515
|
+
/**
|
|
516
|
+
* Recommended budget allocation
|
|
517
|
+
*/
|
|
518
|
+
budgetAllocation: {
|
|
519
|
+
platform: string;
|
|
520
|
+
amount: number;
|
|
521
|
+
percentage: number;
|
|
522
|
+
}[];
|
|
523
|
+
/**
|
|
524
|
+
* Generated ad creatives
|
|
525
|
+
*/
|
|
526
|
+
creatives: {
|
|
527
|
+
platform: string;
|
|
528
|
+
headlines: string[];
|
|
529
|
+
descriptions: string[];
|
|
530
|
+
callsToAction: string[];
|
|
531
|
+
keywords?: string[];
|
|
532
|
+
}[];
|
|
533
|
+
/**
|
|
534
|
+
* Targeting recommendations
|
|
535
|
+
*/
|
|
536
|
+
targeting: {
|
|
537
|
+
platform: string;
|
|
538
|
+
keywords?: string[];
|
|
539
|
+
interests?: string[];
|
|
540
|
+
demographics?: any;
|
|
541
|
+
locations?: string[];
|
|
542
|
+
}[];
|
|
543
|
+
/**
|
|
544
|
+
* Success metrics to track
|
|
545
|
+
*/
|
|
546
|
+
kpis: {
|
|
547
|
+
metric: string;
|
|
548
|
+
target: number;
|
|
549
|
+
threshold: number;
|
|
550
|
+
}[];
|
|
551
|
+
}
|
|
552
|
+
interface OptimizationRecommendation {
|
|
553
|
+
/**
|
|
554
|
+
* Campaign ID
|
|
555
|
+
*/
|
|
556
|
+
campaignId: string;
|
|
557
|
+
/**
|
|
558
|
+
* Type of optimization
|
|
559
|
+
*/
|
|
560
|
+
type: 'budget' | 'creative' | 'targeting' | 'bidding';
|
|
561
|
+
/**
|
|
562
|
+
* Current performance
|
|
563
|
+
*/
|
|
564
|
+
current: {
|
|
565
|
+
metric: string;
|
|
566
|
+
value: number;
|
|
567
|
+
};
|
|
568
|
+
/**
|
|
569
|
+
* Recommended action
|
|
570
|
+
*/
|
|
571
|
+
recommendation: string;
|
|
572
|
+
/**
|
|
573
|
+
* Expected impact
|
|
574
|
+
*/
|
|
575
|
+
expectedImpact: {
|
|
576
|
+
metric: string;
|
|
577
|
+
change: number;
|
|
578
|
+
changePercent: number;
|
|
579
|
+
};
|
|
580
|
+
/**
|
|
581
|
+
* Confidence score (0-1)
|
|
582
|
+
*/
|
|
583
|
+
confidence: number;
|
|
584
|
+
/**
|
|
585
|
+
* Reasoning
|
|
586
|
+
*/
|
|
587
|
+
reasoning: string;
|
|
588
|
+
}
|
|
589
|
+
interface CreativeVariant {
|
|
590
|
+
/**
|
|
591
|
+
* Variant ID
|
|
592
|
+
*/
|
|
593
|
+
id: string;
|
|
594
|
+
/**
|
|
595
|
+
* Creative content
|
|
596
|
+
*/
|
|
597
|
+
headline: string;
|
|
598
|
+
description: string;
|
|
599
|
+
callToAction: string;
|
|
600
|
+
/**
|
|
601
|
+
* Performance metrics (if tested)
|
|
602
|
+
*/
|
|
603
|
+
performance?: {
|
|
604
|
+
impressions: number;
|
|
605
|
+
clicks: number;
|
|
606
|
+
ctr: number;
|
|
607
|
+
conversions: number;
|
|
608
|
+
cost: number;
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Amp Advertising Toolbox
|
|
613
|
+
*
|
|
614
|
+
* Provides AI-powered tools for campaign creation, optimization, and creative generation
|
|
615
|
+
*/
|
|
616
|
+
declare class AmpToolbox {
|
|
617
|
+
private client;
|
|
618
|
+
private config;
|
|
619
|
+
constructor(client: Synter, config?: AmpToolboxConfig);
|
|
620
|
+
/**
|
|
621
|
+
* Generate a complete campaign from a brief description
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* ```ts
|
|
625
|
+
* const campaign = await amp.generateCampaign({
|
|
626
|
+
* product: 'AI-powered email marketing platform',
|
|
627
|
+
* audience: 'SaaS marketers, 25-45, tech-savvy',
|
|
628
|
+
* goals: ['lead-generation', 'brand-awareness'],
|
|
629
|
+
* budget: { total: 10000, currency: 'USD' },
|
|
630
|
+
* platforms: ['google', 'linkedin'],
|
|
631
|
+
* brandVoice: 'professional, innovative, data-driven'
|
|
632
|
+
* });
|
|
633
|
+
* ```
|
|
634
|
+
*/
|
|
635
|
+
generateCampaign(brief: CampaignBriefInput): Promise<GeneratedCampaign>;
|
|
636
|
+
/**
|
|
637
|
+
* Generate creative variations for A/B testing
|
|
638
|
+
*
|
|
639
|
+
* @example
|
|
640
|
+
* ```ts
|
|
641
|
+
* const variants = await amp.generateCreativeVariants({
|
|
642
|
+
* baseCreative: {
|
|
643
|
+
* headline: 'Transform Your Email Marketing',
|
|
644
|
+
* description: 'AI-powered automation for better results'
|
|
645
|
+
* },
|
|
646
|
+
* count: 5,
|
|
647
|
+
* platform: 'google'
|
|
648
|
+
* });
|
|
649
|
+
* ```
|
|
650
|
+
*/
|
|
651
|
+
generateCreativeVariants(options: {
|
|
652
|
+
baseCreative?: {
|
|
653
|
+
headline?: string;
|
|
654
|
+
description?: string;
|
|
655
|
+
callToAction?: string;
|
|
656
|
+
};
|
|
657
|
+
productDescription?: string;
|
|
658
|
+
count: number;
|
|
659
|
+
platform: 'google' | 'reddit' | 'x' | 'linkedin';
|
|
660
|
+
tone?: 'professional' | 'casual' | 'urgent' | 'friendly';
|
|
661
|
+
}): Promise<CreativeVariant[]>;
|
|
662
|
+
/**
|
|
663
|
+
* Analyze campaign performance and get AI-powered optimization recommendations
|
|
664
|
+
*
|
|
665
|
+
* @example
|
|
666
|
+
* ```ts
|
|
667
|
+
* const recommendations = await amp.getOptimizationRecommendations({
|
|
668
|
+
* campaignIds: ['cmp_123', 'cmp_456'],
|
|
669
|
+
* window: '7d',
|
|
670
|
+
* minConfidence: 0.7
|
|
671
|
+
* });
|
|
672
|
+
* ```
|
|
673
|
+
*/
|
|
674
|
+
getOptimizationRecommendations(options: {
|
|
675
|
+
campaignIds?: string[];
|
|
676
|
+
window?: string;
|
|
677
|
+
minConfidence?: number;
|
|
678
|
+
}): Promise<OptimizationRecommendation[]>;
|
|
679
|
+
/**
|
|
680
|
+
* Auto-optimize campaigns based on performance data
|
|
681
|
+
*
|
|
682
|
+
* @example
|
|
683
|
+
* ```ts
|
|
684
|
+
* const result = await amp.autoOptimize({
|
|
685
|
+
* campaignIds: ['cmp_123'],
|
|
686
|
+
* dryRun: true, // Preview changes first
|
|
687
|
+
* optimizationTypes: ['budget', 'bidding']
|
|
688
|
+
* });
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
autoOptimize(options: {
|
|
692
|
+
campaignIds?: string[];
|
|
693
|
+
dryRun?: boolean;
|
|
694
|
+
optimizationTypes?: ('budget' | 'creative' | 'targeting' | 'bidding')[];
|
|
695
|
+
minConfidence?: number;
|
|
696
|
+
}): Promise<{
|
|
697
|
+
appliedOptimizations: OptimizationRecommendation[];
|
|
698
|
+
skippedOptimizations: OptimizationRecommendation[];
|
|
699
|
+
dryRun: boolean;
|
|
700
|
+
}>;
|
|
701
|
+
/**
|
|
702
|
+
* Generate keyword suggestions based on product/service
|
|
703
|
+
*
|
|
704
|
+
* @example
|
|
705
|
+
* ```ts
|
|
706
|
+
* const keywords = await amp.generateKeywords({
|
|
707
|
+
* product: 'AI email marketing platform',
|
|
708
|
+
* audience: 'SaaS marketers',
|
|
709
|
+
* count: 50
|
|
710
|
+
* });
|
|
711
|
+
* ```
|
|
712
|
+
*/
|
|
713
|
+
generateKeywords(options: {
|
|
714
|
+
product: string;
|
|
715
|
+
audience?: string;
|
|
716
|
+
competitors?: string[];
|
|
717
|
+
count?: number;
|
|
718
|
+
}): Promise<{
|
|
719
|
+
keywords: Array<{
|
|
720
|
+
keyword: string;
|
|
721
|
+
intent: 'commercial' | 'informational' | 'transactional';
|
|
722
|
+
estimatedVolume?: number;
|
|
723
|
+
competition?: 'low' | 'medium' | 'high';
|
|
724
|
+
relevanceScore: number;
|
|
725
|
+
}>;
|
|
726
|
+
}>;
|
|
727
|
+
/**
|
|
728
|
+
* Analyze competitor ads and get insights
|
|
729
|
+
*
|
|
730
|
+
* @example
|
|
731
|
+
* ```ts
|
|
732
|
+
* const analysis = await amp.analyzeCompetitors({
|
|
733
|
+
* competitors: ['competitor1.com', 'competitor2.com'],
|
|
734
|
+
* industry: 'SaaS'
|
|
735
|
+
* });
|
|
736
|
+
* ```
|
|
737
|
+
*/
|
|
738
|
+
analyzeCompetitors(options: {
|
|
739
|
+
competitors: string[];
|
|
740
|
+
industry?: string;
|
|
741
|
+
}): Promise<{
|
|
742
|
+
competitors: Array<{
|
|
743
|
+
name: string;
|
|
744
|
+
url: string;
|
|
745
|
+
adStrategies: string[];
|
|
746
|
+
messaging: string[];
|
|
747
|
+
strengths: string[];
|
|
748
|
+
weaknesses: string[];
|
|
749
|
+
}>;
|
|
750
|
+
opportunities: string[];
|
|
751
|
+
threats: string[];
|
|
752
|
+
recommendations: string[];
|
|
753
|
+
}>;
|
|
754
|
+
/**
|
|
755
|
+
* Create an A/B test for campaign creatives
|
|
756
|
+
*
|
|
757
|
+
* @example
|
|
758
|
+
* ```ts
|
|
759
|
+
* const test = await amp.createABTest({
|
|
760
|
+
* campaignId: 'cmp_123',
|
|
761
|
+
* variants: [
|
|
762
|
+
* { headline: 'Version A', description: 'Test A' },
|
|
763
|
+
* { headline: 'Version B', description: 'Test B' }
|
|
764
|
+
* ],
|
|
765
|
+
* trafficSplit: [50, 50],
|
|
766
|
+
* duration: '7d'
|
|
767
|
+
* });
|
|
768
|
+
* ```
|
|
769
|
+
*/
|
|
770
|
+
createABTest(options: {
|
|
771
|
+
campaignId: string;
|
|
772
|
+
variants: Array<{
|
|
773
|
+
headline: string;
|
|
774
|
+
description: string;
|
|
775
|
+
callToAction?: string;
|
|
776
|
+
}>;
|
|
777
|
+
trafficSplit?: number[];
|
|
778
|
+
duration?: string;
|
|
779
|
+
successMetric?: 'ctr' | 'conversions' | 'cpa' | 'roas';
|
|
780
|
+
}): Promise<{
|
|
781
|
+
testId: string;
|
|
782
|
+
status: 'running' | 'scheduled';
|
|
783
|
+
variants: CreativeVariant[];
|
|
784
|
+
startDate: string;
|
|
785
|
+
endDate: string;
|
|
786
|
+
}>;
|
|
787
|
+
/**
|
|
788
|
+
* Get A/B test results and winner
|
|
789
|
+
*
|
|
790
|
+
* @example
|
|
791
|
+
* ```ts
|
|
792
|
+
* const results = await amp.getABTestResults('test_123');
|
|
793
|
+
* ```
|
|
794
|
+
*/
|
|
795
|
+
getABTestResults(testId: string): Promise<{
|
|
796
|
+
testId: string;
|
|
797
|
+
status: 'running' | 'completed' | 'inconclusive';
|
|
798
|
+
variants: CreativeVariant[];
|
|
799
|
+
winner?: {
|
|
800
|
+
variantId: string;
|
|
801
|
+
confidence: number;
|
|
802
|
+
improvement: number;
|
|
803
|
+
};
|
|
804
|
+
recommendations: string[];
|
|
805
|
+
}>;
|
|
806
|
+
/**
|
|
807
|
+
* Generate audience personas based on campaign data
|
|
808
|
+
*
|
|
809
|
+
* @example
|
|
810
|
+
* ```ts
|
|
811
|
+
* const personas = await amp.generatePersonas({
|
|
812
|
+
* campaignIds: ['cmp_123'],
|
|
813
|
+
* count: 3
|
|
814
|
+
* });
|
|
815
|
+
* ```
|
|
816
|
+
*/
|
|
817
|
+
generatePersonas(options: {
|
|
818
|
+
campaignIds?: string[];
|
|
819
|
+
product?: string;
|
|
820
|
+
industry?: string;
|
|
821
|
+
count?: number;
|
|
822
|
+
}): Promise<{
|
|
823
|
+
personas: Array<{
|
|
824
|
+
name: string;
|
|
825
|
+
demographics: {
|
|
826
|
+
age: string;
|
|
827
|
+
gender?: string;
|
|
828
|
+
location?: string;
|
|
829
|
+
income?: string;
|
|
830
|
+
};
|
|
831
|
+
psychographics: {
|
|
832
|
+
interests: string[];
|
|
833
|
+
values: string[];
|
|
834
|
+
painPoints: string[];
|
|
835
|
+
};
|
|
836
|
+
behavior: {
|
|
837
|
+
platforms: string[];
|
|
838
|
+
contentPreferences: string[];
|
|
839
|
+
purchaseDrivers: string[];
|
|
840
|
+
};
|
|
841
|
+
messagingTips: string[];
|
|
842
|
+
}>;
|
|
843
|
+
}>;
|
|
844
|
+
/**
|
|
845
|
+
* Predict campaign performance before launch
|
|
846
|
+
*
|
|
847
|
+
* @example
|
|
848
|
+
* ```ts
|
|
849
|
+
* const prediction = await amp.predictPerformance({
|
|
850
|
+
* platform: 'google',
|
|
851
|
+
* budget: { daily: 100, total: 3000 },
|
|
852
|
+
* targeting: { keywords: ['email marketing', 'automation'] },
|
|
853
|
+
* creative: { headline: 'Transform Your Email Marketing' }
|
|
854
|
+
* });
|
|
855
|
+
* ```
|
|
856
|
+
*/
|
|
857
|
+
predictPerformance(options: {
|
|
858
|
+
platform: string;
|
|
859
|
+
budget: {
|
|
860
|
+
daily?: number;
|
|
861
|
+
total: number;
|
|
862
|
+
};
|
|
863
|
+
targeting: any;
|
|
864
|
+
creative: {
|
|
865
|
+
headline: string;
|
|
866
|
+
description?: string;
|
|
867
|
+
};
|
|
868
|
+
}): Promise<{
|
|
869
|
+
estimatedMetrics: {
|
|
870
|
+
impressions: {
|
|
871
|
+
min: number;
|
|
872
|
+
max: number;
|
|
873
|
+
expected: number;
|
|
874
|
+
};
|
|
875
|
+
clicks: {
|
|
876
|
+
min: number;
|
|
877
|
+
max: number;
|
|
878
|
+
expected: number;
|
|
879
|
+
};
|
|
880
|
+
conversions: {
|
|
881
|
+
min: number;
|
|
882
|
+
max: number;
|
|
883
|
+
expected: number;
|
|
884
|
+
};
|
|
885
|
+
cpa: {
|
|
886
|
+
min: number;
|
|
887
|
+
max: number;
|
|
888
|
+
expected: number;
|
|
889
|
+
};
|
|
890
|
+
};
|
|
891
|
+
confidence: number;
|
|
892
|
+
recommendations: string[];
|
|
893
|
+
}>;
|
|
894
|
+
/**
|
|
895
|
+
* Get intelligent budget allocation across platforms
|
|
896
|
+
*
|
|
897
|
+
* @example
|
|
898
|
+
* ```ts
|
|
899
|
+
* const allocation = await amp.optimizeBudgetAllocation({
|
|
900
|
+
* totalBudget: 10000,
|
|
901
|
+
* platforms: ['google', 'linkedin', 'reddit'],
|
|
902
|
+
* goal: 'conversions'
|
|
903
|
+
* });
|
|
904
|
+
* ```
|
|
905
|
+
*/
|
|
906
|
+
optimizeBudgetAllocation(options: {
|
|
907
|
+
totalBudget: number;
|
|
908
|
+
platforms: string[];
|
|
909
|
+
goal: 'conversions' | 'awareness' | 'engagement' | 'revenue';
|
|
910
|
+
constraints?: {
|
|
911
|
+
minPerPlatform?: number;
|
|
912
|
+
maxPerPlatform?: number;
|
|
913
|
+
};
|
|
914
|
+
}): Promise<{
|
|
915
|
+
allocation: Array<{
|
|
916
|
+
platform: string;
|
|
917
|
+
amount: number;
|
|
918
|
+
percentage: number;
|
|
919
|
+
expectedROI: number;
|
|
920
|
+
reasoning: string;
|
|
921
|
+
}>;
|
|
922
|
+
totalBudget: number;
|
|
923
|
+
expectedOverallROI: number;
|
|
924
|
+
}>;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Error types for @synterai/sdk-js
|
|
929
|
+
*
|
|
930
|
+
* Per SPEC.md's "Error model" section: every SDK exposes one error type
|
|
931
|
+
* carrying `message`, `status`, `code`, and `details`, plus a distinct,
|
|
932
|
+
* clearly-named error for client-side validation failures (caught before
|
|
933
|
+
* any network call) so callers can tell "I called it wrong" apart from
|
|
934
|
+
* "the API rejected it" apart from "the network failed".
|
|
935
|
+
*/
|
|
936
|
+
/**
|
|
937
|
+
* Raised for any non-2xx response from the Synter API, and for network
|
|
938
|
+
* failures that exhaust the retry budget (in which case `status` is `0`,
|
|
939
|
+
* per SPEC.md's error model: "0 or absent for network-level failures").
|
|
940
|
+
*/
|
|
941
|
+
declare class SynterError extends Error {
|
|
942
|
+
/** HTTP status code; `0` for network-level failures. */
|
|
943
|
+
readonly status: number;
|
|
944
|
+
/** Machine-readable error code from the response body, when present. */
|
|
945
|
+
readonly code: string | null;
|
|
946
|
+
/** Additional structured error detail from the response body, when present. */
|
|
947
|
+
readonly details: Record<string, unknown> | null;
|
|
948
|
+
constructor(message: string, status?: number, code?: string | null, details?: Record<string, unknown> | null);
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* Raised when a required field is missing (or malformed) for a tool call,
|
|
952
|
+
* caught client-side before any network request is made. Distinct from
|
|
953
|
+
* {@link SynterError} so callers can tell a bad call apart from a rejected
|
|
954
|
+
* or failed one.
|
|
955
|
+
*/
|
|
956
|
+
declare class SynterValidationError extends Error {
|
|
957
|
+
/** The input field that failed validation, when applicable. */
|
|
958
|
+
readonly field?: string;
|
|
959
|
+
constructor(message: string, field?: string);
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Main Synter SDK client.
|
|
964
|
+
*
|
|
965
|
+
* Transport per SPEC.md: nearly every tool dispatches through
|
|
966
|
+
* `POST /api/v1/tools/run` on `https://syntermedia.ai` with
|
|
967
|
+
* `{ script_name, args, platform? }`, auth via `Authorization: Bearer <key>`.
|
|
968
|
+
* Two tools bypass that dispatcher (`list_landing_pages`, `stage_audience_artifact`)
|
|
969
|
+
* — see `resources/audiences.ts` and `listLandingPages` below.
|
|
970
|
+
*/
|
|
971
|
+
|
|
972
|
+
/** Real, production base URL — see SPEC.md's "Transport" section. */
|
|
973
|
+
declare const DEFAULT_BASE_URL = "https://syntermedia.ai";
|
|
974
|
+
interface SynterConfig {
|
|
975
|
+
/** `syn_` + 32 base64url characters, issued at syntermedia.ai/developer. */
|
|
976
|
+
apiKey: string;
|
|
977
|
+
/** Override the base URL (defaults to `https://syntermedia.ai`). Mostly for tests. */
|
|
978
|
+
baseUrl?: string;
|
|
979
|
+
/** Request timeout in ms. Default 30000 (30s), per SPEC.md. */
|
|
980
|
+
timeout?: number;
|
|
981
|
+
/** Max retry attempts for 429s and network/timeout errors. Default 3, per SPEC.md. */
|
|
982
|
+
maxRetries?: number;
|
|
983
|
+
/** Inject a custom `fetch` implementation — primarily for testing without a real network. */
|
|
984
|
+
fetch?: typeof fetch;
|
|
985
|
+
}
|
|
986
|
+
interface UploadImageInput {
|
|
987
|
+
/** Source image URL. */
|
|
988
|
+
image_url: string;
|
|
989
|
+
/** Asset name for organization. */
|
|
990
|
+
asset_name: string;
|
|
991
|
+
/**
|
|
992
|
+
* Optional platform hint (google/meta/linkedin).
|
|
993
|
+
*
|
|
994
|
+
* KNOWN ISSUE (see SPEC.md "Known issues" #2, catalog.json `knownIssues`):
|
|
995
|
+
* live dispatch hardcodes `platform=google` unconditionally regardless of
|
|
996
|
+
* this value. Preserved verbatim — not silently "fixed" here.
|
|
997
|
+
*/
|
|
998
|
+
platform?: 'google' | 'meta' | 'linkedin';
|
|
999
|
+
}
|
|
1000
|
+
declare class Synter {
|
|
1001
|
+
private readonly apiKey;
|
|
1002
|
+
private readonly baseUrl;
|
|
1003
|
+
private readonly timeout;
|
|
1004
|
+
private readonly maxRetries;
|
|
1005
|
+
private readonly fetchImpl;
|
|
1006
|
+
readonly campaigns: CampaignsResource;
|
|
1007
|
+
readonly analytics: AnalyticsResource;
|
|
1008
|
+
readonly keywords: KeywordsResource;
|
|
1009
|
+
readonly conversions: ConversionsResource;
|
|
1010
|
+
readonly creative: CreativeResource;
|
|
1011
|
+
readonly meta: MetaResource;
|
|
1012
|
+
readonly linkedin: LinkedInResource;
|
|
1013
|
+
readonly reddit: RedditResource;
|
|
1014
|
+
readonly audiences: AudiencesResource;
|
|
1015
|
+
/** AI-powered advertising toolbox for Amp integration — unchanged, out of scope for the transport rewrite. */
|
|
1016
|
+
readonly amp: AmpToolbox;
|
|
1017
|
+
constructor(config: SynterConfig | string, ampConfig?: AmpToolboxConfig);
|
|
1018
|
+
/**
|
|
1019
|
+
* Low-level dispatcher used by every typed resource method. Not usually
|
|
1020
|
+
* called directly by SDK consumers — use `execute()` for the public
|
|
1021
|
+
* escape hatch, or a typed resource method for everything else.
|
|
1022
|
+
*/
|
|
1023
|
+
runTool(scriptName: string, args?: string[], platform?: string): Promise<Record<string, unknown>>;
|
|
1024
|
+
/**
|
|
1025
|
+
* Universal escape hatch mirroring the `run_tool` catalog tool: run any
|
|
1026
|
+
* of the 140+ backend scripts by name. `args` is an idiomatic flag-name
|
|
1027
|
+
* map (not a raw CLI string array) — converted internally the same way
|
|
1028
|
+
* every other typed method builds its wire args.
|
|
1029
|
+
*/
|
|
1030
|
+
execute(scriptName: string, args?: Record<string, string | number | boolean>, platform?: string): Promise<Record<string, unknown>>;
|
|
1031
|
+
/** List all connected ad accounts across platforms. */
|
|
1032
|
+
listAdAccounts(): Promise<Record<string, unknown>>;
|
|
1033
|
+
/**
|
|
1034
|
+
* Upload an image as an asset for use in ads.
|
|
1035
|
+
*
|
|
1036
|
+
* KNOWN ISSUE (SPEC.md "Known issues" #2): live dispatch hardcodes
|
|
1037
|
+
* `platform=google` regardless of `input.platform`. Preserved verbatim.
|
|
1038
|
+
*/
|
|
1039
|
+
uploadImage(input: UploadImageInput): Promise<Record<string, unknown>>;
|
|
1040
|
+
/**
|
|
1041
|
+
* List all landing pages for the authenticated workspace.
|
|
1042
|
+
*
|
|
1043
|
+
* Bypasses the primary `tools/run` dispatcher — special endpoint per
|
|
1044
|
+
* SPEC.md/catalog.json `transport.special`: `GET /api/v1/landing-pages`.
|
|
1045
|
+
*/
|
|
1046
|
+
listLandingPages(): Promise<Record<string, unknown>>;
|
|
1047
|
+
private authHeaders;
|
|
1048
|
+
/** The raw API key, for the small number of tools that need a non-Bearer header (e.g. `stage_audience_artifact`). */
|
|
1049
|
+
getApiKey(): string;
|
|
1050
|
+
/**
|
|
1051
|
+
* Low-level generic HTTP helper retained for `AmpToolbox` and any other
|
|
1052
|
+
* advanced/internal callers that need to hit an arbitrary path relative
|
|
1053
|
+
* to the configured base URL, with the same retry/timeout/error
|
|
1054
|
+
* semantics as the primary dispatcher.
|
|
1055
|
+
*/
|
|
1056
|
+
request<T = unknown>(method: string, path: string, options?: {
|
|
1057
|
+
body?: unknown;
|
|
1058
|
+
query?: Record<string, unknown>;
|
|
1059
|
+
headers?: Record<string, string>;
|
|
1060
|
+
}): Promise<T>;
|
|
1061
|
+
/**
|
|
1062
|
+
* Sends a request to an arbitrary absolute URL with arbitrary headers —
|
|
1063
|
+
* used by the two special-endpoint tools (`list_landing_pages` uses
|
|
1064
|
+
* `request`/`runTool` against the default base URL; `stage_audience_artifact`
|
|
1065
|
+
* needs a different host and a different auth header entirely).
|
|
1066
|
+
*/
|
|
1067
|
+
sendAbsolute<T = unknown>(url: string, init: {
|
|
1068
|
+
method: string;
|
|
1069
|
+
headers: Record<string, string>;
|
|
1070
|
+
body?: string;
|
|
1071
|
+
}): Promise<T>;
|
|
1072
|
+
/**
|
|
1073
|
+
* Core transport: timeout + retry policy from SPEC.md — up to 3 retries,
|
|
1074
|
+
* exponential backoff (1s base, 10s cap), retrying only 429 (honoring
|
|
1075
|
+
* `Retry-After`) and network/timeout errors. Never retries other 4xx
|
|
1076
|
+
* (or 5xx — not listed in SPEC.md's `retryOn`).
|
|
1077
|
+
*/
|
|
1078
|
+
private sendWithRetry;
|
|
1079
|
+
private toSynterError;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* Legacy support types.
|
|
1084
|
+
*
|
|
1085
|
+
* These are unrelated to the catalog.json-driven tool methods (see
|
|
1086
|
+
* `resources/*.ts` and `resources/shared-types.ts` for those) — they back
|
|
1087
|
+
* `utils/utm.ts`, `utils/conversion-tracking.ts`, and
|
|
1088
|
+
* `utils/analytics-integrations.ts`, which are out of scope for the
|
|
1089
|
+
* transport rewrite and kept as-is. Trimmed of the fictional REST-API
|
|
1090
|
+
* business types (`Campaign`, `Conversion`, `Agent*`, `DataExport*`, etc.)
|
|
1091
|
+
* that used to live here alongside the old, non-functional client.
|
|
1092
|
+
*/
|
|
1093
|
+
type Platform = 'google' | 'reddit' | 'x';
|
|
1094
|
+
type PlatformStatus = 'connected' | 'disconnected' | 'error';
|
|
1095
|
+
interface PlatformConnection {
|
|
1096
|
+
platform: Platform;
|
|
1097
|
+
status: PlatformStatus;
|
|
1098
|
+
accountId?: string;
|
|
1099
|
+
accountName?: string;
|
|
1100
|
+
connectedAt?: string;
|
|
1101
|
+
lastSyncedAt?: string;
|
|
1102
|
+
}
|
|
1103
|
+
interface UTMTemplate {
|
|
1104
|
+
source: string;
|
|
1105
|
+
medium: string;
|
|
1106
|
+
campaign: string;
|
|
1107
|
+
content?: string;
|
|
1108
|
+
term?: string;
|
|
1109
|
+
}
|
|
1110
|
+
interface UTMParameters extends UTMTemplate {
|
|
1111
|
+
/** Auto-populated fields using platform macros */
|
|
1112
|
+
dynamicFields?: Record<string, string>;
|
|
1113
|
+
}
|
|
1114
|
+
type AnalyticsPlatform = 'posthog' | 'heap' | 'mixpanel' | 'segment';
|
|
1115
|
+
interface AnalyticsEvent {
|
|
1116
|
+
event: string;
|
|
1117
|
+
properties?: Record<string, any>;
|
|
1118
|
+
timestamp?: string;
|
|
1119
|
+
userId?: string;
|
|
1120
|
+
anonymousId?: string;
|
|
1121
|
+
}
|
|
1122
|
+
interface AnalyticsIntegrationConfig {
|
|
1123
|
+
platform: AnalyticsPlatform;
|
|
1124
|
+
apiKey: string;
|
|
1125
|
+
enabled: boolean;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* UTM parameter management utilities
|
|
1130
|
+
*
|
|
1131
|
+
* Handles automatic UTM generation with platform-specific macros
|
|
1132
|
+
*/
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Build complete UTM parameters with platform-specific macros
|
|
1136
|
+
*/
|
|
1137
|
+
declare function buildUTMParameters(template: UTMTemplate, platform: Platform): UTMParameters;
|
|
1138
|
+
/**
|
|
1139
|
+
* Generate tracking URL with UTM parameters
|
|
1140
|
+
*/
|
|
1141
|
+
declare function buildTrackingURL(baseUrl: string, utmParams: UTMParameters): string;
|
|
1142
|
+
/**
|
|
1143
|
+
* Extract UTM parameters from URL
|
|
1144
|
+
*/
|
|
1145
|
+
declare function extractUTMParameters(url: string): Partial<UTMParameters>;
|
|
1146
|
+
/**
|
|
1147
|
+
* Validate UTM template
|
|
1148
|
+
*/
|
|
1149
|
+
declare function validateUTMTemplate(template: UTMTemplate): {
|
|
1150
|
+
valid: boolean;
|
|
1151
|
+
errors: string[];
|
|
1152
|
+
};
|
|
1153
|
+
/**
|
|
1154
|
+
* Generate default UTM template for a campaign
|
|
1155
|
+
*/
|
|
1156
|
+
declare function generateDefaultUTMTemplate(platform: Platform, campaignName: string): UTMTemplate;
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* Conversion tracking utilities
|
|
1160
|
+
*
|
|
1161
|
+
* Handles click ID detection and conversion event normalization
|
|
1162
|
+
*/
|
|
1163
|
+
|
|
1164
|
+
/**
|
|
1165
|
+
* Detect platform and click ID from URL parameters
|
|
1166
|
+
*/
|
|
1167
|
+
declare function detectClickId(urlOrParams: string | Record<string, string>): {
|
|
1168
|
+
platform: Platform | null;
|
|
1169
|
+
clickId: string | null;
|
|
1170
|
+
paramName: string | null;
|
|
1171
|
+
};
|
|
1172
|
+
/**
|
|
1173
|
+
* Extract all tracking parameters from URL
|
|
1174
|
+
*/
|
|
1175
|
+
interface TrackingParams {
|
|
1176
|
+
clickIds: Partial<Record<Platform, string>>;
|
|
1177
|
+
utm: {
|
|
1178
|
+
source?: string;
|
|
1179
|
+
medium?: string;
|
|
1180
|
+
campaign?: string;
|
|
1181
|
+
content?: string;
|
|
1182
|
+
term?: string;
|
|
1183
|
+
};
|
|
1184
|
+
referrer?: string;
|
|
1185
|
+
}
|
|
1186
|
+
declare function extractTrackingParams(url: string, referrer?: string): TrackingParams;
|
|
1187
|
+
/**
|
|
1188
|
+
* Validate click ID format by platform
|
|
1189
|
+
*/
|
|
1190
|
+
declare function validateClickId(platform: Platform, clickId: string): boolean;
|
|
1191
|
+
/**
|
|
1192
|
+
* Build conversion payload for platform-specific APIs
|
|
1193
|
+
*/
|
|
1194
|
+
interface ConversionPayload {
|
|
1195
|
+
platform: Platform;
|
|
1196
|
+
clickId: string;
|
|
1197
|
+
conversionName: string;
|
|
1198
|
+
conversionTime: string;
|
|
1199
|
+
value?: number;
|
|
1200
|
+
currency?: string;
|
|
1201
|
+
orderId?: string;
|
|
1202
|
+
}
|
|
1203
|
+
declare function buildConversionPayload(params: {
|
|
1204
|
+
platform: Platform;
|
|
1205
|
+
clickId: string;
|
|
1206
|
+
event: string;
|
|
1207
|
+
value?: number;
|
|
1208
|
+
currency?: string;
|
|
1209
|
+
timestamp?: string;
|
|
1210
|
+
orderId?: string;
|
|
1211
|
+
}): ConversionPayload;
|
|
1212
|
+
declare function normalizeEventName(eventName: string, platform: Platform): string;
|
|
1213
|
+
|
|
1214
|
+
/**
|
|
1215
|
+
* Analytics platform integrations (PostHog, Heap, Mixpanel)
|
|
1216
|
+
*
|
|
1217
|
+
* Fan out ad events to downstream analytics tools
|
|
1218
|
+
*/
|
|
1219
|
+
|
|
1220
|
+
interface AnalyticsIntegration {
|
|
1221
|
+
platform: AnalyticsPlatform;
|
|
1222
|
+
apiKey: string;
|
|
1223
|
+
enabled: boolean;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Analytics integration manager
|
|
1227
|
+
*/
|
|
1228
|
+
declare class AnalyticsIntegrationManager {
|
|
1229
|
+
private adapters;
|
|
1230
|
+
constructor(integrations: AnalyticsIntegration[]);
|
|
1231
|
+
/**
|
|
1232
|
+
* Track event across all enabled integrations
|
|
1233
|
+
*/
|
|
1234
|
+
track(event: AnalyticsEvent): Promise<void>;
|
|
1235
|
+
/**
|
|
1236
|
+
* Track event to specific platform
|
|
1237
|
+
*/
|
|
1238
|
+
trackTo(platform: AnalyticsPlatform, event: AnalyticsEvent): Promise<void>;
|
|
1239
|
+
/**
|
|
1240
|
+
* Identify user across all enabled integrations
|
|
1241
|
+
*/
|
|
1242
|
+
identify(userId: string, traits?: Record<string, any>): Promise<void>;
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Normalize ad click event for analytics platforms
|
|
1246
|
+
*/
|
|
1247
|
+
declare function normalizeAdClickEvent(trackingParams: any): AnalyticsEvent;
|
|
1248
|
+
/**
|
|
1249
|
+
* Normalize conversion event for analytics platforms
|
|
1250
|
+
*/
|
|
1251
|
+
declare function normalizeConversionEvent(params: {
|
|
1252
|
+
event: string;
|
|
1253
|
+
value?: number;
|
|
1254
|
+
currency?: string;
|
|
1255
|
+
platform?: string;
|
|
1256
|
+
campaignId?: string;
|
|
1257
|
+
metadata?: Record<string, any>;
|
|
1258
|
+
}): AnalyticsEvent;
|
|
1259
|
+
|
|
1260
|
+
export { type AdPlatform, type AddKeywordsInput, type AddNegativeKeywordsInput, AmpToolbox, type AmpToolboxConfig, type AnalyticsEvent, type AnalyticsIntegration, type AnalyticsIntegrationConfig, AnalyticsIntegrationManager, type AnalyticsPlatform, AnalyticsResource, AudiencesResource, type CampaignBriefInput, CampaignsResource, type ConversionPayload, ConversionsResource, type CreateConversionInput, type CreateDisplayCampaignInput, type CreateLinkedInCampaignInput, type CreateMetaCampaignInput, type CreatePmaxCampaignInput, type CreateRedditCampaignInput, type CreateSearchCampaignInput, CreativeResource, type CreativeVariant, DEFAULT_BASE_URL, type DateRange, type DiagnoseTrackingInput, type GenerateImageInput, type GenerateVideoInput, type GeneratedCampaign, type GetDailySpendInput, type GetPerformanceInput, KeywordsResource, LinkedInResource, type ListCampaignsInput, type ManageAudienceInput, MetaResource, type OptimizationRecommendation, type PauseCampaignInput, type Platform, type PlatformConnection, type PlatformStatus, RedditResource, type StageAudienceArtifactInput, type StageAudienceArtifactResult, type SyncAudienceInput, Synter, type SynterConfig, SynterError, SynterValidationError, type TrackingParams, type UTMParameters, type UTMTemplate, type UpdateCampaignBudgetInput, type UploadImageInput, buildConversionPayload, buildTrackingURL, buildUTMParameters, Synter as default, detectClickId, extractTrackingParams, extractUTMParameters, generateDefaultUTMTemplate, normalizeAdClickEvent, normalizeConversionEvent, normalizeEventName, validateClickId, validateUTMTemplate };
|