@sendmailos/sdk 1.3.1 → 1.4.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 +47 -0
- package/dist/index.d.mts +86 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +67 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -315,6 +315,53 @@ await platform.campaigns.send({
|
|
|
315
315
|
|
|
316
316
|
**One verified domain = One workspace.** Simple.
|
|
317
317
|
|
|
318
|
+
### Master API Keys
|
|
319
|
+
|
|
320
|
+
Master API keys can access all workspaces in your organization with a single key. Ideal for SaaS platforms that need to manage multiple client workspaces programmatically.
|
|
321
|
+
|
|
322
|
+
#### Recommended Flow for SaaS Platforms
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
// Your platform backend - when a new client signs up
|
|
326
|
+
const platform = new SendMailOS('sk_live_master_key');
|
|
327
|
+
|
|
328
|
+
// 1. Create workspace first (with your client's data)
|
|
329
|
+
const { workspace } = await platform.workspaces.create({
|
|
330
|
+
name: 'Pizza Palace', // From your user's profile
|
|
331
|
+
industry: 'restaurants', // Optional - can be null
|
|
332
|
+
website: 'https://pizzapalace.com'
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
// 2. Add domain TO that workspace
|
|
336
|
+
const { dns_records } = await platform.domains.create({
|
|
337
|
+
domain: 'pizzapalace.com',
|
|
338
|
+
workspaceId: workspace.id // Link to the workspace
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// 3. Show DNS records to your user
|
|
342
|
+
// They verify DNS, domain becomes active
|
|
343
|
+
|
|
344
|
+
// 4. Now send emails using workspace_id or domain
|
|
345
|
+
await platform.emails.send({
|
|
346
|
+
to: 'customer@example.com',
|
|
347
|
+
fromEmail: 'hello@pizzapalace.com',
|
|
348
|
+
subject: 'Welcome!',
|
|
349
|
+
html: '<h1>Welcome!</h1>',
|
|
350
|
+
workspaceId: workspace.id
|
|
351
|
+
});
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
Your end users only see: **"Add domain → Verify DNS → Done"**
|
|
355
|
+
|
|
356
|
+
Behind the scenes: Workspace created with proper settings → Domain linked → Ready to send.
|
|
357
|
+
|
|
358
|
+
**Master Key vs Workspace Key:**
|
|
359
|
+
| Feature | Master Key | Workspace Key |
|
|
360
|
+
|---------|-----------|---------------|
|
|
361
|
+
| Access | All workspaces | Single workspace |
|
|
362
|
+
| workspaceId param | Required | Not needed |
|
|
363
|
+
| Use case | Platform/SaaS backend | Per-client integrations |
|
|
364
|
+
|
|
318
365
|
## Agency Workspaces (Advanced)
|
|
319
366
|
|
|
320
367
|
For more control, you can manually manage workspaces:
|
package/dist/index.d.mts
CHANGED
|
@@ -391,6 +391,41 @@ interface WorkflowStatusResponse {
|
|
|
391
391
|
status: WorkflowStatus;
|
|
392
392
|
};
|
|
393
393
|
}
|
|
394
|
+
interface Pixel$1 {
|
|
395
|
+
id: string;
|
|
396
|
+
name: string;
|
|
397
|
+
domain: string;
|
|
398
|
+
token: string;
|
|
399
|
+
active: boolean;
|
|
400
|
+
workspaceId?: string;
|
|
401
|
+
workspace?: {
|
|
402
|
+
id: string;
|
|
403
|
+
name: string;
|
|
404
|
+
};
|
|
405
|
+
createdAt: string;
|
|
406
|
+
}
|
|
407
|
+
interface CreatePixelRequest {
|
|
408
|
+
/** Pixel name (for identification) */
|
|
409
|
+
name: string;
|
|
410
|
+
/** Domain where the pixel will be installed */
|
|
411
|
+
domain: string;
|
|
412
|
+
/** Workspace ID (for agency accounts) - use this OR domain auto-detection */
|
|
413
|
+
workspace_id?: string;
|
|
414
|
+
}
|
|
415
|
+
interface CreatePixelResponse {
|
|
416
|
+
success: boolean;
|
|
417
|
+
pixel: Pixel$1;
|
|
418
|
+
}
|
|
419
|
+
interface ListPixelsRequest {
|
|
420
|
+
/** Filter by workspace ID (for agency accounts) */
|
|
421
|
+
workspace_id?: string;
|
|
422
|
+
/** Filter by domain (alternative to workspace_id) */
|
|
423
|
+
domain?: string;
|
|
424
|
+
}
|
|
425
|
+
interface ListPixelsResponse {
|
|
426
|
+
success: boolean;
|
|
427
|
+
pixels: Pixel$1[];
|
|
428
|
+
}
|
|
394
429
|
interface ApiError {
|
|
395
430
|
success: false;
|
|
396
431
|
error: string;
|
|
@@ -1215,6 +1250,55 @@ declare class WebhooksResource {
|
|
|
1215
1250
|
}>;
|
|
1216
1251
|
}
|
|
1217
1252
|
|
|
1253
|
+
/**
|
|
1254
|
+
* Pixels resource for managing tracking pixels
|
|
1255
|
+
*/
|
|
1256
|
+
declare class PixelsResource {
|
|
1257
|
+
private request;
|
|
1258
|
+
constructor(request: <T>(endpoint: string, options?: RequestInit) => Promise<T>);
|
|
1259
|
+
/**
|
|
1260
|
+
* Create a new tracking pixel
|
|
1261
|
+
* Returns a pixel with token for installation
|
|
1262
|
+
*
|
|
1263
|
+
* @example
|
|
1264
|
+
* ```ts
|
|
1265
|
+
* const { pixel } = await client.pixels.create({
|
|
1266
|
+
* name: 'Main Website',
|
|
1267
|
+
* domain: 'example.com'
|
|
1268
|
+
* });
|
|
1269
|
+
*
|
|
1270
|
+
* console.log('Pixel token:', pixel.token);
|
|
1271
|
+
* ```
|
|
1272
|
+
*/
|
|
1273
|
+
create(params: CreatePixelRequest): Promise<CreatePixelResponse>;
|
|
1274
|
+
/**
|
|
1275
|
+
* List all pixels for the organization
|
|
1276
|
+
*
|
|
1277
|
+
* @example
|
|
1278
|
+
* ```ts
|
|
1279
|
+
* // List all pixels
|
|
1280
|
+
* const { pixels } = await client.pixels.list();
|
|
1281
|
+
*
|
|
1282
|
+
* // List pixels for a specific domain (agency accounts)
|
|
1283
|
+
* const { pixels } = await client.pixels.list({ domain: 'client.com' });
|
|
1284
|
+
* ```
|
|
1285
|
+
*/
|
|
1286
|
+
list(params?: ListPixelsRequest): Promise<ListPixelsResponse>;
|
|
1287
|
+
/**
|
|
1288
|
+
* Get a single pixel by ID
|
|
1289
|
+
*/
|
|
1290
|
+
get(pixelId: string): Promise<{
|
|
1291
|
+
success: boolean;
|
|
1292
|
+
pixel: Pixel$1;
|
|
1293
|
+
}>;
|
|
1294
|
+
/**
|
|
1295
|
+
* Delete a pixel
|
|
1296
|
+
*/
|
|
1297
|
+
delete(pixelId: string): Promise<{
|
|
1298
|
+
success: boolean;
|
|
1299
|
+
}>;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1218
1302
|
/**
|
|
1219
1303
|
* SendMailOS SDK Client
|
|
1220
1304
|
*
|
|
@@ -1259,6 +1343,8 @@ declare class SendMailOS {
|
|
|
1259
1343
|
readonly workflows: WorkflowsResource;
|
|
1260
1344
|
/** Webhook management */
|
|
1261
1345
|
readonly webhooks: WebhooksResource;
|
|
1346
|
+
/** Tracking pixel management */
|
|
1347
|
+
readonly pixels: PixelsResource;
|
|
1262
1348
|
constructor(apiKey: string, options?: SendMailOSOptions);
|
|
1263
1349
|
/**
|
|
1264
1350
|
* Make an authenticated request to the API
|
package/dist/index.d.ts
CHANGED
|
@@ -391,6 +391,41 @@ interface WorkflowStatusResponse {
|
|
|
391
391
|
status: WorkflowStatus;
|
|
392
392
|
};
|
|
393
393
|
}
|
|
394
|
+
interface Pixel$1 {
|
|
395
|
+
id: string;
|
|
396
|
+
name: string;
|
|
397
|
+
domain: string;
|
|
398
|
+
token: string;
|
|
399
|
+
active: boolean;
|
|
400
|
+
workspaceId?: string;
|
|
401
|
+
workspace?: {
|
|
402
|
+
id: string;
|
|
403
|
+
name: string;
|
|
404
|
+
};
|
|
405
|
+
createdAt: string;
|
|
406
|
+
}
|
|
407
|
+
interface CreatePixelRequest {
|
|
408
|
+
/** Pixel name (for identification) */
|
|
409
|
+
name: string;
|
|
410
|
+
/** Domain where the pixel will be installed */
|
|
411
|
+
domain: string;
|
|
412
|
+
/** Workspace ID (for agency accounts) - use this OR domain auto-detection */
|
|
413
|
+
workspace_id?: string;
|
|
414
|
+
}
|
|
415
|
+
interface CreatePixelResponse {
|
|
416
|
+
success: boolean;
|
|
417
|
+
pixel: Pixel$1;
|
|
418
|
+
}
|
|
419
|
+
interface ListPixelsRequest {
|
|
420
|
+
/** Filter by workspace ID (for agency accounts) */
|
|
421
|
+
workspace_id?: string;
|
|
422
|
+
/** Filter by domain (alternative to workspace_id) */
|
|
423
|
+
domain?: string;
|
|
424
|
+
}
|
|
425
|
+
interface ListPixelsResponse {
|
|
426
|
+
success: boolean;
|
|
427
|
+
pixels: Pixel$1[];
|
|
428
|
+
}
|
|
394
429
|
interface ApiError {
|
|
395
430
|
success: false;
|
|
396
431
|
error: string;
|
|
@@ -1215,6 +1250,55 @@ declare class WebhooksResource {
|
|
|
1215
1250
|
}>;
|
|
1216
1251
|
}
|
|
1217
1252
|
|
|
1253
|
+
/**
|
|
1254
|
+
* Pixels resource for managing tracking pixels
|
|
1255
|
+
*/
|
|
1256
|
+
declare class PixelsResource {
|
|
1257
|
+
private request;
|
|
1258
|
+
constructor(request: <T>(endpoint: string, options?: RequestInit) => Promise<T>);
|
|
1259
|
+
/**
|
|
1260
|
+
* Create a new tracking pixel
|
|
1261
|
+
* Returns a pixel with token for installation
|
|
1262
|
+
*
|
|
1263
|
+
* @example
|
|
1264
|
+
* ```ts
|
|
1265
|
+
* const { pixel } = await client.pixels.create({
|
|
1266
|
+
* name: 'Main Website',
|
|
1267
|
+
* domain: 'example.com'
|
|
1268
|
+
* });
|
|
1269
|
+
*
|
|
1270
|
+
* console.log('Pixel token:', pixel.token);
|
|
1271
|
+
* ```
|
|
1272
|
+
*/
|
|
1273
|
+
create(params: CreatePixelRequest): Promise<CreatePixelResponse>;
|
|
1274
|
+
/**
|
|
1275
|
+
* List all pixels for the organization
|
|
1276
|
+
*
|
|
1277
|
+
* @example
|
|
1278
|
+
* ```ts
|
|
1279
|
+
* // List all pixels
|
|
1280
|
+
* const { pixels } = await client.pixels.list();
|
|
1281
|
+
*
|
|
1282
|
+
* // List pixels for a specific domain (agency accounts)
|
|
1283
|
+
* const { pixels } = await client.pixels.list({ domain: 'client.com' });
|
|
1284
|
+
* ```
|
|
1285
|
+
*/
|
|
1286
|
+
list(params?: ListPixelsRequest): Promise<ListPixelsResponse>;
|
|
1287
|
+
/**
|
|
1288
|
+
* Get a single pixel by ID
|
|
1289
|
+
*/
|
|
1290
|
+
get(pixelId: string): Promise<{
|
|
1291
|
+
success: boolean;
|
|
1292
|
+
pixel: Pixel$1;
|
|
1293
|
+
}>;
|
|
1294
|
+
/**
|
|
1295
|
+
* Delete a pixel
|
|
1296
|
+
*/
|
|
1297
|
+
delete(pixelId: string): Promise<{
|
|
1298
|
+
success: boolean;
|
|
1299
|
+
}>;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1218
1302
|
/**
|
|
1219
1303
|
* SendMailOS SDK Client
|
|
1220
1304
|
*
|
|
@@ -1259,6 +1343,8 @@ declare class SendMailOS {
|
|
|
1259
1343
|
readonly workflows: WorkflowsResource;
|
|
1260
1344
|
/** Webhook management */
|
|
1261
1345
|
readonly webhooks: WebhooksResource;
|
|
1346
|
+
/** Tracking pixel management */
|
|
1347
|
+
readonly pixels: PixelsResource;
|
|
1262
1348
|
constructor(apiKey: string, options?: SendMailOSOptions);
|
|
1263
1349
|
/**
|
|
1264
1350
|
* Make an authenticated request to the API
|
package/dist/index.js
CHANGED
|
@@ -1000,10 +1000,75 @@ var WebhooksResource = class {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
};
|
|
1002
1002
|
|
|
1003
|
+
// src/resources/pixels.ts
|
|
1004
|
+
var PixelsResource = class {
|
|
1005
|
+
constructor(request) {
|
|
1006
|
+
this.request = request;
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Create a new tracking pixel
|
|
1010
|
+
* Returns a pixel with token for installation
|
|
1011
|
+
*
|
|
1012
|
+
* @example
|
|
1013
|
+
* ```ts
|
|
1014
|
+
* const { pixel } = await client.pixels.create({
|
|
1015
|
+
* name: 'Main Website',
|
|
1016
|
+
* domain: 'example.com'
|
|
1017
|
+
* });
|
|
1018
|
+
*
|
|
1019
|
+
* console.log('Pixel token:', pixel.token);
|
|
1020
|
+
* ```
|
|
1021
|
+
*/
|
|
1022
|
+
async create(params) {
|
|
1023
|
+
return this.request("/pixels", {
|
|
1024
|
+
method: "POST",
|
|
1025
|
+
body: JSON.stringify(params)
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* List all pixels for the organization
|
|
1030
|
+
*
|
|
1031
|
+
* @example
|
|
1032
|
+
* ```ts
|
|
1033
|
+
* // List all pixels
|
|
1034
|
+
* const { pixels } = await client.pixels.list();
|
|
1035
|
+
*
|
|
1036
|
+
* // List pixels for a specific domain (agency accounts)
|
|
1037
|
+
* const { pixels } = await client.pixels.list({ domain: 'client.com' });
|
|
1038
|
+
* ```
|
|
1039
|
+
*/
|
|
1040
|
+
async list(params) {
|
|
1041
|
+
const searchParams = new URLSearchParams();
|
|
1042
|
+
if (params?.workspace_id) searchParams.set("workspace_id", params.workspace_id);
|
|
1043
|
+
if (params?.domain) searchParams.set("domain", params.domain);
|
|
1044
|
+
const query = searchParams.toString();
|
|
1045
|
+
const endpoint = query ? `/pixels?${query}` : "/pixels";
|
|
1046
|
+
return this.request(endpoint, {
|
|
1047
|
+
method: "GET"
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Get a single pixel by ID
|
|
1052
|
+
*/
|
|
1053
|
+
async get(pixelId) {
|
|
1054
|
+
return this.request(`/pixels/${pixelId}`, {
|
|
1055
|
+
method: "GET"
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Delete a pixel
|
|
1060
|
+
*/
|
|
1061
|
+
async delete(pixelId) {
|
|
1062
|
+
return this.request(`/pixels/${pixelId}`, {
|
|
1063
|
+
method: "DELETE"
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1003
1068
|
// src/client.ts
|
|
1004
1069
|
var DEFAULT_BASE_URL = "https://sendmailos.com/api/v1";
|
|
1005
1070
|
var DEFAULT_TIMEOUT = 3e4;
|
|
1006
|
-
var SDK_VERSION = "1.
|
|
1071
|
+
var SDK_VERSION = "1.4.0";
|
|
1007
1072
|
var SendMailOS = class {
|
|
1008
1073
|
constructor(apiKey, options = {}) {
|
|
1009
1074
|
if (!apiKey) {
|
|
@@ -1032,6 +1097,7 @@ var SendMailOS = class {
|
|
|
1032
1097
|
this.workspaces = new WorkspacesResource(boundRequest);
|
|
1033
1098
|
this.workflows = new WorkflowsResource(boundRequest);
|
|
1034
1099
|
this.webhooks = new WebhooksResource(boundRequest);
|
|
1100
|
+
this.pixels = new PixelsResource(boundRequest);
|
|
1035
1101
|
}
|
|
1036
1102
|
/**
|
|
1037
1103
|
* Make an authenticated request to the API
|