samva 0.50.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 (64) hide show
  1. package/AGENTS.md +44 -3
  2. package/README.md +136 -7
  3. package/dist/client/sdk.gen.d.ts +12 -11
  4. package/dist/client/sdk.gen.js +1399 -940
  5. package/dist/client/types.gen.d.ts +21 -10
  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/email.d.ts +17 -16
  15. package/dist/effect/errors.d.ts +1 -0
  16. package/dist/effect/errors.js +2 -1
  17. package/dist/effect/generated/api-keys.d.ts +0 -15
  18. package/dist/effect/generated/api-keys.js +1 -2
  19. package/dist/effect/generated/campaigns.d.ts +0 -62
  20. package/dist/effect/generated/campaigns.js +3 -9
  21. package/dist/effect/generated/email.d.ts +10 -3
  22. package/dist/effect/generated/email.js +3 -2
  23. package/dist/effect/generated/mailboxes.js +6 -6
  24. package/dist/effect/generated/namespaces.js +1 -1
  25. package/dist/effect/generated/policies.js +2 -2
  26. package/dist/effect/generated/scheduled-messages.d.ts +0 -26
  27. package/dist/effect/generated/scheduled-messages.js +1 -3
  28. package/dist/effect/generated/shared.d.ts +1 -0
  29. package/dist/effect/generated/shared.js +2 -1
  30. package/dist/effect/index.js +2 -1
  31. package/dist/effect/integrations.d.ts +2 -2
  32. package/dist/effect/internal/client.d.ts +19 -2
  33. package/dist/effect/internal/client.js +10 -2
  34. package/dist/effect/internal/email-sender.d.ts +4 -4
  35. package/dist/effect/internal/email-sender.js +5 -3
  36. package/dist/effect/internal/operation.d.ts +11 -0
  37. package/dist/effect/internal/operation.js +10 -6
  38. package/dist/effect/internal/send.d.ts +4 -0
  39. package/dist/effect/internal/send.js +11 -8
  40. package/dist/effect/internal/timeout.d.ts +16 -0
  41. package/dist/effect/internal/timeout.js +20 -0
  42. package/dist/effect/journeys.d.ts +152 -152
  43. package/dist/effect/mailboxes.d.ts +28 -28
  44. package/dist/effect/messages.d.ts +5 -5
  45. package/dist/effect/namespaces.d.ts +4 -4
  46. package/dist/effect/newsletter-domains.d.ts +2 -2
  47. package/dist/effect/operations.d.ts +2 -2
  48. package/dist/effect/scheduled-messages.d.ts +2 -6
  49. package/dist/effect/templates.d.ts +6 -6
  50. package/dist/effect/topics.d.ts +4 -4
  51. package/dist/effect/webhooks.d.ts +4 -4
  52. package/dist/effect/whatsapp-setup-links.d.ts +2 -2
  53. package/dist/index.js +2 -2
  54. package/dist/package.js +1 -1
  55. package/dist/promises/client.d.ts +5 -0
  56. package/dist/promises/client.js +12 -8
  57. package/dist/promises/errors.gen.d.ts +12 -1
  58. package/dist/promises/errors.gen.js +21 -2
  59. package/dist/promises/index.js +2 -2
  60. package/dist/promises/request.d.ts +31 -2
  61. package/dist/promises/request.js +42 -7
  62. package/dist/request-policy.d.ts +9 -0
  63. package/dist/request-policy.js +16 -1
  64. package/package.json +2 -2
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>",
@@ -9,6 +9,8 @@ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends
9
9
  client?: Client | undefined;
10
10
  idempotencyKey?: string | undefined;
11
11
  maxRetries?: number | undefined;
