@hermoso/ads 0.0.0-stage → 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.
@@ -0,0 +1,391 @@
1
+ # Bring your own developer app
2
+
3
+ `@hermoso/ads` talks to each ad platform with **your** credentials. Each section below says which developer app
4
+ to create, which scopes to request, what review the platform requires, and which credential fields (and
5
+ environment variables, for the MCP server) to set.
6
+
7
+ > **Or use hosted Hermoso.** Getting a developer app approved takes weeks to months on several of these platforms.
8
+ > [Hosted Hermoso](https://hermoso.ai) connects with one click where supported, and you use the same tools over the
9
+ > hosted MCP at `https://app.hermoso.ai/mcp`, plus AI ad creative and research.
10
+ > ChatGPT Ads, Apple Ads, AppLovin, Outbrain, Taboola and The Trade Desk issue credentials per advertiser,
11
+ > so you connect those with your own credentials on hosted Hermoso too. Each section below says which applies.
12
+
13
+ Credentials are read through `@hermoso/core`'s `credentialStore` (`get(account, provider)`), keyed by the
14
+ **provider** shown below. Store them once:
15
+
16
+ ```js
17
+ import { connectors } from '@hermoso/core';
18
+ await connectors.credentialStore.set('default', 'google_ads', { clientId, clientSecret, refreshToken, developerToken });
19
+ ```
20
+
21
+ or pass any store (`memoryCredentialStore`, `envCredentialStore`) to `createAds({ credentials })`. Access tokens
22
+ that expire are refreshed automatically when a refresh token (and the app's client id/secret) is stored, and the
23
+ refreshed token is written back to the store.
24
+
25
+ ## Platforms
26
+
27
+ - [Meta Ads](#meta) (`meta`)
28
+ - [Google Ads](#google-ads) (`google_ads`)
29
+ - [Microsoft Advertising](#microsoft-ads) (`microsoft_ads`)
30
+ - [LinkedIn Ads](#linkedin-ads) (`linkedin_ads`)
31
+ - [TikTok Ads](#tiktok-ads) (`tiktok_ads`)
32
+ - [Reddit Ads](#reddit-ads) (`reddit_ads`)
33
+ - [Pinterest Ads](#pinterest-ads) (`pinterest_ads`)
34
+ - [Snapchat Ads](#snapchat-ads) (`snapchat_ads`)
35
+ - [X Ads](#x-ads) (`x_ads`)
36
+ - [ChatGPT Ads](#openai-ads) (`openai_ads`)
37
+ - [Apple Ads](#apple-ads) (`apple_ads`)
38
+ - [Amazon Ads](#amazon-ads) (`amazon_ads`)
39
+ - [AppLovin](#applovin-ads) (`applovin_ads`)
40
+ - [Outbrain](#outbrain-ads) (`outbrain_ads`)
41
+ - [Taboola](#taboola-ads) (`taboola_ads`)
42
+ - [The Trade Desk](#trade-desk) (`trade_desk`)
43
+
44
+ <a id="meta"></a>
45
+ ## Meta Ads
46
+
47
+ - **Platform id:** `meta` · **credential provider:** `meta` · **money on the wire:** minor units (cents) (you always pass plain amounts)
48
+ - **Developer app:** A Meta app (type Business) at developers.facebook.com with the Marketing API product added.
49
+ - **Scopes:** `ads_management`, `ads_read`, `business_management`, `pages_show_list`, `pages_manage_ads`, `pages_read_engagement`
50
+ - **Review / access:** Standard access works for ad accounts you (or your app's roles) own. Managing other people's accounts needs Advanced Access for ads_management and ads_read through App Review, plus Business Verification.
51
+ - **Hosted:** Hosted Hermoso connects with one click where supported, with no developer app of your own.
52
+ - **Docs:** https://developers.facebook.com/docs/marketing-apis
53
+
54
+ | Field | Env var | Required | Notes |
55
+ |---|---|---|---|
56
+ | `accessToken` | `META_ACCESS_TOKEN` | yes | User or system-user access token with ads_management + ads_read. |
57
+ | `appId` | `META_APP_ID` | | Optional: your app id, to renew long-lived tokens. |
58
+ | `appSecret` | `META_APP_SECRET` | | Optional: your app secret, to renew long-lived tokens. |
59
+ | `graphVersion` | `META_GRAPH_VERSION` | | Optional Graph API version (default v27.0). |
60
+
61
+ - Budgets are plain amounts; they are converted to the account currency's minor unit (zero-decimal currencies like JPY are sent as-is).
62
+ - special_ad_categories is always sent (empty when none). A special category also needs specialAdCountries.
63
+ - Advantage+ creative enhancements are opted out by default; pass creativeFeatures to opt in.
64
+ - Deletes do not cascade on Meta, so deleteObject removes ads, then ad sets, then the campaign.
65
+
66
+ <a id="google-ads"></a>
67
+ ## Google Ads
68
+
69
+ - **Platform id:** `google_ads` · **credential provider:** `google_ads` · **money on the wire:** micros (1,000,000 = 1) (you always pass plain amounts)
70
+ - **Developer app:** A Google Cloud project with the Google Ads API enabled, an OAuth client (web or desktop), and a developer token from a Google Ads manager account (API Center).
71
+ - **Scopes:** `https://www.googleapis.com/auth/adwords`
72
+ - **Review / access:** The adwords scope is sensitive: an external OAuth app needs Google verification. The developer token starts at Test access (test accounts only); apply for Basic, then Standard access for production accounts and higher quotas.
73
+ - **Hosted:** Hosted Hermoso connects with one click where supported, with no developer app of your own.
74
+ - **Docs:** https://developers.google.com/google-ads/api/docs/start
75
+
76
+ | Field | Env var | Required | Notes |
77
+ |---|---|---|---|
78
+ | `clientId` | `GOOGLE_ADS_CLIENT_ID` | yes | OAuth client id of your Google Cloud project. |
79
+ | `clientSecret` | `GOOGLE_ADS_CLIENT_SECRET` | yes | |
80
+ | `refreshToken` | `GOOGLE_ADS_REFRESH_TOKEN` | yes | From an OAuth consent with the adwords scope and access_type=offline. |
81
+ | `developerToken` | `GOOGLE_ADS_DEVELOPER_TOKEN` | | Developer token from your manager account (sent when set). |
82
+ | `loginCustomerId` | `GOOGLE_ADS_LOGIN_CUSTOMER_ID` | | Manager account id, only when acting on a client through a manager. |
83
+ | `apiVersion` | `GOOGLE_ADS_API_VERSION` | | Default v26. |
84
+
85
+ - Account ids are digits only (dashes are stripped).
86
+ - Campaign creation is one atomic mutate: budget, campaign and targeting succeed or fail together.
87
+ - Pass validateOnly: true to any create to have Google check it without creating anything.
88
+ - Removing a campaign also removes its budget when nothing else uses it.
89
+
90
+ <a id="microsoft-ads"></a>
91
+ ## Microsoft Advertising
92
+
93
+ - **Platform id:** `microsoft_ads` · **credential provider:** `microsoft_ads` · **money on the wire:** plain amounts (you always pass plain amounts)
94
+ - **Developer app:** An app registration in Microsoft Entra ID (Azure portal) with a redirect URI, plus a developer token requested in Microsoft Advertising (Settings > Developer settings).
95
+ - **Scopes:** `https://ads.microsoft.com/msads.manage`, `offline_access`, `openid`
96
+ - **Review / access:** A multi-tenant app needs publisher verification for other organisations to consent. The developer token is issued per user; a universal sandbox token exists for testing.
97
+ - **Hosted:** Hosted Hermoso connects with one click where supported, with no developer app of your own.
98
+ - **Docs:** https://learn.microsoft.com/advertising/guides/get-started
99
+
100
+ | Field | Env var | Required | Notes |
101
+ |---|---|---|---|
102
+ | `clientId` | `MICROSOFT_ADS_CLIENT_ID` | yes | Entra (Azure AD) app registration client id. |
103
+ | `clientSecret` | `MICROSOFT_ADS_CLIENT_SECRET` | | Client secret (web apps); omit for public clients. |
104
+ | `refreshToken` | `MICROSOFT_ADS_REFRESH_TOKEN` | yes | |
105
+ | `developerToken` | `MICROSOFT_ADS_DEVELOPER_TOKEN` | yes | From Microsoft Advertising > Settings > Developer settings. |
106
+ | `customerId` | `MICROSOFT_ADS_CUSTOMER_ID` | yes | Manager/customer id that owns the accounts. |
107
+ | `sandbox` | `MICROSOFT_ADS_SANDBOX` | | "true" to use the sandbox hosts. |
108
+
109
+ - With no locations a campaign serves worldwide; createCampaign says so loudly.
110
+ - Campaign types are a flags enum sent as a comma-separated string.
111
+ - A shared budget makes a campaign's DailyBudget read-only; setBudget refuses it.
112
+ - Reports are submitted, polled and downloaded as a zipped CSV; a pending report returns reportRequestId to resume.
113
+
114
+ <a id="linkedin-ads"></a>
115
+ ## LinkedIn Ads
116
+
117
+ - **Platform id:** `linkedin_ads` · **credential provider:** `linkedin` · **money on the wire:** plain amounts (you always pass plain amounts)
118
+ - **Developer app:** A LinkedIn developer app (linkedin.com/developers) associated with a company Page, with the Advertising API product added.
119
+ - **Scopes:** `r_ads`, `rw_ads`, `r_ads_reporting`
120
+ - **Review / access:** The Advertising API product starts at the Development tier (read for any account you can access, edit for up to 5 registered ad accounts); apply for the Standard tier to manage more. Request only the scopes your app was granted: one ungranted scope fails the whole consent screen.
121
+ - **Hosted:** Hosted Hermoso connects with one click where supported, with no developer app of your own.
122
+ - **Docs:** https://learn.microsoft.com/linkedin/marketing/
123
+
124
+ | Field | Env var | Required | Notes |
125
+ |---|---|---|---|
126
+ | `accessToken` | `LINKEDIN_ADS_ACCESS_TOKEN` | unless refreshToken is set | Token with r_ads, rw_ads, r_ads_reporting. |
127
+ | `refreshToken` | `LINKEDIN_ADS_REFRESH_TOKEN` | | |
128
+ | `clientId` | `LINKEDIN_ADS_CLIENT_ID` | | |
129
+ | `clientSecret` | `LINKEDIN_ADS_CLIENT_SECRET` | | |
130
+ | `linkedinVersion` | `LINKEDIN_VERSION` | | API version YYYYMM (default 202611). LinkedIn retires each version after about a year. |
131
+
132
+ - Vocabulary: campaign = LinkedIn campaign group, adGroup = LinkedIn campaign (targeting, budget, bid), ad = creative.
133
+ - Everything is created as DRAFT. Nothing serves unless the group, the campaign and a creative are all ACTIVE.
134
+ - Only DRAFT objects can be hard-deleted; anything else is moved to PENDING_DELETION (history is kept).
135
+ - A daily budget can be overspent by up to 50% on high-opportunity days.
136
+ - audience counts under 300 are reported as 0 by LinkedIn (privacy floor), not empty.
137
+
138
+ <a id="tiktok-ads"></a>
139
+ ## TikTok Ads
140
+
141
+ - **Platform id:** `tiktok_ads` · **credential provider:** `tiktok_ads` · **money on the wire:** plain amounts (you always pass plain amounts)
142
+ - **Developer app:** A developer app on TikTok for Business (business-api.tiktok.com/portal) with the Marketing API, and the permission groups you need ticked (Ads Management, Ad Account Management, Audience Management, Reporting, Creative Management, Pixel Management).
143
+ - **Scopes:** (TikTok has no OAuth scopes: permission groups are chosen on the app and granted at authorization)
144
+ - **Review / access:** The app is reviewed by TikTok before it can be authorized by other advertisers. Permission groups bind at authorization time, so adding a group later means re-authorizing. Rate limits start low and are raised on request.
145
+ - **Hosted:** Hosted Hermoso connects with one click where supported, with no developer app of your own.
146
+ - **Docs:** https://business-api.tiktok.com/portal/docs
147
+
148
+ | Field | Env var | Required | Notes |
149
+ |---|---|---|---|
150
+ | `accessToken` | `TIKTOK_ADS_ACCESS_TOKEN` | yes | Long-term advertiser access token (does not expire until revoked). |
151
+ | `appId` | `TIKTOK_ADS_APP_ID` | | Your Marketing API app id (needed to list advertisers). |
152
+ | `secret` | `TIKTOK_ADS_APP_SECRET` | | Your app secret (needed to list advertisers). |
153
+ | `sandbox` | `TIKTOK_ADS_SANDBOX` | | "true" for the sandbox host. |
154
+
155
+ - TikTok creates objects ENABLED by default; every create here forces DISABLE and reads it back.
156
+ - An ad needs an identity (identity_id + identity_type); list them with your app or pass a Spark post via tiktokItemId.
157
+ - Smart+ (automated) campaigns: pass smartPlus: true to createCampaign / createAdGroup / createAd / setStatus.
158
+ - Reach & Frequency ad groups cannot be created paused, so they are not offered here.
159
+
160
+ <a id="reddit-ads"></a>
161
+ ## Reddit Ads
162
+
163
+ - **Platform id:** `reddit_ads` · **credential provider:** `reddit_ads` · **money on the wire:** micros (1,000,000 = 1) (you always pass plain amounts)
164
+ - **Developer app:** A Reddit app (reddit.com/prefs/apps, type "web app") with your redirect URI, used by a login that has a role in a Reddit Ads business.
165
+ - **Scopes:** `adsread`, `adsedit`, `adsconversions`, `history`, `read`, `identity`
166
+ - **Review / access:** No separate review: any registered app can call the Ads API for businesses the authorizing user can manage. Authorize with duration=permanent.
167
+ - **Hosted:** Hosted Hermoso connects with one click where supported, with no developer app of your own.
168
+ - **Docs:** https://ads-api.reddit.com/docs/
169
+
170
+ | Field | Env var | Required | Notes |
171
+ |---|---|---|---|
172
+ | `clientId` | `REDDIT_ADS_CLIENT_ID` | yes | |
173
+ | `clientSecret` | `REDDIT_ADS_CLIENT_SECRET` | yes | |
174
+ | `refreshToken` | `REDDIT_ADS_REFRESH_TOKEN` | yes | From an authorization with duration=permanent. |
175
+ | `userAgent` | `REDDIT_ADS_USER_AGENT` | | Descriptive User-Agent, e.g. "web:my-ads-tool:v1.0 (+https://example.com)". |
176
+
177
+ - Authorize with duration=permanent, or Reddit issues no refresh token and access ends after about an hour.
178
+ - Delete means configured_status DELETED (or ARCHIVED, reversible); Reddit refuses deletes within 3 hours of an edit.
179
+ - Archive and delete do not cascade: children keep their own status.
180
+ - Cost Cap (MAXIMIZE_VOLUME) on conversion objectives is retired from 2027-02-10; use TARGET_CPX.
181
+
182
+ <a id="pinterest-ads"></a>
183
+ ## Pinterest Ads
184
+
185
+ - **Platform id:** `pinterest_ads` · **credential provider:** `pinterest_ads` · **money on the wire:** micros (1,000,000 = 1) (you always pass plain amounts)
186
+ - **Developer app:** A Pinterest app at developers.pinterest.com, created from a business account, with your redirect URI.
187
+ - **Scopes:** `ads:read`, `ads:write`
188
+ - **Review / access:** New apps start on Trial access (sandboxed Pins, low write quota). Apply for Standard access with a demo of your integration.
189
+ - **Hosted:** Hosted Hermoso connects with one click where supported, with no developer app of your own.
190
+ - **Docs:** https://developers.pinterest.com/docs/api/v5/
191
+
192
+ | Field | Env var | Required | Notes |
193
+ |---|---|---|---|
194
+ | `accessToken` | `PINTEREST_ADS_ACCESS_TOKEN` | unless refreshToken is set | Token with ads:read and ads:write. |
195
+ | `refreshToken` | `PINTEREST_ADS_REFRESH_TOKEN` | | |
196
+ | `clientId` | `PINTEREST_ADS_CLIENT_ID` | | |
197
+ | `clientSecret` | `PINTEREST_ADS_CLIENT_SECRET` | | |
198
+
199
+ - An ad promotes an existing Pin (pinId): publish the Pin first.
200
+ - There is no delete: deleteObject archives (effectively permanent) and does not cascade.
201
+ - Every ad group needs a bid and GEO (or LOCATION) targeting.
202
+ - Under Trial access, objects are sandboxed and invisible to the public; apply for Standard access before running real ads.
203
+
204
+ <a id="snapchat-ads"></a>
205
+ ## Snapchat Ads
206
+
207
+ - **Platform id:** `snapchat_ads` · **credential provider:** `snapchat_ads` · **money on the wire:** micros (1,000,000 = 1) (you always pass plain amounts)
208
+ - **Developer app:** An OAuth app created in Snapchat Business Manager (Business Details > OAuth Apps) with your redirect URI.
209
+ - **Scopes:** `snapchat-marketing-api`
210
+ - **Review / access:** No allowlist: the OAuth app works for any ad account the authorizing member can manage.
211
+ - **Hosted:** Hosted Hermoso connects with one click where supported, with no developer app of your own.
212
+ - **Docs:** https://developers.snap.com/api/marketing-api/Ads-API/introduction
213
+
214
+ | Field | Env var | Required | Notes |
215
+ |---|---|---|---|
216
+ | `clientId` | `SNAPCHAT_ADS_CLIENT_ID` | yes | |
217
+ | `clientSecret` | `SNAPCHAT_ADS_CLIENT_SECRET` | yes | |
218
+ | `refreshToken` | `SNAPCHAT_ADS_REFRESH_TOKEN` | yes | |
219
+
220
+ - Budgets and bids are micro-currency on the wire; pass plain amounts here. Minimum daily budget is 5.
221
+ - Creative headline limit is 34 characters and brand name 32: longer copy is refused, never cut.
222
+ - Every creative needs a public profile id (profileId).
223
+ - Updates are JSON Patch (application/json-patch+json).
224
+
225
+ <a id="x-ads"></a>
226
+ ## X Ads
227
+
228
+ - **Platform id:** `x_ads` · **credential provider:** `x_ads` · **money on the wire:** micros (1,000,000 = 1) (you always pass plain amounts)
229
+ - **Developer app:** An app in the X developer portal with Ads API access approved for it, and OAuth 1.0a user authentication enabled with your callback URL.
230
+ - **Scopes:** (OAuth 1.0a has no scopes: access comes from the app's Ads API approval and the user's role on the ad account)
231
+ - **Review / access:** Ads API access is applied for per developer app and reviewed by X. Each advertiser then authorizes your app (three-legged OAuth 1.0a) and needs a role on the ad account.
232
+ - **Hosted:** Hosted Hermoso connects with one click where supported, with no developer app of your own.
233
+ - **Docs:** https://docs.x.com/x-ads-api
234
+
235
+ | Field | Env var | Required | Notes |
236
+ |---|---|---|---|
237
+ | `consumerKey` | `X_ADS_CONSUMER_KEY` | yes | API key of your developer app (with Ads API access). |
238
+ | `consumerSecret` | `X_ADS_CONSUMER_SECRET` | yes | |
239
+ | `accessToken` | `X_ADS_ACCESS_TOKEN` | yes | OAuth 1.0a user access token. |
240
+ | `accessTokenSecret` | `X_ADS_ACCESS_TOKEN_SECRET` | yes | |
241
+ | `sandbox` | `X_ADS_SANDBOX` | | "true" for the sandbox host. |
242
+
243
+ - A campaign needs a funding instrument; createCampaign lists the usable ones when none is given.
244
+ - Delivery needs BOTH the campaign and the line item active. Promoted posts cannot be paused: pause the line item.
245
+ - X silently ignores changes to immutable fields (objective, product type); updates read back and report what did not change.
246
+ - Report windows must fall on whole UTC hours; empty stats mean "no data or wrong id", never zero.
247
+
248
+ <a id="openai-ads"></a>
249
+ ## ChatGPT Ads
250
+
251
+ - **Platform id:** `openai_ads` · **credential provider:** `openai_ads` · **money on the wire:** micros (1,000,000 = 1) (you always pass plain amounts)
252
+ - **Developer app:** No developer app: create an Advertiser API key in ChatGPT Ads Manager > Settings > API keys.
253
+ - **Scopes:** (API keys carry the ad account's permissions; no scopes)
254
+ - **Review / access:** The ad account itself must be approved to advertise. Some features (target CPA/CPC bidding, daily spend limits) are switched on per account.
255
+ - **Hosted:** connect with your own credentials. ChatGPT Ads issues API keys per ad account.
256
+ - **Docs:** https://developers.openai.com/ads/
257
+
258
+ | Field | Env var | Required | Notes |
259
+ |---|---|---|---|
260
+ | `apiKey` | `OPENAI_ADS_API_KEY` | yes | Advertiser API key from ChatGPT Ads Manager > Settings > API keys (one key = one ad account). |
261
+
262
+ - One key is one ad account; accountId is not needed.
263
+ - Creative: a text + image card. Title 3-50 characters, body 1-100. There is no video.
264
+ - `targeting` and `bidding_config` are REPLACED wholesale on update: send the complete object.
265
+ - There is no delete: deleteObject archives, which is irreversible.
266
+
267
+ <a id="apple-ads"></a>
268
+ ## Apple Ads
269
+
270
+ - **Platform id:** `apple_ads` · **credential provider:** `apple_ads` · **money on the wire:** plain amounts (you always pass plain amounts)
271
+ - **Developer app:** No developer app: in Apple Ads, invite a user with an API role (API Account Manager), sign in as that user, and under Account Settings > API upload the public key of an EC P-256 key pair to get clientId, teamId and keyId.
272
+ - **Scopes:** `searchadsorg`
273
+ - **Review / access:** None beyond the API role. Only a user holding an API role sees the API settings (an Account Admin does not).
274
+ - **Hosted:** connect with your own credentials. Apple Ads issues API credentials per organization.
275
+ - **Docs:** https://developer.apple.com/documentation/apple_ads
276
+
277
+ | Field | Env var | Required | Notes |
278
+ |---|---|---|---|
279
+ | `clientId` | `APPLE_ADS_CLIENT_ID` | yes | |
280
+ | `teamId` | `APPLE_ADS_TEAM_ID` | yes | |
281
+ | `keyId` | `APPLE_ADS_KEY_ID` | yes | |
282
+ | `privateKey` | `APPLE_ADS_PRIVATE_KEY` | yes | EC P-256 private key PEM (its public half is uploaded in Apple Ads). |
283
+ | `accountId` | `APPLE_ADS_ORG_ID` | | Default ad account (org) id. |
284
+
285
+ - Everything is created PAUSED; enabling needs confirm.
286
+ - Manual CPT bids go on the ad group, not the campaign.
287
+ - Ad group startTime is sent always (Apple requires it in practice).
288
+ - Lists are POST <entity>/query with filters + pagination; arrays in updates replace the whole list (send every country).
289
+
290
+ <a id="amazon-ads"></a>
291
+ ## Amazon Ads
292
+
293
+ - **Platform id:** `amazon_ads` · **credential provider:** `amazon_ads` · **money on the wire:** plain amounts (you always pass plain amounts)
294
+ - **Developer app:** A Login with Amazon security profile (developer.amazon.com), then an Amazon Ads API access request linking that client id (advertising.amazon.com > API).
295
+ - **Scopes:** `advertising::campaign_management`
296
+ - **Review / access:** Amazon reviews the Ads API application (usually about a business day) and grants API access to one client id per company.
297
+ - **Hosted:** Hosted Hermoso connects with one click where supported, with no developer app of your own.
298
+ - **Docs:** https://advertising.amazon.com/API/docs/en-us/
299
+
300
+ | Field | Env var | Required | Notes |
301
+ |---|---|---|---|
302
+ | `clientId` | `AMAZON_ADS_CLIENT_ID` | yes | Login with Amazon security profile client id (approved for the Ads API). |
303
+ | `clientSecret` | `AMAZON_ADS_CLIENT_SECRET` | yes | |
304
+ | `refreshToken` | `AMAZON_ADS_REFRESH_TOKEN` | yes | From a consent with scope advertising::campaign_management. |
305
+ | `region` | `AMAZON_ADS_REGION` | | NA (default), EU or FE. |
306
+
307
+ - accountId is the advertising PROFILE id (one per advertiser per marketplace), from listAccounts.
308
+ - Profiles appear only after the account has created at least one campaign in the Amazon Ads console.
309
+ - A seller advertises by SKU, a vendor by ASIN.
310
+ - Archiving is permanent on Amazon: an archived object cannot be re-enabled.
311
+ - Negative keywords are created enabled on purpose: they only exclude traffic.
312
+
313
+ <a id="applovin-ads"></a>
314
+ ## AppLovin
315
+
316
+ - **Platform id:** `applovin_ads` · **credential provider:** `applovin_ads` · **money on the wire:** plain amounts (you always pass plain amounts)
317
+ - **Developer app:** No developer app: copy keys from the AppLovin dashboard (Account > Keys). Ask AppLovin to enable the Campaign Management API on the account for write access.
318
+ - **Scopes:** (keys, no scopes)
319
+ - **Review / access:** Campaign management is an allowlist beta enabled per account on request; reporting keys are self-serve.
320
+ - **Hosted:** connect with your own credentials. AppLovin issues keys per account, and campaign management is enabled per account on request.
321
+ - **Docs:** https://support.axon.ai/
322
+
323
+ | Field | Env var | Required | Notes |
324
+ |---|---|---|---|
325
+ | `campaignKey` | `APPLOVIN_CAMPAIGN_KEY` | | Campaign Management API key (enabled per account by AppLovin). |
326
+ | `reportKey` | `APPLOVIN_REPORT_KEY` | | Reporting key (dashboard > Account > Keys). |
327
+ | `accountId` | `APPLOVIN_ACCOUNT_ID` | yes | |
328
+ | `accountType` | `APPLOVIN_ACCOUNT_TYPE` | | WEB (default) or APP. |
329
+
330
+ - The API has no delete or archive: pause a campaign to stop it.
331
+ - AppLovin ignores the status on create; createCampaign reads it back and pauses it if needed.
332
+ - Targeting is replaced wholesale on update.
333
+ - Never loop retries: 100 errors in 5 minutes lock the account's API for 24 hours.
334
+
335
+ <a id="outbrain-ads"></a>
336
+ ## Outbrain
337
+
338
+ - **Platform id:** `outbrain_ads` · **credential provider:** `outbrain_ads` · **money on the wire:** plain amounts (you always pass plain amounts)
339
+ - **Developer app:** No developer app: request Amplify API access from Outbrain, then generate a token on the Amplify API Token page (or GET /login with basic auth, limited to 2 per hour).
340
+ - **Scopes:** (token, no scopes)
341
+ - **Review / access:** Outbrain enables API access on request.
342
+ - **Hosted:** connect with your own credentials. Outbrain issues API tokens per account.
343
+ - **Docs:** https://amplifyv01.docs.apiary.io/
344
+
345
+ | Field | Env var | Required | Notes |
346
+ |---|---|---|---|
347
+ | `token` | `OUTBRAIN_TOKEN` | yes | Amplify API token (valid 30 days; a password or email change revokes it). |
348
+
349
+ - accountId is the marketer id (listAccounts).
350
+ - Campaigns are created disabled and are archived, not deleted. Every budget change needs confirm.
351
+ - Campaign targeting language is mandatory and lives inside targeting.
352
+ - Reporting data lags 10-30 minutes.
353
+
354
+ <a id="taboola-ads"></a>
355
+ ## Taboola
356
+
357
+ - **Platform id:** `taboola_ads` · **credential provider:** `taboola_ads` · **money on the wire:** plain amounts (you always pass plain amounts)
358
+ - **Developer app:** No developer app: create API credentials (client id + secret) in Taboola Ads under API keys.
359
+ - **Scopes:** (client credentials, no scopes)
360
+ - **Review / access:** Self-serve; credentials are valid for a year.
361
+ - **Hosted:** connect with your own credentials. Taboola issues API credentials per account.
362
+ - **Docs:** https://developers.taboola.com/backstage-api/
363
+
364
+ | Field | Env var | Required | Notes |
365
+ |---|---|---|---|
366
+ | `clientId` | `TABOOLA_CLIENT_ID` | yes | |
367
+ | `clientSecret` | `TABOOLA_CLIENT_SECRET` | yes | |
368
+ | `accountId` | `TABOOLA_ACCOUNT_ID` | | Default account id (the slug used in paths). |
369
+
370
+ - Read-only: campaign lists and the campaign summary report.
371
+ - Conversions can still change for up to 30 days.
372
+
373
+ <a id="trade-desk"></a>
374
+ ## The Trade Desk
375
+
376
+ - **Platform id:** `trade_desk` · **credential provider:** `trade_desk` · **money on the wire:** plain amounts (you always pass plain amounts)
377
+ - **Developer app:** No developer app: generate a Platform API token in The Trade Desk (Access Management > Generate Token, application "Platform API").
378
+ - **Scopes:** (token, no scopes)
379
+ - **Review / access:** API access comes with your partner seat; tokens last one week to one year.
380
+ - **Hosted:** connect with your own credentials. The Trade Desk issues API tokens per partner seat.
381
+ - **Docs:** https://partner.thetradedesk.com/v3/portal/api/doc/ApiOverview
382
+
383
+ | Field | Env var | Required | Notes |
384
+ |---|---|---|---|
385
+ | `token` | `TTD_API_TOKEN` | yes | Platform API token (Access Management > Generate Token). |
386
+ | `partnerId` | `TTD_PARTNER_ID` | yes | |
387
+
388
+ - accountId is the advertiser id (listAccounts).
389
+ - Campaigns have no status: they deliver through enabled ad groups. Pausing a campaign pauses all its ad groups.
390
+ - Archiving is permanent.
391
+ - Every ad group budget change needs confirm.
package/package.json CHANGED
@@ -1,6 +1,68 @@
1
1
  {
2
2
  "name": "@hermoso/ads",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Open-source ads management for 16 ad platforms (Meta, Google, Microsoft, LinkedIn, TikTok, Reddit, Pinterest, Snapchat, X, ChatGPT Ads, Apple, Amazon, AppLovin, Outbrain, Taboola, The Trade Desk): campaigns, ad groups, ads, creatives, audiences, budgets, reports and targeting with safe defaults.",
5
+ "keywords": [
6
+ "ads",
7
+ "ads-api",
8
+ "google-ads",
9
+ "google-ads-api",
10
+ "meta-ads",
11
+ "facebook-ads",
12
+ "meta-marketing-api",
13
+ "tiktok-ads",
14
+ "linkedin-ads",
15
+ "microsoft-ads",
16
+ "bing-ads",
17
+ "reddit-ads",
18
+ "pinterest-ads",
19
+ "snapchat-ads",
20
+ "x-ads",
21
+ "apple-search-ads",
22
+ "amazon-ads",
23
+ "ppc",
24
+ "marketing-automation",
25
+ "ai-agents",
26
+ "hermoso",
27
+ "open-source"
28
+ ],
29
+ "homepage": "https://github.com/hermoso-ai/hermoso/tree/main/packages/ads#readme",
30
+ "bugs": {
31
+ "url": "https://github.com/hermoso-ai/hermoso/issues"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/hermoso-ai/hermoso.git",
36
+ "directory": "packages/ads"
37
+ },
38
+ "license": "Apache-2.0",
39
+ "author": "Hermoso <hello@hermoso.ai>",
40
+ "type": "module",
41
+ "main": "./src/index.js",
42
+ "exports": {
43
+ ".": "./src/index.js",
44
+ "./platforms/*": "./src/platforms/*.js",
45
+ "./package.json": "./package.json"
46
+ },
47
+ "files": [
48
+ "src",
49
+ "docs",
50
+ "README.md",
51
+ "LICENSE"
52
+ ],
53
+ "engines": {
54
+ "node": ">=22.5"
55
+ },
56
+ "scripts": {
57
+ "test": "node --test test/*.test.js"
58
+ },
59
+ "dependencies": {
60
+ "@hermoso/core": "^0.1.0"
61
+ },
62
+ "devDependencies": {
63
+ "@hermoso/agent": "^0.1.0"
64
+ },
65
+ "publishConfig": {
66
+ "access": "public"
67
+ }
68
+ }
package/src/core.js ADDED
@@ -0,0 +1,20 @@
1
+
2
+ import * as core from '@hermoso/core';
3
+
4
+ export const coreHooks = () => core.hooks;
5
+
6
+ export function defaultCredentialStore() {
7
+ return core.connectors?.credentialStore ?? core.credentialStore ?? null;
8
+ }
9
+
10
+ /** SSRF-guarded fetch for URLs a user supplied (e.g. "upload the image at this link"). */
11
+ export function publicFetch() {
12
+ return core.http?.fetchSafe ?? core.fetchSafe ?? null;
13
+ }
14
+
15
+ /** Core's in-memory credential store factory. */
16
+ export function coreMemoryStore() {
17
+ const f = core.connectors?.memoryCredentialStore ?? core.memoryCredentialStore;
18
+ if (!f) throw new Error('@hermoso/core does not provide memoryCredentialStore');
19
+ return f();
20
+ }
@@ -0,0 +1,53 @@
1
+ import { coreMemoryStore } from './core.js';
2
+
3
+
4
+ /**
5
+ * Core's in-memory store, optionally seeded: memoryCredentialStore({ meta: { accessToken } }) puts each provider
6
+ * under account "default". Handy for scripts and tests.
7
+ */
8
+ export function memoryCredentialStore(initial = {}) {
9
+ const store = coreMemoryStore();
10
+ const seeded = Promise.all(Object.entries(initial).map(([provider, value]) => store.set('default', provider, value)));
11
+ return {
12
+ async get(account, provider) { await seeded; return store.get(account, provider); },
13
+ async set(account, provider, value) { await seeded; return store.set(account, provider, value); },
14
+ async delete(account, provider) { await seeded; return store.delete(account, provider); },
15
+ };
16
+ }
17
+
18
+ /**
19
+ * Reads each platform's credentials from environment variables named in the platform's
20
+ * `credentials[].env`. Refreshed tokens are kept in memory for the life of the process.
21
+ */
22
+ export function envCredentialStore(platforms, env = process.env) {
23
+ const overlay = new Map();
24
+ const byProvider = new Map(platforms.map((p) => [p.provider, p]));
25
+ return {
26
+ async get(account, provider) {
27
+ if (overlay.has(provider)) return { ...overlay.get(provider) };
28
+ const p = byProvider.get(provider);
29
+ if (!p) return null;
30
+ const out = {};
31
+ for (const f of p.credentials ?? []) {
32
+ const v = f.env ? env[f.env] : undefined;
33
+ if (v != null && v !== '') out[f.name] = v;
34
+ }
35
+ return Object.keys(out).length ? out : null;
36
+ },
37
+ async set(account, provider, value) { overlay.set(provider, { ...value }); },
38
+ async delete(account, provider) { overlay.delete(provider); },
39
+ };
40
+ }
41
+
42
+ /** First store that has the provider wins; writes go to the first store. */
43
+ export function layeredCredentialStore(...stores) {
44
+ const list = stores.filter(Boolean);
45
+ return {
46
+ async get(account, provider) {
47
+ for (const s of list) { const v = await s.get(account, provider); if (v) return v; }
48
+ return null;
49
+ },
50
+ async set(account, provider, value) { return list[0]?.set(account, provider, value); },
51
+ async delete(account, provider) { return list[0]?.delete(account, provider); },
52
+ };
53
+ }
package/src/errors.js ADDED
@@ -0,0 +1,29 @@
1
+
2
+ export class AdsError extends Error {
3
+ constructor(kind, message, extra = {}) {
4
+ super(message);
5
+ this.name = 'AdsError';
6
+ this.kind = kind;
7
+ Object.assign(this, extra);
8
+ }
9
+
10
+ toJSON() {
11
+ const out = { error: this.message, kind: this.kind };
12
+ for (const k of ['platform', 'op', 'status', 'code', 'field', 'max', 'length', 'retryAfter', 'vendor', 'hint']) {
13
+ if (this[k] !== undefined) out[k] = this[k];
14
+ }
15
+ return out;
16
+ }
17
+ }
18
+
19
+ export const isAdsError = (e) => e instanceof AdsError || e?.name === 'AdsError';
20
+
21
+ /** Map an HTTP status to a default kind; platforms refine this with their own body parsing. */
22
+ export function kindForStatus(status) {
23
+ if (status === 401) return 'auth';
24
+ if (status === 403) return 'permission';
25
+ if (status === 404) return 'not_found';
26
+ if (status === 429) return 'rate_limit';
27
+ if (status === 400 || status === 409 || status === 422) return 'validation';
28
+ return 'vendor';
29
+ }
package/src/hash.js ADDED
@@ -0,0 +1,30 @@
1
+ import { createHash } from 'node:crypto';
2
+
3
+
4
+ export const sha256 = (s) => createHash('sha256').update(String(s), 'utf8').digest('hex');
5
+ export const isHashed = (s) => /^[a-f0-9]{64}$/i.test(String(s ?? '').trim());
6
+
7
+ const pass = (v, norm) => {
8
+ if (v == null || String(v).trim() === '') return null;
9
+ if (isHashed(v)) return String(v).trim().toLowerCase();
10
+ const n = norm(String(v));
11
+ return n ? sha256(n) : null;
12
+ };
13
+
14
+ /** Trim + lowercase (most platforms). */
15
+ export const hashEmail = (v) => pass(v, (s) => s.trim().toLowerCase());
16
+
17
+ /** Digits only, leading zeros dropped (country code expected in the number). */
18
+ export const hashPhoneDigits = (v) => pass(v, (s) => s.replace(/\D/g, '').replace(/^0+/, ''));
19
+
20
+ /**
21
+ * Email normalisation for platforms that canonicalise the mailbox: drop dots in the local part
22
+ * and anything after "+", then lowercase.
23
+ */
24
+ export const hashEmailCanonical = (v) => pass(v, (s) => {
25
+ const t = s.trim().toLowerCase();
26
+ const at = t.lastIndexOf('@');
27
+ if (at < 1) return t;
28
+ const local = t.slice(0, at).split('+')[0].replace(/\./g, '');
29
+ return `${local}${t.slice(at)}`;
30
+ });