samva 0.49.0 → 0.51.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.
Files changed (74) hide show
  1. package/AGENTS.md +44 -3
  2. package/README.md +136 -7
  3. package/dist/client/sdk.gen.d.ts +63 -18
  4. package/dist/client/sdk.gen.js +1549 -945
  5. package/dist/client/types.gen.d.ts +269 -31
  6. package/dist/effect/agents.d.ts +4 -4
  7. package/dist/effect/api-keys.d.ts +4 -6
  8. package/dist/effect/campaigns.d.ts +166 -174
  9. package/dist/effect/categories.d.ts +2 -2
  10. package/dist/effect/categories.js +6 -4
  11. package/dist/effect/contact-groups.d.ts +4 -4
  12. package/dist/effect/contacts.d.ts +8 -8
  13. package/dist/effect/conversations.d.ts +4 -4
  14. package/dist/effect/descriptors/mailboxes.d.ts +41 -1
  15. package/dist/effect/descriptors/mailboxes.js +53 -1
  16. package/dist/effect/email.d.ts +17 -16
  17. package/dist/effect/errors.d.ts +1 -0
  18. package/dist/effect/errors.js +2 -1
  19. package/dist/effect/generated/api-keys.d.ts +0 -15
  20. package/dist/effect/generated/api-keys.js +1 -2
  21. package/dist/effect/generated/campaigns.d.ts +0 -62
  22. package/dist/effect/generated/campaigns.js +3 -9
  23. package/dist/effect/generated/email.d.ts +10 -3
  24. package/dist/effect/generated/email.js +3 -2
  25. package/dist/effect/generated/mailboxes.d.ts +780 -77
  26. package/dist/effect/generated/mailboxes.js +135 -12
  27. package/dist/effect/generated/namespaces.js +1 -1
  28. package/dist/effect/generated/policies.js +2 -2
  29. package/dist/effect/generated/scheduled-messages.d.ts +0 -26
  30. package/dist/effect/generated/scheduled-messages.js +1 -3
  31. package/dist/effect/generated/shared.d.ts +28 -31
  32. package/dist/effect/generated/shared.js +12 -19
  33. package/dist/effect/generated/template-registrations.d.ts +6 -6
  34. package/dist/effect/generated/template-registrations.js +3 -3
  35. package/dist/effect/generated-metadata.d.ts +24 -0
  36. package/dist/effect/generated-metadata.js +4 -0
  37. package/dist/effect/index.js +2 -1
  38. package/dist/effect/integrations.d.ts +2 -2
  39. package/dist/effect/internal/client.d.ts +19 -2
  40. package/dist/effect/internal/client.js +10 -2
  41. package/dist/effect/internal/email-sender.d.ts +4 -4
  42. package/dist/effect/internal/email-sender.js +5 -3
  43. package/dist/effect/internal/operation.d.ts +11 -0
  44. package/dist/effect/internal/operation.js +10 -6
  45. package/dist/effect/internal/send.d.ts +4 -0
  46. package/dist/effect/internal/send.js +11 -8
  47. package/dist/effect/internal/timeout.d.ts +16 -0
  48. package/dist/effect/internal/timeout.js +20 -0
  49. package/dist/effect/journeys.d.ts +152 -152
  50. package/dist/effect/mailboxes.d.ts +54 -30
  51. package/dist/effect/mailboxes.js +10 -2
  52. package/dist/effect/messages.d.ts +5 -5
  53. package/dist/effect/namespaces.d.ts +4 -4
  54. package/dist/effect/newsletter-domains.d.ts +2 -2
  55. package/dist/effect/operations.d.ts +2 -2
  56. package/dist/effect/scheduled-messages.d.ts +2 -6
  57. package/dist/effect/templates.d.ts +6 -6
  58. package/dist/effect/topics.d.ts +4 -4
  59. package/dist/effect/webhooks.d.ts +4 -4
  60. package/dist/effect/whatsapp-setup-links.d.ts +2 -2
  61. package/dist/index.js +2 -2
  62. package/dist/package.js +1 -1
  63. package/dist/promises/client.d.ts +5 -0
  64. package/dist/promises/client.js +12 -8
  65. package/dist/promises/errors.gen.d.ts +12 -1
  66. package/dist/promises/errors.gen.js +21 -2
  67. package/dist/promises/index.js +2 -2
  68. package/dist/promises/request.d.ts +31 -2
  69. package/dist/promises/request.js +42 -7
  70. package/dist/promises/types.gen.d.ts +1 -1
  71. package/dist/request-policy.d.ts +9 -0
  72. package/dist/request-policy.js +16 -1
  73. package/dist/service-map.d.ts +22 -2
  74. package/package.json +3 -3
