@agentisend/sdk-node 0.5.0 → 0.5.2

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/dist/types.d.ts CHANGED
@@ -16,7 +16,11 @@ export interface Attachment {
16
16
  content_id?: string;
17
17
  }
18
18
  export interface SendEmailPayload {
19
- from: string;
19
+ /**
20
+ * Required unless `template_id` or `template` names a published template
21
+ * with a default sender. A `from` here overrides the template's.
22
+ */
23
+ from?: string;
20
24
  to: AddressList;
21
25
  /** Required unless `template_id` or `template` names a published template with a subject. */
22
26
  subject?: string;
@@ -44,10 +48,10 @@ export interface SendEmailPayload {
44
48
  topic_id?: string;
45
49
  /** Resend Node SDK name for `topic_id`. */
46
50
  topicId?: string;
47
- /** Published template to render, instead of html or text. */
51
+ /** Id or alias of a published template to render, instead of html or text. */
48
52
  template_id?: string;
49
53
  template_values?: Record<string, unknown>;
50
- /** Resend's send shape: `{id, variables}` instead of sibling `template_id`/`template_values`. */
54
+ /** Resend's send shape: `{id, variables}`; `id` is the template's id or its alias. */
51
55
  template?: {
52
56
  id: string;
53
57
  variables?: Record<string, string | number>;
@@ -55,6 +59,34 @@ export interface SendEmailPayload {
55
59
  /** When a held send stops waiting for a person. At most 7 days ahead. */
56
60
  expires_at?: string;
57
61
  }
62
+ /** A template variable as Resend writes it: a key, a type, and an optional fallback. */
63
+ export interface TemplateVariableInput {
64
+ key: string;
65
+ type: 'string' | 'number' | 'boolean';
66
+ /** With no fallback the variable is required when sending. */
67
+ fallback_value?: string | number | boolean;
68
+ }
69
+ /**
70
+ * POST /templates. Send `html` the way Resend does, or `content` for markdown
71
+ * and blocks. `variables` take Resend's `{key, type, fallback_value}` or the
72
+ * native `{name, type, required, default}`.
73
+ */
74
+ export interface TemplateCreatePayload {
75
+ name: string;
76
+ /** Unique on the account. Use it wherever a template id is taken. */
77
+ alias?: string;
78
+ /** Default sender, such as `Acme <hello@acme.com>`. A send's own `from` overrides it. */
79
+ from?: string;
80
+ subject?: string;
81
+ /** Default Reply-To. A send's own `reply_to` overrides it. */
82
+ reply_to?: string | string[];
83
+ html?: string;
84
+ /** Native body: `{mode: 'markdown' | 'html', source}` or `{mode: 'block', blocks}`. */
85
+ content?: unknown;
86
+ /** Plain-text part. Left out, one is made from the HTML; `''` sends no text part. */
87
+ text?: string;
88
+ variables?: Array<TemplateVariableInput | Record<string, unknown>>;
89
+ }
58
90
  export type MessageStatus = 'queued' | 'scheduled' | 'sent' | 'delivered' | 'delivery_delayed' | 'bounced' | 'complained' | 'opened' | 'clicked' | 'failed' | 'canceled' | 'suppressed';
59
91
  export interface AttachmentView {
60
92
  filename: string;
@@ -64,6 +96,7 @@ export interface AttachmentView {
64
96
  path: string | null;
65
97
  }
66
98
  export interface Email {
99
+ object?: 'email';
67
100
  id: string;
68
101
  from: string;
69
102
  to: string[];
@@ -71,6 +104,8 @@ export interface Email {
71
104
  bcc: string[] | null;
72
105
  reply_to: string[] | null;
73
106
  subject: string;
107
+ /** The Message-ID header the message carries, angle brackets included. */
108
+ message_id?: string | null;
74
109
  html: string | null;
75
110
  text: string | null;
76
111
  headers: Record<string, string> | null;
@@ -109,14 +144,59 @@ export interface ListQuery {
109
144
  /** Resend's previous-page cursor. Mutually exclusive with cursor/after. */
110
145
  before?: string;
111
146
  }
112
- /** GET /metrics and GET /emails/metrics (W4.10). */
147
+ /**
148
+ * GET /metrics and GET /emails/metrics (W4.10).
149
+ *
150
+ * `since` and `until` (and `group_by`, `event`, `domain`, `api_key_id` on the
151
+ * route) select this API's own shape. `start_date`, `end_date` and the rest
152
+ * select Resend's: totals, or rows broken down by `dimensions`.
153
+ */
113
154
  export interface MetricsQuery {
114
155
  since?: string;
115
156
  until?: string;
116
- /** Resend's name for `since`. A YYYY-MM-DD date is 00:00 UTC. */
157
+ /** The start of the range: an ISO 8601 date or datetime. Defaults to 6 days before `end_date`. */
117
158
  start_date?: string;
118
- /** Resend's name for `until`. A YYYY-MM-DD date is 23:59:59.999 UTC. */
159
+ /** The end of the range. A date covers that whole day. A future value is clamped to now. */
119
160
  end_date?: string;
161
+ /** IANA timezone that buckets periods when `period` is a dimension. Default UTC. */
162
+ timezone?: string;
163
+ /** Bucket size when `period` is a dimension. Default daily. At most 10,000 periods. */
164
+ granularity?: 'hourly' | 'daily' | 'weekly' | 'monthly';
165
+ /** Metrics to return (a list, or a comma-separated string). Omit for all. */
166
+ metrics?: string | string[];
167
+ /** Any of period, domain, email, broadcast. `email` cannot be combined with `broadcast`. */
168
+ dimensions?: string | string[];
169
+ /** Up to 100 sending domain ids. */
170
+ domain_id?: string | string[];
171
+ /** Up to 100 email ids. Not with the broadcast dimension or `broadcast_id`. */
172
+ email_id?: string | string[];
173
+ /** Up to 100 broadcast ids. Not with the email dimension or `email_id`. */
174
+ broadcast_id?: string | string[];
175
+ }
176
+ /** GET /broadcasts/{id}/recipients (Resend: list-broadcast-recipients). */
177
+ export interface BroadcastRecipientsQuery {
178
+ type: 'sent' | 'delivered' | 'opened' | 'clicked' | 'bounced' | 'complained' | 'unsubscribed' | 'suppressed';
179
+ /** Keep recipients whose email contains this value. */
180
+ email?: string;
181
+ /** Only with `type: 'bounced'`. */
182
+ bounce_type?: 'permanent' | 'transient' | 'undetermined';
183
+ /** 1 to 100. Default 20. */
184
+ limit?: number;
185
+ after?: string;
186
+ before?: string;
187
+ }
188
+ /** GET /broadcasts/{id}/clicked-links (Resend: list-broadcast-clicked-links). */
189
+ export interface BroadcastClickedLinksQuery {
190
+ /** 1 to 100. Default 20. */
191
+ limit?: number;
192
+ after?: string;
193
+ before?: string;
194
+ }
195
+ /** Resend's list envelope for the broadcast engagement routes. */
196
+ export interface EngagementList<T> {
197
+ object: 'list';
198
+ has_more: boolean;
199
+ data: T[];
120
200
  }
121
201
  /** One component on the public status page, and what it reports about itself. */
122
202
  export interface ServiceComponent {
@@ -131,13 +211,18 @@ export interface ServiceStatus {
131
211
  }
132
212
  /** One API call this account made, as the request log recorded it (M5.9). */
133
213
  export interface RequestLogEntry {
214
+ object?: 'log';
134
215
  id: string;
135
216
  request_id: string;
136
217
  method: string;
137
218
  path: string;
219
+ /** Resend's name for `path`. */
220
+ endpoint?: string;
138
221
  /** The route template — what you group by when one id is not the question. */
139
222
  route: string | null;
140
223
  status: number;
224
+ /** Resend's name for `status`. */
225
+ response_status?: number;
141
226
  duration_ms: number;
142
227
  /** The catalogue code on a refusal; null when nothing refused. */
143
228
  error_code: string | null;
@@ -147,25 +232,43 @@ export interface RequestLogEntry {
147
232
  user_agent: string | null;
148
233
  created_at: string;
149
234
  }
150
- /** One attachment on a message you sent (M5.10). Ids are stable positions. */
235
+ /**
236
+ * One attachment on a message you sent (M5.10). The id is a stable uuid; the
237
+ * position ("0", "1", …) this API returned before is still accepted.
238
+ */
151
239
  export interface SentAttachment {
152
240
  id: string;
153
241
  filename: string;
154
242
  content_type: string | null;
155
243
  size_bytes: number | null;
244
+ /** Resend's name for `size_bytes`. */
245
+ size?: number | null;
156
246
  content_id: string | null;
247
+ content_disposition?: 'inline' | 'attachment';
248
+ /** Downloads the bytes with no API key until `expires_at`. Null once the bytes are gone. */
249
+ download_url?: string | null;
250
+ expires_at?: string | null;
157
251
  /** Set when you sent a URL instead of bytes — nothing was stored here. */
158
252
  path: string | null;
159
253
  /** False for a URL attachment, and once retention has taken the message. */
160
254
  bytes_available: boolean;
161
255
  }
162
- /** One attachment on a received message (M5.8). Ids are stable positions. */
256
+ /**
257
+ * One attachment on a received message (M5.8). The id is a stable uuid; the
258
+ * position ("0", "1", …) this API returned before is still accepted.
259
+ */
163
260
  export interface ReceivedAttachment {
164
261
  id: string;
165
262
  filename: string;
166
263
  content_type: string;
167
264
  size_bytes: number;
265
+ /** Resend's name for `size_bytes`. */
266
+ size?: number;
168
267
  content_id: string | null;
268
+ content_disposition?: 'inline' | 'attachment';
269
+ /** On the attachments endpoints: downloads the bytes with no API key until `expires_at`. */
270
+ download_url?: string;
271
+ expires_at?: string;
169
272
  }
170
273
  /** Received mail grouped by Message-ID / In-Reply-To / References (W4.9a). */
171
274
  export interface ReceivedThread {
@@ -175,21 +278,50 @@ export interface ReceivedThread {
175
278
  message_count: number;
176
279
  last_received_at: string;
177
280
  latest_id: string;
281
+ /** The label on the newest message in the thread. */
282
+ verdict?: 'clear' | 'review' | 'unavailable';
178
283
  }
179
284
  /** A message someone sent to one of your domains. */
180
285
  export interface ReceivedEmail {
286
+ object?: 'email';
181
287
  id: string;
182
288
  from: string;
289
+ /** The address on your domain this copy was delivered to. */
183
290
  to: string;
184
291
  subject: string | null;
185
292
  received_at: string;
293
+ /** Resend's name for `received_at`. */
294
+ created_at?: string;
295
+ /** The message's own Message-ID header, or null. */
296
+ message_id?: string | null;
297
+ cc?: string[];
298
+ /** Always empty: a received message carries no Bcc list. */
299
+ bcc?: string[];
300
+ reply_to?: string[];
186
301
  size_bytes: number;
187
302
  attachment_count: number;
303
+ attachments?: ReceivedAttachment[];
304
+ /** Present on the single read: the envelope recipient this copy was delivered for. */
305
+ received_for?: string[];
188
306
  /** Present on the single read. Data as it arrived — this SDK renders nothing. */
189
307
  headers?: Record<string, string>;
190
308
  text?: string | null;
191
309
  html?: string | null;
192
- attachments?: ReceivedAttachment[];
310
+ /** The reply with quoted history removed. Null when it could not be produced. Present on the single read. */
311
+ extracted_text?: string | null;
312
+ /** The same cut, in HTML. Present on the single read. */
313
+ extracted_html?: string | null;
314
+ /** clear, review, or unavailable. */
315
+ verdict?: 'clear' | 'review' | 'unavailable';
316
+ /** Why the message was labeled. Empty when it is clear. */
317
+ reasons?: string[];
318
+ /** True while a person has not released a message the domain is holding. */
319
+ held?: boolean;
320
+ /** Present on the single read and on the arrival webhook. */
321
+ inbound_verdict?: {
322
+ verdict: 'clear' | 'review' | 'unavailable';
323
+ reasons: string[];
324
+ };
193
325
  }
194
326
  /** The types a declared event field can take (M5.7). */
195
327
  export type EventFieldType = 'string' | 'number' | 'boolean' | 'date' | 'enum';
@@ -207,31 +339,62 @@ export interface EventDefinition {
207
339
  updated_at: string;
208
340
  }
209
341
  /** One step of one automation run, and what it did (M5.6). */
342
+ /** A graph step (Resend's shape): `config` depends on `type`. */
343
+ export interface AutomationGraphStep {
344
+ key: string;
345
+ type: 'trigger' | 'delay' | 'send_email' | 'wait_for_event' | 'condition' | 'contact_update' | 'contact_delete' | 'add_to_segment';
346
+ config: Record<string, unknown>;
347
+ }
348
+ /** A link between two graph steps, by key. `type` defaults to `default`. */
349
+ export interface AutomationConnection {
350
+ from: string;
351
+ to: string;
352
+ type?: 'default' | 'condition_met' | 'condition_not_met' | 'timeout' | 'event_received';
353
+ }
210
354
  export interface AutomationRunStep {
211
355
  index: number;
212
356
  kind: string;
357
+ /** A graph step's key; null on a linear run. */
358
+ key: string | null;
359
+ type: string;
213
360
  /**
214
- * `skipped` is a real outcome: a step that did nothing on purpose.
215
- * `waiting`: sending is paused for every account; the step runs again after
216
- * `output.retry_at`, and the run stays `running` until it does.
361
+ * Linear: succeeded, skipped, failed, or waiting (sending is paused for
362
+ * every account; the step runs again after `output.retry_at`). Graph:
363
+ * completed, skipped, failed, or waiting (a delay or a wait for an event).
217
364
  */
218
- status: 'succeeded' | 'skipped' | 'failed' | 'waiting';
365
+ status: 'succeeded' | 'completed' | 'skipped' | 'failed' | 'waiting' | 'pending' | 'running';
219
366
  output: Record<string, unknown> | null;
220
- error: string | null;
367
+ /** A linear run's sentence, or a graph run's `{ message }`. */
368
+ error: string | {
369
+ message: string;
370
+ } | null;
221
371
  started_at: string;
222
372
  finished_at: string | null;
373
+ completed_at: string | null;
374
+ created_at: string;
223
375
  }
224
376
  /** One execution of one automation. `steps` is present on the single read. */
225
377
  export interface AutomationRun {
378
+ object: 'automation_run';
226
379
  id: string;
227
380
  automation_id: string;
228
381
  version_number: number | null;
229
382
  trigger_type: string;
230
383
  event_name: string | null;
231
384
  contact_id: string | null;
232
- status: 'running' | 'succeeded' | 'failed';
385
+ /** Linear: running, succeeded or failed. Graph: running, completed, failed or cancelled. */
386
+ status: 'running' | 'succeeded' | 'completed' | 'failed' | 'cancelled';
233
387
  started_at: string;
234
388
  finished_at: string | null;
389
+ completed_at: string | null;
390
+ created_at: string;
391
+ /** Graph runs: the step the run is on. */
392
+ current_step: string | null;
393
+ /** Graph runs: the event a wait holds for, and when a delay or timeout ends. */
394
+ waiting_for: {
395
+ event: string | null;
396
+ until: string | null;
397
+ } | null;
235
398
  steps?: AutomationRunStep[];
236
399
  }
237
400
  /** One item's outcome in a suppression batch (M5.5). */
@@ -249,6 +412,7 @@ export interface SuppressionBatchItem {
249
412
  }
250
413
  /** M5.4 — a subscription topic: the kind of mail a contact consented to. */
251
414
  export interface Topic {
415
+ object?: 'topic';
252
416
  id: string;
253
417
  name: string;
254
418
  description: string | null;
@@ -305,10 +469,15 @@ export interface CreatedApiKey {
305
469
  }
306
470
  export type EventType = string;
307
471
  export interface WebhookEndpoint {
472
+ object?: 'webhook';
308
473
  id: string;
309
474
  url: string;
475
+ /** Resend's name for `url`. */
476
+ endpoint?: string;
310
477
  events: EventType[];
311
478
  disabled: boolean;
479
+ /** Resend's name for `disabled`. */
480
+ status?: 'enabled' | 'disabled';
312
481
  /** True when deliveries also carry svix-id / -timestamp / -signature (M5.11). */
313
482
  svix_compat: boolean;
314
483
  created_at: string;
@@ -459,7 +628,35 @@ export interface DomainRecord {
459
628
  /** What to do about this record, the alternative accepted forms included. */
460
629
  fix: string;
461
630
  }
631
+ /** What a domain does. Sending defaults to enabled, receiving to disabled. */
632
+ export interface DomainCapabilities {
633
+ sending?: 'enabled' | 'disabled';
634
+ receiving?: 'enabled' | 'disabled';
635
+ }
636
+ /** `POST /domains/claim`, `GET /domains/:id/claim` and `POST /domains/:id/claim/verify`. */
637
+ export interface DomainClaim {
638
+ object: 'domain_claim';
639
+ id: string;
640
+ name: string;
641
+ status: 'pending' | 'verified' | 'completed' | 'blocked' | 'expired' | 'superseded' | 'canceled' | 'failed';
642
+ /** The placeholder domain the claim created on your account. */
643
+ domain_id: string | null;
644
+ region: DomainRegion | null;
645
+ /** The TXT record to publish at your DNS to prove you control the domain. */
646
+ record: {
647
+ type: 'TXT';
648
+ name: string;
649
+ value: string;
650
+ ttl: string;
651
+ };
652
+ blocked_reason: 'grace_period' | 'recent_owner_activity' | 'pending_scheduled_emails' | null;
653
+ failure_reason: string | null;
654
+ created_at: string;
655
+ expires_at: string;
656
+ }
462
657
  export interface Domain {
658
+ /** `domain` on a retrieved domain; absent on list items. */
659
+ object?: 'domain';
463
660
  id: string;
464
661
  name: string;
465
662
  zone?: string;
@@ -471,6 +668,13 @@ export interface Domain {
471
668
  open_tracking: boolean;
472
669
  tracking_subdomain: string;
473
670
  return_path_subdomain?: string;
671
+ /** Whether the domain sends and whether it receives. */
672
+ capabilities?: {
673
+ sending: 'enabled' | 'disabled';
674
+ receiving: 'enabled' | 'disabled';
675
+ };
676
+ /** monitor labels received mail. hold keeps a review message until a person releases it. */
677
+ inbound_hold_mode?: 'monitor' | 'hold';
474
678
  /**
475
679
  * DNS sheet. Present on create, get, verify, and update. `list()` omits it
476
680
  * (research/01-resend-api-baseline.md:182); call `get(id)` for the records.
@@ -520,6 +724,8 @@ export interface DomainSetup {
520
724
  deep_link: string | null;
521
725
  }
522
726
  export interface Deleted {
727
+ /** The type of what was deleted, e.g. `domain`, `webhook`, `topic`. */
728
+ object?: string;
523
729
  id: string;
524
730
  deleted: boolean;
525
731
  }
package/dist/version.d.ts CHANGED
@@ -5,4 +5,4 @@
5
5
  * JSON import and no bundler has to resolve one. It cannot drift silently:
6
6
  * `sdk_node_is_publishable_standalone` compares it to the manifest.
7
7
  */
8
- export declare const SDK_VERSION = "0.5.0";
8
+ export declare const SDK_VERSION = "0.5.2";
package/dist/version.js CHANGED
@@ -5,5 +5,5 @@
5
5
  * JSON import and no bundler has to resolve one. It cannot drift silently:
6
6
  * `sdk_node_is_publishable_standalone` compares it to the manifest.
7
7
  */
8
- export const SDK_VERSION = '0.5.0';
8
+ export const SDK_VERSION = '0.5.2';
9
9
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentisend/sdk-node",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "AgentiSend is a transactional email API for AI agents. This is its typed Node client.",
5
5
  "author": "AgentiSend <hello@agentisend.com>",
6
6
  "type": "module",
@@ -57,7 +57,6 @@
57
57
  "README.md"
58
58
  ],
59
59
  "devDependencies": {
60
- "resend": "6.30.0",
61
60
  "typescript": "^5.6.0",
62
61
  "vitest": "^3.0.0"
63
62
  },