@sendmailos/sdk 1.2.2 → 1.3.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/README.md CHANGED
@@ -33,6 +33,7 @@ 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
+ - **Attachments**: Send files via Base64 or URL (auto-fetched)
36
37
  - **Email Automation**: Build workflows with triggers, delays, conditions, and actions
37
38
  - **Industry Templates**: 50+ pre-built templates for different industries
38
39
  - **Agency Workspaces**: Manage multiple clients from one account
@@ -73,6 +74,66 @@ await client.emails.sendTemplate({
73
74
  });
74
75
  ```
75
76
 
77
+ ### Attachments
78
+
79
+ Send emails with file attachments (max 5 files, 7MB total).
80
+
81
+ ```typescript
82
+ // With Base64 content
83
+ await client.emails.send({
84
+ to: 'user@example.com',
85
+ subject: 'Invoice Attached',
86
+ html: '<p>Please find your invoice attached.</p>',
87
+ fromEmail: 'billing@company.com',
88
+ fromName: 'Billing',
89
+ attachments: [
90
+ {
91
+ filename: 'invoice.pdf',
92
+ content: 'JVBERi0xLjQK...', // Base64 encoded
93
+ contentType: 'application/pdf'
94
+ }
95
+ ]
96
+ });
97
+
98
+ // With URL (fetched automatically)
99
+ await client.emails.send({
100
+ to: 'user@example.com',
101
+ subject: 'Your Report',
102
+ html: '<p>Here is your report.</p>',
103
+ fromEmail: 'reports@company.com',
104
+ attachments: [
105
+ {
106
+ filename: 'report.pdf',
107
+ url: 'https://cdn.example.com/reports/123.pdf',
108
+ contentType: 'application/pdf'
109
+ }
110
+ ]
111
+ });
112
+
113
+ // Inline images (using cid)
114
+ await client.emails.send({
115
+ to: 'user@example.com',
116
+ subject: 'Check out our logo',
117
+ html: '<p>Our logo: <img src="cid:logo-image"></p>',
118
+ fromEmail: 'hello@company.com',
119
+ attachments: [
120
+ {
121
+ filename: 'logo.png',
122
+ url: 'https://cdn.example.com/logo.png',
123
+ contentType: 'image/png',
124
+ cid: 'logo-image' // Reference in HTML with cid:logo-image
125
+ }
126
+ ]
127
+ });
128
+ ```
129
+
130
+ **Attachment Limits:**
131
+ | Limit | Value |
132
+ |-------|-------|
133
+ | Max attachments | 5 |
134
+ | Single file max | 5 MB |
135
+ | Total size | 7 MB |
136
+
76
137
  ### Subscribers
77
138
 
78
139
  ```typescript
package/dist/index.d.mts CHANGED
@@ -2,13 +2,29 @@
2
2
  * SendMailOS SDK Types
3
3
  */
4
4
  interface SendMailOSOptions {
5
- /** Base URL for the API (default: https://api.sendmailos.com) */
5
+ /** Base URL for the API (default: https://sendmailos.com) */
6
6
  baseUrl?: string;
7
7
  /** Request timeout in milliseconds (default: 30000) */
8
8
  timeout?: number;
9
9
  /** Custom fetch implementation (for testing/Node.js polyfill) */
10
10
  fetch?: typeof fetch;
11
11
  }
