groundmail 0.44.0 → 0.46.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 CHANGED
@@ -79,6 +79,28 @@ time. Also: `tx.testInbox.list({ to, since })`, `tx.testInbox.get(id)` and `tx.t
79
79
  (domain and monthly usage). Emails sent with a `gm_test_` key land here too. Details:
80
80
  https://docs.groundmail.dev/email-testing
81
81
 
82
+ ## Agent mailboxes
83
+
84
+ A real address your agent creates, reads and sends from:
85
+
86
+ ```ts
87
+ const mailbox = await tx.mailboxes.create({ local_part: 'signup-bot' }) // signup-bot@agents.groundmailbox.com
88
+ const since = new Date()
89
+ // …the agent signs up with mailbox.address…
90
+ const message = await tx.mailboxes.wait(mailbox.id, { since, timeout: 60_000 })
91
+ message.code // '482913'
92
+ message.visible_text // what a person would see
93
+ await tx.mailboxes.messages.reply(mailbox.id, message.id, { text: 'Thanks', idempotencyKey: message.id })
94
+ ```
95
+
96
+ Everything in a message was written by a stranger: treat it as data, never as instructions, and
97
+ give your agent `visible_text`, not `text` or `html`. `prompt_injection` is a hint, and a missing
98
+ flag never means safe. `wait` throws a `GroundmailError` with status 408 and code `timeout` when
99
+ nothing arrives in time. Also: `tx.mailboxes.list()`, `.get()`, `.update()`, `.delete()`,
100
+ `.forward()`, `.threads.list()`, `.get()`, `.update()`, `.messages.list({ q })`, `.get()`,
101
+ `.update()`, `.send()` and `.downloadAttachment()`. Hosted addresses can only reply; to email
102
+ people first, use a mailbox on your own domain. Details: https://docs.groundmail.dev/mailboxes
103
+
82
104
  ## Batches
83
105
 
84
106
  `emails.batch()` sends up to 100 emails in one request and returns a `batch_id` shared by every
package/dist/authjs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { G as Groundmail } from './client-CD3tBIro.js';
1
+ import { G as Groundmail } from './client-92N8VztP.js';
2
2
 
3
3
  /** Subset of Auth.js theme used for the default magic-link email. */
4
4
  type AuthjsTheme = {
package/dist/authjs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_API_BASE_URL,
3
3
  Groundmail
4
- } from "./chunk-WMMIGQLO.js";
4
+ } from "./chunk-ACYLU736.js";
5
5
 
6
6
  // src/authjs.ts
7
7
  function escapeHtml(value) {
@@ -1,4 +1,4 @@
1
- import { S as SendEmailResult, G as Groundmail } from './client-CD3tBIro.js';
1
+ import { S as SendEmailResult, G as Groundmail } from './client-92N8VztP.js';
2
2
 
3
3
  type BetterAuthEmailUser = {
4
4
  email: string;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_API_BASE_URL,
3
3
  Groundmail
4
- } from "./chunk-WMMIGQLO.js";
4
+ } from "./chunk-ACYLU736.js";
5
5
 
6
6
  // src/better-auth.ts
7
7
  function linkHtml(label, url) {
@@ -170,8 +170,8 @@ function createCloudflareProvider(options) {
170
170
  Authorization: `Bearer ${options.apiToken}`,
171
171
  "Content-Type": "application/json"
172
172
  };
173
- async function cf(path, init) {
174
- const response = await fetchImpl(`https://api.cloudflare.com/client/v4${path}`, {
173
+ async function cf(path2, init) {
174
+ const response = await fetchImpl(`https://api.cloudflare.com/client/v4${path2}`, {
175
175
  ...init,
176
176
  headers: { ...headers, ...init?.headers || {} }
177
177
  });
@@ -504,8 +504,8 @@ async function resolveZone(domain, hostLabel, lookup) {
504
504
  // src/dns/godaddy-token.ts
505
505
  function createGoDaddyTokenProvider(options) {
506
506
  const fetchImpl = options.fetchImpl || fetch;
507
- async function godaddy(path, init) {
508
- const response = await fetchImpl(`https://api.godaddy.com/v3/domains${path}`, {
507
+ async function godaddy(path2, init) {
508
+ const response = await fetchImpl(`https://api.godaddy.com/v3/domains${path2}`, {
509
509
  ...init,
510
510
  headers: {
511
511
  Authorization: `Bearer ${options.apiToken}`,
@@ -532,7 +532,7 @@ function createGoDaddyTokenProvider(options) {
532
532
  const { status } = await godaddy(`/zones/${encodeURIComponent(candidate)}/dns-records?pageSize=1`);
533
533
  return status === 404 ? null : true;
534
534
  });
535
- const path = `/zones/${encodeURIComponent(zone)}/dns-records`;
535
+ const path2 = `/zones/${encodeURIComponent(zone)}/dns-records`;
536
536
  const body = (record) => ({
537
537
  name: record.name || "@",
538
538
  type: record.type,
@@ -541,14 +541,14 @@ function createGoDaddyTokenProvider(options) {
541
541
  ...record.priority != null ? { priority: record.priority } : {}
542
542
  });
543
543
  const write = async (method, suffix, record) => {
544
- const { status } = await godaddy(`${path}${suffix}`, { method, body: JSON.stringify(body(record)) });
544
+ const { status } = await godaddy(`${path2}${suffix}`, { method, body: JSON.stringify(body(record)) });
545
545
  if (status === 404) throw new Error(`GoDaddy lost the ${zone} zone mid-update`);
546
546
  };
547
547
  return applyToRecordStore(zone, records, {
548
548
  async list() {
549
549
  const rows = [];
550
550
  for (let page = 1; page <= 20; page++) {
551
- const { body: list } = await godaddy(`${path}?page=${page}&pageSize=100`);
551
+ const { body: list } = await godaddy(`${path2}?page=${page}&pageSize=100`);
552
552
  const items = list.items || [];
553
553
  rows.push(...items);
554
554
  if (items.length < 100 || !list.links?.some((link) => link.rel === "next")) break;
@@ -592,8 +592,8 @@ function createGoDaddyKeyProvider(options) {
592
592
  "Content-Type": "application/json",
593
593
  Accept: "application/json"
594
594
  };
595
- async function gd(path, init) {
596
- const response = await fetchImpl(`https://api.godaddy.com${path}`, {
595
+ async function gd(path2, init) {
596
+ const response = await fetchImpl(`https://api.godaddy.com${path2}`, {
597
597
  ...init,
598
598
  headers: { ...headers, ...init?.headers || {} }
599
599
  });
@@ -752,8 +752,8 @@ function createGoDaddyProvider(options) {
752
752
  // src/dns/digitalocean.ts
753
753
  function createDigitalOceanProvider(options) {
754
754
  const fetchImpl = options.fetchImpl || fetch;
755
- async function digitalocean(path, init) {
756
- const response = await fetchImpl(`https://api.digitalocean.com/v2${path}`, {
755
+ async function digitalocean(path2, init) {
756
+ const response = await fetchImpl(`https://api.digitalocean.com/v2${path2}`, {
757
757
  ...init,
758
758
  headers: { Authorization: `Bearer ${options.apiToken}`, "Content-Type": "application/json", ...init?.headers || {} }
759
759
  });
@@ -773,7 +773,7 @@ function createDigitalOceanProvider(options) {
773
773
  const { status } = await digitalocean(`/domains/${encodeURIComponent(candidate)}`);
774
774
  return status === 404 ? null : true;
775
775
  });
776
- const path = `/domains/${encodeURIComponent(zone)}/records`;
776
+ const path2 = `/domains/${encodeURIComponent(zone)}/records`;
777
777
  const body = (record) => ({
778
778
  type: record.type,
779
779
  name: record.name || "@",
@@ -782,14 +782,14 @@ function createDigitalOceanProvider(options) {
782
782
  ...record.priority != null ? { priority: record.priority } : {}
783
783
  });
784
784
  const write = async (method, suffix, record) => {
785
- const { status } = await digitalocean(`${path}${suffix}`, { method, body: JSON.stringify(body(record)) });
785
+ const { status } = await digitalocean(`${path2}${suffix}`, { method, body: JSON.stringify(body(record)) });
786
786
  if (status === 404) throw new Error(`DigitalOcean lost the ${zone} zone mid-update`);
787
787
  };
788
788
  return applyToRecordStore(zone, records, {
789
789
  async list() {
790
790
  const rows = [];
791
791
  for (let page = 1; page <= 20; page++) {
792
- const { body: list } = await digitalocean(`${path}?per_page=200&page=${page}`);
792
+ const { body: list } = await digitalocean(`${path2}?per_page=200&page=${page}`);
793
793
  rows.push(...list.domain_records || []);
794
794
  if (!list.links?.pages?.next) break;
795
795
  }
@@ -812,8 +812,8 @@ function createDigitalOceanProvider(options) {
812
812
  function createDnsimpleProvider(options) {
813
813
  const fetchImpl = options.fetchImpl || fetch;
814
814
  const base = `https://api.dnsimple.com/v2/${encodeURIComponent(options.accountId)}`;
815
- async function dnsimple(path, init) {
816
- const response = await fetchImpl(`${base}${path}`, {
815
+ async function dnsimple(path2, init) {
816
+ const response = await fetchImpl(`${base}${path2}`, {
817
817
  ...init,
818
818
  headers: {
819
819
  Authorization: `Bearer ${options.apiToken}`,
@@ -833,7 +833,7 @@ function createDnsimpleProvider(options) {
833
833
  const { status } = await dnsimple(`/zones/${encodeURIComponent(candidate)}`);
834
834
  return status === 404 ? null : true;
835
835
  });
836
- const path = `/zones/${encodeURIComponent(zone)}/records`;
836
+ const path2 = `/zones/${encodeURIComponent(zone)}/records`;
837
837
  const body = (record) => ({
838
838
  name: record.name,
839
839
  type: record.type,
@@ -842,14 +842,14 @@ function createDnsimpleProvider(options) {
842
842
  ...record.priority != null ? { priority: record.priority } : {}
843
843
  });
844
844
  const write = async (method, suffix, record) => {
845
- const { status } = await dnsimple(`${path}${suffix}`, { method, body: JSON.stringify(body(record)) });
845
+ const { status } = await dnsimple(`${path2}${suffix}`, { method, body: JSON.stringify(body(record)) });
846
846
  if (status === 404) throw new Error(`DNSimple lost the ${zone} zone mid-update`);
847
847
  };
848
848
  return applyToRecordStore(zone, records, {
849
849
  async list() {
850
850
  const rows = [];
851
851
  for (let page = 1; page <= 20; page++) {
852
- const { body: list } = await dnsimple(`${path}?per_page=100&page=${page}`);
852
+ const { body: list } = await dnsimple(`${path2}?per_page=100&page=${page}`);
853
853
  rows.push(...list.data || []);
854
854
  if ((list.pagination?.total_pages ?? 1) <= page) break;
855
855
  }
@@ -871,8 +871,8 @@ function createDnsimpleProvider(options) {
871
871
  // src/dns/netlify.ts
872
872
  function createNetlifyProvider(options) {
873
873
  const fetchImpl = options.fetchImpl || fetch;
874
- async function netlify(path, init) {
875
- const response = await fetchImpl(`https://api.netlify.com/api/v1${path}`, {
874
+ async function netlify(path2, init) {
875
+ const response = await fetchImpl(`https://api.netlify.com/api/v1${path2}`, {
876
876
  ...init,
877
877
  headers: { Authorization: `Bearer ${options.apiToken}`, "Content-Type": "application/json", ...init?.headers || {} }
878
878
  });
@@ -954,8 +954,8 @@ function createVercelProvider(options) {
954
954
  "Content-Type": "application/json"
955
955
  };
956
956
  const teamQs = teamQuery(options.teamId);
957
- async function vercel(path, init) {
958
- const url = path.includes("?") ? `https://api.vercel.com${path}${options.teamId?.trim() ? `&teamId=${encodeURIComponent(options.teamId.trim())}` : ""}` : `https://api.vercel.com${path}${teamQs}`;
957
+ async function vercel(path2, init) {
958
+ const url = path2.includes("?") ? `https://api.vercel.com${path2}${options.teamId?.trim() ? `&teamId=${encodeURIComponent(options.teamId.trim())}` : ""}` : `https://api.vercel.com${path2}${teamQs}`;
959
959
  const response = await fetchImpl(url, {
960
960
  ...init,
961
961
  headers: { ...headers, ...init?.headers || {} }
@@ -1222,6 +1222,268 @@ async function applyDnsRecords(input) {
1222
1222
  };
1223
1223
  }
1224
1224
 
1225
+ // src/mailboxes.ts
1226
+ var MAILBOX_WAIT_MAX_SECONDS = 60;
1227
+ var MAILBOX_WAIT_DEFAULT_MS = 3e4;
1228
+ function isoTime(value) {
1229
+ if (value === void 0 || value === null || value === "") return null;
1230
+ return value instanceof Date ? value.toISOString() : String(value);
1231
+ }
1232
+ function path(mailbox, ...rest) {
1233
+ return ["/mailboxes", mailbox, ...rest].map((part, index) => index ? encodeURIComponent(part) : part).join("/");
1234
+ }
1235
+ function withQuery(base, search) {
1236
+ const query = search.toString();
1237
+ return query ? `${base}?${query}` : base;
1238
+ }
1239
+ function setFlag(search, key, value) {
1240
+ if (value !== void 0) search.set(key, String(value));
1241
+ }
1242
+ function filenameOf(disposition) {
1243
+ if (!disposition) return null;
1244
+ const encoded = /filename\*=UTF-8''([^;]+)/i.exec(disposition)?.[1];
1245
+ if (encoded) {
1246
+ try {
1247
+ return decodeURIComponent(encoded);
1248
+ } catch {
1249
+ }
1250
+ }
1251
+ return /filename="([^"]*)"/i.exec(disposition)?.[1] ?? null;
1252
+ }
1253
+ function idempotencyHeaders(key) {
1254
+ return key ? { "Idempotency-Key": key } : {};
1255
+ }
1256
+ function attachmentsBody(attachments) {
1257
+ if (attachments === void 0) return {};
1258
+ return {
1259
+ attachments: attachments.map((attachment) => ({
1260
+ name: attachment.name ?? attachment.filename,
1261
+ content_type: attachment.content_type ?? attachment.contentType,
1262
+ data: attachment.data ?? attachment.content,
1263
+ ...attachment.content_id ?? attachment.contentId ? { content_id: attachment.content_id ?? attachment.contentId } : {}
1264
+ }))
1265
+ };
1266
+ }
1267
+ var MailboxThreadsResource = class {
1268
+ constructor(client) {
1269
+ this.client = client;
1270
+ }
1271
+ /** Threads, newest activity first. Held and archived threads only when asked for. */
1272
+ async list(mailbox, params = {}) {
1273
+ const search = new URLSearchParams();
1274
+ if (params.label) search.set("label", params.label);
1275
+ if (params.participant) search.set("participant", params.participant);
1276
+ setFlag(search, "unread", params.unread);
1277
+ setFlag(search, "archived", params.archived);
1278
+ const since = isoTime(params.since);
1279
+ if (since) search.set("since", since);
1280
+ setFlag(search, "include_held", params.include_held);
1281
+ if (params.limit != null) search.set("limit", String(params.limit));
1282
+ if (params.cursor) search.set("cursor", params.cursor);
1283
+ return this.client.request(withQuery(path(mailbox, "threads"), search), { method: "GET" });
1284
+ }
1285
+ /** One thread with its messages, oldest first. */
1286
+ async get(mailbox, threadId, params = {}) {
1287
+ const search = new URLSearchParams();
1288
+ setFlag(search, "include_held", params.include_held);
1289
+ const { thread } = await this.client.request(
1290
+ withQuery(path(mailbox, "threads", threadId), search),
1291
+ { method: "GET" }
1292
+ );
1293
+ return thread;
1294
+ }
1295
+ /** Replace its labels, or mark it read or archived. */
1296
+ async update(mailbox, threadId, params) {
1297
+ const { thread } = await this.client.request(path(mailbox, "threads", threadId), {
1298
+ method: "PATCH",
1299
+ body: JSON.stringify(params)
1300
+ });
1301
+ return thread;
1302
+ }
1303
+ };
1304
+ var MailboxMessagesResource = class {
1305
+ constructor(client) {
1306
+ this.client = client;
1307
+ }
1308
+ /** Messages without their bodies, newest first. `q` searches the subject, sender and visible text. */
1309
+ async list(mailbox, params = {}) {
1310
+ const search = new URLSearchParams();
1311
+ if (params.q) search.set("q", params.q);
1312
+ if (params.from) search.set("from", params.from);
1313
+ if (params.thread) search.set("thread", params.thread);
1314
+ if (params.label) search.set("label", params.label);
1315
+ setFlag(search, "unread", params.unread);
1316
+ const since = isoTime(params.since);
1317
+ if (since) search.set("since", since);
1318
+ setFlag(search, "include_held", params.include_held);
1319
+ if (params.limit != null) search.set("limit", String(params.limit));
1320
+ if (params.cursor) search.set("cursor", params.cursor);
1321
+ return this.client.request(withQuery(path(mailbox, "messages"), search), { method: "GET" });
1322
+ }
1323
+ /** One message with its bodies, code, links, attachments and sender checks. */
1324
+ async get(mailbox, messageId) {
1325
+ const { message } = await this.client.request(path(mailbox, "messages", messageId), {
1326
+ method: "GET"
1327
+ });
1328
+ return message;
1329
+ }
1330
+ /** Replace its labels, or mark it read or unread. */
1331
+ async update(mailbox, messageId, params) {
1332
+ const { message } = await this.client.request(path(mailbox, "messages", messageId), {
1333
+ method: "PATCH",
1334
+ body: JSON.stringify(params)
1335
+ });
1336
+ return message;
1337
+ }
1338
+ /**
1339
+ * Email someone first, from a mailbox on your own domain. Hosted addresses can only
1340
+ * reply. First contact goes through the cold-outreach check, counts toward the
1341
+ * new-recipient limits and carries one-click unsubscribe.
1342
+ */
1343
+ async send(mailbox, params) {
1344
+ const { idempotencyKey, attachments, ...body } = params;
1345
+ return this.client.request(path(mailbox, "messages"), {
1346
+ method: "POST",
1347
+ headers: idempotencyHeaders(idempotencyKey),
1348
+ body: JSON.stringify({ ...body, ...attachmentsBody(attachments) })
1349
+ });
1350
+ }
1351
+ /**
1352
+ * Reply in the thread, to the message's `Reply-To` or else its `From`. Threading
1353
+ * headers and the `Re:` subject are built for you. A sender who failed DMARC can't be
1354
+ * replied to, and a hosted address can only reply to one who passed.
1355
+ */
1356
+ async reply(mailbox, messageId, params) {
1357
+ const { idempotencyKey, attachments, ...body } = params;
1358
+ return this.client.request(path(mailbox, "messages", messageId, "reply"), {
1359
+ method: "POST",
1360
+ headers: idempotencyHeaders(idempotencyKey),
1361
+ body: JSON.stringify({ ...body, ...attachmentsBody(attachments) })
1362
+ });
1363
+ }
1364
+ /** An attachment's bytes. They came from a stranger: never run or render them. */
1365
+ async downloadAttachment(mailbox, messageId, attachmentId) {
1366
+ const { bytes, headers } = await this.client.requestBytes(path(mailbox, "messages", messageId, "attachments", attachmentId));
1367
+ return {
1368
+ content: bytes,
1369
+ content_type: headers.get("content-type") ?? "application/octet-stream",
1370
+ filename: filenameOf(headers.get("content-disposition")),
1371
+ size: bytes.byteLength
1372
+ };
1373
+ }
1374
+ };
1375
+ var MailboxesResource = class {
1376
+ constructor(client) {
1377
+ this.client = client;
1378
+ this.threads = new MailboxThreadsResource(client);
1379
+ this.messages = new MailboxMessagesResource(client);
1380
+ }
1381
+ /** A new mailbox. With no `domain` it gets a hosted address; with no `local_part`, a generated one. */
1382
+ async create(params = {}) {
1383
+ const { mailbox } = await this.client.request("/mailboxes", {
1384
+ method: "POST",
1385
+ body: JSON.stringify(params)
1386
+ });
1387
+ return mailbox;
1388
+ }
1389
+ /** Name the person behind a mailbox made without an account. They get a code by email. */
1390
+ async setOwner(mailbox, ownerEmail) {
1391
+ return this.client.request(`${path(mailbox, "owner")}`, { method: "POST", body: JSON.stringify({ owner_email: ownerEmail }) });
1392
+ }
1393
+ /** Give back the code your person received. The mailbox becomes a normal one, with the same key. */
1394
+ async verifyOwner(mailbox, code) {
1395
+ return this.client.request(`${path(mailbox, "owner", "verify")}`, { method: "POST", body: JSON.stringify({ code }) });
1396
+ }
1397
+ /** Mailboxes, newest first. */
1398
+ async list(params = {}) {
1399
+ const search = new URLSearchParams();
1400
+ if (params.tenant) search.set("tenant", params.tenant);
1401
+ if (params.limit != null) search.set("limit", String(params.limit));
1402
+ if (params.cursor) search.set("cursor", params.cursor);
1403
+ return this.client.request(withQuery("/mailboxes", search), { method: "GET" });
1404
+ }
1405
+ async get(mailbox) {
1406
+ const { mailbox: found } = await this.client.request(path(mailbox), {
1407
+ method: "GET"
1408
+ });
1409
+ return found;
1410
+ }
1411
+ async update(mailbox, params) {
1412
+ const { mailbox: updated } = await this.client.request(path(mailbox), {
1413
+ method: "PATCH",
1414
+ body: JSON.stringify(params)
1415
+ });
1416
+ return updated;
1417
+ }
1418
+ /**
1419
+ * Move a hosted address to a mailbox on your own domain: its mail arrives there for
1420
+ * 30 days, then it is dropped. `to` is the new mailbox's id, address or `external_id`,
1421
+ * of the same tenant. The 30 days can't be extended, and the old address can't send
1422
+ * and isn't billed in the meantime. Returns the old mailbox.
1423
+ */
1424
+ async forward(mailbox, params) {
1425
+ const { mailbox: forwarding } = await this.client.request(path(mailbox, "forward"), {
1426
+ method: "POST",
1427
+ body: JSON.stringify(params)
1428
+ });
1429
+ return forwarding;
1430
+ }
1431
+ /** Deletes the mailbox and all its mail. A hosted address is never given out again. */
1432
+ async delete(mailbox) {
1433
+ return this.client.request(path(mailbox), { method: "DELETE" });
1434
+ }
1435
+ /**
1436
+ * Wait for the next message and return it. Counts from `since`, or from now when
1437
+ * left out: to catch mail a step of yours sets off, take `since` before that step.
1438
+ * Waits up to `timeout` ms (default 30s), then throws a `GroundmailError` with
1439
+ * status 408 and code `timeout`; pass its `details.since` to carry on from there.
1440
+ */
1441
+ async wait(mailbox, params = {}) {
1442
+ const totalMs = params.timeout ?? MAILBOX_WAIT_DEFAULT_MS;
1443
+ const deadline = Date.now() + totalMs;
1444
+ let since = isoTime(params.since);
1445
+ for (; ; ) {
1446
+ const remainingMs = Math.max(0, deadline - Date.now());
1447
+ const seconds = Math.min(MAILBOX_WAIT_MAX_SECONDS, Math.ceil(remainingMs / 1e3));
1448
+ const search = new URLSearchParams({ timeout: String(seconds) });
1449
+ if (since) search.set("since", since);
1450
+ if (params.from) search.set("from", params.from);
1451
+ if (params.thread) search.set("thread", params.thread);
1452
+ try {
1453
+ const { message } = await this.client.request(
1454
+ `${path(mailbox, "wait")}?${search}`,
1455
+ { method: "GET" }
1456
+ );
1457
+ if (message) return message;
1458
+ } catch (error) {
1459
+ const timedOut = error instanceof GroundmailError && error.status === 408;
1460
+ if (!timedOut) throw error;
1461
+ const details = error.details && typeof error.details === "object" ? error.details : {};
1462
+ if (typeof details.since === "string") since = details.since;
1463
+ if (Date.now() >= deadline || seconds === 0) {
1464
+ throw new GroundmailError(
1465
+ `No message arrived at ${mailbox} within ${Math.round(totalMs / 1e3)} seconds`,
1466
+ 408,
1467
+ { ...details, ...since ? { since } : {} },
1468
+ { code: "timeout", hint: error.hint, docsUrl: error.docsUrl }
1469
+ );
1470
+ }
1471
+ }
1472
+ }
1473
+ }
1474
+ };
1475
+ async function createInstantMailbox(params = {}, options = {}) {
1476
+ const base = (options.baseUrl || "https://api.groundmail.dev").replace(/\/$/, "");
1477
+ const response = await fetch(`${base}/mailboxes/instant`, {
1478
+ method: "POST",
1479
+ headers: { "Content-Type": "application/json" },
1480
+ body: JSON.stringify(params)
1481
+ });
1482
+ const body = await response.json().catch(() => null);
1483
+ if (!response.ok || !body) throw new Error(body?.error?.message ?? `Could not create a mailbox (${response.status})`);
1484
+ return body;
1485
+ }
1486
+
1225
1487
  // src/migrations.ts
1226
1488
  function mergeMigrations(previous, next) {
1227
1489
  if (!previous || previous.id !== next.id) return next;
@@ -1303,7 +1565,7 @@ function cleanPrefix(prefix) {
1303
1565
  const cleaned = (prefix ?? "").trim().toLowerCase().replace(/[^a-z0-9._+-]+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 48);
1304
1566
  return cleaned || "run";
1305
1567
  }
1306
- function isoTime(value) {
1568
+ function isoTime2(value) {
1307
1569
  if (value === void 0 || value === null || value === "") return null;
1308
1570
  return value instanceof Date ? value.toISOString() : String(value);
1309
1571
  }
@@ -1327,7 +1589,7 @@ var TestInboxResource = class {
1327
1589
  async list(params = {}) {
1328
1590
  const search = new URLSearchParams();
1329
1591
  if (params.to) search.set("to", params.to);
1330
- const since = isoTime(params.since);
1592
+ const since = isoTime2(params.since);
1331
1593
  if (since) search.set("since", since);
1332
1594
  if (params.limit != null) search.set("limit", String(params.limit));
1333
1595
  if (params.cursor) search.set("cursor", params.cursor);
@@ -1351,7 +1613,7 @@ var TestInboxResource = class {
1351
1613
  if (!params?.to) throw new Error("testInbox.waitFor: `to` is required");
1352
1614
  const totalMs = params.timeout ?? TEST_INBOX_WAIT_DEFAULT_MS;
1353
1615
  const deadline = Date.now() + totalMs;
1354
- const since = isoTime(params.since);
1616
+ const since = isoTime2(params.since);
1355
1617
  for (; ; ) {
1356
1618
  const remainingMs = Math.max(0, deadline - Date.now());
1357
1619
  const seconds = Math.min(TEST_INBOX_WAIT_MAX_SECONDS, Math.ceil(remainingMs / 1e3));
@@ -1408,7 +1670,7 @@ function verifyWebhookSignature(secret, payload, header, toleranceSec = 300) {
1408
1670
  }
1409
1671
 
1410
1672
  // package.json
1411
- var version = "0.44.0";
1673
+ var version = "0.46.0";
1412
1674
 
1413
1675
  // src/automations.ts
1414
1676
  var AutomationsResource = class {
@@ -1843,7 +2105,8 @@ var KeysResource = class {
1843
2105
  ...params.scopes?.length ? { scopes: params.scopes } : {},
1844
2106
  ...params.allowedDomains?.length ? { allowed_domains: params.allowedDomains } : {},
1845
2107
  ...params.test ? { test: true } : {},
1846
- ...params.tenant ? { tenant: params.tenant } : {}
2108
+ ...params.tenant ? { tenant: params.tenant } : {},
2109
+ ...params.mailboxIds?.length ? { mailbox_ids: params.mailboxIds } : {}
1847
2110
  })
1848
2111
  });
1849
2112
  }
@@ -2295,6 +2558,7 @@ var _Groundmail = class _Groundmail {
2295
2558
  this.migrations = new MigrationsResource(this);
2296
2559
  this.dmarc = new DmarcResource(this);
2297
2560
  this.testInbox = new TestInboxResource(this);
2561
+ this.mailboxes = new MailboxesResource(this);
2298
2562
  }
2299
2563
  /**
2300
2564
  * Check one address with Groundmail validation before you accept it (for
@@ -2355,16 +2619,25 @@ var _Groundmail = class _Groundmail {
2355
2619
  return response;
2356
2620
  }
2357
2621
  /** GET a text body (CSV downloads). Errors are JSON, like every other route. */
2358
- async requestText(path) {
2359
- const response = await this.authorizedFetch(`${this.baseUrl}${path}`, { method: "GET" }, {});
2622
+ async requestText(path2) {
2623
+ const response = await this.authorizedFetch(`${this.baseUrl}${path2}`, { method: "GET" }, {});
2360
2624
  if (!response.ok) {
2361
2625
  const body = await response.json().catch(() => ({}));
2362
2626
  throw GroundmailError.fromResponse(response.status, body);
2363
2627
  }
2364
2628
  return response.text();
2365
2629
  }
2366
- async request(path, init) {
2367
- const response = await this.authorizedFetch(`${this.baseUrl}${path}`, init, { "Content-Type": "application/json" });
2630
+ /** GET a binary body (attachment downloads) with its headers. Errors are JSON, like every other route. */
2631
+ async requestBytes(path2) {
2632
+ const response = await this.authorizedFetch(`${this.baseUrl}${path2}`, { method: "GET" }, {});
2633
+ if (!response.ok) {
2634
+ const body = await response.json().catch(() => ({}));
2635
+ throw GroundmailError.fromResponse(response.status, body);
2636
+ }
2637
+ return { bytes: new Uint8Array(await response.arrayBuffer()), headers: response.headers };
2638
+ }
2639
+ async request(path2, init) {
2640
+ const response = await this.authorizedFetch(`${this.baseUrl}${path2}`, init, { "Content-Type": "application/json" });
2368
2641
  const body = await response.json().catch(() => ({}));
2369
2642
  if (!response.ok) {
2370
2643
  throw GroundmailError.fromResponse(response.status, body);
@@ -2405,6 +2678,12 @@ export {
2405
2678
  BurrowGuardResource,
2406
2679
  mergeSpfInclude,
2407
2680
  applyDnsRecords,
2681
+ MAILBOX_WAIT_MAX_SECONDS,
2682
+ MAILBOX_WAIT_DEFAULT_MS,
2683
+ MailboxThreadsResource,
2684
+ MailboxMessagesResource,
2685
+ MailboxesResource,
2686
+ createInstantMailbox,
2408
2687
  mergeMigrations,
2409
2688
  TEST_INBOX_WAIT_MAX_SECONDS,
2410
2689
  TEST_INBOX_WAIT_DEFAULT_MS,
package/dist/clerk.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { G as Groundmail, S as SendEmailResult } from './client-CD3tBIro.js';
1
+ import { G as Groundmail, S as SendEmailResult } from './client-92N8VztP.js';
2
2
 
3
3
  /**
4
4
  * Subset of Clerk `email.created` webhook `data` used for delivery.
package/dist/clerk.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_API_BASE_URL,
3
3
  Groundmail
4
- } from "./chunk-WMMIGQLO.js";
4
+ } from "./chunk-ACYLU736.js";
5
5
 
6
6
  // src/clerk.ts
7
7
  function resolveApiKey(options) {
@@ -424,6 +424,8 @@ type ApiKey = {
424
424
  test?: boolean;
425
425
  /** The tenant this key is limited to (external id). Absent or null for an account-wide key. */
426
426
  tenant?: string | null;
427
+ /** The mailboxes this key is limited to (`mbx_…`). Absent on a key that isn't. */
428
+ mailbox_ids?: string[];
427
429
  prefix: string;
428
430
  created_at: string;
429
431
  last_used_at: string | null;
@@ -454,6 +456,11 @@ type CreateApiKeyParams = {
454
456
  * tenant and sees only that tenant's emails, domains and suppressions.
455
457
  */
456
458
  tenant?: string;
459
+ /**
460
+ * Limit the key to these mailboxes (`mbx_…`): it reads and works with their mail and
461
+ * nothing else on the account. Needs `mailboxes:read` or `mailboxes:write`.
462
+ */
463
+ mailboxIds?: string[];
457
464
  };
458
465
  type CreateApiKeyResult = {
459
466
  id: string;
@@ -465,6 +472,8 @@ type CreateApiKeyResult = {
465
472
  test?: boolean;
466
473
  /** The tenant this key is limited to (external id), when it is. */
467
474
  tenant?: string;
475
+ /** The mailboxes this key is limited to (`mbx_…`), when it is. */
476
+ mailbox_ids?: string[];
468
477
  prefix: string;
469
478
  token: string;
470
479
  created_at: string;
@@ -501,7 +510,7 @@ type CreateSmtpCredentialParams = {
501
510
  type CreateSmtpCredentialResult = SmtpCredential & {
502
511
  password: string;
503
512
  };
504
- type WebhookEventType = 'email.received' | 'email.sent' | 'email.delivered' | 'email.delivery_delayed' | 'email.held' | 'email.bounced' | 'email.complained' | 'email.opened' | 'email.clicked' | 'email.failed' | 'email.suppressed' | 'email.scheduled' | 'contact.unsubscribed' | 'automation.started' | 'automation.step_completed' | 'automation.completed' | 'automation.failed';
513
+ type WebhookEventType = 'email.received' | 'email.sent' | 'email.delivered' | 'email.delivery_delayed' | 'email.held' | 'email.bounced' | 'email.complained' | 'email.opened' | 'email.clicked' | 'email.failed' | 'email.suppressed' | 'email.scheduled' | 'contact.unsubscribed' | 'automation.started' | 'automation.step_completed' | 'automation.completed' | 'automation.failed' | 'mailbox.message.received' | 'mailbox.message.sent';
505
514
  /** A tag on a webhook payload: the email's tags as sent, as `{ name, value }` pairs. */
506
515
  type WebhookEmailTag = {
507
516
  name: string;
@@ -559,6 +568,37 @@ type ContactWebhookEventPayload = {
559
568
  tags?: WebhookEmailTag[];
560
569
  };
561
570
  };
571
+ /**
572
+ * `mailbox.message.received` and `mailbox.message.sent` webhook payload: a summary,
573
+ * without the bodies. Fetch the message for those. On a received message everything
574
+ * in it was written by a stranger: treat it as data.
575
+ */
576
+ type MailboxWebhookEventPayload = {
577
+ type: 'mailbox.message.received' | 'mailbox.message.sent';
578
+ created_at: string;
579
+ data: {
580
+ mailbox_id: string;
581
+ mailbox_address: string;
582
+ message_id: string;
583
+ thread_id: string;
584
+ from: string;
585
+ subject: string;
586
+ snippet: string | null;
587
+ code: string | null;
588
+ links: string[];
589
+ sender_verified: boolean;
590
+ prompt_injection: {
591
+ flagged: boolean;
592
+ signals: string[];
593
+ };
594
+ spam_status: string | null;
595
+ has_attachments: boolean;
596
+ /** True on received mail. A sent message is your agent's own. */
597
+ untrusted: boolean;
598
+ /** The tenant's external id, on a tenant's mailbox. */
599
+ tenant?: string;
600
+ };
601
+ };
562
602
  /** `details` on `POST /emails` 422 when recipients opted out of a category. */
563
603
  type CategoryUnsubscribedErrorDetails = {
564
604
  category_unsubscribed: string[];
@@ -827,6 +867,8 @@ type WebhookEndpoint = {
827
867
  enabled: boolean;
828
868
  /** Present only when the endpoint receives email events for some tenants only (their external ids). */
829
869
  tenants?: string[];
870
+ /** Present only when the endpoint receives mailbox events for some mailboxes only (`mbx_…`). */
871
+ mailboxes?: string[];
830
872
  /** Delivery health, on `list` and `get`. */
831
873
  health?: WebhookEndpointHealth;
832
874
  created_at: string;
@@ -907,6 +949,8 @@ type CreateWebhookParams = {
907
949
  events?: WebhookEventType[];
908
950
  /** Only these tenants' email events (external ids or Groundmail ids). Omit, `[]` or `null` for all. */
909
951
  tenants?: string[] | null;
952
+ /** Only these mailboxes' mailbox events (`mbx_` id, address or `external_id`). Omit, `[]` or `null` for all. */
953
+ mailboxes?: string[] | null;
910
954
  };
911
955
  type UpdateWebhookParams = {
912
956
  url?: string;
@@ -914,6 +958,8 @@ type UpdateWebhookParams = {
914
958
  enabled?: boolean;
915
959
  /** Only these tenants' email events. `[]` or `null` removes the filter. */
916
960
  tenants?: string[] | null;
961
+ /** Only these mailboxes' mailbox events. `[]` or `null` removes the filter. */
962
+ mailboxes?: string[] | null;
917
963
  };
918
964
  type WebhookEndpointWithSecret = {
919
965
  webhook: WebhookEndpoint;
@@ -1855,6 +1901,289 @@ type UpdateBrandParams = {
1855
1901
  address?: string | null;
1856
1902
  website?: string | null;
1857
1903
  };
1904
+ type MailboxStatus = 'active' | 'paused' | 'forwarding';
1905
+ /** A hosted address that moved to a mailbox on your own domain. */
1906
+ type MailboxForwarding = {
1907
+ /** The address its mail arrives at. */
1908
+ to: string | null;
1909
+ /** When forwarding ends. It can't be extended. */
1910
+ until: string;
1911
+ /** False once forwarding has ended, or if the new mailbox is gone. Mail is then dropped. */
1912
+ active: boolean;
1913
+ };
1914
+ /** A real address your agent receives at. */
1915
+ type Mailbox = {
1916
+ object: 'mailbox';
1917
+ id: string;
1918
+ address: string;
1919
+ local_part: string;
1920
+ domain: string;
1921
+ /** On the hosted domain, not one of yours. */
1922
+ hosted: boolean;
1923
+ display_name: string | null;
1924
+ /** Your own id for this mailbox. */
1925
+ external_id: string | null;
1926
+ /** A paused mailbox still receives mail, but can't send. A `forwarding` one can't send either. */
1927
+ status: MailboxStatus;
1928
+ /** `reply_only` on hosted addresses, which can't email anyone first. `first_contact` on your own domain. */
1929
+ send_policy: 'reply_only' | 'first_contact';
1930
+ /** Most emails a day from this mailbox; null for no limit of its own. */
1931
+ daily_send_limit: number | null;
1932
+ /** Why it is paused, by you or automatically; null while active. */
1933
+ paused_reason: string | null;
1934
+ /** Set while a hosted address forwards to its new mailbox; null otherwise. */
1935
+ forwarding: MailboxForwarding | null;
1936
+ /** Spam score at or above which mail is held; null uses the default. */
1937
+ spam_threshold: number | null;
1938
+ /** Days mail is kept; null uses your plan's default. */
1939
+ retention_days: number | null;
1940
+ metadata: Record<string, unknown> | null;
1941
+ /** The tenant's external id, on a tenant's mailbox. */
1942
+ tenant?: string;
1943
+ created_at: string;
1944
+ updated_at: string;
1945
+ };
1946
+ type CreateMailboxParams = {
1947
+ /** Left out, the address gets a generated local part. Letters, numbers, dots, hyphens and underscores. */
1948
+ local_part?: string;
1949
+ /** A verified domain of yours. Left out, the address is on the hosted domain. */
1950
+ domain?: string;
1951
+ display_name?: string | null;
1952
+ /** Your own id for this mailbox. Usable wherever a mailbox is named. */
1953
+ external_id?: string | null;
1954
+ /** The tenant the mailbox belongs to. */
1955
+ tenant?: string;
1956
+ /** Days to keep mail: 1 to 365 on paid plans, at most 7 on Free. */
1957
+ retention_days?: number | null;
1958
+ /** Spam score at or above which mail is held, above 0 and at most 100. */
1959
+ spam_threshold?: number | null;
1960
+ metadata?: Record<string, unknown> | null;
1961
+ /** A hosted mailbox this new one replaces: it forwards here for 30 days. Needs `domain`. */
1962
+ forward_from?: string;
1963
+ };
1964
+ type ForwardMailboxParams = {
1965
+ /** The new mailbox: its `mbx_` id, address or `external_id`. On your own domain, same tenant. */
1966
+ to: string;
1967
+ };
1968
+ /** Fields left out keep their value; `null` clears one. */
1969
+ type UpdateMailboxParams = Omit<CreateMailboxParams, 'local_part' | 'domain' | 'tenant' | 'forward_from'> & {
1970
+ /** A paused mailbox still receives mail, but can't send. */
1971
+ status?: 'active' | 'paused';
1972
+ /** Most emails a day from this mailbox, 1 to 100000. `null` removes the limit. */
1973
+ daily_send_limit?: number | null;
1974
+ };
1975
+ type ListMailboxesParams = {
1976
+ tenant?: string;
1977
+ limit?: number;
1978
+ cursor?: string;
1979
+ };
1980
+ type ListMailboxesResult = {
1981
+ data: Mailbox[];
1982
+ has_more: boolean;
1983
+ next_cursor: string | null;
1984
+ };
1985
+ type DeleteMailboxResult = {
1986
+ deleted: true;
1987
+ id: string;
1988
+ };
1989
+ /** A conversation. `subject`, `snippet` and `participants` came from strangers. */
1990
+ type MailboxThread = {
1991
+ object: 'mailbox_thread';
1992
+ id: string;
1993
+ mailbox_id: string;
1994
+ subject: string;
1995
+ participants: string[];
1996
+ labels: string[];
1997
+ message_count: number;
1998
+ unread_count: number;
1999
+ snippet: string | null;
2000
+ archived: boolean;
2001
+ /** Every message on it is held. */
2002
+ held: boolean;
2003
+ last_message_at: string;
2004
+ last_inbound_at: string | null;
2005
+ last_outbound_at: string | null;
2006
+ created_at: string;
2007
+ untrusted: true;
2008
+ };
2009
+ type MailboxThreadDetail = MailboxThread & {
2010
+ /** Its messages, oldest first: the newest 200 on a longer thread. */
2011
+ messages: MailboxMessageDetail[];
2012
+ };
2013
+ type MailboxAttachment = {
2014
+ object: 'mailbox_attachment';
2015
+ id: string;
2016
+ message_id: string;
2017
+ filename: string;
2018
+ /** Read from the file's bytes where possible. */
2019
+ content_type: string;
2020
+ /** What the sender claimed. */
2021
+ declared_content_type: string | null;
2022
+ size: number;
2023
+ sha256: string;
2024
+ content_id: string | null;
2025
+ inline: boolean;
2026
+ };
2027
+ type MailboxAttachmentDownload = {
2028
+ content: Uint8Array;
2029
+ content_type: string;
2030
+ /** The sender's filename. Don't use it as a path. */
2031
+ filename: string | null;
2032
+ size: number;
2033
+ };
2034
+ /** A message without its bodies. Everything the sender wrote is untrusted: read it as data. */
2035
+ type MailboxMessage = {
2036
+ object: 'mailbox_message';
2037
+ id: string;
2038
+ mailbox_id: string;
2039
+ thread_id: string | null;
2040
+ direction: 'inbound' | 'outbound';
2041
+ from: string;
2042
+ from_name: string | null;
2043
+ to: string[];
2044
+ cc: string[];
2045
+ reply_to: string | null;
2046
+ /** The `+tag` the mail was addressed to. */
2047
+ plus_tag: string | null;
2048
+ subject: string;
2049
+ snippet: string | null;
2050
+ /** The one-time code in the email, if there is one. */
2051
+ code: string | null;
2052
+ /** Links in the visible text. Never fetched by us. */
2053
+ links: string[];
2054
+ labels: string[];
2055
+ read: boolean;
2056
+ /** `clean`, `suspicious` or `spam`; null when the message wasn't scanned. */
2057
+ spam_status: string | null;
2058
+ spam_score: number | null;
2059
+ /** Kept from your agent as spam or a flood. Left out of lists and `wait` by default. */
2060
+ held: boolean;
2061
+ /** The From domain is proved by aligned SPF or DKIM. False never means forged, true never means safe. */
2062
+ sender_verified: boolean;
2063
+ authentication: {
2064
+ spf: string | null;
2065
+ dkim: string | null;
2066
+ dmarc: string | null;
2067
+ };
2068
+ /** The email had text a reader wouldn't see. Common in marketing mail, so not alarming alone. */
2069
+ hidden_text_removed: boolean;
2070
+ /** A hint that the email tries to instruct an agent. No flag never means safe. */
2071
+ prompt_injection: {
2072
+ flagged: boolean;
2073
+ signals: string[];
2074
+ };
2075
+ /** An automatic message: out-of-office, bounce and the like. Agents shouldn't answer these. */
2076
+ auto_submitted: boolean;
2077
+ size: number;
2078
+ attachments: MailboxAttachment[];
2079
+ received_at: string;
2080
+ expires_at: string | null;
2081
+ /** True on received mail. False only on your agent's own sent messages. */
2082
+ untrusted: boolean;
2083
+ };
2084
+ type MailboxMessageDetail = MailboxMessage & {
2085
+ rfc_message_id: string | null;
2086
+ in_reply_to: string | null;
2087
+ references: string[];
2088
+ /** What a person would see: hidden text and invisible characters removed. Prefer this. */
2089
+ visible_text: string | null;
2090
+ /** `visible_text` without quoted history. */
2091
+ reply_text: string | null;
2092
+ /** The raw text body, hidden text included. */
2093
+ text: string | null;
2094
+ /** The raw HTML body, hidden text included, remote images removed. */
2095
+ html: string | null;
2096
+ };
2097
+ type ListMailboxThreadsParams = {
2098
+ label?: string;
2099
+ participant?: string;
2100
+ unread?: boolean;
2101
+ /** True lists archived threads instead of the others. */
2102
+ archived?: boolean;
2103
+ since?: Date | string;
2104
+ include_held?: boolean;
2105
+ limit?: number;
2106
+ cursor?: string;
2107
+ };
2108
+ type ListMailboxThreadsResult = {
2109
+ data: MailboxThread[];
2110
+ has_more: boolean;
2111
+ next_cursor: string | null;
2112
+ };
2113
+ type GetMailboxThreadParams = {
2114
+ include_held?: boolean;
2115
+ };
2116
+ type UpdateMailboxThreadParams = {
2117
+ /** Replaces the thread's labels. */
2118
+ labels?: string[];
2119
+ /** Marks every received message on it read or unread. */
2120
+ read?: boolean;
2121
+ archived?: boolean;
2122
+ };
2123
+ type ListMailboxMessagesParams = {
2124
+ /** Searches the subject, sender and visible text. */
2125
+ q?: string;
2126
+ from?: string;
2127
+ /** Thread id (`thd_…`). */
2128
+ thread?: string;
2129
+ label?: string;
2130
+ unread?: boolean;
2131
+ since?: Date | string;
2132
+ include_held?: boolean;
2133
+ limit?: number;
2134
+ cursor?: string;
2135
+ };
2136
+ type ListMailboxMessagesResult = {
2137
+ data: MailboxMessage[];
2138
+ has_more: boolean;
2139
+ next_cursor: string | null;
2140
+ };
2141
+ type UpdateMailboxMessageParams = {
2142
+ /** Replaces the message's labels. */
2143
+ labels?: string[];
2144
+ read?: boolean;
2145
+ };
2146
+ type MailboxOutgoingAttachment = NonNullable<SendEmailParams['attachments']>[number];
2147
+ type SendMailboxMessageParams = {
2148
+ to: string | string[];
2149
+ cc?: string | string[];
2150
+ subject: string;
2151
+ /** `text`, `html` or both. */
2152
+ text?: string;
2153
+ html?: string;
2154
+ attachments?: MailboxOutgoingAttachment[];
2155
+ /** Optional Idempotency-Key (24h TTL): a retry with the same key doesn't send twice. */
2156
+ idempotencyKey?: string;
2157
+ };
2158
+ type ReplyToMailboxMessageParams = {
2159
+ /** `text`, `html` or both. */
2160
+ text?: string;
2161
+ html?: string;
2162
+ /** Also copy everyone else on the message. Each of them counts toward the new-recipient limits. */
2163
+ reply_all?: boolean;
2164
+ attachments?: MailboxOutgoingAttachment[];
2165
+ /** Optional Idempotency-Key (24h TTL): a retry with the same key doesn't send twice. */
2166
+ idempotencyKey?: string;
2167
+ };
2168
+ type MailboxSendResult = {
2169
+ object: 'mailbox_send';
2170
+ /** The sent message (`mbm_…`). */
2171
+ message_id: string;
2172
+ thread_id: string;
2173
+ /** The email (`msg_…`), for delivery events and `emails.get`. */
2174
+ email_id: string;
2175
+ status: string;
2176
+ };
2177
+ type WaitForMailboxMessageParams = {
2178
+ /** Only this sender. */
2179
+ from?: string;
2180
+ /** Only this thread (`thd_…`). */
2181
+ thread?: string;
2182
+ /** Only mail stored after this time. Default: now. To walk through mail, pass the last message's `received_at`. */
2183
+ since?: Date | string;
2184
+ /** Total milliseconds to wait. Default 30000. */
2185
+ timeout?: number;
2186
+ };
1858
2187
 
1859
2188
  declare class AutomationsResource {
1860
2189
  private readonly client;
@@ -2220,6 +2549,119 @@ declare class KeysResource {
2220
2549
  }>;
2221
2550
  }
2222
2551
 
2552
+ /** Longest single wait the API holds open, in seconds. */
2553
+ declare const MAILBOX_WAIT_MAX_SECONDS = 60;
2554
+ declare const MAILBOX_WAIT_DEFAULT_MS = 30000;
2555
+ /** A mailbox's conversations. Takes the mailbox's `mbx_` id, address or `external_id`. */
2556
+ declare class MailboxThreadsResource {
2557
+ private readonly client;
2558
+ constructor(client: Groundmail);
2559
+ /** Threads, newest activity first. Held and archived threads only when asked for. */
2560
+ list(mailbox: string, params?: ListMailboxThreadsParams): Promise<ListMailboxThreadsResult>;
2561
+ /** One thread with its messages, oldest first. */
2562
+ get(mailbox: string, threadId: string, params?: GetMailboxThreadParams): Promise<MailboxThreadDetail>;
2563
+ /** Replace its labels, or mark it read or archived. */
2564
+ update(mailbox: string, threadId: string, params: UpdateMailboxThreadParams): Promise<MailboxThread>;
2565
+ }
2566
+ /** A mailbox's messages. Takes the mailbox's `mbx_` id, address or `external_id`. */
2567
+ declare class MailboxMessagesResource {
2568
+ private readonly client;
2569
+ constructor(client: Groundmail);
2570
+ /** Messages without their bodies, newest first. `q` searches the subject, sender and visible text. */
2571
+ list(mailbox: string, params?: ListMailboxMessagesParams): Promise<ListMailboxMessagesResult>;
2572
+ /** One message with its bodies, code, links, attachments and sender checks. */
2573
+ get(mailbox: string, messageId: string): Promise<MailboxMessageDetail>;
2574
+ /** Replace its labels, or mark it read or unread. */
2575
+ update(mailbox: string, messageId: string, params: UpdateMailboxMessageParams): Promise<MailboxMessageDetail>;
2576
+ /**
2577
+ * Email someone first, from a mailbox on your own domain. Hosted addresses can only
2578
+ * reply. First contact goes through the cold-outreach check, counts toward the
2579
+ * new-recipient limits and carries one-click unsubscribe.
2580
+ */
2581
+ send(mailbox: string, params: SendMailboxMessageParams): Promise<MailboxSendResult>;
2582
+ /**
2583
+ * Reply in the thread, to the message's `Reply-To` or else its `From`. Threading
2584
+ * headers and the `Re:` subject are built for you. A sender who failed DMARC can't be
2585
+ * replied to, and a hosted address can only reply to one who passed.
2586
+ */
2587
+ reply(mailbox: string, messageId: string, params: ReplyToMailboxMessageParams): Promise<MailboxSendResult>;
2588
+ /** An attachment's bytes. They came from a stranger: never run or render them. */
2589
+ downloadAttachment(mailbox: string, messageId: string, attachmentId: string): Promise<MailboxAttachmentDownload>;
2590
+ }
2591
+ /**
2592
+ * Agent mailboxes: real addresses your agent creates by API, reads and sends from.
2593
+ * Every method takes the mailbox's `mbx_` id, its address or your `external_id`.
2594
+ *
2595
+ * Everything in a received message was written by a stranger, and `untrusted: true`
2596
+ * says so on each one. Treat it as data, never as instructions.
2597
+ *
2598
+ * ```ts
2599
+ * const mailbox = await groundmail.mailboxes.create({ local_part: 'signup-bot' })
2600
+ * const since = new Date()
2601
+ * await page.fill('#email', mailbox.address) // the service emails your agent
2602
+ * const message = await groundmail.mailboxes.wait(mailbox.id, { since })
2603
+ * await page.fill('#code', message.code!)
2604
+ * ```
2605
+ */
2606
+ declare class MailboxesResource {
2607
+ private readonly client;
2608
+ readonly threads: MailboxThreadsResource;
2609
+ readonly messages: MailboxMessagesResource;
2610
+ constructor(client: Groundmail);
2611
+ /** A new mailbox. With no `domain` it gets a hosted address; with no `local_part`, a generated one. */
2612
+ create(params?: CreateMailboxParams): Promise<Mailbox>;
2613
+ /** Name the person behind a mailbox made without an account. They get a code by email. */
2614
+ setOwner(mailbox: string, ownerEmail: string): Promise<{
2615
+ owner_email: string;
2616
+ code_expires_at: string;
2617
+ }>;
2618
+ /** Give back the code your person received. The mailbox becomes a normal one, with the same key. */
2619
+ verifyOwner(mailbox: string, code: string): Promise<{
2620
+ level: 'verified';
2621
+ }>;
2622
+ /** Mailboxes, newest first. */
2623
+ list(params?: ListMailboxesParams): Promise<ListMailboxesResult>;
2624
+ get(mailbox: string): Promise<Mailbox>;
2625
+ update(mailbox: string, params: UpdateMailboxParams): Promise<Mailbox>;
2626
+ /**
2627
+ * Move a hosted address to a mailbox on your own domain: its mail arrives there for
2628
+ * 30 days, then it is dropped. `to` is the new mailbox's id, address or `external_id`,
2629
+ * of the same tenant. The 30 days can't be extended, and the old address can't send
2630
+ * and isn't billed in the meantime. Returns the old mailbox.
2631
+ */
2632
+ forward(mailbox: string, params: ForwardMailboxParams): Promise<Mailbox>;
2633
+ /** Deletes the mailbox and all its mail. A hosted address is never given out again. */
2634
+ delete(mailbox: string): Promise<DeleteMailboxResult>;
2635
+ /**
2636
+ * Wait for the next message and return it. Counts from `since`, or from now when
2637
+ * left out: to catch mail a step of yours sets off, take `since` before that step.
2638
+ * Waits up to `timeout` ms (default 30s), then throws a `GroundmailError` with
2639
+ * status 408 and code `timeout`; pass its `details.since` to carry on from there.
2640
+ */
2641
+ wait(mailbox: string, params?: WaitForMailboxMessageParams): Promise<MailboxMessageDetail>;
2642
+ }
2643
+ type InstantMailboxParams = {
2644
+ local_part?: string;
2645
+ display_name?: string;
2646
+ /** The person behind the agent. They get a code that unlocks sending. */
2647
+ owner_email?: string;
2648
+ /** Where the agent found us. */
2649
+ source?: string;
2650
+ };
2651
+ type InstantMailbox = {
2652
+ mailbox: Mailbox;
2653
+ /** A key limited to this mailbox. Shown once. */
2654
+ api_key: string;
2655
+ level: 'none' | 'attached';
2656
+ };
2657
+ /**
2658
+ * A mailbox with no account and no key: receive mail straight away, then pass `api_key`
2659
+ * to `new Groundmail(key)`. Sending starts once a person is attached.
2660
+ */
2661
+ declare function createInstantMailbox(params?: InstantMailboxParams, options?: {
2662
+ baseUrl?: string;
2663
+ }): Promise<InstantMailbox>;
2664
+
2223
2665
  /** Combine the reports of one import's requests: every item, the latest totals. */
2224
2666
  declare function mergeMigrations(previous: Migration | null, next: Migration): Migration;
2225
2667
  /**
@@ -2552,6 +2994,8 @@ declare class Groundmail {
2552
2994
  readonly testInbox: TestInboxResource;
2553
2995
  /** BurrowGuard: keep bots and bad addresses out of your sign-up and contact forms. */
2554
2996
  readonly burrowguard: BurrowGuardResource;
2997
+ /** Agent mailboxes: real addresses your agent creates by API, receives at and reads. */
2998
+ readonly mailboxes: MailboxesResource;
2555
2999
  private readonly apiKey;
2556
3000
  private readonly options;
2557
3001
  private readonly getToken;
@@ -2585,6 +3029,11 @@ declare class Groundmail {
2585
3029
  private authorizedFetch;
2586
3030
  /** GET a text body (CSV downloads). Errors are JSON, like every other route. */
2587
3031
  requestText(path: string): Promise<string>;
3032
+ /** GET a binary body (attachment downloads) with its headers. Errors are JSON, like every other route. */
3033
+ requestBytes(path: string): Promise<{
3034
+ bytes: Uint8Array;
3035
+ headers: Headers;
3036
+ }>;
2588
3037
  request<T>(path: string, init: RequestInit): Promise<T>;
2589
3038
  }
2590
3039
  /** A token provider's result → the token and its expiry (ms since epoch), if known. */
@@ -2593,4 +3042,4 @@ declare function normalizeAccessToken(value: GroundmailAccessToken | null | unde
2593
3042
  expiresAt: number | null;
2594
3043
  };
2595
3044
 
2596
- export { type CreateSenderParams as $, type ApiErrorBody as A, type Batch as B, type BrandLogo as C, type DnsRecord as D, type BrandSettings as E, type BurrowGuardCheck as F, Groundmail as G, type BurrowGuardReason as H, BurrowGuardResource as I, type BurrowGuardSite as J, type BurrowGuardSiteWithSecret as K, type BurrowGuardVerifyParams as L, type BurrowGuardVerifyResult as M, type CancelBatchResult as N, type CategoryOptOut as O, type CategoryOptOutCategory as P, type CategoryUnsubscribedErrorDetails as Q, type ConnectTwilioParams as R, type SendEmailResult as S, type ContactWebhookEventPayload as T, type CreateApiKeyParams as U, type CreateApiKeyResult as V, type CreateAutomationParams as W, type CreateBurrowGuardSiteParams as X, type CreateDomainParams as Y, type CreateDomainResult as Z, type CreateMigrationParams as _, type ApiErrorCode as a, type ListReceivedEmailsResult as a$, type CreateSuppressionParams as a0, type CreateTemplateParams as a1, type CreateTenantParams as a2, type CreateWebhookParams as a3, DEFAULT_API_BASE_URL as a4, type DailyRampLimitErrorDetails as a5, type DeleteTenantResult as a6, type DeliverabilityBucket as a7, type DeliverabilityDomainInsight as a8, type DeliverabilityInsightsResult as a9, type EmailWebhookEventType as aA, type EnableDmarcParams as aB, type EnableDmarcResult as aC, type EnrollmentSkip as aD, type EventRecord as aE, type GroundmailAccessToken as aF, type GroundmailOptions as aG, type GroundmailTokenOptions as aH, type GroundmailTokenProvider as aI, type HeldBackErrorDetails as aJ, type HeldBackReason as aK, type HeldBackRecipient as aL, type InReplyToEmail as aM, type ListApiKeysParams as aN, type ListApiKeysResult as aO, type ListAutomationRunsParams as aP, type ListAutomationRunsResult as aQ, type ListAutomationsResult as aR, type ListBurrowGuardChecksParams as aS, type ListBurrowGuardChecksResult as aT, type ListCategoryOptOutsParams as aU, type ListCategoryOptOutsResult as aV, type ListDomainsParams as aW, type ListDomainsResult as aX, type ListEmailsParams as aY, type ListEmailsResult as aZ, type ListReceivedEmailsParams as a_, type DeliverabilityMailServerRelay as aa, type DeliverabilityWindow as ab, type DmarcDailyPoint as ac, type DmarcMonitoring as ad, type DmarcMonitoringDisabled as ae, type DmarcReadiness as af, type DmarcReadinessVerdict as ag, type DmarcSource as ah, type DmarcSourceStatus as ai, type DmarcStatus as aj, type DnsProviderName as ak, type Domain as al, type DomainBimiAnalysis as am, type DomainBlocklistListing as an, type DomainBlocklistStatus as ao, type DomainBlocklists as ap, type DomainDetailResult as aq, type DomainDmarcAnalysis as ar, type DomainDnsAnalysis as as, type DomainStatus as at, type DomainTlsMode as au, type DomainTrackingDns as av, type DomainTrackingStatus as aw, type EmailDelivery as ax, type EmailListItem as ay, type EmailWebhookEventPayload as az, type ApiKey as b, type TwilioIntegrationResponse as b$, type ListSendersResult as b0, type ListSuppressionsParams as b1, type ListSuppressionsResult as b2, type ListTemplatesParams as b3, type ListTemplatesResult as b4, type ListTenantDomainsResult as b5, type ListTenantsParams as b6, type ListTenantsResult as b7, type ListTestInboxEmailsParams as b8, type ListTestInboxEmailsResult as b9, type Suppression as bA, TEST_INBOX_WAIT_DEFAULT_MS as bB, TEST_INBOX_WAIT_MAX_SECONDS as bC, type Template as bD, type TemplateFormat as bE, type TemplateLintWarning as bF, type TemplateStarter as bG, type TemplateStatus as bH, type TemplateVersion as bI, type Tenant as bJ, type TenantPauseSource as bK, type TenantRamp as bL, type TenantStats as bM, type TenantStatsResult as bN, type TenantStatus as bO, type TenantStreamPolicy as bP, type TestEmailWebhookParams as bQ, type TestEmailWebhookResult as bR, type TestInbox as bS, type TestInboxAddressOptions as bT, type TestInboxEmail as bU, type TestInboxEmailDetail as bV, type TestInboxHeader as bW, TestInboxResource as bX, type TestInboxUsage as bY, type TriggerEventParams as bZ, type TriggerEventResult as b_, type ListWebhookDeliveriesParams as ba, type ListWebhookDeliveriesResult as bb, type MailServerSigningStatus as bc, type MailStream as bd, type Migration as be, type MigrationDnsChange as bf, type MigrationDnsPlan as bg, type MigrationDomainItem as bh, type MigrationItemStatus as bi, type MigrationProvider as bj, type MigrationResource as bk, type MigrationSummary as bl, type MigrationTemplateItem as bm, type MigrationTotals as bn, type MigrationWebhookItem as bo, type ReceivedEmail as bp, type ReceivedEmailAttachment as bq, type ReceivedEmailAttachmentMeta as br, type RemoteApplyDnsCredentials as bs, type RemoveCategoryOptOutOptions as bt, type RunMigrationOptions as bu, type SendEmailParams as bv, type Sender as bw, type SesMigrationParams as bx, type StreamDeliverability as by, type SuppressedErrorDetails as bz, type ApiKeyMigrationParams as c, type TwilioIntegrationStatus as c0, type UpdateAutomationParams as c1, type UpdateBrandParams as c2, type UpdateBurrowGuardSiteParams as c3, type UpdateDomainParams as c4, type UpdateEmailParams as c5, type UpdateSenderParams as c6, type UpdateTemplateParams as c7, type UpdateTenantParams as c8, type UpdateWebhookParams as c9, type ValidateEmailResult as ca, type ValidationReason as cb, type ValidationVerdict as cc, type VerifyDomainResult as cd, type WaitForTestEmailParams as ce, type WebhookDelivery as cf, type WebhookDeliveryAttempt as cg, type WebhookDeliveryDetail as ch, type WebhookDeliveryStatus as ci, type WebhookEmailTag as cj, type WebhookEndpoint as ck, type WebhookEndpointHealth as cl, type WebhookEndpointWithSecret as cm, type WebhookEventType as cn, mergeMigrations as co, normalizeAccessToken as cp, type ApiKeyScope as d, type ApplyDnsParams as e, type ApplyDnsRecordResult as f, type ApplyDnsResult as g, type Asset as h, type Automation as i, type AutomationBranchQuestion as j, type AutomationBranchStep as k, type AutomationInlineEmail as l, type AutomationResult as m, type AutomationRun as n, type AutomationRunResponse as o, type AutomationRunStatus as p, type AutomationRunStep as q, type AutomationRunStepStatus as r, type AutomationSendEmailStep as s, type AutomationStatus as t, type AutomationStep as u, type AutomationTemplateEmail as v, type AutomationTrigger as w, type BatchSendEmailResult as x, type BounceType as y, type Brand as z };
3045
+ export { type CreateMigrationParams as $, type ApiErrorBody as A, type Batch as B, type BrandLogo as C, type DnsRecord as D, type BrandSettings as E, type BurrowGuardCheck as F, Groundmail as G, type BurrowGuardReason as H, BurrowGuardResource as I, type BurrowGuardSite as J, type BurrowGuardSiteWithSecret as K, type BurrowGuardVerifyParams as L, type BurrowGuardVerifyResult as M, type CancelBatchResult as N, type CategoryOptOut as O, type CategoryOptOutCategory as P, type CategoryUnsubscribedErrorDetails as Q, type ConnectTwilioParams as R, type SendEmailResult as S, type ContactWebhookEventPayload as T, type CreateApiKeyParams as U, type CreateApiKeyResult as V, type CreateAutomationParams as W, type CreateBurrowGuardSiteParams as X, type CreateDomainParams as Y, type CreateDomainResult as Z, type CreateMailboxParams as _, type ApiErrorCode as a, type ListCategoryOptOutsResult as a$, type CreateSenderParams as a0, type CreateSuppressionParams as a1, type CreateTemplateParams as a2, type CreateTenantParams as a3, type CreateWebhookParams as a4, DEFAULT_API_BASE_URL as a5, type DailyRampLimitErrorDetails as a6, type DeleteMailboxResult as a7, type DeleteTenantResult as a8, type DeliverabilityBucket as a9, type EmailListItem as aA, type EmailWebhookEventPayload as aB, type EmailWebhookEventType as aC, type EnableDmarcParams as aD, type EnableDmarcResult as aE, type EnrollmentSkip as aF, type EventRecord as aG, type ForwardMailboxParams as aH, type GetMailboxThreadParams as aI, type GroundmailAccessToken as aJ, type GroundmailOptions as aK, type GroundmailTokenOptions as aL, type GroundmailTokenProvider as aM, type HeldBackErrorDetails as aN, type HeldBackReason as aO, type HeldBackRecipient as aP, type InReplyToEmail as aQ, type InstantMailbox as aR, type InstantMailboxParams as aS, type ListApiKeysParams as aT, type ListApiKeysResult as aU, type ListAutomationRunsParams as aV, type ListAutomationRunsResult as aW, type ListAutomationsResult as aX, type ListBurrowGuardChecksParams as aY, type ListBurrowGuardChecksResult as aZ, type ListCategoryOptOutsParams as a_, type DeliverabilityDomainInsight as aa, type DeliverabilityInsightsResult as ab, type DeliverabilityMailServerRelay as ac, type DeliverabilityWindow as ad, type DmarcDailyPoint as ae, type DmarcMonitoring as af, type DmarcMonitoringDisabled as ag, type DmarcReadiness as ah, type DmarcReadinessVerdict as ai, type DmarcSource as aj, type DmarcSourceStatus as ak, type DmarcStatus as al, type DnsProviderName as am, type Domain as an, type DomainBimiAnalysis as ao, type DomainBlocklistListing as ap, type DomainBlocklistStatus as aq, type DomainBlocklists as ar, type DomainDetailResult as as, type DomainDmarcAnalysis as at, type DomainDnsAnalysis as au, type DomainStatus as av, type DomainTlsMode as aw, type DomainTrackingDns as ax, type DomainTrackingStatus as ay, type EmailDelivery as az, type ApiKey as b, type Sender as b$, type ListDomainsParams as b0, type ListDomainsResult as b1, type ListEmailsParams as b2, type ListEmailsResult as b3, type ListMailboxMessagesParams as b4, type ListMailboxMessagesResult as b5, type ListMailboxThreadsParams as b6, type ListMailboxThreadsResult as b7, type ListMailboxesParams as b8, type ListMailboxesResult as b9, type MailboxSendResult as bA, type MailboxStatus as bB, type MailboxThread as bC, type MailboxThreadDetail as bD, MailboxThreadsResource as bE, type MailboxWebhookEventPayload as bF, MailboxesResource as bG, type Migration as bH, type MigrationDnsChange as bI, type MigrationDnsPlan as bJ, type MigrationDomainItem as bK, type MigrationItemStatus as bL, type MigrationProvider as bM, type MigrationResource as bN, type MigrationSummary as bO, type MigrationTemplateItem as bP, type MigrationTotals as bQ, type MigrationWebhookItem as bR, type ReceivedEmail as bS, type ReceivedEmailAttachment as bT, type ReceivedEmailAttachmentMeta as bU, type RemoteApplyDnsCredentials as bV, type RemoveCategoryOptOutOptions as bW, type ReplyToMailboxMessageParams as bX, type RunMigrationOptions as bY, type SendEmailParams as bZ, type SendMailboxMessageParams as b_, type ListReceivedEmailsParams as ba, type ListReceivedEmailsResult as bb, type ListSendersResult as bc, type ListSuppressionsParams as bd, type ListSuppressionsResult as be, type ListTemplatesParams as bf, type ListTemplatesResult as bg, type ListTenantDomainsResult as bh, type ListTenantsParams as bi, type ListTenantsResult as bj, type ListTestInboxEmailsParams as bk, type ListTestInboxEmailsResult as bl, type ListWebhookDeliveriesParams as bm, type ListWebhookDeliveriesResult as bn, MAILBOX_WAIT_DEFAULT_MS as bo, MAILBOX_WAIT_MAX_SECONDS as bp, type MailServerSigningStatus as bq, type MailStream as br, type Mailbox as bs, type MailboxAttachment as bt, type MailboxAttachmentDownload as bu, type MailboxForwarding as bv, type MailboxMessage as bw, type MailboxMessageDetail as bx, MailboxMessagesResource as by, type MailboxOutgoingAttachment as bz, type ApiKeyMigrationParams as c, type SesMigrationParams as c0, type StreamDeliverability as c1, type SuppressedErrorDetails as c2, type Suppression as c3, TEST_INBOX_WAIT_DEFAULT_MS as c4, TEST_INBOX_WAIT_MAX_SECONDS as c5, type Template as c6, type TemplateFormat as c7, type TemplateLintWarning as c8, type TemplateStarter as c9, type UpdateEmailParams as cA, type UpdateMailboxMessageParams as cB, type UpdateMailboxParams as cC, type UpdateMailboxThreadParams as cD, type UpdateSenderParams as cE, type UpdateTemplateParams as cF, type UpdateTenantParams as cG, type UpdateWebhookParams as cH, type ValidateEmailResult as cI, type ValidationReason as cJ, type ValidationVerdict as cK, type VerifyDomainResult as cL, type WaitForMailboxMessageParams as cM, type WaitForTestEmailParams as cN, type WebhookDelivery as cO, type WebhookDeliveryAttempt as cP, type WebhookDeliveryDetail as cQ, type WebhookDeliveryStatus as cR, type WebhookEmailTag as cS, type WebhookEndpoint as cT, type WebhookEndpointHealth as cU, type WebhookEndpointWithSecret as cV, type WebhookEventType as cW, createInstantMailbox as cX, mergeMigrations as cY, normalizeAccessToken as cZ, type TemplateStatus as ca, type TemplateVersion as cb, type Tenant as cc, type TenantPauseSource as cd, type TenantRamp as ce, type TenantStats as cf, type TenantStatsResult as cg, type TenantStatus as ch, type TenantStreamPolicy as ci, type TestEmailWebhookParams as cj, type TestEmailWebhookResult as ck, type TestInbox as cl, type TestInboxAddressOptions as cm, type TestInboxEmail as cn, type TestInboxEmailDetail as co, type TestInboxHeader as cp, TestInboxResource as cq, type TestInboxUsage as cr, type TriggerEventParams as cs, type TriggerEventResult as ct, type TwilioIntegrationResponse as cu, type TwilioIntegrationStatus as cv, type UpdateAutomationParams as cw, type UpdateBrandParams as cx, type UpdateBurrowGuardSiteParams as cy, type UpdateDomainParams as cz, type ApiKeyScope as d, type ApplyDnsParams as e, type ApplyDnsRecordResult as f, type ApplyDnsResult as g, type Asset as h, type Automation as i, type AutomationBranchQuestion as j, type AutomationBranchStep as k, type AutomationInlineEmail as l, type AutomationResult as m, type AutomationRun as n, type AutomationRunResponse as o, type AutomationRunStatus as p, type AutomationRunStep as q, type AutomationRunStepStatus as r, type AutomationSendEmailStep as s, type AutomationStatus as t, type AutomationStep as u, type AutomationTemplateEmail as v, type AutomationTrigger as w, type BatchSendEmailResult as x, type BounceType as y, type Brand as z };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as ApiErrorBody, D as DnsRecord } from './client-CD3tBIro.js';
2
- export { a as ApiErrorCode, b as ApiKey, c as ApiKeyMigrationParams, d as ApiKeyScope, e as ApplyDnsParams, f as ApplyDnsRecordResult, g as ApplyDnsResult, h as Asset, i as Automation, j as AutomationBranchQuestion, k as AutomationBranchStep, l as AutomationInlineEmail, m as AutomationResult, n as AutomationRun, o as AutomationRunResponse, p as AutomationRunStatus, q as AutomationRunStep, r as AutomationRunStepStatus, s as AutomationSendEmailStep, t as AutomationStatus, u as AutomationStep, v as AutomationTemplateEmail, w as AutomationTrigger, B as Batch, x as BatchSendEmailResult, y as BounceType, z as Brand, C as BrandLogo, E as BrandSettings, F as BurrowGuardCheck, H as BurrowGuardReason, I as BurrowGuardResource, J as BurrowGuardSite, K as BurrowGuardSiteWithSecret, L as BurrowGuardVerifyParams, M as BurrowGuardVerifyResult, N as CancelBatchResult, O as CategoryOptOut, P as CategoryOptOutCategory, Q as CategoryUnsubscribedErrorDetails, R as ConnectTwilioParams, T as ContactWebhookEventPayload, U as CreateApiKeyParams, V as CreateApiKeyResult, W as CreateAutomationParams, X as CreateBurrowGuardSiteParams, Y as CreateDomainParams, Z as CreateDomainResult, _ as CreateMigrationParams, $ as CreateSenderParams, a0 as CreateSuppressionParams, a1 as CreateTemplateParams, a2 as CreateTenantParams, a3 as CreateWebhookParams, a4 as DEFAULT_API_BASE_URL, a5 as DailyRampLimitErrorDetails, a6 as DeleteTenantResult, a7 as DeliverabilityBucket, a8 as DeliverabilityDomainInsight, a9 as DeliverabilityInsightsResult, aa as DeliverabilityMailServerRelay, ab as DeliverabilityWindow, ac as DmarcDailyPoint, ad as DmarcMonitoring, ae as DmarcMonitoringDisabled, af as DmarcReadiness, ag as DmarcReadinessVerdict, ah as DmarcSource, ai as DmarcSourceStatus, aj as DmarcStatus, ak as DnsProviderName, al as Domain, am as DomainBimiAnalysis, an as DomainBlocklistListing, ao as DomainBlocklistStatus, ap as DomainBlocklists, aq as DomainDetailResult, ar as DomainDmarcAnalysis, as as DomainDnsAnalysis, at as DomainStatus, au as DomainTlsMode, av as DomainTrackingDns, aw as DomainTrackingStatus, ax as EmailDelivery, ay as EmailListItem, az as EmailWebhookEventPayload, aA as EmailWebhookEventType, aB as EnableDmarcParams, aC as EnableDmarcResult, aD as EnrollmentSkip, aE as EventRecord, G as Groundmail, aF as GroundmailAccessToken, aG as GroundmailOptions, aH as GroundmailTokenOptions, aI as GroundmailTokenProvider, aJ as HeldBackErrorDetails, aK as HeldBackReason, aL as HeldBackRecipient, aM as InReplyToEmail, aN as ListApiKeysParams, aO as ListApiKeysResult, aP as ListAutomationRunsParams, aQ as ListAutomationRunsResult, aR as ListAutomationsResult, aS as ListBurrowGuardChecksParams, aT as ListBurrowGuardChecksResult, aU as ListCategoryOptOutsParams, aV as ListCategoryOptOutsResult, aW as ListDomainsParams, aX as ListDomainsResult, aY as ListEmailsParams, aZ as ListEmailsResult, a_ as ListReceivedEmailsParams, a$ as ListReceivedEmailsResult, b0 as ListSendersResult, b1 as ListSuppressionsParams, b2 as ListSuppressionsResult, b3 as ListTemplatesParams, b4 as ListTemplatesResult, b5 as ListTenantDomainsResult, b6 as ListTenantsParams, b7 as ListTenantsResult, b8 as ListTestInboxEmailsParams, b9 as ListTestInboxEmailsResult, ba as ListWebhookDeliveriesParams, bb as ListWebhookDeliveriesResult, bc as MailServerSigningStatus, bd as MailStream, be as Migration, bf as MigrationDnsChange, bg as MigrationDnsPlan, bh as MigrationDomainItem, bi as MigrationItemStatus, bj as MigrationProvider, bk as MigrationResource, bl as MigrationSummary, bm as MigrationTemplateItem, bn as MigrationTotals, bo as MigrationWebhookItem, bp as ReceivedEmail, bq as ReceivedEmailAttachment, br as ReceivedEmailAttachmentMeta, bs as RemoteApplyDnsCredentials, bt as RemoveCategoryOptOutOptions, bu as RunMigrationOptions, bv as SendEmailParams, S as SendEmailResult, bw as Sender, bx as SesMigrationParams, by as StreamDeliverability, bz as SuppressedErrorDetails, bA as Suppression, bB as TEST_INBOX_WAIT_DEFAULT_MS, bC as TEST_INBOX_WAIT_MAX_SECONDS, bD as Template, bE as TemplateFormat, bF as TemplateLintWarning, bG as TemplateStarter, bH as TemplateStatus, bI as TemplateVersion, bJ as Tenant, bK as TenantPauseSource, bL as TenantRamp, bM as TenantStats, bN as TenantStatsResult, bO as TenantStatus, bP as TenantStreamPolicy, bQ as TestEmailWebhookParams, bR as TestEmailWebhookResult, bS as TestInbox, bT as TestInboxAddressOptions, bU as TestInboxEmail, bV as TestInboxEmailDetail, bW as TestInboxHeader, bX as TestInboxResource, bY as TestInboxUsage, bZ as TriggerEventParams, b_ as TriggerEventResult, b$ as TwilioIntegrationResponse, c0 as TwilioIntegrationStatus, c1 as UpdateAutomationParams, c2 as UpdateBrandParams, c3 as UpdateBurrowGuardSiteParams, c4 as UpdateDomainParams, c5 as UpdateEmailParams, c6 as UpdateSenderParams, c7 as UpdateTemplateParams, c8 as UpdateTenantParams, c9 as UpdateWebhookParams, ca as ValidateEmailResult, cb as ValidationReason, cc as ValidationVerdict, cd as VerifyDomainResult, ce as WaitForTestEmailParams, cf as WebhookDelivery, cg as WebhookDeliveryAttempt, ch as WebhookDeliveryDetail, ci as WebhookDeliveryStatus, cj as WebhookEmailTag, ck as WebhookEndpoint, cl as WebhookEndpointHealth, cm as WebhookEndpointWithSecret, cn as WebhookEventType, co as mergeMigrations, cp as normalizeAccessToken } from './client-CD3tBIro.js';
1
+ import { A as ApiErrorBody, D as DnsRecord } from './client-92N8VztP.js';
2
+ export { a as ApiErrorCode, b as ApiKey, c as ApiKeyMigrationParams, d as ApiKeyScope, e as ApplyDnsParams, f as ApplyDnsRecordResult, g as ApplyDnsResult, h as Asset, i as Automation, j as AutomationBranchQuestion, k as AutomationBranchStep, l as AutomationInlineEmail, m as AutomationResult, n as AutomationRun, o as AutomationRunResponse, p as AutomationRunStatus, q as AutomationRunStep, r as AutomationRunStepStatus, s as AutomationSendEmailStep, t as AutomationStatus, u as AutomationStep, v as AutomationTemplateEmail, w as AutomationTrigger, B as Batch, x as BatchSendEmailResult, y as BounceType, z as Brand, C as BrandLogo, E as BrandSettings, F as BurrowGuardCheck, H as BurrowGuardReason, I as BurrowGuardResource, J as BurrowGuardSite, K as BurrowGuardSiteWithSecret, L as BurrowGuardVerifyParams, M as BurrowGuardVerifyResult, N as CancelBatchResult, O as CategoryOptOut, P as CategoryOptOutCategory, Q as CategoryUnsubscribedErrorDetails, R as ConnectTwilioParams, T as ContactWebhookEventPayload, U as CreateApiKeyParams, V as CreateApiKeyResult, W as CreateAutomationParams, X as CreateBurrowGuardSiteParams, Y as CreateDomainParams, Z as CreateDomainResult, _ as CreateMailboxParams, $ as CreateMigrationParams, a0 as CreateSenderParams, a1 as CreateSuppressionParams, a2 as CreateTemplateParams, a3 as CreateTenantParams, a4 as CreateWebhookParams, a5 as DEFAULT_API_BASE_URL, a6 as DailyRampLimitErrorDetails, a7 as DeleteMailboxResult, a8 as DeleteTenantResult, a9 as DeliverabilityBucket, aa as DeliverabilityDomainInsight, ab as DeliverabilityInsightsResult, ac as DeliverabilityMailServerRelay, ad as DeliverabilityWindow, ae as DmarcDailyPoint, af as DmarcMonitoring, ag as DmarcMonitoringDisabled, ah as DmarcReadiness, ai as DmarcReadinessVerdict, aj as DmarcSource, ak as DmarcSourceStatus, al as DmarcStatus, am as DnsProviderName, an as Domain, ao as DomainBimiAnalysis, ap as DomainBlocklistListing, aq as DomainBlocklistStatus, ar as DomainBlocklists, as as DomainDetailResult, at as DomainDmarcAnalysis, au as DomainDnsAnalysis, av as DomainStatus, aw as DomainTlsMode, ax as DomainTrackingDns, ay as DomainTrackingStatus, az as EmailDelivery, aA as EmailListItem, aB as EmailWebhookEventPayload, aC as EmailWebhookEventType, aD as EnableDmarcParams, aE as EnableDmarcResult, aF as EnrollmentSkip, aG as EventRecord, aH as ForwardMailboxParams, aI as GetMailboxThreadParams, G as Groundmail, aJ as GroundmailAccessToken, aK as GroundmailOptions, aL as GroundmailTokenOptions, aM as GroundmailTokenProvider, aN as HeldBackErrorDetails, aO as HeldBackReason, aP as HeldBackRecipient, aQ as InReplyToEmail, aR as InstantMailbox, aS as InstantMailboxParams, aT as ListApiKeysParams, aU as ListApiKeysResult, aV as ListAutomationRunsParams, aW as ListAutomationRunsResult, aX as ListAutomationsResult, aY as ListBurrowGuardChecksParams, aZ as ListBurrowGuardChecksResult, a_ as ListCategoryOptOutsParams, a$ as ListCategoryOptOutsResult, b0 as ListDomainsParams, b1 as ListDomainsResult, b2 as ListEmailsParams, b3 as ListEmailsResult, b4 as ListMailboxMessagesParams, b5 as ListMailboxMessagesResult, b6 as ListMailboxThreadsParams, b7 as ListMailboxThreadsResult, b8 as ListMailboxesParams, b9 as ListMailboxesResult, ba as ListReceivedEmailsParams, bb as ListReceivedEmailsResult, bc as ListSendersResult, bd as ListSuppressionsParams, be as ListSuppressionsResult, bf as ListTemplatesParams, bg as ListTemplatesResult, bh as ListTenantDomainsResult, bi as ListTenantsParams, bj as ListTenantsResult, bk as ListTestInboxEmailsParams, bl as ListTestInboxEmailsResult, bm as ListWebhookDeliveriesParams, bn as ListWebhookDeliveriesResult, bo as MAILBOX_WAIT_DEFAULT_MS, bp as MAILBOX_WAIT_MAX_SECONDS, bq as MailServerSigningStatus, br as MailStream, bs as Mailbox, bt as MailboxAttachment, bu as MailboxAttachmentDownload, bv as MailboxForwarding, bw as MailboxMessage, bx as MailboxMessageDetail, by as MailboxMessagesResource, bz as MailboxOutgoingAttachment, bA as MailboxSendResult, bB as MailboxStatus, bC as MailboxThread, bD as MailboxThreadDetail, bE as MailboxThreadsResource, bF as MailboxWebhookEventPayload, bG as MailboxesResource, bH as Migration, bI as MigrationDnsChange, bJ as MigrationDnsPlan, bK as MigrationDomainItem, bL as MigrationItemStatus, bM as MigrationProvider, bN as MigrationResource, bO as MigrationSummary, bP as MigrationTemplateItem, bQ as MigrationTotals, bR as MigrationWebhookItem, bS as ReceivedEmail, bT as ReceivedEmailAttachment, bU as ReceivedEmailAttachmentMeta, bV as RemoteApplyDnsCredentials, bW as RemoveCategoryOptOutOptions, bX as ReplyToMailboxMessageParams, bY as RunMigrationOptions, bZ as SendEmailParams, S as SendEmailResult, b_ as SendMailboxMessageParams, b$ as Sender, c0 as SesMigrationParams, c1 as StreamDeliverability, c2 as SuppressedErrorDetails, c3 as Suppression, c4 as TEST_INBOX_WAIT_DEFAULT_MS, c5 as TEST_INBOX_WAIT_MAX_SECONDS, c6 as Template, c7 as TemplateFormat, c8 as TemplateLintWarning, c9 as TemplateStarter, ca as TemplateStatus, cb as TemplateVersion, cc as Tenant, cd as TenantPauseSource, ce as TenantRamp, cf as TenantStats, cg as TenantStatsResult, ch as TenantStatus, ci as TenantStreamPolicy, cj as TestEmailWebhookParams, ck as TestEmailWebhookResult, cl as TestInbox, cm as TestInboxAddressOptions, cn as TestInboxEmail, co as TestInboxEmailDetail, cp as TestInboxHeader, cq as TestInboxResource, cr as TestInboxUsage, cs as TriggerEventParams, ct as TriggerEventResult, cu as TwilioIntegrationResponse, cv as TwilioIntegrationStatus, cw as UpdateAutomationParams, cx as UpdateBrandParams, cy as UpdateBurrowGuardSiteParams, cz as UpdateDomainParams, cA as UpdateEmailParams, cB as UpdateMailboxMessageParams, cC as UpdateMailboxParams, cD as UpdateMailboxThreadParams, cE as UpdateSenderParams, cF as UpdateTemplateParams, cG as UpdateTenantParams, cH as UpdateWebhookParams, cI as ValidateEmailResult, cJ as ValidationReason, cK as ValidationVerdict, cL as VerifyDomainResult, cM as WaitForMailboxMessageParams, cN as WaitForTestEmailParams, cO as WebhookDelivery, cP as WebhookDeliveryAttempt, cQ as WebhookDeliveryDetail, cR as WebhookDeliveryStatus, cS as WebhookEmailTag, cT as WebhookEndpoint, cU as WebhookEndpointHealth, cV as WebhookEndpointWithSecret, cW as WebhookEventType, cX as createInstantMailbox, cY as mergeMigrations, cZ as normalizeAccessToken } from './client-92N8VztP.js';
3
3
 
4
4
  type GroundmailErrorOptions = {
5
5
  code?: string;
package/dist/index.js CHANGED
@@ -3,17 +3,23 @@ import {
3
3
  DEFAULT_API_BASE_URL,
4
4
  Groundmail,
5
5
  GroundmailError,
6
+ MAILBOX_WAIT_DEFAULT_MS,
7
+ MAILBOX_WAIT_MAX_SECONDS,
8
+ MailboxMessagesResource,
9
+ MailboxThreadsResource,
10
+ MailboxesResource,
6
11
  TEST_INBOX_WAIT_DEFAULT_MS,
7
12
  TEST_INBOX_WAIT_MAX_SECONDS,
8
13
  TestInboxResource,
9
14
  applyDnsRecords,
10
15
  buildSignatureHeader,
16
+ createInstantMailbox,
11
17
  mergeMigrations,
12
18
  mergeSpfInclude,
13
19
  normalizeAccessToken,
14
20
  signWebhookPayload,
15
21
  verifyWebhookSignature
16
- } from "./chunk-WMMIGQLO.js";
22
+ } from "./chunk-ACYLU736.js";
17
23
 
18
24
  // src/simulator.ts
19
25
  var SIMULATOR_DOMAIN = "simulator.groundmail.dev";
@@ -39,6 +45,11 @@ export {
39
45
  DEFAULT_API_BASE_URL,
40
46
  Groundmail,
41
47
  GroundmailError,
48
+ MAILBOX_WAIT_DEFAULT_MS,
49
+ MAILBOX_WAIT_MAX_SECONDS,
50
+ MailboxMessagesResource,
51
+ MailboxThreadsResource,
52
+ MailboxesResource,
42
53
  SIMULATOR_DOMAIN,
43
54
  SIMULATOR_OUTCOMES,
44
55
  TEST_API_KEY_PREFIX,
@@ -47,6 +58,7 @@ export {
47
58
  TestInboxResource,
48
59
  applyDnsRecords,
49
60
  buildSignatureHeader,
61
+ createInstantMailbox,
50
62
  isSimulatorAddress,
51
63
  isTestApiKey,
52
64
  mergeMigrations,
package/dist/payload.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { G as Groundmail } from './client-CD3tBIro.js';
1
+ import { G as Groundmail } from './client-92N8VztP.js';
2
2
 
3
3
  /**
4
4
  * Minimal Payload `SendEmailOptions` / address shapes used by this adapter.
package/dist/payload.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_API_BASE_URL,
3
3
  Groundmail
4
- } from "./chunk-WMMIGQLO.js";
4
+ } from "./chunk-ACYLU736.js";
5
5
 
6
6
  // src/payload.ts
7
7
  function resolveApiKey(args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "groundmail",
3
- "version": "0.44.0",
3
+ "version": "0.46.0",
4
4
  "description": "Groundmail transactional email API client",
5
5
  "license": "MIT",
6
6
  "type": "module",