package/AGENTS.md CHANGED
@@ -25,11 +25,51 @@ Mailbox send operations return asynchronous action receipts. Interpret `state`,
25
25
  and read `mailboxes.getAction` (or `Mailboxes.getAction`) to follow progress. Narrow on action `type`
26
26
  before reading send-specific `send` receipt and frozen `intent`. `queued` is not a sent confirmation;
27
27
  `accepted` supplies `messageId` and `acceptedAt`, while `completed` records mailbox projection,
28
- not recipient delivery. A timeout preserves the original idempotency key and body; a new key can
28
+ not recipient delivery. Each request attempt fails with `SamvaTimeoutError` after 30 000 ms; set
29
+ `timeoutMs` on the client (`createClient`, `Client.layerFetch`) or per call, and `null` disables
30
+ the bound. A retry after a timeout preserves the original idempotency key and body; a new key can
29
31
  send another email. `uncertain` requires reconciliation. Only a permitted person can cancel before
30
32
  acceptance or retry an eligible original action without extending its deadline. Approval is also
31
33
  asynchronous. See https://samva.dev/docs/mailboxes/approvals for the receipt contract.
32
34
 
35
+ `email.send` takes `from` as `{ email, name? }`, never a string. Without `from` it falls back to the
36
+ template's `fromDefault`, then the organization default sender, then the only verified sender; a new
37
+ organization whose only sending identity is a hosted mailbox address has none, so the send fails with
38
+ `FromAddressRequiredError` (`422`, with `verifiedDomains` and `addresses`) and the example must pass `from`.
39
+ `mailboxes.sendMessage` takes plain address strings and sends from the mailbox's default email
40
+ endpoint; it has no `from` or template fields. `mailboxes.create` takes a full address on
41
+ `whoami.get()`'s `organization.hostedMailDomain`; a slug is not an address.
42
+
43
+ A thread id is not a message id: `mailboxes.getThread` returns no messages, so read a thread's
44
+ `msg_` ids from `listThreadMessages({ id, threadId })` (or `getThreadContent`) and pass an item's
45
+ `id` as `messageId` to `reply`, `replyAll`, and `forward`. A thread's folder is set when it is
46
+ created and does not move on later replies: a thread a send started stays in `sent`, so
47
+ `listThreads({ folder: "inbox" })` omits it; omit `folder` and pass `unread: true` for replies.
48
+ To confirm a send landed, poll `getAction` until `state` is `completed`, `notSent`, or `uncertain`
49
+ within `executeUntil`, then read `action.send.messageId` and `action.send.threadId`.
50
+
51
+ A mailbox email endpoint's `sendingStatus` (`mailboxes.get`) reports the address's setup: `pending`,
52
+ `ready`, or `failed`. While the organization's email onboarding review is undecided, a send from a
53
+ `ready` address stays `queued`; read `email.getOnboardingReview()` for the cause.
54
+
55
+ Each SDK method is named for its API operation, so a REST `DELETE` is `remove` (`mailboxes.remove`,
56
+ `namespaces.remove`, `webhooks.remove`, `email.removeDomain`, `newsletters.domains.remove`). The
57
+ exceptions are `apiKeys.revoke`, `whatsappSetupLinks.revoke`, `campaigns.archive`,
58
+ `templates.delete`, `templates.deleteProject`, and `templateShareLinks.delete`. The identity call is
59
+ `whoami.get()`. `apiKeys.create` and `apiKeys.rotate` return the secret in `key`; destructure it and
60
+ keep the response out of logs.
61
+
62
+ Email domain methods are flat on `client.email`: `addDomain`, `getDomainVerification`,
63
+ `advanceDomainVerification` (checks DNS now; repeat until `phase` is `ready`), `enableReceiving`
64
+ (takes `id` and optional `catchAll`, `endpointId`, `addresses`; the domain must be
65
+ verified), `getReceivingStatus`, and `removeDomain`. Only newsletter domains nest, under
66
+ `client.newsletters.domains`.
67
+
68
+ Create and publish a template from code with `templates.create({ name, slug })`, `openWorkspace`,
69
+ `patchWorkspace`, `checkWorkspace`, `saveWorkspace`, `publish`, and `renderPublication`; every
70
+ workspace call carries the workspace `revision` as `expectedRevision`, and Save also carries
71
+ `expectedHead`. See https://samva.dev/docs/sml/create-and-publish-from-code.
72
+
33
73
  Use `client.policies` or `Policies` from `samva/effect/policies` to read, replace, or clear an
