@motorical/sdk 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Motorical
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,27 @@
1
- # Temporary Holding Version
1
+ # @motorical/sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Node.js client for the Motorical APIs: the transactional Send API, the Public API (analytics, logs, domains, webhooks, Motor Blocks) and the Communications API. One method per `operationId` in [openapi.json](https://docs.motorical.com/openapi.json), generated from it, no dependencies (Node 18+, built-in `fetch`).
4
+
5
+ ```bash
6
+ npm install @motorical/sdk
7
+ ```
8
+
9
+ ```js
10
+ const { Motorical, MotoricalError } = require('@motorical/sdk');
11
+
12
+ const m = new Motorical({ apiKey: process.env.MOTORICAL_API_KEY }); // mk_live_... Motor Block key
13
+
14
+ const res = await m.sendEmail({
15
+ body: { from: 'you@yourdomain.com', to: 'someone@example.com', subject: 'Hello', text: 'Hi', dryRun: true },
16
+ });
17
+ ```
18
+
19
+ **Arguments:** one object with path, query and header parameters by their API name (`{ id, days }`, `{ 'Idempotency-Key': ... }` or `idempotencyKey`), the request body as `body`, and `workspaceId` for Communications calls.
20
+
21
+ **Credentials** (pass the ones you use): `apiKey` (Motor Block key, Send API), `bearerToken` (Public API token or OAuth access token), `accountKey` (`ak_live_...`, token minting and the Communications API), `dashboardToken`, `workspaceId`. Each method sends the credential its operation accepts.
22
+
23
+ **Errors** throw `MotoricalError` with `status`, `code` (branch on it: [error codes](https://docs.motorical.com/api-reference/errors)), `requestId` (quote it to support) and `body`.
24
+
25
+ **A successful send is acceptance, not delivery:** read the outcome with `getMessage` or a webhook.
26
+
27
+ Method names never change once published ([versioning policy](https://docs.motorical.com/api-reference/versioning)). Regenerate with `node packages/sdk-generator/generate.js` after the OpenAPI changes.
package/index.d.ts ADDED
@@ -0,0 +1,437 @@
1
+ // GENERATED from docs-site/static/openapi.json by packages/sdk-generator/generate.js. Do not edit.
2
+ // OpenAPI 1.11.0. Arguments: path, query and header parameters by name, the request body as `body`,
3
+ // and for Communications calls `workspaceId`. Every method resolves to the parsed JSON response.
4
+ export interface MotoricalConfig {
5
+ /** Motor Block API key (mk_live_...) for the Send API. */ apiKey?: string;
6
+ /** Account API key (ak_live_...) for token minting and the Communications API. */ accountKey?: string;
7
+ /** Public API bearer token (or an OAuth access token) for /api/public/v1. */ bearerToken?: string;
8
+ /** Dashboard session JWT (onboarding, sandbox, token minting). */ dashboardToken?: string;
9
+ /** Default Communications workspace (X-Tenant-Id). */ workspaceId?: string;
10
+ /** Defaults to https://api.motorical.com. */ baseUrl?: string;
11
+ /** Overrides the Communications API host (https://motorical.com). */ commsBaseUrl?: string;
12
+ fetch?: typeof fetch; userAgent?: string;
13
+ }
14
+ export type Args = Record<string, unknown> & { body?: unknown; workspaceId?: string };
15
+ export declare class MotoricalError extends Error { status: number; code: string | null; requestId: string | null; body: unknown; }
16
+ export declare class Motorical {
17
+ constructor(config?: MotoricalConfig);
18
+ /** POST /api/public/v1/domains: Add a customer domain (account-wide, OAuth/MCP-capable) */
19
+ addDomain(args: Args): Promise<any>;
20
+ /** POST /api/domains: Add a customer domain */
21
+ addDomainDashboard(args: Args): Promise<any>;
22
+ /** POST /api/public/v1/account/free-recipients: Ask a recipient to allow test email (OAuth/Public API bearer) */
23
+ addFreeRecipient(args: Args): Promise<any>;
24
+ /** POST /api/public/v1/account/motor-blocks/{id}/assign-domain: Assign a verified domain to a Motor Block */
25
+ assignMotorBlockDomain(args: Args): Promise<any>;
26
+ /** PATCH /api/public/v1/account/motor-blocks/{id}/type: Switch a Motor Block between transactional and general_purpose */
27
+ changeMotorBlockType(args: Args): Promise<any>;
28
+ /** POST /api/public/v1/domains/{id}/check-dns: Check DKIM/SPF/DMARC and persist send-readiness flags (account-wide, OAuth/MCP-capable) */
29
+ checkDomainDns(args: Args): Promise<any>;
30
+ /** POST /api/domains/{id}/check-dns: Check DKIM/SPF/DMARC and persist send-readiness flags */
31
+ checkDomainDnsDashboard(args: Args): Promise<any>;
32
+ /** GET /api/public/v1/account/authorization/motor-blocks/{id}: Live grant-coverage check for one Motor Block (infrastructure) */
33
+ checkMotorBlockAuthorization(args: Args): Promise<any>;
34
+ /** POST /comm-api/api/lists/{id}/contacts: Add contacts to a list */
35
+ commsAddListContact(args: Args): Promise<any>;
36
+ /** POST /comm-api/api/lists/{id}/contacts/bulk: Add up to 1001 contacts as JSON, with a dry run and a result for every row */
37
+ commsAddListContacts(args: Args): Promise<any>;
38
+ /** POST /comm-api/api/workspaces/{id}/motor-blocks/from-domain: Resolve a sending domain to a companion marketing Motor Block */
39
+ commsAddSendingIdentity(args: Args): Promise<any>;
40
+ /** POST /comm-api/api/suppressions: Add a suppression */
41
+ commsAddSuppression(args?: Args): Promise<any>;
42
+ /** POST /comm-api/api/suppressions/bulk: Bulk import suppressions */
43
+ commsAddSuppressions(args?: Args): Promise<any>;
44
+ /** POST /comm-api/api/templates/fix: Apply the safe fixes to a template in memory */
45
+ commsApplyTemplateFixes(args?: Args): Promise<any>;
46
+ /** POST /comm-api/api/lists/{id}/archive: Archive a list (hidden from the default list view, refused by campaigns) */
47
+ commsArchiveList(args: Args): Promise<any>;
48
+ /** POST /comm-api/api/recipients/summary: Counts for the whole audience or a filter: by status, consent, engagement, domain and list; no addresses */
49
+ commsAudienceSummary(args?: Args): Promise<any>;
50
+ /** POST /comm-api/api/recipients/bulk-delete: Bulk delete recipients */
51
+ commsBulkDeleteRecipients(args?: Args): Promise<any>;
52
+ /** POST /comm-api/api/recipients/bulk-delete-by-filter: Bulk delete recipients matching a filter */
53
+ commsBulkDeleteRecipientsByFilter(args?: Args): Promise<any>;
54
+ /** POST /comm-api/api/recipients/bulk-move: Bulk move recipients */
55
+ commsBulkMoveRecipients(args?: Args): Promise<any>;
56
+ /** POST /comm-api/api/recipients/bulk-permanent-delete: Permanently delete several deleted recipients at once */
57
+ commsBulkPermanentlyDeleteRecipients(args?: Args): Promise<any>;
58
+ /** POST /comm-api/api/campaigns/{id}/cancel: Cancel a draft, scheduled or sending campaign (final) */
59
+ commsCancelCampaign(args: Args): Promise<any>;
60
+ /** POST /comm-api/api/templates/check-links: Check every link of a template */
61
+ commsCheckLinks(args?: Args): Promise<any>;
62
+ /** POST /comm-api/api/contacts/cleanup-orphans: Delete contacts that are on no list, with a dry run */
63
+ commsCleanupOrphanContacts(args?: Args): Promise<any>;
64
+ /** GET /comm-api/api/lists/compare: Compare two lists: who is only in one, who is in both */
65
+ commsCompareLists(args: Args): Promise<any>;
66
+ /** POST /comm-api/api/campaigns/{id}/compile: Preview-compile a draft campaign (optional: scheduling compiles by itself) */
67
+ commsCompileCampaign(args: Args): Promise<any>;
68
+ /** POST /comm-api/api/campaigns: Create a campaign */
69
+ commsCreateCampaign(args?: Args): Promise<any>;
70
+ /** POST /comm-api/api/gdpr/export: Email a contact their GDPR data export */
71
+ commsCreateGdprExport(args?: Args): Promise<any>;
72
+ /** POST /comm-api/api/lists: Create a contact list */
73
+ commsCreateList(args?: Args): Promise<any>;
74
+ /** POST /comm-api/api/lists/from-filter: Create a smart list from filters */
75
+ commsCreateListFromFilter(args?: Args): Promise<any>;
76
+ /** POST /comm-api/api/templates: Create a template */
77
+ commsCreateTemplate(args?: Args): Promise<any>;
78
+ /** POST /comm-api/api/templates/from-starter: Create a template from a starter and the brand kit */
79
+ commsCreateTemplateFromStarter(args?: Args): Promise<any>;
80
+ /** POST /comm-api/api/workspaces/{id}/webhooks: Create a workspace webhook */
81
+ commsCreateWebhook(args: Args): Promise<any>;
82
+ /** POST /comm-api/api/workspaces: Create a Communications workspace */
83
+ commsCreateWorkspace(args?: Args): Promise<any>;
84
+ /** DELETE /comm-api/api/campaigns/{id}: Delete a campaign */
85
+ commsDeleteCampaign(args: Args): Promise<any>;
86
+ /** DELETE /comm-api/api/contacts/{id}: Delete a contact */
87
+ commsDeleteContact(args: Args): Promise<any>;
88
+ /** DELETE /comm-api/api/lists/{id}: Delete a contact list */
89
+ commsDeleteList(args: Args): Promise<any>;
90
+ /** DELETE /comm-api/api/lists: Bulk delete contact lists */
91
+ commsDeleteLists(args?: Args): Promise<any>;
92
+ /** DELETE /comm-api/api/suppressions/{id}: Remove a suppression (a spam-complaint one needs acknowledge_complaint=true) */
93
+ commsDeleteSuppression(args: Args): Promise<any>;
94
+ /** DELETE /comm-api/api/templates/{id}: Delete a template */
95
+ commsDeleteTemplate(args: Args): Promise<any>;
96
+ /** DELETE /comm-api/api/templates: Bulk delete templates */
97
+ commsDeleteTemplates(args?: Args): Promise<any>;
98
+ /** DELETE /comm-api/api/workspaces/{id}/webhooks/{webhookId}: Delete a workspace webhook */
99
+ commsDeleteWebhook(args: Args): Promise<any>;
100
+ /** DELETE /comm-api/api/workspaces/{id}: Delete a Communications workspace and everything in it (irreversible) */
101
+ commsDeleteWorkspace(args: Args): Promise<any>;
102
+ /** POST /comm-api/api/lists/derive: Make a new list from other lists (union, intersection or difference) or from an audience filter (operation filter) */
103
+ commsDeriveList(args?: Args): Promise<any>;
104
+ /** POST /comm-api/api/campaigns/{id}/duplicate: Duplicate a campaign into a new draft */
105
+ commsDuplicateCampaign(args: Args): Promise<any>;
106
+ /** POST /comm-api/api/templates/{id}/duplicate: Duplicate a template */
107
+ commsDuplicateTemplate(args: Args): Promise<any>;
108
+ /** GET /comm-api/api/lists/{id}/contacts/export: Export list contacts */
109
+ commsExportListContacts(args: Args): Promise<any>;
110
+ /** POST /comm-api/api/recipients/export: Export recipients */
111
+ commsExportRecipients(args?: Args): Promise<any>;
112
+ /** GET /comm-api/api/tracking/export: Export tracking events */
113
+ commsExportTrackingEvents(args?: Args): Promise<any>;
114
+ /** POST /comm-api/api/recipients/filter: Filter recipients */
115
+ commsFilterRecipients(args?: Args): Promise<any>;
116
+ /** GET /comm-api/api/analytics/overview: Get Communications analytics overview */
117
+ commsGetAnalyticsOverview(args?: Args): Promise<any>;
118
+ /** GET /comm-api/api/settings/brand-kit: Get the workspace brand kit */
119
+ commsGetBrandKit(args?: Args): Promise<any>;
120
+ /** GET /comm-api/api/campaigns/{id}: Get campaign details */
121
+ commsGetCampaign(args: Args): Promise<any>;
122
+ /** GET /comm-api/api/campaigns/{id}/analytics: Get campaign analytics */
123
+ commsGetCampaignAnalytics(args: Args): Promise<any>;
124
+ /** GET /comm-api/api/campaigns/{id}/click-breakdown: Get click breakdown */
125
+ commsGetCampaignClickBreakdown(args: Args): Promise<any>;
126
+ /** GET /comm-api/api/campaigns/{id}/recipient-consent: Get campaign recipient consent status */
127
+ commsGetCampaignRecipientConsent(args: Args): Promise<any>;
128
+ /** GET /comm-api/api/campaigns/{id}/report: Get the per-recipient delivery report for a campaign */
129
+ commsGetCampaignReport(args: Args): Promise<any>;
130
+ /** GET /comm-api/api/campaigns/{id}/stats: Get campaign stats */
131
+ commsGetCampaignStats(args: Args): Promise<any>;
132
+ /** GET /comm-api/api/consent-events/analytics: Get consent-event analytics */
133
+ commsGetConsentAnalytics(args?: Args): Promise<any>;
134
+ /** GET /comm-api/api/settings/consent: Get current workspace consent settings */
135
+ commsGetConsentSettings(args?: Args): Promise<any>;
136
+ /** GET /comm-api/api/contacts/{id}/erase-impact: What erasing a contact would remove (lists, campaign statistics, consent records), before you confirm */
137
+ commsGetContactEraseImpact(args: Args): Promise<any>;
138
+ /** GET /comm-api/api/gdpr/export: Email a contact their GDPR data export (deprecated: use POST) @deprecated */
139
+ commsGetGdprExport(args?: Args): Promise<any>;
140
+ /** GET /comm-api/api/lists/{id}: Get one contact list as a card */
141
+ commsGetList(args: Args): Promise<any>;
142
+ /** GET /comm-api/api/lists/{id}/relations: Where a list came from and what was made from it */
143
+ commsGetListRelations(args: Args): Promise<any>;
144
+ /** GET /comm-api/api/map: The workspace at a glance: lists, campaigns, templates and how they connect */
145
+ commsGetMap(args?: Args): Promise<any>;
146
+ /** GET /comm-api/api/settings/open-tracking: Get current workspace open-tracking settings */
147
+ commsGetOpenTrackingSettings(args?: Args): Promise<any>;
148
+ /** GET /comm-api/api/readiness: What is still missing before a campaign can be sent */
149
+ commsGetReadiness(args?: Args): Promise<any>;
150
+ /** GET /comm-api/api/recipients/facets: List recipient filter facets */
151
+ commsGetRecipientFacets(args?: Args): Promise<any>;
152
+ /** GET /comm-api/api/templates/starters/{key}: Get one template starter */
153
+ commsGetStarter(args: Args): Promise<any>;
154
+ /** GET /comm-api/api/suppressions/stats: Get suppression stats */
155
+ commsGetSuppressionStats(args?: Args): Promise<any>;
156
+ /** GET /comm-api/api/templates/{id}: Get a template */
157
+ commsGetTemplate(args: Args): Promise<any>;
158
+ /** GET /comm-api/api/templates/rules: The template rulebook */
159
+ commsGetTemplateRules(args?: Args): Promise<any>;
160
+ /** GET /comm-api/api/tracking/stats: Get tracking stats */
161
+ commsGetTrackingStats(args?: Args): Promise<any>;
162
+ /** GET /comm-api/api/unsubscribe-analytics: Get unsubscribe analytics */
163
+ commsGetUnsubscribeAnalytics(args?: Args): Promise<any>;
164
+ /** GET /comm-api/api/settings/unsubscribe: Get the current workspace unsubscribe landing page */
165
+ commsGetUnsubscribeSettings(args?: Args): Promise<any>;
166
+ /** GET /comm-api/api/unsubscribe-trends: Get unsubscribe trends */
167
+ commsGetUnsubscribeTrends(args?: Args): Promise<any>;
168
+ /** GET /comm-api/api/workspaces/{id}/settings/consent: Get workspace consent settings */
169
+ commsGetWorkspaceConsentSettings(args: Args): Promise<any>;
170
+ /** GET /comm-api/api/workspaces/{id}/settings/open-tracking: Get workspace open-tracking settings */
171
+ commsGetWorkspaceOpenTrackingSettings(args: Args): Promise<any>;
172
+ /** GET /comm-api/api/workspaces/{id}/settings/unsubscribe: Get workspace unsubscribe landing page */
173
+ commsGetWorkspaceUnsubscribeSettings(args: Args): Promise<any>;
174
+ /** GET /comm-api/api/health: Communications API health */
175
+ commsHealth(args?: Args): Promise<any>;
176
+ /** POST /comm-api/api/suppressions/import-bounces: Import bounces into suppressions */
177
+ commsImportBounceSuppressions(args?: Args): Promise<any>;
178
+ /** POST /comm-api/api/lists/{id}/contacts/import: Import list contacts from CSV */
179
+ commsImportContacts(args: Args): Promise<any>;
180
+ /** POST /comm-api/api/templates/lint: Check a template against the rulebook */
181
+ commsLintTemplate(args?: Args): Promise<any>;
182
+ /** GET /comm-api/api/campaigns/{id}/clicks: List campaign clicks */
183
+ commsListCampaignClicks(args: Args): Promise<any>;
184
+ /** GET /comm-api/api/campaigns/{id}/events: List campaign events */
185
+ commsListCampaignEvents(args: Args): Promise<any>;
186
+ /** GET /comm-api/api/campaigns/{id}/recipients: List campaign recipients */
187
+ commsListCampaignRecipients(args: Args): Promise<any>;
188
+ /** GET /comm-api/api/campaigns: List campaigns */
189
+ commsListCampaigns(args?: Args): Promise<any>;
190
+ /** GET /comm-api/api/consent-events: List consent events */
191
+ commsListConsentEvents(args?: Args): Promise<any>;
192
+ /** GET /comm-api/api/campaigns/deleted: List deleted campaigns */
193
+ commsListDeletedCampaigns(args?: Args): Promise<any>;
194
+ /** GET /comm-api/api/recipients/deleted: List deleted recipients */
195
+ commsListDeletedRecipients(args?: Args): Promise<any>;
196
+ /** GET /comm-api/api/lists/{id}/imports: The import batches of a list */
197
+ commsListImports(args: Args): Promise<any>;
198
+ /** GET /comm-api/api/lists/{id}/contacts: List contacts in a list */
199
+ commsListListContacts(args: Args): Promise<any>;
200
+ /** GET /comm-api/api/lists: List contact lists */
201
+ commsListLists(args?: Args): Promise<any>;
202
+ /** GET /comm-api/api/workspaces/current/motor-blocks: List marketing Motor Blocks assigned to the workspace */
203
+ commsListMarketingBlocks(args?: Args): Promise<any>;
204
+ /** GET /comm-api/api/recipients/campaigns: List recipient campaign groupings */
205
+ commsListRecipientCampaigns(args?: Args): Promise<any>;
206
+ /** GET /comm-api/api/recipients: Search recipients */
207
+ commsListRecipients(args?: Args): Promise<any>;
208
+ /** GET /comm-api/api/templates/starters: List the template starters */
209
+ commsListStarters(args?: Args): Promise<any>;
210
+ /** GET /comm-api/api/suppressions: List suppressions */
211
+ commsListSuppressions(args?: Args): Promise<any>;
212
+ /** GET /comm-api/api/templates: List templates */
213
+ commsListTemplates(args?: Args): Promise<any>;
214
+ /** GET /comm-api/api/tracking/events: Search tracking events */
215
+ commsListTrackingEvents(args?: Args): Promise<any>;
216
+ /** GET /comm-api/api/unsubscribe-events: List unsubscribe events */
217
+ commsListUnsubscribeEvents(args?: Args): Promise<any>;
218
+ /** GET /comm-api/api/workspaces/{id}/webhooks: List the webhooks of a workspace */
219
+ commsListWebhooks(args: Args): Promise<any>;
220
+ /** GET /comm-api/api/workspaces/{id}/motor-blocks: List Motor Blocks assigned to a workspace */
221
+ commsListWorkspaceMotorBlocks(args: Args): Promise<any>;
222
+ /** GET /comm-api/api/workspaces: List Communications workspaces */
223
+ commsListWorkspaces(args?: Args): Promise<any>;
224
+ /** DELETE /comm-api/api/campaigns/{id}/permanent: Permanently delete a campaign */
225
+ commsPermanentlyDeleteCampaign(args: Args): Promise<any>;
226
+ /** DELETE /comm-api/api/recipients/{id}/permanent: Permanently delete a recipient */
227
+ commsPermanentlyDeleteRecipient(args: Args): Promise<any>;
228
+ /** POST /comm-api/api/templates/preview: Render a template for a contact or a sample */
229
+ commsPreviewTemplate(args?: Args): Promise<any>;
230
+ /** DELETE /comm-api/api/campaigns/cleanup: Cleanup deleted campaigns */
231
+ commsPurgeDeletedCampaigns(args?: Args): Promise<any>;
232
+ /** DELETE /comm-api/api/recipients/cleanup: Cleanup deleted recipients */
233
+ commsPurgeDeletedRecipients(args?: Args): Promise<any>;
234
+ /** DELETE /comm-api/api/lists/{id}/contacts/{contactId}: Remove a contact from a list */
235
+ commsRemoveFromList(args: Args): Promise<any>;
236
+ /** POST /comm-api/api/templates/starters/{key}/render: Render a starter with a brand kit, without saving */
237
+ commsRenderStarter(args: Args): Promise<any>;
238
+ /** PATCH /comm-api/api/campaigns/{id}/restore: Restore a campaign */
239
+ commsRestoreCampaign(args: Args): Promise<any>;
240
+ /** PATCH /comm-api/api/recipients/{id}/restore: Restore a recipient */
241
+ commsRestoreRecipient(args: Args): Promise<any>;
242
+ /** POST /comm-api/api/recipients/restore: Restore recipients */
243
+ commsRestoreRecipients(args?: Args): Promise<any>;
244
+ /** PUT /comm-api/api/contacts/{id}/resubscribe: Resubscribe a contact */
245
+ commsResubscribeContact(args: Args): Promise<any>;
246
+ /** POST /comm-api/api/campaigns/{id}/schedule: Schedule a draft campaign: compiles it, then sends now or at scheduled_at */
247
+ commsScheduleCampaign(args: Args): Promise<any>;
248
+ /** POST /comm-api/api/recipients/search: Search the whole audience with a structured filter (domain, status, campaign, import batch, dates, on no list, not on these lists); returns each person with the lists they are on */
249
+ commsSearchAudience(args?: Args): Promise<any>;
250
+ /** POST /comm-api/api/campaigns/{id}/test-send: Send the campaign as a test to the account owner only */
251
+ commsSendCampaignTest(args: Args): Promise<any>;
252
+ /** POST /comm-api/api/templates/{id}/test-send: Send a template as a test to the account owner only, without a campaign */
253
+ commsSendTemplateTest(args: Args): Promise<any>;
254
+ /** PATCH /comm-api/api/settings/brand-kit: Update the workspace brand kit */
255
+ commsSetBrandKit(args?: Args): Promise<any>;
256
+ /** PUT /comm-api/api/workspaces/{id}/motor-blocks: Replace workspace Motor Block assignments */
257
+ commsSetWorkspaceMotorBlocks(args: Args): Promise<any>;
258
+ /** GET /comm-api/api/suppressions/lookup: Is one address suppressed: the reason, the source and since when (account-wide) */
259
+ commsSuppressionInfo(args: Args): Promise<any>;
260
+ /** POST /comm-api/api/workspaces/{id}/webhooks/{webhookId}/test: Queue a test event for a workspace webhook */
261
+ commsTestWebhook(args: Args): Promise<any>;
262
+ /** POST /comm-api/api/lists/{id}/unarchive: Restore an archived list */
263
+ commsUnarchiveList(args: Args): Promise<any>;
264
+ /** POST /comm-api/api/lists/{id}/imports/{batchId}/undo: Undo one import batch, with a dry run */
265
+ commsUndoImport(args: Args): Promise<any>;
266
+ /** POST /comm-api/api/contacts/{id}/unsubscribe: Unsubscribe a contact */
267
+ commsUnsubscribeContact(args: Args): Promise<any>;
268
+ /** PATCH /comm-api/api/campaigns/{id}/settings: Update campaign settings (what can change depends on the status) */
269
+ commsUpdateCampaign(args: Args): Promise<any>;
270
+ /** PATCH /comm-api/api/settings/consent: Update current workspace consent settings */
271
+ commsUpdateConsentSettings(args?: Args): Promise<any>;
272
+ /** PATCH /comm-api/api/lists/{id}: Update a contact list */
273
+ commsUpdateList(args: Args): Promise<any>;
274
+ /** PATCH /comm-api/api/settings/open-tracking: Update current workspace open-tracking settings */
275
+ commsUpdateOpenTrackingSettings(args?: Args): Promise<any>;
276
+ /** PATCH /comm-api/api/templates/{id}: Update a template */
277
+ commsUpdateTemplate(args: Args): Promise<any>;
278
+ /** PATCH /comm-api/api/settings/unsubscribe: Set or clear the current workspace unsubscribe landing page */
279
+ commsUpdateUnsubscribeSettings(args?: Args): Promise<any>;
280
+ /** PATCH /comm-api/api/workspaces/{id}/webhooks/{webhookId}: Update a workspace webhook */
281
+ commsUpdateWebhook(args: Args): Promise<any>;
282
+ /** PATCH /comm-api/api/workspaces/{id}: Update a Communications workspace */
283
+ commsUpdateWorkspace(args: Args): Promise<any>;
284
+ /** PATCH /comm-api/api/workspaces/{id}/settings/consent: Update workspace consent settings */
285
+ commsUpdateWorkspaceConsentSettings(args: Args): Promise<any>;
286
+ /** PATCH /comm-api/api/workspaces/{id}/settings/open-tracking: Update workspace open-tracking settings */
287
+ commsUpdateWorkspaceOpenTrackingSettings(args: Args): Promise<any>;
288
+ /** PATCH /comm-api/api/workspaces/{id}/settings/unsubscribe: Update workspace unsubscribe landing page */
289
+ commsUpdateWorkspaceUnsubscribeSettings(args: Args): Promise<any>;
290
+ /** POST /comm-api/api/contacts/upsert: Create or update a contact */
291
+ commsUpsertContact(args?: Args): Promise<any>;
292
+ /** POST /comm-api/api/templates/validate: Validate a template without saving */
293
+ commsValidateTemplate(args?: Args): Promise<any>;
294
+ /** POST /api/public/v1/account/sandbox/convert: Convert account sandbox to a verified production domain (OAuth/Public API bearer) */
295
+ convertSandbox(args: Args): Promise<any>;
296
+ /** POST /api/developer/sandbox/convert: Convert sandbox Motor Block to a verified production domain */
297
+ convertSandboxDashboard(args: Args): Promise<any>;
298
+ /** POST /api/public/v1/motor-blocks/{id}/exports: Create export job */
299
+ createExport(args: Args): Promise<any>;
300
+ /** POST /api/public/v1/account/motor-blocks: Create a production Motor Block (OAuth/Public API bearer) */
301
+ createMotorBlock(args: Args): Promise<any>;
302
+ /** POST /api/auth/web-handoff: Mint a one-time browser handoff URL */
303
+ createWebHandoff(args?: Args): Promise<any>;
304
+ /** POST /api/public/v1/motor-blocks/{id}/webhooks: Create webhook */
305
+ createWebhook(args: Args): Promise<any>;
306
+ /** POST /api/public/v1/account/motor-blocks/{id}/deactivate: Deactivate (pause) a Motor Block — reversible */
307
+ deactivateMotorBlock(args: Args): Promise<any>;
308
+ /** DELETE /api/public/v1/account/motor-blocks/{id}: Permanently delete a Motor Block — asynchronous and irrecoverable */
309
+ deleteMotorBlock(args: Args): Promise<any>;
310
+ /** DELETE /api/public/v1/motor-blocks/{id}/webhooks/{webhookId}: Delete webhook */
311
+ deleteWebhook(args: Args): Promise<any>;
312
+ /** GET /api/public/v1/exports/{jobId}/download: Download export file (signed token, single-use) */
313
+ downloadExport(args: Args): Promise<any>;
314
+ /** GET /api/public/v1/account/rate-limits: Account-wide rate limits */
315
+ getAccountRateLimits(args?: Args): Promise<any>;
316
+ /** GET /api/public/v1/account/state: Composed account state */
317
+ getAccountState(args?: Args): Promise<any>;
318
+ /** GET /api/public/v1/motor-blocks/{id}/anomalies: Anomaly detection (bounce spikes) */
319
+ getAnomalies(args: Args): Promise<any>;
320
+ /** GET /api/comm/tenant: Discover or provision Communications workspaces */
321
+ getCommsTenant(args?: Args): Promise<any>;
322
+ /** GET /api/public/v1/motor-blocks/{id}/config: Motor Block config snapshot */
323
+ getConfig(args: Args): Promise<any>;
324
+ /** GET /api/public/v1/motor-blocks/{id}/daily-summary: Daily summary */
325
+ getDailySummary(args: Args): Promise<any>;
326
+ /** GET /api/public/v1/motor-blocks/{id}/deliverability: Deliverability by recipient domain */
327
+ getDeliverability(args: Args): Promise<any>;
328
+ /** GET /api/public/v1/domains/{id}: One sending domain */
329
+ getDomain(args: Args): Promise<any>;
330
+ /** GET /api/public/v1/domains/{id}/dns-records: DNS records to publish for one domain */
331
+ getDomainDnsRecords(args: Args): Promise<any>;
332
+ /** GET /api/public/v1/motor-blocks/{id}/domain-health: Domain health (SPF/DKIM/DMARC): a set-up status, not a score */
333
+ getDomainHealth(args: Args): Promise<any>;
334
+ /** GET /api/public/v1/domains/{id}/health: Email-authentication health of one domain */
335
+ getDomainHealthById(args: Args): Promise<any>;
336
+ /** GET /api/public/v1/motor-blocks/{id}/error-codes: SMTP error code diagnostics */
337
+ getErrorCodes(args: Args): Promise<any>;
338
+ /** GET /api/public/v1/exports/{jobId}: Get export job status */
339
+ getExport(args: Args): Promise<any>;
340
+ /** GET /api/public/v1/motor-blocks/{id}/logs: Search logs with cursor pagination */
341
+ getLogs(args: Args): Promise<any>;
342
+ /** GET /api/public/v1/messages/{id}: Get message by send id (UUID) */
343
+ getMessage(args: Args): Promise<any>;
344
+ /** GET /api/public/v1/messages/{id}/events: Get message event timeline */
345
+ getMessageEvents(args: Args): Promise<any>;
346
+ /** GET /api/public/v1/messages/{id}/recipients: Per-recipient outcomes for a multi-recipient send */
347
+ getMessageRecipients(args: Args): Promise<any>;
348
+ /** GET /api/public/v1/motor-blocks/{id}/metrics: Metrics series and totals */
349
+ getMetrics(args: Args): Promise<any>;
350
+ /** GET /api/public/v1/account/motor-block-deletions/{jobId}: Poll a permanent-deletion job */
351
+ getMotorBlockDeletionStatus(args: Args): Promise<any>;
352
+ /** GET /api/public/v1/motor-blocks/{id}/overview: Motor Block overview */
353
+ getOverview(args: Args): Promise<any>;
354
+ /** GET /api/system/public-status: Platform status (overall and per component) */
355
+ getPlatformStatus(args?: Args): Promise<any>;
356
+ /** GET /api/public/v1/motor-blocks/{id}/providers: Provider breakdown (gmail, outlook, yahoo, other) */
357
+ getProviders(args: Args): Promise<any>;
358
+ /** GET /api/public/v1/motor-blocks/{id}/rate-limits: Motor Block rate limits */
359
+ getRateLimits(args: Args): Promise<any>;
360
+ /** GET /api/public/v1/motor-blocks/{id}/reputation: Delivery reputation score */
361
+ getReputation(args: Args): Promise<any>;
362
+ /** GET /api/developer/sandbox: Get developer sandbox status */
363
+ getSandboxDashboard(args?: Args): Promise<any>;
364
+ /** GET /api/public/v1/account/sandbox: Get account sandbox status (OAuth/Public API bearer) */
365
+ getSandboxStatus(args?: Args): Promise<any>;
366
+ /** GET /v1/status: Get HTTP Send API service status */
367
+ getSendStatus(args?: Args): Promise<any>;
368
+ /** GET /api/public/v1/motor-blocks/{id}/webhooks/{webhookId}/deliveries: Webhook delivery history */
369
+ getWebhookDeliveries(args: Args): Promise<any>;
370
+ /** GET /api/public/v1/motor-blocks/{id}/webhooks/{webhookId}/stats: Webhook delivery stats */
371
+ getWebhookStats(args: Args): Promise<any>;
372
+ /** GET /api/public/v1/domains: List domains on the account */
373
+ listDomains(args?: Args): Promise<any>;
374
+ /** GET /api/public/v1/motor-blocks/{id}/exports: List recent export jobs */
375
+ listExports(args: Args): Promise<any>;
376
+ /** GET /api/public/v1/account/free-recipients: List Free-account recipients (OAuth/Public API bearer) */
377
+ listFreeRecipients(args?: Args): Promise<any>;
378
+ /** GET /api/public/v1/account/motor-blocks: List the account's production Motor Blocks (OAuth/Public API bearer) */
379
+ listManagedMotorBlocks(args?: Args): Promise<any>;
380
+ /** GET /api/public/v1/messages: Lookup message by RFC Message-ID header */
381
+ listMessages(args: Args): Promise<any>;
382
+ /** GET /api/public/v1/motor-blocks: List motor blocks bound to the token */
383
+ listMotorBlocks(args?: Args): Promise<any>;
384
+ /** GET /api/public/v1/motor-blocks/{id}/webhooks: List webhooks */
385
+ listWebhooks(args: Args): Promise<any>;
386
+ /** POST /api/auth/login: Password login (returns JWT + refreshToken) */
387
+ login(args: Args): Promise<any>;
388
+ /** POST /api/public/token: Mint a Public Analytics API token with a dashboard JWT */
389
+ mintPublicToken(args: Args): Promise<any>;
390
+ /** POST /api/public/token/account-key: Mint a Public Analytics API token with an Account API Key */
391
+ mintPublicTokenFromAccountKey(args: Args): Promise<any>;
392
+ /** GET /api/oauth2/authorize: OAuth 2.0 authorization endpoint (consent HTML) */
393
+ oauthAuthorize(args: Args): Promise<any>;
394
+ /** POST /api/oauth2/token: OAuth 2.0 token endpoint */
395
+ oauthToken(args: Args): Promise<any>;
396
+ /** GET /api/oauth2/validate: Validate an OAuth access token */
397
+ oauthValidateToken(args?: Args): Promise<any>;
398
+ /** GET /api/public/v1/motor-blocks/{id}/exports/preview: Preview recent logs (no job creation) */
399
+ previewExport(args: Args): Promise<any>;
400
+ /** POST /api/public/v1/account/sandbox/provision: Provision account sandbox (OAuth/Public API bearer) */
401
+ provisionSandbox(args?: Args): Promise<any>;
402
+ /** POST /api/developer/sandbox/provision: Provision unpaid developer sandbox */
403
+ provisionSandboxDashboard(args?: Args): Promise<any>;
404
+ /** POST /api/public/v1/account/motor-blocks/{id}/reactivate: Reactivate a deactivated Motor Block */
405
+ reactivateMotorBlock(args: Args): Promise<any>;
406
+ /** POST /api/auth/refresh: Rotate refresh token; issue new access JWT (non-interactive) */
407
+ refreshSession(args?: Args): Promise<any>;
408
+ /** POST /api/auth/register: Start agent signup (email verification code) */
409
+ register(args: Args): Promise<any>;
410
+ /** DELETE /api/public/v1/account/free-recipients/{id}: Remove a Free-account recipient (OAuth/Public API bearer) */
411
+ removeFreeRecipient(args: Args): Promise<any>;
412
+ /** PATCH /api/public/v1/account/motor-blocks/{id}/name: Rename a Motor Block (display name only) */
413
+ renameMotorBlock(args: Args): Promise<any>;
414
+ /** POST /v1/send: Send or validate an email */
415
+ sendEmail(args: Args): Promise<any>;
416
+ /** POST /v1/test-email: Test SMTP setup parameters */
417
+ sendTestEmail(args: Args): Promise<any>;
418
+ /** POST /api/auth/set-password: Set password after email verification (returns JWT + refreshToken) */
419
+ setPassword(args: Args): Promise<any>;
420
+ /** PATCH /api/developer/sandbox/outbound: Update sandbox outbound lock / allowlist */
421
+ setSandboxOutboundDashboard(args?: Args): Promise<any>;
422
+ /** GET /api/public/v1/motor-blocks/{id}/events/stream: Event stream (SSE) */
423
+ streamEvents(args: Args): Promise<any>;
424
+ /** POST /api/public/v1/motor-blocks/{id}/webhooks/{webhookId}/test: Enqueue a test webhook delivery */
425
+ testWebhook(args: Args): Promise<any>;
426
+ /** PUT /api/public/v1/motor-blocks/{id}/webhooks/{webhookId}: Update webhook */
427
+ updateWebhook(args: Args): Promise<any>;
428
+ /** POST /api/public/v1/domains/{id}/verify: Verify ownership and refresh DKIM/SPF send-readiness (account-wide, OAuth/MCP-capable) */
429
+ verifyDomain(args: Args): Promise<any>;
430
+ /** POST /api/domains/{id}/verify: Verify ownership and refresh DKIM/SPF send-readiness */
431
+ verifyDomainDashboard(args: Args): Promise<any>;
432
+ /** POST /api/auth/verify-code: Verify email with 6-digit code */
433
+ verifySignupCode(args: Args): Promise<any>;
434
+ /** GET /api/public/v1/account/whoami: Account identity, plan and grant */
435
+ whoami(args?: Args): Promise<any>;
436
+ }
437
+ export declare const OPENAPI_VERSION: "1.11.0";
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@motorical/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Official Node.js client for the Motorical transactional email API, Public API and Communications API, generated from the OpenAPI specification. No dependencies.",
5
+ "main": "src/index.js",
6
+ "types": "index.d.ts",
7
+ "files": [
8
+ "src",
9
+ "index.d.ts",
10
+ "README.md",
11
+ "LICENSE"
12
+ ],
13
+ "engines": {
14
+ "node": ">=18"
15
+ },
16
+ "scripts": {
17
+ "test": "node --test test/sdk.test.js"
18
+ },
19
+ "keywords": [
20
+ "motorical",
21
+ "email",
22
+ "transactional email",
23
+ "smtp",
24
+ "email api",
25
+ "sdk"
26
+ ],
27
+ "license": "MIT",
28
+ "homepage": "https://docs.motorical.com/api-reference/endpoints#generate-a-client",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/motorical-smtp/motorical-packages.git",
32
+ "directory": "packages/motorical-sdk-node"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/motorical-smtp/motorical-packages/issues"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ }
40
+ }
package/src/core.js ADDED
@@ -0,0 +1,93 @@
1
+ 'use strict';
2
+ // Hand-written core of the Motorical Node SDK. The operation table (operations.js) and the typings are generated from
3
+ // openapi.json by packages/sdk-generator; this file turns one operation plus its arguments into an HTTP request.
4
+
5
+ const DEFAULT_BASE_URL = 'https://api.motorical.com';
6
+
7
+ class MotoricalError extends Error {
8
+ constructor({ status, code, message, requestId, body }) {
9
+ super(message || code || `HTTP ${status}`);
10
+ this.name = 'MotoricalError';
11
+ this.status = status; // HTTP status
12
+ this.code = code || null; // stable error code: branch on this (docs.motorical.com/api-reference/errors)
13
+ this.requestId = requestId || null; // quote to support
14
+ this.body = body; // the full error body
15
+ }
16
+ }
17
+
18
+ function headerFor(kind, creds) {
19
+ if (kind === 'apiKey' && creds.apiKey) return ['Authorization', `ApiKey ${creds.apiKey}`];
20
+ if (kind === 'accountKey' && creds.accountKey) return ['Authorization', `ApiKey ${creds.accountKey}`];
21
+ if (kind === 'bearerToken' && creds.bearerToken) return ['Authorization', `Bearer ${creds.bearerToken}`];
22
+ if (kind === 'dashboardToken' && creds.dashboardToken) return ['Authorization', `Bearer ${creds.dashboardToken}`];
23
+ return null;
24
+ }
25
+
26
+ function buildRequest(op, args = {}, config = {}) {
27
+ const a = { ...args };
28
+ let path = op.path;
29
+ for (const name of op.pathParams) {
30
+ if (a[name] === undefined || a[name] === null || a[name] === '') throw new TypeError(`${op.id}: missing path parameter "${name}"`);
31
+ path = path.replace(`{${name}}`, encodeURIComponent(String(a[name])));
32
+ delete a[name];
33
+ }
34
+ const qs = new URLSearchParams();
35
+ for (const q of op.query) {
36
+ if (a[q.name] !== undefined && a[q.name] !== null) qs.set(q.name, String(a[q.name]));
37
+ else if (q.required) throw new TypeError(`${op.id}: missing query parameter "${q.name}"`);
38
+ delete a[q.name];
39
+ }
40
+ const headers = { Accept: 'application/json', 'User-Agent': config.userAgent || 'motorical-sdk-node' };
41
+ for (const h of op.headers) {
42
+ const key = h.name.replace(/-([a-z])/gi, (_, c) => c.toUpperCase()).replace(/^./, (c) => c.toLowerCase());
43
+ const v = a[h.name] !== undefined ? a[h.name] : a[key];
44
+ if (v !== undefined && v !== null) headers[h.name] = String(v);
45
+ else if (h.required) throw new TypeError(`${op.id}: missing header "${h.name}"`);
46
+ delete a[h.name]; delete a[key];
47
+ }
48
+ // Authentication: the first credential the operation accepts that is configured (in the operation's order).
49
+ for (const kind of op.auth) {
50
+ if (kind === 'workspace') continue;
51
+ const h = headerFor(kind, config);
52
+ if (h) { headers[h[0]] = h[1]; break; }
53
+ }
54
+ if (op.auth.includes('workspace')) {
55
+ const ws = a.workspaceId || config.workspaceId;
56
+ if (!ws) throw new TypeError(`${op.id}: needs a Communications workspace id (workspaceId)`);
57
+ headers['X-Tenant-Id'] = String(ws);
58
+ delete a.workspaceId;
59
+ // Communications calls authenticate the caller with the account key, or else a dashboard session.
60
+ if (!headers.Authorization) {
61
+ const h = headerFor('accountKey', config) || headerFor('dashboardToken', config);
62
+ if (h) headers[h[0]] = h[1];
63
+ }
64
+ }
65
+ let body;
66
+ if (op.body) {
67
+ const payload = a.body !== undefined ? a.body : undefined;
68
+ if (payload === undefined && op.bodyRequired) throw new TypeError(`${op.id}: missing body`);
69
+ if (payload !== undefined) { body = JSON.stringify(payload); headers['Content-Type'] = 'application/json'; }
70
+ }
71
+ // An operation served by another host (the Communications API on motorical.com) names its own server; commsBaseUrl
72
+ // overrides it, baseUrl overrides everything else.
73
+ const base = (op.server ? (config.commsBaseUrl || op.server) : (config.baseUrl || DEFAULT_BASE_URL)).replace(/\/$/, '');
74
+ const url = `${base}${path}${qs.toString() ? `?${qs}` : ''}`;
75
+ return { method: op.method, url, headers, body };
76
+ }
77
+
78
+ async function execute(op, args, config) {
79
+ const req = buildRequest(op, args, config);
80
+ const fetchImpl = config.fetch || globalThis.fetch;
81
+ const res = await fetchImpl(req.url, { method: req.method, headers: req.headers, body: req.body });
82
+ const requestId = res.headers && typeof res.headers.get === 'function' ? res.headers.get('x-request-id') : null;
83
+ const text = await res.text();
84
+ let data = text;
85
+ try { data = text ? JSON.parse(text) : null; } catch (_) { /* not JSON, e.g. a CSV export */ }
86
+ if (!res.ok) {
87
+ const b = data && typeof data === 'object' ? data : {};
88
+ throw new MotoricalError({ status: res.status, code: b.code, message: b.message || b.error, requestId: b.requestId || requestId, body: data });
89
+ }
90
+ return data;
91
+ }
92
+
93
+ module.exports = { buildRequest, execute, MotoricalError, DEFAULT_BASE_URL };