12
+ /** Milliseconds each attempt may take; `null` disables the bound, `undefined` inherits the client's. */
13
+ timeoutMs?: number | null | undefined;
12
14
  /**
13
15
  * You can pass arbitrary values through the `meta` object. This can be
14
16
  * used to access values that aren't defined as part of the SDK function.
@@ -511,7 +513,7 @@ export declare class Email {
511
513
  /**
512
514
  * Remove a sending domain
513
515
  *
514
- * Permanently deletes a sending domain from the organization.
516
+ * Permanently deletes a sending domain from the organization. Removal is asynchronous: a `200` means its teardown was accepted. The domain stays listed with `deleting: true` and sends nothing until teardown finishes, then reads as `404`. A repeat call while teardown runs answers `200` again; once it finishes, a `404` means the domain is gone.
515
517
  */
516
518
  static removeDomain<ThrowOnError extends boolean = false>(parameters: {
517
519
  id: EmailDomainId;
@@ -569,7 +571,6 @@ export declare class Email {
569
571
  */
570
572
  static enableReceiving<ThrowOnError extends boolean = false>(parameters: {
571
573
  id: EmailDomainId;
572
- domain: string;
573
574
  catchAll?: boolean | null | undefined;
574
575
  endpointId?: WebhookEndpointId | null | undefined;
575
576
  addresses?: Array<string> | null | undefined;
@@ -4033,7 +4034,7 @@ export declare class Mailboxes {
4033
4034
  /**
4034
4035
  * List threads in a mailbox
4035
4036
  *
4036
- * Returns thread summaries. With `q`, semantic and keyword search returns up to 100 best-matching threads in relevance order across cursor pages. It searches subjects, participants, message text including quoted history, and attachment filenames, not attachment contents. New mail can take a few seconds to become searchable. Other filters narrow the searchable set. Without `q`, threads use most recent activity first; `after` and `before` filter by last activity for polling. Pass `nextCursor` back as `cursor` for the next page; it is null on the last page. In a list without `q`, a thread that gains activity while you page moves ahead of the cursor, so a walk lists each thread at most once.
4037
+ * Returns thread summaries. With `q`, semantic and keyword search returns up to 100 best-matching threads in relevance order across cursor pages. It searches subjects, participants, message text including quoted history, and attachment filenames, not attachment contents. New mail can take a few seconds to become searchable. Other filters narrow the searchable set. Without `q`, threads use most recent activity first; `after` and `before` filter by last activity for polling. Pass `nextCursor` back as `cursor` for the next page; it is null on the last page. In a list without `q`, a thread that gains activity while you page moves ahead of the cursor, so a walk lists each thread at most once. Omit `folder` to list every folder. A thread's folder is set when it is created and does not move on later replies: a thread a send started stays in `sent`, so find replies with `unread: true` and no `folder`.
4037
4038
  */
4038
4039
  static listThreads<ThrowOnError extends boolean = false>(parameters: {
4039
4040
  id: MailboxId;
@@ -4286,7 +4287,7 @@ export declare class Mailboxes {
4286
4287
  /**
4287
4288
  * Discard held malware
4288
4289
  *
4289
- * Permanently removes isolated malware from the mailbox's held list. Publishes one `mailbox.message.discarded` event. Retrying returns the same result and publishes nothing. Delete readable Spam through the thread delete endpoint. Only a person with `spam.discard` can discard held mail.
4290
+ * Permanently removes isolated malware from the mailbox's held list. Publishes one `mailbox.message.discarded` event. Retrying returns the same result and publishes nothing. Delete readable Spam through the thread delete endpoint. Only a person signed in to Samva with `spam.discard` can discard held mail; an API key is rejected with `403`.
4290
4291
  */
4291
4292
  static discardSpamHeld<ThrowOnError extends boolean = false>(parameters: {
4292
4293
  id: MailboxId;
@@ -4441,7 +4442,7 @@ export declare class Mailboxes {
4441
4442
  /**
4442
4443
  * Cancel a mailbox send
4443
4444
  *
4444
- * Cancels a definitely unsent action and reopens its draft atomically. Only an authorized person who proposed the send or can approve actions may cancel. Accepted sends return 409 with their winning receipt and cannot be withdrawn. An uncertain send requires reconciliation and cannot be cancelled as unsent. Cancelling a send held for approval records `resolution.outcome: cancelled` and publishes one `mailbox.action.resolved` event.
4445
+ * Cancels a definitely unsent action and reopens its draft atomically. Only an authorized person who proposed the send or can approve actions may cancel; an API key is rejected with `403`, even one with full access. Accepted sends return 409 with their winning receipt and cannot be withdrawn. An uncertain send requires reconciliation and cannot be cancelled as unsent. Cancelling a send held for approval records `resolution.outcome: cancelled` and publishes one `mailbox.action.resolved` event.
4445
4446
  */
4446
4447
  static cancelAction<ThrowOnError extends boolean = false>(parameters: {
4447
4448
  id: MailboxId;
@@ -4450,7 +4451,7 @@ export declare class Mailboxes {
4450
4451
  /**
4451
4452
  * Resume a mailbox send
4452
4453
  *
4453
- * Resumes the same eligible action while preserving its content, message identity, existing retry delays and original deadline. A queued action can resume while cleanup from an ended send attempt waits. A send attempt that is still running or whose status is unknown cannot be retried. Only an authorized person who proposed the send or can approve actions may retry. Automatic waits need no manual Retry. This does not grant new approval or resubmit an accepted or uncertain send.
4454
+ * Resumes the same eligible action while preserving its content, message identity, existing retry delays and original deadline. A queued action can resume while cleanup from an ended send attempt waits. A send attempt that is still running or whose status is unknown cannot be retried. Only an authorized person who proposed the send or can approve actions may retry; an API key is rejected with `403`, even one with full access. Automatic waits need no manual Retry. This does not grant new approval or resubmit an accepted or uncertain send.
4454
4455
  */
4455
4456
  static retryAction<ThrowOnError extends boolean = false>(parameters: {
4456
4457
  id: MailboxId;
@@ -4459,7 +4460,7 @@ export declare class Mailboxes {
4459
4460
  /**
4460
4461
  * Approve a mailbox action
4461
4462
  *
4462
- * Records approval of a send and returns 202 while it is pending. A send is queued for automatic retry within 15 minutes of approval; repeating approval does not extend this deadline. Accepted, completed, and notSent replays return 200. No expiry applies before approval. Only a person signed in or through OAuth may approve, and never the proposer. Non-send approvals execute synchronously and return 200 with their own execution states. Set `always: true` to add an actor-specific rule allowing matching future actions, subject to policy floors and guards. Remembering an allowance for a hosted agent or API key requires an organization owner or admin; for a hosted agent's integration tool call it lets that tool run without approval for every agent, which only the organization owner may do. A held action's `alwaysAllow` says who may and whether the caller can. A hand-off cannot be always allowed. The action's `resolution` names the approver; approving a held send publishes one `mailbox.action.resolved` event.
4463
+ * Records approval of a send and returns 202 while it is pending. A send is queued for automatic retry within 15 minutes of approval; repeating approval does not extend this deadline. Accepted, completed, and notSent replays return 200. No expiry applies before approval. Only a person signed in or through OAuth may approve, and never the proposer; an API key is rejected with `403`. Non-send approvals execute synchronously and return 200 with their own execution states. Set `always: true` to add an actor-specific rule allowing matching future actions, subject to policy floors and guards. Remembering an allowance for a hosted agent or API key requires an organization owner or admin; for a hosted agent's integration tool call it lets that tool run without approval for every agent, which only the organization owner may do. A held action's `alwaysAllow` says who may and whether the caller can. A hand-off cannot be always allowed. The action's `resolution` names the approver; approving a held send publishes one `mailbox.action.resolved` event.
4463
4464
  */
4464
4465
  static approveAction<ThrowOnError extends boolean = false>(parameters: {
4465
4466
  id: MailboxId;
@@ -4474,7 +4475,7 @@ export declare class Mailboxes {
4474
4475
  /**
4475
4476
  * Deny a mailbox action
4476
4477
  *
4477
- * Denies an action waiting for approval with a reason and returns it without executing it. Only a person signed in or through OAuth may deny, and never the one who proposed it. The action's `resolution` records the denier and reason; denying a held send publishes one `mailbox.action.resolved` event.
4478
+ * Denies an action waiting for approval with a reason and returns it without executing it. Only a person signed in or through OAuth may deny, and never the one who proposed it; an API key is rejected with `403`. The action's `resolution` records the denier and reason; denying a held send publishes one `mailbox.action.resolved` event.
4478
4479
  */
4479
4480
  static denyAction<ThrowOnError extends boolean = false>(parameters: {
4480
4481
  id: MailboxId;
@@ -4572,7 +4573,7 @@ export declare class Policies {
4572
4573
  /**
4573
4574
  * Clear decision rules
4574
4575
  *
4575
- * Clears this scope's rules and instructions only when ifVersion matches, and returns the next version. The stored version is retained. Other scopes and subject defaults continue to apply.
4576
+ * Clears this scope's rules and instructions only when ifVersion matches, and returns the next version. The stored version is retained. Other scopes and subject defaults continue to apply. An API key with organization-wide reach may clear another key's policy; clearing its own key, a mailbox that holds rules, the organization, or an agent returns 403.
4576
4577
  */
4577
4578
  static deletePolicy<ThrowOnError extends boolean = false>(parameters: {
4578
4579
  kind: "organization" | "mailbox" | "apiKey" | "agent";
@@ -4591,7 +4592,7 @@ export declare class Policies {
4591
4592
  /**
4592
4593
  * Set decision rules
4593
4594
  *
4594
- * Replaces this scope's rules and instructions only when ifVersion matches its current version. A stale version returns a conflict. More specific scopes replace defaults; atLeast floors remain binding. Identical rule matches in one scope are rejected.
4595
+ * Replaces this scope's rules and instructions only when ifVersion matches its current version. A stale version returns a conflict. More specific scopes replace defaults; atLeast floors remain binding. Identical rule matches in one scope are rejected. An API key changes policy only with organization-wide reach (full access, no namespace, owned by an organization owner or admin): it may set any rule on another key, and on a mailbox it can configure only add atLeast person or never floors or decide: never rules while keeping every existing rule. Its own key, the organization, and agents return 403; a person changes those.
4595
4596
  */
4596
4597
  static setPolicy<ThrowOnError extends boolean = false>(parameters: {
4597
4598
  kind: "organization" | "mailbox" | "apiKey" | "agent";
@@ -4629,7 +4630,7 @@ export declare class Namespaces {
4629
4630
  /**
4630
4631
  * Delete a namespace
4631
4632
  *
4632
- * Deletes an empty namespace. A namespace that still holds anything conflicts, and the error names and counts each resource kind that remains. Delete each, or return it to organization level with `DELETE /v1/namespaces/{id}/resources/{type}/{resourceId}`; mailboxes, keys, and webhook endpoints cannot move and are deleted. Messages keep the namespace they ran in.
4633
+ * Deletes an empty namespace. A namespace that still holds anything conflicts, and the error names and counts each resource kind that remains. Delete each, or return it to organization level with `DELETE /v1/namespaces/{id}/resources/{type}/{resourceId}`; mailboxes and webhook endpoints cannot move and are deleted. Only an enabled API key holds the namespace: revoke the namespace's keys, and deletion retires and detaches each one, keeping its record. Deletion also deletes the namespace's portal links and WhatsApp setup links, so their URLs stop working. Messages keep the namespace they ran in.
4633
4634
  */
4634
4635
  static remove<ThrowOnError extends boolean = false>(parameters: {
4635
4636
  id: NamespaceId;