34
74
  organization, mailbox, or API key's decision rules. Policy writes require a person's OAuth session
35
75
  (`authToken` and `orgSlug`), not an API key. Each rule sets `decide` (a default) or `atLeast`
@@ -62,8 +102,9 @@ https://samva.dev/docs/channels/email/newsletters.
62
102
 
63
103
  Every idempotent operation generates one key per logical call and reuses it across built-in
64
104
  retries. Override only through the second options argument, `{ idempotencyKey }`. Both clients
65
- retry reads and contract-marked idempotent mutations. Promise clients accept `maxRetries` at
66
- client and call level. `contacts.startImport` retries only `mode: "new"`; a resume uses
105
+ retry reads and contract-marked idempotent mutations, after a timeout too. Promise clients accept
106
+ `maxRetries` at client and call level. Storage puts of oversized inline attachments use
107
+ `uploadTimeoutMs` (default 300 000 ms) instead of `timeoutMs`. `contacts.startImport` retries only `mode: "new"`; a resume uses
67
108
  a generation fence and must be followed by `getImportJob` after an ambiguous response. Promise cursor lists expose lazy `.pages(params)` and `.items(params)`
68
109
  async iterators. `orgSlug` selects an organization when paired with `authToken`.
69
110
 
package/README.md CHANGED
@@ -125,6 +125,13 @@ const receipt = await samva.mailboxes.sendMessage({
125
125
  console.log(receipt.state);
126
126
  ```
127
127
 
128
+ A hosted address receives mail at once. Read each email endpoint's `sendingStatus` from
129
+ `mailboxes.get`: `pending` means sending setup is still running, and `failed` means setup failed
130
+ and support recovers the address. `ready` describes the address's setup only. While the
131
+ organization's email onboarding review is undecided, a send from a ready address returns a receipt
132
+ whose action stays `queued`; read `samva.email.getOnboardingReview()` (or run `samva email doctor`)
133
+ for the reason. See [a send that stays queued](https://samva.dev/docs/mailboxes/approvals?utm_source=readme&utm_medium=sdk#a-send-that-stays-queued).
134
+
128
135
  Replies arrive as signed webhooks or over the mailbox event stream, threaded to the conversation. Give
129
136
  the agent a key that reaches only its own mailbox, and set rules that hold a send for a person to
130
137
  approve: see [Give an agent an inbox](https://samva.dev/docs/mailboxes?utm_source=readme&utm_medium=sdk). To drive the same mailbox
@@ -143,7 +150,7 @@ The root entrypoint is Promise-based:
143
150
  import { createClient } from "samva";
144
151
  ```
145
152
 
146
- The same Promise SDK is also available at `samva/promises`. Native Effect users import domain modules such as `samva/effect/email` and provide `samva/effect/client`. Both clients are generated from Samva's public OpenAPI document, while the Effect runtime does not wrap or execute the Promise samva. Effect is an optional peer dependency, so Promise-only applications do not install or load it.
153
+ The same Promise SDK is also available at `samva/promises`. Native Effect users import domain modules such as `samva/effect/email` and provide `samva/effect/client`. Both clients are generated from Samva's public OpenAPI document, while the Effect runtime does not wrap or execute the Promise SDK. Effect is an optional peer dependency, so Promise-only applications do not install or load it.
147
154
 
148
155
  ## Installation
149
156
 
@@ -171,6 +178,7 @@ const { contact } = await samva.contacts.findOrCreate({
171
178
  });
172
179
 
173
180
  const message = await samva.email.send({
181
+ from: { email: "hello@yourdomain.com" },
174
182
  to: [contact],
175
183
  subject: "Hello",
176
184
  html: "<p>Hello World</p>",
@@ -185,15 +193,22 @@ for await (const message of samva.messages.list.items({ limit: 20 })) {
185
193
  }
186
194
  ```
187
195
 
196
+ `from` is an object, `{ email, name? }`, never a string, on an address at a verified domain
197
+ (a hosted mailbox domain counts). Omit it only when the template sets `fromDefault`, the
198
+ organization has a default sender, or it has exactly one verified sender. A new organization whose
199
+ only sending identity is a hosted mailbox address has none of these, so the send fails with
200
+ `FromAddressRequiredError` (`422`) with its `verifiedDomains` and `addresses`; pass one of those
201
+ addresses as `from: { email }`, or set a default with `samva.email.setDefaultSender` (`samva email senders set-default`).
202
+
188
203
  Creation fails with `ConflictError` (HTTP 409) when an external ID or address belongs to another
189
204
  contact. The error names the conflicting field and the creation is rolled back.
190
205
 
191
206
  ## Effect Quick Start
192
207
 
193
- Install `effect` next to `samva` when using the Effect entrypoint:
208
+ Install `effect` next to `samva` when using the Effect entrypoint, at a version in the range `samva` lists in `peerDependencies`:
194
209
 
195
210
  ```bash
196
- bun add samva effect@4.0.6
211
+ bun add samva effect
197
212
  ```
198
213
 
199
214
  ```typescript
@@ -202,6 +217,7 @@ import * as Client from "samva/effect/client";
202
217
  import * as Email from "samva/effect/email";
203
218
 
204
219
  const program = Email.send({
220
+ from: { email: "hello@yourdomain.com" },
205
221
  to: "ada@example.com",
206
222
  subject: "Welcome",
207
223
  html: "<h1>Welcome to Samva</h1>",
@@ -299,7 +315,9 @@ advisory `x-samva-client` request header. Supply your own value in `headers`, or
299
315
 
300
316
  Author a template as TSX with `samva templates init`, then publish an exact commit with
301
317
  `samva templates publish --commit HEAD` (see [`@samva/cli`](https://www.npmjs.com/package/@samva/cli)).
302
- A published template is addressed by its slug, which is the `id` in its `defineTemplate`:
318
+ A published template is addressed by its slug, which is the `id` in its `defineTemplate` unless
319
+ `samva templates add --slug` chose another handle. `templateSlug` takes that slug; `templateId` takes
320
+ the template's `tmpl_...` id. A send names exactly one of them:
303
321
 
304
322
  ```typescript
305
323
  import { createClient } from "samva";
@@ -307,6 +325,7 @@ import { createClient } from "samva";
307
325
  const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });
308
326
 
309
327
  await samva.email.send({
328
+ from: { email: "hello@yourdomain.com" },
310
329
  to: [{ email: "ada@example.com" }],
311
330
  templateSlug: "order-shipped",
312
331
  templateData: { name: "Ada", orderId: "A-1042" },
@@ -314,7 +333,26 @@ await samva.email.send({
314
333
  ```
315
334
 
316
335
  A template send omits `subject`, `html`, and `text`; the request fails if `templateData` does not
317
- match the template's input schema. `samva templates types` generates TypeScript types for that input.
336
+ match the template's input schema. `from` follows the same rule as above: pass it unless the
337
+ template's `fromDefault`, the organization default sender, or a single verified sender supplies it. `samva templates types` generates TypeScript types for that input.
338
+
339
+ The SDK and CLI flatten `templateSlug`, `templateData`, `templateId`, `publicationId`, `locale`, and
340
+ `timeZone` into the call. Over REST, `POST /v1/messages` nests them under `email`:
341
+
342
+ ```json
343
+ {
344
+ "channel": "email",
345
+ "from": { "email": "hello@yourdomain.com" },
346
+ "to": [{ "email": "ada@example.com" }],
347
+ "email": {
348
+ "templateSlug": "order-shipped",
349
+ "templateData": { "name": "Ada", "orderId": "A-1042" }
350
+ }
351
+ }
352
+ ```
353
+
354
+ To create, save, and publish a template without Git or the CLI, see
355
+ [Create and publish a template from code](https://samva.dev/docs/sml/create-and-publish-from-code?utm_source=readme&utm_medium=sdk).
318
356
 
319
357
  ## Copy a Share Link
320
358
 
@@ -335,6 +373,16 @@ reuse the organization's existing copy. An unavailable share link returns `Share
335
373
  Effect applications use `Templates.create({ shareLinkSlug })` from `samva/effect/templates`.
336
374
  The CLI accepts `samva templates create --data '{"shareLinkSlug":"for-context-dev"}' --json`.
337
375
 
376
+ ## Method Names
377
+
378
+ Each method is named for its API operation. A REST `DELETE` is `remove`: `mailboxes.remove`,
379
+ `namespaces.remove`, `webhooks.remove`, `email.removeDomain`, `newsletters.domains.remove`. The
380
+ exceptions are `apiKeys.revoke`, `whatsappSetupLinks.revoke`, `campaigns.archive`,
381
+ `templates.delete`, `templates.deleteProject`, and `templateShareLinks.delete`. The identity call is `samva.whoami.get()`, listing sent mail is
382
+ `messages.list`, and sending from a mailbox is `mailboxes.sendMessage`. Hosted MCP tool names are
383
+ `<group>_<operation>` and can use a different verb for the same operation, such as
384
+ `namespaces_delete` for `namespaces.remove`.
385
+
338
386
  ## Service Surface
339
387
 
340
388
  The Promise client exposes:
@@ -410,7 +458,7 @@ error with `Effect.catchTag` does not require importing its constructor.
410
458
  Both clients retry safe operations by default:
411
459
 
412
460
  - **What retries**: reads (`GET`/`HEAD`) and requests covered by `x-idempotent` in the OpenAPI document and its optional `x-idempotent-when` condition. Both clients attach one key per logical call and reuse it across retries. Other mutations never retry.
413
- - **When**: only for `isRetryable` failures: throttling (`429`), transient server errors (including a transient `BillingProviderError`), and request-transport failures. `ValidationError`, `ConflictError`, `NotFound`, auth, and billing-limit `PaymentRequiredError` failures never retry.
461
+ - **When**: only for `isRetryable` failures: throttling (`429`), transient server errors (including a transient `BillingProviderError`), request-transport failures, and attempt timeouts. `ValidationError`, `ConflictError`, `NotFound`, auth, and billing-limit `PaymentRequiredError` failures never retry.
414
462
  - **How**: jittered exponential backoff, bounded to four attempts total. A `429` honors the server's `retryAfterSeconds` hint (capped at 60s) in place of the computed delay.
415
463
 
416
464
  `contacts.startImport` retries only `mode: "new"`. Resumes use a generation fence and never retry automatically, even with an explicit key. After an ambiguous resume response, read `contacts.getImportJob` before deciding what to do next.
@@ -429,6 +477,39 @@ program.pipe(Effect.provide(Retry.layerDisabled));
429
477
  program.pipe(Effect.provide(Retry.layer({ times: 6, while: isRetryable })));
430
478
  ```
431
479
 
480
+ ### Timeouts
481
+
482
+ Each request attempt has a 30 000 ms bound. An attempt that outlasts it is aborted and fails with
483
+ `SamvaTimeoutError`, which carries `timeoutMs`. Every retry starts a fresh timer, and a timeout
484
+ retries exactly where a transport failure would: on reads and idempotent operations, with the same
485
+ idempotency key. Set `timeoutMs` on the client or per call; a per-call `undefined` inherits the
486
+ client's value, and `null` at either level disables the bound. A value that is not a positive,
487
+ finite number of milliseconds throws a `RangeError`.
488
+
489
+ ```typescript
490
+ import { createClient, SamvaTimeoutError } from "samva";
491
+
492
+ const samva = createClient({ apiKey: process.env.SAMVA_API_KEY!, timeoutMs: 10_000 });
493
+
494
+ try {
495
+ await samva.email.listDomains({}, { timeoutMs: 60_000 });
496
+ } catch (error) {
497
+ if (error instanceof SamvaTimeoutError) console.error(`No answer in ${error.timeoutMs} ms`);
498
+ else throw error;
499
+ }
500
+ ```
501
+
502
+ `SamvaTimeoutError` extends `SamvaTransportError`. Aborting your own `signal` is not a timeout: it
503
+ rejects with a `SamvaTransportError` whose `cause` is the abort. Storage puts of oversized inline
504
+ attachments have their own bound, `uploadTimeoutMs` (default 300 000 ms, same rules), on the client
505
+ and on `email.send` and `messages.send`; a put past it fails as `MediaUploadError` caused by
506
+ `SamvaTimeoutError`. The media and send requests around the put keep `timeoutMs`.
507
+
508
+ The Effect client takes the same options on `Client.layer` and `Client.layerFetch`, `timeoutMs` per
509
+ call in each operation's options, and `uploadTimeoutMs` per call on `Email.send` and
510
+ `Messages.send`. A timed-out attempt fails with the tagged `SamvaTimeoutError` from
511
+ `samva/effect/errors`, which `isRetryable` accepts; interrupting the fiber stays an interruption.
512
+
432
513
  ### Idempotency keys
433
514
 
434
515
  Each idempotent operation generates an `Idempotency-Key` per logical call, stable across the built-in retries and distinct across calls, so a retried send never delivers twice. Pass an explicit key for cross-process deduplication (safe to replay the same request from a different machine):
@@ -440,6 +521,7 @@ const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });
440
521
 
441
522
  await samva.email.send(
442
523
  {
524
+ from: { email: "hello@yourdomain.com" },
443
525
  to: "ada@example.com",
444
526
  subject: "Your receipt",
445
527
  html: "<p>Thanks for your order.</p>",
@@ -502,6 +584,13 @@ const inspectKey = Effect.gen(function* () {
502
584
 
503
585
  The wire body and the Promise client keep plain strings; only the Effect surface is `Redacted`.
504
586
 
587
+ `apiKeys.create` and `apiKeys.rotate` return the whole key object with the secret in `key`, and the
588
+ Promise client returns it as a plain string. Destructure the secret
589
+ (`const { key: secret } = await samva.apiKeys.create({ ... })`), write it to your secret store,
590
+ and keep the response out of request logs and agent tool output. Revoke a key that was printed.
591
+ Capture the key before any redaction filter runs; a filter that blanks the response loses the only
592
+ copy.
593
+
505
594
  ## OpenAPI vendor extensions
506
595
 
507
596
  The published `openapi.json` carries machine-readable semantics on top of the standard schema, derived from the same contract annotations the Effect SDK uses (no second taxonomy):
@@ -531,6 +620,7 @@ const { contact } = await samva.contacts.findOrCreate({
531
620
  });
532
621
 
533
622
  const response = await samva.email.send({
623
+ from: { email: "hello@yourdomain.com" },
534
624
  to: [contact],
535
625
  subject: "Welcome",
536
626
  html: "<h1>Welcome to Samva</h1>",
@@ -549,6 +639,7 @@ import * as Client from "samva/effect/client";
549
639
  import * as Email from "samva/effect/email";
550
640
 
551
641
  const program = Email.send({
642
+ from: { email: "hello@yourdomain.com" },
552
643
  to: "ada@example.com",
553
644
  subject: "Welcome",
554
645
  html: "<h1>Welcome to Samva</h1>",
@@ -570,6 +661,42 @@ const response = await samva.conversations.list({
570
661
  });
571
662
  ```
572
663
 
664
+ ### Add and Verify a Domain
665
+
666
+ Email domain methods are flat on `samva.email`; only newsletter domains are nested under
667
+ `samva.newsletters.domains`. There is no `samva.email.domains`.
668
+
669
+ ```typescript
670
+ import { createClient } from "samva";
671
+
672
+ const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });
673
+
674
+ // Register the domain. The response lists the DNS records to publish in `dnsRecords`.
675
+ const domain = await samva.email.addDomain({ domain: "mail.example.com" });
676
+
677
+ // Read the last observed state, then check DNS now. Repeat after publishing the records
678
+ // until `phase` is "ready".
679
+ await samva.email.getDomainVerification({ id: domain.id });
680
+ const verification = await samva.email.advanceDomainVerification({ id: domain.id });
681
+ console.log(verification.phase);
682
+
683
+ // Receive mail on a verified domain.
684
+ await samva.email.enableReceiving({ id: domain.id, catchAll: true });
685
+ const receiving = await samva.email.getReceivingStatus({ id: domain.id });
686
+ console.log(receiving.ready, receiving.mx.expected);
687
+
688
+ // Delete the domain. Removal finishes in the background: the domain reads `deleting: true`
689
+ // until teardown completes, then reads as not found.
690
+ await samva.email.removeDomain({ id: domain.id });
691
+ ```
692
+
693
+ `enableReceiving` on a domain that is not verified returns a `ValidationError`; check verification
694
+ first. The MX record `getReceivingStatus` reports is the one to publish for inbound mail. The same
695
+ steps over REST are `POST /v1/email/domains`, `GET /v1/email/domains/{id}/verification`,
696
+ `POST /v1/email/domains/{id}/verify`, `POST /v1/email/domains/{id}/enable-receiving`,
697
+ `GET /v1/email/domains/{id}/receiving-status`, and `DELETE /v1/email/domains/{id}`; authenticate
698
+ with the `X-API-Key` header.
699
+
573
700
  ### Schedule a Message
574
701
 
575
702
  ```typescript
@@ -713,6 +840,7 @@ const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });
713
840
 
714
841
  try {
715
842
  const message = await samva.email.send({
843
+ from: { email: "hello@yourdomain.com" },
716
844
  to: "ada@example.com",
717
845
  subject: "Test",
718
846
  html: "<p>Test</p>",
@@ -733,7 +861,7 @@ try {
733
861
 
734
862
  Every ergonomic method returns its decoded success value and throws a generated `SamvaApiError`
735
863
  subclass for failures declared by OpenAPI. Network and malformed-response failures throw
736
- `SamvaTransportError`.
864
+ `SamvaTransportError`; an attempt past its `timeoutMs` throws its subclass `SamvaTimeoutError`.
737
865
 
738
866
  ### Raw response access
739
867
 
@@ -762,6 +890,7 @@ const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });
762
890
  type EmailInput = Parameters<typeof samva.email.send>[0];
763
891
 
764
892
  const input = {
893
+ from: { email: "hello@yourdomain.com" },
765
894
  to: "ada@example.com",
766
895
  subject: "Hello",
767
896
  html: "<p>Hello World</p>",