12
+ /**
13
+ * Email attachment configuration
14
+ * Provide either `content` (Base64) or `url` (fetched automatically)
15
+ */
16
+ interface EmailAttachment {
17
+ /** Filename shown to recipient */
18
+ filename: string;
19
+ /** Base64-encoded file content (required if no url) */
20
+ content?: string;
21
+ /** URL to fetch attachment from (required if no content) */
22
+ url?: string;
23
+ /** MIME type (e.g., 'application/pdf', 'image/png') */
24
+ contentType: string;
25
+ /** Content-ID for inline images - reference in HTML with cid:your-id */
26
+ cid?: string;
27
+ }
12
28
  interface SendEmailRequest {
13
29
  /** Recipient email address */
14
30
  to: string;
@@ -37,6 +53,11 @@ interface SendEmailRequest {
37
53
  * @note Agency accounts MUST specify either workspaceId or domain
38
54
  */
39
55
  domain?: string;
56
+ /**
57
+ * File attachments (max 5 files, 7MB total)
58
+ * Provide either Base64 content or URL for each attachment
59
+ */
60
+ attachments?: EmailAttachment[];
40
61
  }
41
62
  interface SendEmailResponse {
42
63
  success: boolean;
@@ -1418,4 +1439,4 @@ declare function constructWebhookEvent<T = unknown>(payload: string, headers: {
1418
1439
  timestamp: string;
1419
1440
  }, secret: string): T;
1420
1441
 
1421
- export { type ApiError, AuthenticationError, type CreateDomainRequest, type CreateDomainResponse, type CreateSubscriberRequest, type CreateSubscriberResponse, type CreateWebhookRequest, type CreateWorkflowRequest, type CreateWorkflowResponse, type CreateWorkspaceRequest, type DnsRecord, type Domain, type GetWorkflowResponse, INDUSTRIES, type IdentifyTraits, type Industry, type ListDomainsResponse, type ListSubscribersRequest, type ListSubscribersResponse, type ListWorkflowsRequest, type ListWorkflowsResponse, NotFoundError, type OnboardClientRequest, type OnboardClientResponse, type Organization, type OrganizationType, Pixel, type PixelConfig, type PixelOptions, type ProvisionWorkspaceRequest, type ProvisionWorkspaceResponse, RateLimitError, type SendCampaignRequest, type SendCampaignResponse, type SendEmailRequest, type SendEmailResponse, SendMailOS, SendMailOSError, type SendMailOSOptions, SendmailPixel, type Subscriber, type TrackEventProperties, type TrackProps, type TriggerWorkflowRequest, type TriggerWorkflowResponse, type UpdateOrganizationRequest, type UpdateWorkflowRequest, type UpdateWorkflowResponse, type UpdateWorkspaceRequest, ValidationError, type VerifyWebhookParams, type Webhook, type WebhookEvent, type WebhookEventType, type Workflow, type WorkflowEdge, type WorkflowNode, type WorkflowStats, type WorkflowStatus, type WorkflowStatusResponse, type WorkflowTrigger, type WorkflowTriggerType, type Workspace, type WorkspaceStats, constructWebhookEvent, createGlobalPixel, SendMailOS as default, verifyWebhookSignature, verifyWebhookSignatureAsync };
1442
+ export { type ApiError, AuthenticationError, type CreateDomainRequest, type CreateDomainResponse, type CreateSubscriberRequest, type CreateSubscriberResponse, type CreateWebhookRequest, type CreateWorkflowRequest, type CreateWorkflowResponse, type CreateWorkspaceRequest, type DnsRecord, type Domain, type EmailAttachment, type GetWorkflowResponse, INDUSTRIES, type IdentifyTraits, type Industry, type ListDomainsResponse, type ListSubscribersRequest, type ListSubscribersResponse, type ListWorkflowsRequest, type ListWorkflowsResponse, NotFoundError, type OnboardClientRequest, type OnboardClientResponse, type Organization, type OrganizationType, Pixel, type PixelConfig, type PixelOptions, type ProvisionWorkspaceRequest, type ProvisionWorkspaceResponse, RateLimitError, type SendCampaignRequest, type SendCampaignResponse, type SendEmailRequest, type SendEmailResponse, SendMailOS, SendMailOSError, type SendMailOSOptions, SendmailPixel, type Subscriber, type TrackEventProperties, type TrackProps, type TriggerWorkflowRequest, type TriggerWorkflowResponse, type UpdateOrganizationRequest, type UpdateWorkflowRequest, type UpdateWorkflowResponse, type UpdateWorkspaceRequest, ValidationError, type VerifyWebhookParams, type Webhook, type WebhookEvent, type WebhookEventType, type Workflow, type WorkflowEdge, type WorkflowNode, type WorkflowStats, type WorkflowStatus, type WorkflowStatusResponse, type WorkflowTrigger, type WorkflowTriggerType, type Workspace, type WorkspaceStats, constructWebhookEvent, createGlobalPixel, SendMailOS as default, verifyWebhookSignature, verifyWebhookSignatureAsync };
package/dist/index.d.ts CHANGED
@@ -2,13 +2,29 @@
2
2
  * SendMailOS SDK Types
3
3
  */
4
4
  interface SendMailOSOptions {
5
- /** Base URL for the API (default: https://api.sendmailos.com) */
5
+ /** Base URL for the API (default: https://sendmailos.com) */
6
6
  baseUrl?: string;
7
7
  /** Request timeout in milliseconds (default: 30000) */
8
8
  timeout?: number;
9
9
  /** Custom fetch implementation (for testing/Node.js polyfill) */
10
10
  fetch?: typeof fetch;
11
11
  }
12
+ /**
13
+ * Email attachment configuration
14
+ * Provide either `content` (Base64) or `url` (fetched automatically)
15
+ */
16
+ interface EmailAttachment {
17
+ /** Filename shown to recipient */
18
+ filename: string;
19
+ /** Base64-encoded file content (required if no url) */
20
+ content?: string;
21
+ /** URL to fetch attachment from (required if no content) */
22
+ url?: string;
23
+ /** MIME type (e.g., 'application/pdf', 'image/png') */
24
+ contentType: string;
25
+ /** Content-ID for inline images - reference in HTML with cid:your-id */
26
+ cid?: string;
27
+ }
12
28
  interface SendEmailRequest {
13
29
  /** Recipient email address */
14
30
  to: string;
@@ -37,6 +53,11 @@ interface SendEmailRequest {
37
53
  * @note Agency accounts MUST specify either workspaceId or domain
38
54
  */
39
55
  domain?: string;
56
+ /**
57
+ * File attachments (max 5 files, 7MB total)
58
+ * Provide either Base64 content or URL for each attachment
59
+ */
60
+ attachments?: EmailAttachment[];
40
61
  }
41
62
  interface SendEmailResponse {
42
63
  success: boolean;
@@ -1418,4 +1439,4 @@ declare function constructWebhookEvent<T = unknown>(payload: string, headers: {
1418
1439
  timestamp: string;
1419
1440
  }, secret: string): T;
1420
1441
 
1421
- export { type ApiError, AuthenticationError, type CreateDomainRequest, type CreateDomainResponse, type CreateSubscriberRequest, type CreateSubscriberResponse, type CreateWebhookRequest, type CreateWorkflowRequest, type CreateWorkflowResponse, type CreateWorkspaceRequest, type DnsRecord, type Domain, type GetWorkflowResponse, INDUSTRIES, type IdentifyTraits, type Industry, type ListDomainsResponse, type ListSubscribersRequest, type ListSubscribersResponse, type ListWorkflowsRequest, type ListWorkflowsResponse, NotFoundError, type OnboardClientRequest, type OnboardClientResponse, type Organization, type OrganizationType, Pixel, type PixelConfig, type PixelOptions, type ProvisionWorkspaceRequest, type ProvisionWorkspaceResponse, RateLimitError, type SendCampaignRequest, type SendCampaignResponse, type SendEmailRequest, type SendEmailResponse, SendMailOS, SendMailOSError, type SendMailOSOptions, SendmailPixel, type Subscriber, type TrackEventProperties, type TrackProps, type TriggerWorkflowRequest, type TriggerWorkflowResponse, type UpdateOrganizationRequest, type UpdateWorkflowRequest, type UpdateWorkflowResponse, type UpdateWorkspaceRequest, ValidationError, type VerifyWebhookParams, type Webhook, type WebhookEvent, type WebhookEventType, type Workflow, type WorkflowEdge, type WorkflowNode, type WorkflowStats, type WorkflowStatus, type WorkflowStatusResponse, type WorkflowTrigger, type WorkflowTriggerType, type Workspace, type WorkspaceStats, constructWebhookEvent, createGlobalPixel, SendMailOS as default, verifyWebhookSignature, verifyWebhookSignatureAsync };
1442
+ export { type ApiError, AuthenticationError, type CreateDomainRequest, type CreateDomainResponse, type CreateSubscriberRequest, type CreateSubscriberResponse, type CreateWebhookRequest, type CreateWorkflowRequest, type CreateWorkflowResponse, type CreateWorkspaceRequest, type DnsRecord, type Domain, type EmailAttachment, type GetWorkflowResponse, INDUSTRIES, type IdentifyTraits, type Industry, type ListDomainsResponse, type ListSubscribersRequest, type ListSubscribersResponse, type ListWorkflowsRequest, type ListWorkflowsResponse, NotFoundError, type OnboardClientRequest, type OnboardClientResponse, type Organization, type OrganizationType, Pixel, type PixelConfig, type PixelOptions, type ProvisionWorkspaceRequest, type ProvisionWorkspaceResponse, RateLimitError, type SendCampaignRequest, type SendCampaignResponse, type SendEmailRequest, type SendEmailResponse, SendMailOS, SendMailOSError, type SendMailOSOptions, SendmailPixel, type Subscriber, type TrackEventProperties, type TrackProps, type TriggerWorkflowRequest, type TriggerWorkflowResponse, type UpdateOrganizationRequest, type UpdateWorkflowRequest, type UpdateWorkflowResponse, type UpdateWorkspaceRequest, ValidationError, type VerifyWebhookParams, type Webhook, type WebhookEvent, type WebhookEventType, type Workflow, type WorkflowEdge, type WorkflowNode, type WorkflowStats, type WorkflowStatus, type WorkflowStatusResponse, type WorkflowTrigger, type WorkflowTriggerType, type Workspace, type WorkspaceStats, constructWebhookEvent, createGlobalPixel, SendMailOS as default, verifyWebhookSignature, verifyWebhookSignatureAsync };
package/dist/index.js CHANGED
@@ -94,7 +94,8 @@ var EmailsResource = class {
94
94
  variables: params.variables,
95
95
  type: params.type || "transactional",
96
96
  workspace_id: params.workspaceId,
97
- domain: params.domain
97
+ domain: params.domain,
98
+ attachments: params.attachments
98
99
  })
99
100
  });
100
101
  }
@@ -1000,9 +1001,9 @@ var WebhooksResource = class {
1000
1001
  };
1001
1002
 
1002
1003
  // src/client.ts
1003
- var DEFAULT_BASE_URL = "https://api.sendmailos.com/api/v1";
1004
+ var DEFAULT_BASE_URL = "https://sendmailos.com/api/v1";
1004
1005
  var DEFAULT_TIMEOUT = 3e4;
1005
- var SDK_VERSION = "1.2.0";
1006
+ var SDK_VERSION = "1.3.1";
1006
1007
  var SendMailOS = class {
1007
1008
  constructor(apiKey, options = {}) {
1008
1009
  if (!apiKey) {