@sendmailos/sdk 1.1.0 → 1.2.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 +184 -1
- package/dist/index.d.mts +214 -1
- package/dist/index.d.ts +214 -1
- package/dist/index.js +233 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +233 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,10 @@ await client.emails.send({
|
|
|
33
33
|
|
|
34
34
|
- **Type-safe**: Full TypeScript support with exported types
|
|
35
35
|
- **Lightweight**: Zero dependencies for core SDK
|
|
36
|
-
- **
|
|
36
|
+
- **Industry Templates**: 50+ pre-built templates for different industries
|
|
37
|
+
- **Agency Workspaces**: Manage multiple clients from one account
|
|
38
|
+
- **Pixel Tracking**: Track website visitors and link to email campaigns
|
|
39
|
+
- **React Components**: Pre-built components and hooks
|
|
37
40
|
- **Webhook Verification**: Secure signature verification utilities
|
|
38
41
|
- **Error Handling**: Custom error classes for different scenarios
|
|
39
42
|
|
|
@@ -101,6 +104,186 @@ const { domain } = await client.domains.create({
|
|
|
101
104
|
console.log('DNS Records to add:', domain.dnsRecords);
|
|
102
105
|
```
|
|
103
106
|
|
|
107
|
+
## Organization & Industries
|
|
108
|
+
|
|
109
|
+
Set your industry during onboarding to get pre-built templates and workflows.
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { SendMailOS, INDUSTRIES } from '@sendmailos/sdk';
|
|
113
|
+
|
|
114
|
+
const client = new SendMailOS('sk_live_...');
|
|
115
|
+
|
|
116
|
+
// Get current organization
|
|
117
|
+
const org = await client.organization.get();
|
|
118
|
+
|
|
119
|
+
// Set industries (multi-select)
|
|
120
|
+
await client.organization.setIndustries(['ecommerce', 'saas']);
|
|
121
|
+
|
|
122
|
+
// Convert to agency account (enables workspaces)
|
|
123
|
+
await client.organization.convertToAgency();
|
|
124
|
+
|
|
125
|
+
// Available industries (50+)
|
|
126
|
+
console.log(INDUSTRIES);
|
|
127
|
+
// { hotels: 'Hotels & Hospitality', restaurants: 'Restaurants & Food Service', ... }
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Supported Industries
|
|
131
|
+
|
|
132
|
+
Hotels, Restaurants, Gyms, Travel Agencies, Real Estate, Schools, E-commerce, Dentists, Car Dealerships, Events, Beauty Salons, Law Firms, Non-Profits, SaaS, Recruitment, Insurance, Online Courses, Municipalities, Personal Trainers, Influencers, Doctors/Clinics, Nightclubs, Coworking, Wedding Planners, Art Galleries, Car Rentals, Podcasters, Consultants, Bakeries, Veterinarians, Airbnb Hosts, Accountants, Developers, Musicians, Spas, Bookstores, Cleaning Services, Churches, Graphic Designers, Coffee Shops, Florists, Political Campaigns, Libraries, Taxis/Limos, Home Inspectors, Photographers, Universities, Fashion, Nutritionists, Startups
|
|
133
|
+
|
|
134
|
+
## Agency Workspaces
|
|
135
|
+
|
|
136
|
+
Agencies can manage multiple clients from one account, each with isolated data.
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
// Convert to agency account first
|
|
140
|
+
await client.organization.convertToAgency();
|
|
141
|
+
|
|
142
|
+
// Create client workspaces
|
|
143
|
+
const pizzaPlace = await client.workspaces.create({
|
|
144
|
+
name: 'Pizza Palace',
|
|
145
|
+
industry: 'restaurants',
|
|
146
|
+
import_templates: true // Auto-import restaurant templates
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const gym = await client.workspaces.create({
|
|
150
|
+
name: 'FitLife Gym',
|
|
151
|
+
industry: 'gyms',
|
|
152
|
+
import_templates: true
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// List all clients
|
|
156
|
+
const { workspaces } = await client.workspaces.list();
|
|
157
|
+
for (const ws of workspaces) {
|
|
158
|
+
console.log(`${ws.name}: ${ws.stats?.subscribers} subscribers`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Get detailed stats
|
|
162
|
+
const details = await client.workspaces.get(pizzaPlace.id);
|
|
163
|
+
console.log(details.stats);
|
|
164
|
+
// { total_subscribers: 1200, active_subscribers: 1150, total_campaigns: 24, ... }
|
|
165
|
+
|
|
166
|
+
// Invite client to view reports
|
|
167
|
+
await client.workspaces.inviteClient(pizzaPlace.id, 'owner@pizzapalace.com');
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Pixel Tracking
|
|
171
|
+
|
|
172
|
+
Track website visitors and connect their behavior to email campaigns.
|
|
173
|
+
|
|
174
|
+
### Basic Setup
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import { SendmailPixel } from '@sendmailos/sdk';
|
|
178
|
+
|
|
179
|
+
const pixel = new SendmailPixel({
|
|
180
|
+
token: 'pk_live_your_public_key',
|
|
181
|
+
debug: false // Set true for console logging
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
pixel.init();
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Track Events
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
// Track custom events
|
|
191
|
+
pixel.track('button_clicked', { button_id: 'cta-signup' });
|
|
192
|
+
|
|
193
|
+
// Track page views (called automatically on init)
|
|
194
|
+
pixel.pageView();
|
|
195
|
+
|
|
196
|
+
// Identify a visitor by email
|
|
197
|
+
pixel.identify('user@example.com', {
|
|
198
|
+
first_name: 'John',
|
|
199
|
+
plan: 'premium'
|
|
200
|
+
});
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Privacy Controls
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
// Opt out of tracking (e.g., user declines cookies)
|
|
207
|
+
pixel.optOut();
|
|
208
|
+
|
|
209
|
+
// Opt back in
|
|
210
|
+
pixel.optIn();
|
|
211
|
+
|
|
212
|
+
// Check opt-out status
|
|
213
|
+
if (pixel.isOptedOut()) {
|
|
214
|
+
console.log('Tracking disabled');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Reset identity (e.g., on logout)
|
|
218
|
+
pixel.reset();
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Global smp() Function
|
|
222
|
+
|
|
223
|
+
For script tag usage, use `createGlobalPixel` to set up a global `smp()` function:
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
import { createGlobalPixel } from '@sendmailos/sdk';
|
|
227
|
+
|
|
228
|
+
createGlobalPixel({ token: 'pk_live_...' });
|
|
229
|
+
|
|
230
|
+
// Now use anywhere:
|
|
231
|
+
smp('track', 'event_name', { property: 'value' });
|
|
232
|
+
smp('identify', 'user@example.com');
|
|
233
|
+
smp('optOut');
|
|
234
|
+
smp('optIn');
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### React Pixel Hooks
|
|
238
|
+
|
|
239
|
+
```tsx
|
|
240
|
+
import { usePixel, usePageTracking, useIdentifyOnLogin } from '@sendmailos/sdk/react';
|
|
241
|
+
|
|
242
|
+
// Basic usage
|
|
243
|
+
function MyComponent() {
|
|
244
|
+
const { track, identify, optOut } = usePixel('pk_live_...');
|
|
245
|
+
|
|
246
|
+
return (
|
|
247
|
+
<button onClick={() => track('button_clicked', { id: 'cta' })}>
|
|
248
|
+
Click Me
|
|
249
|
+
</button>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Auto page tracking (Next.js App Router)
|
|
254
|
+
function Layout({ children }) {
|
|
255
|
+
const pathname = usePathname();
|
|
256
|
+
usePageTracking('pk_live_...', pathname);
|
|
257
|
+
return <>{children}</>;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Auto identify on login
|
|
261
|
+
function App() {
|
|
262
|
+
const { user } = useAuth();
|
|
263
|
+
useIdentifyOnLogin('pk_live_...', user?.email, {
|
|
264
|
+
first_name: user?.firstName,
|
|
265
|
+
plan: user?.plan
|
|
266
|
+
});
|
|
267
|
+
return <Main />;
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Data Attributes
|
|
272
|
+
|
|
273
|
+
Track clicks without JavaScript using HTML data attributes:
|
|
274
|
+
|
|
275
|
+
```html
|
|
276
|
+
<button data-smp-track="signup_clicked">Sign Up</button>
|
|
277
|
+
|
|
278
|
+
<button
|
|
279
|
+
data-smp-track="button_clicked"
|
|
280
|
+
data-smp-track-button-id="cta-main"
|
|
281
|
+
data-smp-track-variant="blue"
|
|
282
|
+
>
|
|
283
|
+
Get Started
|
|
284
|
+
</button>
|
|
285
|
+
```
|
|
286
|
+
|
|
104
287
|
## React Integration
|
|
105
288
|
|
|
106
289
|
```tsx
|
package/dist/index.d.mts
CHANGED
|
@@ -348,6 +348,215 @@ declare class DomainsResource {
|
|
|
348
348
|
}>;
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
+
/**
|
|
352
|
+
* Organization management resource
|
|
353
|
+
*/
|
|
354
|
+
type OrganizationType = 'business' | 'agency';
|
|
355
|
+
type Industry = 'hotels' | 'restaurants' | 'gyms' | 'travel_agencies' | 'real_estate' | 'schools' | 'ecommerce' | 'dentists' | 'car_dealerships' | 'events' | 'beauty_salons' | 'law_firms' | 'nonprofits' | 'saas' | 'recruitment' | 'insurance' | 'online_courses' | 'municipalities' | 'personal_trainers' | 'influencers' | 'doctors_clinics' | 'nightclubs' | 'coworking' | 'wedding_planners' | 'art_galleries' | 'car_rentals' | 'podcasters' | 'consultants' | 'bakeries' | 'veterinarians' | 'airbnb_hosts' | 'accountants' | 'developers' | 'musicians' | 'spas' | 'bookstores' | 'cleaning_services' | 'churches' | 'graphic_designers' | 'coffee_shops' | 'florists' | 'political' | 'libraries' | 'taxis_limos' | 'home_inspectors' | 'photographers' | 'universities' | 'fashion' | 'nutritionists' | 'startups' | 'other';
|
|
356
|
+
interface Organization {
|
|
357
|
+
id: string;
|
|
358
|
+
name: string;
|
|
359
|
+
org_type: OrganizationType;
|
|
360
|
+
industries: Industry[];
|
|
361
|
+
onboarding_completed: boolean;
|
|
362
|
+
onboarding_step: string;
|
|
363
|
+
created_at: string;
|
|
364
|
+
free_credits_limit?: number;
|
|
365
|
+
}
|
|
366
|
+
interface UpdateOrganizationRequest {
|
|
367
|
+
name?: string;
|
|
368
|
+
org_type?: OrganizationType;
|
|
369
|
+
industries?: Industry[];
|
|
370
|
+
onboarding_completed?: boolean;
|
|
371
|
+
onboarding_step?: string;
|
|
372
|
+
}
|
|
373
|
+
declare class OrganizationResource {
|
|
374
|
+
private request;
|
|
375
|
+
constructor(request: <T>(endpoint: string, options?: RequestInit) => Promise<T>);
|
|
376
|
+
/**
|
|
377
|
+
* Get current organization details
|
|
378
|
+
*/
|
|
379
|
+
get(): Promise<Organization>;
|
|
380
|
+
/**
|
|
381
|
+
* Update organization settings
|
|
382
|
+
*/
|
|
383
|
+
update(updates: UpdateOrganizationRequest): Promise<Organization>;
|
|
384
|
+
/**
|
|
385
|
+
* Set organization industries (during onboarding)
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```ts
|
|
389
|
+
* await client.organization.setIndustries(['ecommerce', 'saas']);
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
setIndustries(industries: Industry[]): Promise<Organization>;
|
|
393
|
+
/**
|
|
394
|
+
* Convert to agency account (enables workspaces)
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```ts
|
|
398
|
+
* await client.organization.convertToAgency();
|
|
399
|
+
* // Now you can create client workspaces
|
|
400
|
+
* await client.workspaces.create({ name: 'Client A', industry: 'ecommerce' });
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
convertToAgency(): Promise<Organization>;
|
|
404
|
+
/**
|
|
405
|
+
* Complete onboarding
|
|
406
|
+
*/
|
|
407
|
+
completeOnboarding(): Promise<Organization>;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* All available industries with human-readable labels
|
|
411
|
+
*/
|
|
412
|
+
declare const INDUSTRIES: Record<Industry, string>;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Workspace management resource (for agencies)
|
|
416
|
+
*/
|
|
417
|
+
|
|
418
|
+
interface Workspace {
|
|
419
|
+
id: string;
|
|
420
|
+
name: string;
|
|
421
|
+
slug: string;
|
|
422
|
+
industry: Industry | null;
|
|
423
|
+
logo_url: string | null;
|
|
424
|
+
website: string | null;
|
|
425
|
+
is_active: boolean;
|
|
426
|
+
client_email: string | null;
|
|
427
|
+
client_can_view_reports: boolean;
|
|
428
|
+
created_at: string;
|
|
429
|
+
updated_at: string;
|
|
430
|
+
stats?: WorkspaceStats;
|
|
431
|
+
}
|
|
432
|
+
interface WorkspaceStats {
|
|
433
|
+
subscribers?: number;
|
|
434
|
+
campaigns?: number;
|
|
435
|
+
emails_30d?: number;
|
|
436
|
+
total_subscribers?: number;
|
|
437
|
+
active_subscribers?: number;
|
|
438
|
+
total_campaigns?: number;
|
|
439
|
+
sent_campaigns?: number;
|
|
440
|
+
total_emails?: number;
|
|
441
|
+
domains?: number;
|
|
442
|
+
}
|
|
443
|
+
interface CreateWorkspaceRequest {
|
|
444
|
+
/** Client/workspace name */
|
|
445
|
+
name: string;
|
|
446
|
+
/** Industry for pre-built templates */
|
|
447
|
+
industry?: Industry;
|
|
448
|
+
/** Client website URL */
|
|
449
|
+
website?: string;
|
|
450
|
+
/** Logo URL */
|
|
451
|
+
logo_url?: string;
|
|
452
|
+
/** Client email for portal access */
|
|
453
|
+
client_email?: string;
|
|
454
|
+
/** Allow client to view reports */
|
|
455
|
+
client_can_view_reports?: boolean;
|
|
456
|
+
/** Import industry templates automatically */
|
|
457
|
+
import_templates?: boolean;
|
|
458
|
+
/** Custom settings */
|
|
459
|
+
settings?: Record<string, unknown>;
|
|
460
|
+
}
|
|
461
|
+
interface UpdateWorkspaceRequest {
|
|
462
|
+
name?: string;
|
|
463
|
+
industry?: Industry;
|
|
464
|
+
website?: string;
|
|
465
|
+
logo_url?: string;
|
|
466
|
+
is_active?: boolean;
|
|
467
|
+
client_email?: string;
|
|
468
|
+
client_can_view_reports?: boolean;
|
|
469
|
+
billing_enabled?: boolean;
|
|
470
|
+
billing_email?: string;
|
|
471
|
+
settings?: Record<string, unknown>;
|
|
472
|
+
}
|
|
473
|
+
declare class WorkspacesResource {
|
|
474
|
+
private request;
|
|
475
|
+
constructor(request: <T>(endpoint: string, options?: RequestInit) => Promise<T>);
|
|
476
|
+
/**
|
|
477
|
+
* List all workspaces (clients)
|
|
478
|
+
* @note Only available for agency accounts
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* ```ts
|
|
482
|
+
* const { workspaces } = await client.workspaces.list();
|
|
483
|
+
* for (const ws of workspaces) {
|
|
484
|
+
* console.log(`${ws.name}: ${ws.stats?.subscribers} subscribers`);
|
|
485
|
+
* }
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
list(): Promise<{
|
|
489
|
+
workspaces: Workspace[];
|
|
490
|
+
total: number;
|
|
491
|
+
}>;
|
|
492
|
+
/**
|
|
493
|
+
* Create a new workspace (client)
|
|
494
|
+
* @note Only available for agency accounts
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```ts
|
|
498
|
+
* const workspace = await client.workspaces.create({
|
|
499
|
+
* name: 'Pizza Palace',
|
|
500
|
+
* industry: 'restaurants',
|
|
501
|
+
* import_templates: true // Auto-import restaurant templates
|
|
502
|
+
* });
|
|
503
|
+
* ```
|
|
504
|
+
*/
|
|
505
|
+
create(workspace: CreateWorkspaceRequest): Promise<Workspace>;
|
|
506
|
+
/**
|
|
507
|
+
* Get a workspace by ID with detailed stats
|
|
508
|
+
*
|
|
509
|
+
* @example
|
|
510
|
+
* ```ts
|
|
511
|
+
* const workspace = await client.workspaces.get('ws_123');
|
|
512
|
+
* console.log('Active subscribers:', workspace.stats.active_subscribers);
|
|
513
|
+
* ```
|
|
514
|
+
*/
|
|
515
|
+
get(workspaceId: string): Promise<Workspace>;
|
|
516
|
+
/**
|
|
517
|
+
* Update a workspace
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* ```ts
|
|
521
|
+
* await client.workspaces.update('ws_123', {
|
|
522
|
+
* name: 'Pizza Palace - Main Location',
|
|
523
|
+
* client_can_view_reports: true
|
|
524
|
+
* });
|
|
525
|
+
* ```
|
|
526
|
+
*/
|
|
527
|
+
update(workspaceId: string, updates: UpdateWorkspaceRequest): Promise<Workspace>;
|
|
528
|
+
/**
|
|
529
|
+
* Delete a workspace
|
|
530
|
+
* @warning This will delete all associated data (subscribers, campaigns, etc.)
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* ```ts
|
|
534
|
+
* await client.workspaces.delete('ws_123');
|
|
535
|
+
* ```
|
|
536
|
+
*/
|
|
537
|
+
delete(workspaceId: string): Promise<{
|
|
538
|
+
message: string;
|
|
539
|
+
}>;
|
|
540
|
+
/**
|
|
541
|
+
* Activate a workspace
|
|
542
|
+
*/
|
|
543
|
+
activate(workspaceId: string): Promise<Workspace>;
|
|
544
|
+
/**
|
|
545
|
+
* Deactivate a workspace
|
|
546
|
+
*/
|
|
547
|
+
deactivate(workspaceId: string): Promise<Workspace>;
|
|
548
|
+
/**
|
|
549
|
+
* Invite client to view reports
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* ```ts
|
|
553
|
+
* await client.workspaces.inviteClient('ws_123', 'owner@pizzapalace.com');
|
|
554
|
+
* // Client receives email with portal access
|
|
555
|
+
* ```
|
|
556
|
+
*/
|
|
557
|
+
inviteClient(workspaceId: string, email: string): Promise<Workspace>;
|
|
558
|
+
}
|
|
559
|
+
|
|
351
560
|
/**
|
|
352
561
|
* SendMailOS SDK Client
|
|
353
562
|
*
|
|
@@ -384,6 +593,10 @@ declare class SendMailOS {
|
|
|
384
593
|
readonly campaigns: CampaignsResource;
|
|
385
594
|
/** Domain management */
|
|
386
595
|
readonly domains: DomainsResource;
|
|
596
|
+
/** Organization settings (industries, type) */
|
|
597
|
+
readonly organization: OrganizationResource;
|
|
598
|
+
/** Workspace management (for agencies) */
|
|
599
|
+
readonly workspaces: WorkspacesResource;
|
|
387
600
|
constructor(apiKey: string, options?: SendMailOSOptions);
|
|
388
601
|
/**
|
|
389
602
|
* Make an authenticated request to the API
|
|
@@ -564,4 +777,4 @@ declare function constructWebhookEvent<T = unknown>(payload: string, headers: {
|
|
|
564
777
|
timestamp: string;
|
|
565
778
|
}, secret: string): T;
|
|
566
779
|
|
|
567
|
-
export { type ApiError, AuthenticationError, type CreateDomainRequest, type CreateDomainResponse, type CreateSubscriberRequest, type CreateSubscriberResponse, type CreateWebhookRequest, type DnsRecord, type Domain, type IdentifyTraits, type ListDomainsResponse, type ListSubscribersRequest, type ListSubscribersResponse, NotFoundError, Pixel, type PixelConfig, type PixelOptions, RateLimitError, type SendCampaignRequest, type SendCampaignResponse, type SendEmailRequest, type SendEmailResponse, SendMailOS, SendMailOSError, type SendMailOSOptions, SendmailPixel, type Subscriber, type TrackEventProperties, type TrackProps, ValidationError, type VerifyWebhookParams, type Webhook, type WebhookEvent, type WebhookEventType, constructWebhookEvent, createGlobalPixel, SendMailOS as default, verifyWebhookSignature, verifyWebhookSignatureAsync };
|
|
780
|
+
export { type ApiError, AuthenticationError, type CreateDomainRequest, type CreateDomainResponse, type CreateSubscriberRequest, type CreateSubscriberResponse, type CreateWebhookRequest, type CreateWorkspaceRequest, type DnsRecord, type Domain, INDUSTRIES, type IdentifyTraits, type Industry, type ListDomainsResponse, type ListSubscribersRequest, type ListSubscribersResponse, NotFoundError, type Organization, type OrganizationType, Pixel, type PixelConfig, type PixelOptions, RateLimitError, type SendCampaignRequest, type SendCampaignResponse, type SendEmailRequest, type SendEmailResponse, SendMailOS, SendMailOSError, type SendMailOSOptions, SendmailPixel, type Subscriber, type TrackEventProperties, type TrackProps, type UpdateOrganizationRequest, type UpdateWorkspaceRequest, ValidationError, type VerifyWebhookParams, type Webhook, type WebhookEvent, type WebhookEventType, type Workspace, type WorkspaceStats, constructWebhookEvent, createGlobalPixel, SendMailOS as default, verifyWebhookSignature, verifyWebhookSignatureAsync };
|
package/dist/index.d.ts
CHANGED
|
@@ -348,6 +348,215 @@ declare class DomainsResource {
|
|
|
348
348
|
}>;
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
+
/**
|
|
352
|
+
* Organization management resource
|
|
353
|
+
*/
|
|
354
|
+
type OrganizationType = 'business' | 'agency';
|
|
355
|
+
type Industry = 'hotels' | 'restaurants' | 'gyms' | 'travel_agencies' | 'real_estate' | 'schools' | 'ecommerce' | 'dentists' | 'car_dealerships' | 'events' | 'beauty_salons' | 'law_firms' | 'nonprofits' | 'saas' | 'recruitment' | 'insurance' | 'online_courses' | 'municipalities' | 'personal_trainers' | 'influencers' | 'doctors_clinics' | 'nightclubs' | 'coworking' | 'wedding_planners' | 'art_galleries' | 'car_rentals' | 'podcasters' | 'consultants' | 'bakeries' | 'veterinarians' | 'airbnb_hosts' | 'accountants' | 'developers' | 'musicians' | 'spas' | 'bookstores' | 'cleaning_services' | 'churches' | 'graphic_designers' | 'coffee_shops' | 'florists' | 'political' | 'libraries' | 'taxis_limos' | 'home_inspectors' | 'photographers' | 'universities' | 'fashion' | 'nutritionists' | 'startups' | 'other';
|
|
356
|
+
interface Organization {
|
|
357
|
+
id: string;
|
|
358
|
+
name: string;
|
|
359
|
+
org_type: OrganizationType;
|
|
360
|
+
industries: Industry[];
|
|
361
|
+
onboarding_completed: boolean;
|
|
362
|
+
onboarding_step: string;
|
|
363
|
+
created_at: string;
|
|
364
|
+
free_credits_limit?: number;
|
|
365
|
+
}
|
|
366
|
+
interface UpdateOrganizationRequest {
|
|
367
|
+
name?: string;
|
|
368
|
+
org_type?: OrganizationType;
|
|
369
|
+
industries?: Industry[];
|
|
370
|
+
onboarding_completed?: boolean;
|
|
371
|
+
onboarding_step?: string;
|
|
372
|
+
}
|
|
373
|
+
declare class OrganizationResource {
|
|
374
|
+
private request;
|
|
375
|
+
constructor(request: <T>(endpoint: string, options?: RequestInit) => Promise<T>);
|
|
376
|
+
/**
|
|
377
|
+
* Get current organization details
|
|
378
|
+
*/
|
|
379
|
+
get(): Promise<Organization>;
|
|
380
|
+
/**
|
|
381
|
+
* Update organization settings
|
|
382
|
+
*/
|
|
383
|
+
update(updates: UpdateOrganizationRequest): Promise<Organization>;
|
|
384
|
+
/**
|
|
385
|
+
* Set organization industries (during onboarding)
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```ts
|
|
389
|
+
* await client.organization.setIndustries(['ecommerce', 'saas']);
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
setIndustries(industries: Industry[]): Promise<Organization>;
|
|
393
|
+
/**
|
|
394
|
+
* Convert to agency account (enables workspaces)
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```ts
|
|
398
|
+
* await client.organization.convertToAgency();
|
|
399
|
+
* // Now you can create client workspaces
|
|
400
|
+
* await client.workspaces.create({ name: 'Client A', industry: 'ecommerce' });
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
convertToAgency(): Promise<Organization>;
|
|
404
|
+
/**
|
|
405
|
+
* Complete onboarding
|
|
406
|
+
*/
|
|
407
|
+
completeOnboarding(): Promise<Organization>;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* All available industries with human-readable labels
|
|
411
|
+
*/
|
|
412
|
+
declare const INDUSTRIES: Record<Industry, string>;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Workspace management resource (for agencies)
|
|
416
|
+
*/
|
|
417
|
+
|
|
418
|
+
interface Workspace {
|
|
419
|
+
id: string;
|
|
420
|
+
name: string;
|
|
421
|
+
slug: string;
|
|
422
|
+
industry: Industry | null;
|
|
423
|
+
logo_url: string | null;
|
|
424
|
+
website: string | null;
|
|
425
|
+
is_active: boolean;
|
|
426
|
+
client_email: string | null;
|
|
427
|
+
client_can_view_reports: boolean;
|
|
428
|
+
created_at: string;
|
|
429
|
+
updated_at: string;
|
|
430
|
+
stats?: WorkspaceStats;
|
|
431
|
+
}
|
|
432
|
+
interface WorkspaceStats {
|
|
433
|
+
subscribers?: number;
|
|
434
|
+
campaigns?: number;
|
|
435
|
+
emails_30d?: number;
|
|
436
|
+
total_subscribers?: number;
|
|
437
|
+
active_subscribers?: number;
|
|
438
|
+
total_campaigns?: number;
|
|
439
|
+
sent_campaigns?: number;
|
|
440
|
+
total_emails?: number;
|
|
441
|
+
domains?: number;
|
|
442
|
+
}
|
|
443
|
+
interface CreateWorkspaceRequest {
|
|
444
|
+
/** Client/workspace name */
|
|
445
|
+
name: string;
|
|
446
|
+
/** Industry for pre-built templates */
|
|
447
|
+
industry?: Industry;
|
|
448
|
+
/** Client website URL */
|
|
449
|
+
website?: string;
|
|
450
|
+
/** Logo URL */
|
|
451
|
+
logo_url?: string;
|
|
452
|
+
/** Client email for portal access */
|
|
453
|
+
client_email?: string;
|
|
454
|
+
/** Allow client to view reports */
|
|
455
|
+
client_can_view_reports?: boolean;
|
|
456
|
+
/** Import industry templates automatically */
|
|
457
|
+
import_templates?: boolean;
|
|
458
|
+
/** Custom settings */
|
|
459
|
+
settings?: Record<string, unknown>;
|
|
460
|
+
}
|
|
461
|
+
interface UpdateWorkspaceRequest {
|
|
462
|
+
name?: string;
|
|
463
|
+
industry?: Industry;
|
|
464
|
+
website?: string;
|
|
465
|
+
logo_url?: string;
|
|
466
|
+
is_active?: boolean;
|
|
467
|
+
client_email?: string;
|
|
468
|
+
client_can_view_reports?: boolean;
|
|
469
|
+
billing_enabled?: boolean;
|
|
470
|
+
billing_email?: string;
|
|
471
|
+
settings?: Record<string, unknown>;
|
|
472
|
+
}
|
|
473
|
+
declare class WorkspacesResource {
|
|
474
|
+
private request;
|
|
475
|
+
constructor(request: <T>(endpoint: string, options?: RequestInit) => Promise<T>);
|
|
476
|
+
/**
|
|
477
|
+
* List all workspaces (clients)
|
|
478
|
+
* @note Only available for agency accounts
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* ```ts
|
|
482
|
+
* const { workspaces } = await client.workspaces.list();
|
|
483
|
+
* for (const ws of workspaces) {
|
|
484
|
+
* console.log(`${ws.name}: ${ws.stats?.subscribers} subscribers`);
|
|
485
|
+
* }
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
list(): Promise<{
|
|
489
|
+
workspaces: Workspace[];
|
|
490
|
+
total: number;
|
|
491
|
+
}>;
|
|
492
|
+
/**
|
|
493
|
+
* Create a new workspace (client)
|
|
494
|
+
* @note Only available for agency accounts
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```ts
|
|
498
|
+
* const workspace = await client.workspaces.create({
|
|
499
|
+
* name: 'Pizza Palace',
|
|
500
|
+
* industry: 'restaurants',
|
|
501
|
+
* import_templates: true // Auto-import restaurant templates
|
|
502
|
+
* });
|
|
503
|
+
* ```
|
|
504
|
+
*/
|
|
505
|
+
create(workspace: CreateWorkspaceRequest): Promise<Workspace>;
|
|
506
|
+
/**
|
|
507
|
+
* Get a workspace by ID with detailed stats
|
|
508
|
+
*
|
|
509
|
+
* @example
|
|
510
|
+
* ```ts
|
|
511
|
+
* const workspace = await client.workspaces.get('ws_123');
|
|
512
|
+
* console.log('Active subscribers:', workspace.stats.active_subscribers);
|
|
513
|
+
* ```
|
|
514
|
+
*/
|
|
515
|
+
get(workspaceId: string): Promise<Workspace>;
|
|
516
|
+
/**
|
|
517
|
+
* Update a workspace
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* ```ts
|
|
521
|
+
* await client.workspaces.update('ws_123', {
|
|
522
|
+
* name: 'Pizza Palace - Main Location',
|
|
523
|
+
* client_can_view_reports: true
|
|
524
|
+
* });
|
|
525
|
+
* ```
|
|
526
|
+
*/
|
|
527
|
+
update(workspaceId: string, updates: UpdateWorkspaceRequest): Promise<Workspace>;
|
|
528
|
+
/**
|
|
529
|
+
* Delete a workspace
|
|
530
|
+
* @warning This will delete all associated data (subscribers, campaigns, etc.)
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* ```ts
|
|
534
|
+
* await client.workspaces.delete('ws_123');
|
|
535
|
+
* ```
|
|
536
|
+
*/
|
|
537
|
+
delete(workspaceId: string): Promise<{
|
|
538
|
+
message: string;
|
|
539
|
+
}>;
|
|
540
|
+
/**
|
|
541
|
+
* Activate a workspace
|
|
542
|
+
*/
|
|
543
|
+
activate(workspaceId: string): Promise<Workspace>;
|
|
544
|
+
/**
|
|
545
|
+
* Deactivate a workspace
|
|
546
|
+
*/
|
|
547
|
+
deactivate(workspaceId: string): Promise<Workspace>;
|
|
548
|
+
/**
|
|
549
|
+
* Invite client to view reports
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* ```ts
|
|
553
|
+
* await client.workspaces.inviteClient('ws_123', 'owner@pizzapalace.com');
|
|
554
|
+
* // Client receives email with portal access
|
|
555
|
+
* ```
|
|
556
|
+
*/
|
|
557
|
+
inviteClient(workspaceId: string, email: string): Promise<Workspace>;
|
|
558
|
+
}
|
|
559
|
+
|
|
351
560
|
/**
|
|
352
561
|
* SendMailOS SDK Client
|
|
353
562
|
*
|
|
@@ -384,6 +593,10 @@ declare class SendMailOS {
|
|
|
384
593
|
readonly campaigns: CampaignsResource;
|
|
385
594
|
/** Domain management */
|
|
386
595
|
readonly domains: DomainsResource;
|
|
596
|
+
/** Organization settings (industries, type) */
|
|
597
|
+
readonly organization: OrganizationResource;
|
|
598
|
+
/** Workspace management (for agencies) */
|
|
599
|
+
readonly workspaces: WorkspacesResource;
|
|
387
600
|
constructor(apiKey: string, options?: SendMailOSOptions);
|
|
388
601
|
/**
|
|
389
602
|
* Make an authenticated request to the API
|
|
@@ -564,4 +777,4 @@ declare function constructWebhookEvent<T = unknown>(payload: string, headers: {
|
|
|
564
777
|
timestamp: string;
|
|
565
778
|
}, secret: string): T;
|
|
566
779
|
|
|
567
|
-
export { type ApiError, AuthenticationError, type CreateDomainRequest, type CreateDomainResponse, type CreateSubscriberRequest, type CreateSubscriberResponse, type CreateWebhookRequest, type DnsRecord, type Domain, type IdentifyTraits, type ListDomainsResponse, type ListSubscribersRequest, type ListSubscribersResponse, NotFoundError, Pixel, type PixelConfig, type PixelOptions, RateLimitError, type SendCampaignRequest, type SendCampaignResponse, type SendEmailRequest, type SendEmailResponse, SendMailOS, SendMailOSError, type SendMailOSOptions, SendmailPixel, type Subscriber, type TrackEventProperties, type TrackProps, ValidationError, type VerifyWebhookParams, type Webhook, type WebhookEvent, type WebhookEventType, constructWebhookEvent, createGlobalPixel, SendMailOS as default, verifyWebhookSignature, verifyWebhookSignatureAsync };
|
|
780
|
+
export { type ApiError, AuthenticationError, type CreateDomainRequest, type CreateDomainResponse, type CreateSubscriberRequest, type CreateSubscriberResponse, type CreateWebhookRequest, type CreateWorkspaceRequest, type DnsRecord, type Domain, INDUSTRIES, type IdentifyTraits, type Industry, type ListDomainsResponse, type ListSubscribersRequest, type ListSubscribersResponse, NotFoundError, type Organization, type OrganizationType, Pixel, type PixelConfig, type PixelOptions, RateLimitError, type SendCampaignRequest, type SendCampaignResponse, type SendEmailRequest, type SendEmailResponse, SendMailOS, SendMailOSError, type SendMailOSOptions, SendmailPixel, type Subscriber, type TrackEventProperties, type TrackProps, type UpdateOrganizationRequest, type UpdateWorkspaceRequest, ValidationError, type VerifyWebhookParams, type Webhook, type WebhookEvent, type WebhookEventType, type Workspace, type WorkspaceStats, constructWebhookEvent, createGlobalPixel, SendMailOS as default, verifyWebhookSignature, verifyWebhookSignatureAsync };
|