@primitivedotdev/sdk 0.12.0 → 0.14.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.
@@ -560,6 +560,18 @@ type EmailSummary = {
560
560
  domain_id?: string | null;
561
561
  org_id?: string | null;
562
562
  status: 'pending' | 'accepted' | 'completed' | 'rejected';
563
+ /**
564
+ * SMTP envelope sender (return-path) the inbound mail server
565
+ * accepted. For most legitimate mail this equals the bare
566
+ * address in the From header; for mailing lists, bounce
567
+ * handlers, and forwarders it is typically the bounce address
568
+ * rather than the human-visible sender.
569
+ *
570
+ * For the parsed From-header value (with display name handling
571
+ * and a sender-fallback when the header is unparseable), GET
572
+ * the email by id and use `from_email`.
573
+ *
574
+ */
563
575
  sender: string;
564
576
  recipient: string;
565
577
  subject?: string | null;
@@ -576,6 +588,20 @@ type EmailDetail = {
576
588
  message_id?: string | null;
577
589
  domain_id?: string | null;
578
590
  org_id?: string | null;
591
+ /**
592
+ * SMTP envelope sender (return-path) the inbound mail server
593
+ * accepted. Same value as `smtp_mail_from`; both fields exist
594
+ * so protocol-aware tooling can use whichever name it expects.
595
+ *
596
+ * For most legitimate mail this equals `from_email`; for
597
+ * mailing lists, bounce handlers, and forwarders it is
598
+ * typically the bounce-handling address rather than the
599
+ * human-visible sender.
600
+ *
601
+ * **For the canonical "who sent this email" value, use
602
+ * `from_email`.**
603
+ *
604
+ */
579
605
  sender: string;
580
606
  recipient: string;
581
607
  subject?: string | null;
@@ -602,13 +628,43 @@ type EmailDetail = {
602
628
  webhook_last_error?: string | null;
603
629
  webhook_fired_at?: string | null;
604
630
  smtp_helo?: string | null;
631
+ /**
632
+ * SMTP envelope MAIL FROM (return-path), as accepted by the
633
+ * inbound mail server. Same value as `sender`; both fields
634
+ * exist so protocol-aware tooling can use whichever name it
635
+ * expects.
636
+ *
637
+ * For the canonical "who sent this email" value (display name
638
+ * stripped, From-header preferred), use `from_email`.
639
+ *
640
+ */
605
641
  smtp_mail_from?: string | null;
606
642
  smtp_rcpt_to?: Array<string> | null;
643
+ /**
644
+ * Raw `From:` header from the message body, including any
645
+ * display name (e.g. `"Alice Example" <alice@example.com>`).
646
+ * Use this when you need the display name for rendering.
647
+ *
648
+ * For the bare email address (display name stripped), use
649
+ * `from_email`.
650
+ *
651
+ */
607
652
  from_header?: string | null;
608
653
  content_discarded_at?: string | null;
609
654
  content_discarded_by_delivery_id?: string | null;
610
655
  /**
611
- * Parsed from address (from_header or sender fallback)
656
+ * Bare email address parsed from the `From:` header, with
657
+ * display name stripped (e.g. `alice@example.com`). Falls
658
+ * back to `sender` (the SMTP envelope MAIL FROM) when the
659
+ * `From:` header cannot be parsed.
660
+ *
661
+ * **This is the canonical "who sent this email" field for
662
+ * most use cases**, including comparing against allowlists,
663
+ * routing replies, or displaying the sender to a user. Use
664
+ * `from_header` when you specifically need the display name,
665
+ * or `sender`/`smtp_mail_from` when you need the SMTP
666
+ * envelope value (e.g. to follow a bounce).
667
+ *
612
668
  */
613
669
  from_email: string;
614
670
  /**
@@ -690,8 +746,220 @@ type SendMailInput = {
690
746
  */
691
747
  wait_timeout_ms?: number;
692
748
  };
693
- type SentEmailStatus = 'queued' | 'submitted_to_agent' | 'agent_failed' | 'unknown' | 'delivered' | 'bounced' | 'deferred' | 'wait_timeout';
749
+ /**
750
+ * Lifecycle status of a sent_emails row. Possible values:
751
+ *
752
+ * - `queued`: pre-call INSERT; the outbound agent has not
753
+ * yet replied.
754
+ * - `submitted_to_agent`: agent accepted; `queue_id` is set.
755
+ * - `agent_failed`: agent rejected; `error_code` and
756
+ * `error_message` carry the reason.
757
+ * - `gate_denied`: a recipient-scope gate denied the send;
758
+ * the agent was never called. The `gates` array carries
759
+ * the denial detail. /send-mail returns 403 in this case
760
+ * so callers see the denial synchronously; /sent-emails
761
+ * additionally records the row for historical lookup,
762
+ * which is when this status appears in a listing.
763
+ * - `unknown`: terminal indeterminate; the on-box log
764
+ * poller couldn't classify the receiver's response.
765
+ * - `delivered` / `bounced` / `deferred` / `wait_timeout`:
766
+ * terminal delivery outcomes (see DeliveryStatus).
767
+ *
768
+ */
769
+ type SentEmailStatus = 'queued' | 'submitted_to_agent' | 'agent_failed' | 'gate_denied' | 'unknown' | 'delivered' | 'bounced' | 'deferred' | 'wait_timeout';
694
770
  type DeliveryStatus = 'delivered' | 'bounced' | 'deferred' | 'wait_timeout';
771
+ /**
772
+ * List-row projection of a sent-email record. Drops
773
+ * `body_text` and `body_html` to keep paginated responses
774
+ * small; fetch /sent-emails/{id} for the full record with
775
+ * bodies.
776
+ *
777
+ */
778
+ type SentEmailSummary = {
779
+ id: string;
780
+ status: SentEmailStatus;
781
+ /**
782
+ * Timestamp of the most recent status transition.
783
+ * Polling clients should treat `status='queued'` AND
784
+ * `status_changed_at` older than 5 minutes as
785
+ * "stuck-queued" (the post-tx UPDATE failed and the
786
+ * actual delivery state is recoverable from on-box logs
787
+ * via `queue_id` when populated, or `request_id`).
788
+ *
789
+ */
790
+ status_changed_at: string;
791
+ created_at: string;
792
+ updated_at: string;
793
+ /**
794
+ * Effective idempotency key used for this send. If the
795
+ * caller passed the `Idempotency-Key` header, this is
796
+ * that value; otherwise it's a server-derived hash of
797
+ * the canonical request payload.
798
+ *
799
+ */
800
+ client_idempotency_key?: string | null;
801
+ /**
802
+ * Stable hash of the canonical send payload.
803
+ */
804
+ content_hash: string;
805
+ /**
806
+ * Raw `From:` header as sent on the wire, including any
807
+ * display name (e.g. `"Acme Support" <agent@acme.test>`).
808
+ *
809
+ */
810
+ from_header: string;
811
+ /**
812
+ * Bare email address parsed from `from_header`.
813
+ */
814
+ from_address: string;
815
+ /**
816
+ * Raw `To:` header as sent on the wire, including any
817
+ * display name.
818
+ *
819
+ */
820
+ to_header: string;
821
+ /**
822
+ * Bare email address parsed from `to_header`.
823
+ */
824
+ to_address: string;
825
+ subject: string;
826
+ /**
827
+ * Total UTF-8 byte length of `body_text` + `body_html`.
828
+ * Surfaced on the list endpoint so callers can see "this
829
+ * row has a 4MB body" without fetching it.
830
+ *
831
+ */
832
+ body_size_bytes: number;
833
+ /**
834
+ * Timestamp at which the bodies were discarded by an
835
+ * entitlement-driven retention policy. Null when bodies
836
+ * are still present. The detail endpoint returns
837
+ * null-valued `body_text`/`body_html` for discarded rows.
838
+ *
839
+ */
840
+ content_discarded_at?: string | null;
841
+ /**
842
+ * Wire-level Message-ID assigned to the outbound message
843
+ * (RFC 5322). Null on rows that never reached signing
844
+ * (queued, gate_denied, agent_failed before signing).
845
+ *
846
+ */
847
+ message_id?: string | null;
848
+ /**
849
+ * Wire-level In-Reply-To header value, when this send
850
+ * was a reply.
851
+ *
852
+ */
853
+ in_reply_to?: string | null;
854
+ /**
855
+ * Wire-level References header value, when this send
856
+ * was a reply.
857
+ *
858
+ */
859
+ email_references?: string | null;
860
+ /**
861
+ * Reference to the inbound `emails.id` that this send
862
+ * replied to, when known. Populated when the caller used
863
+ * /emails/{id}/reply or when /send-mail's `in_reply_to`
864
+ * matched a stored inbound message_id in the same org.
865
+ *
866
+ */
867
+ in_reply_to_email_id?: string | null;
868
+ /**
869
+ * Message identifier assigned by Primitive's outbound
870
+ * relay once the agent accepts the message. Null on
871
+ * queued, gate_denied, and agent_failed rows.
872
+ *
873
+ */
874
+ queue_id?: string | null;
875
+ /**
876
+ * Receiver's 3-digit SMTP code (e.g. 250, 550, 451).
877
+ * Populated on terminal delivery statuses; may be null
878
+ * on a deferred where the agent never got an SMTP-level
879
+ * response (TCP refused, DNS failed, TLS handshake
880
+ * failed). `smtp_response_text` still carries Postfix's
881
+ * descriptive text in those cases.
882
+ *
883
+ */
884
+ smtp_response_code?: number | null;
885
+ /**
886
+ * Free-form text portion of the receiver's SMTP
887
+ * response. The most useful debugging signal on a
888
+ * `bounced` or `deferred` row.
889
+ *
890
+ */
891
+ smtp_response_text?: string | null;
892
+ /**
893
+ * RFC 3463 enhanced status code (e.g. `5.1.1` for "Bad
894
+ * destination mailbox address"). Distinct from
895
+ * `smtp_response_code`: the basic 3-digit code is coarse
896
+ * (550 = "permanent failure"), the enhanced code is
897
+ * finer-grained.
898
+ *
899
+ */
900
+ smtp_enhanced_status_code?: string | null;
901
+ /**
902
+ * DKIM selector used to sign the outbound message.
903
+ * Public DNS data; useful for diagnosing why a downstream
904
+ * verifier rejected the signature.
905
+ *
906
+ */
907
+ dkim_selector?: string | null;
908
+ /**
909
+ * DKIM signing domain.
910
+ */
911
+ dkim_domain?: string | null;
912
+ /**
913
+ * Stable public error code on `agent_failed` rows. The
914
+ * agent's internal codes are remapped to a stable public
915
+ * taxonomy (see `publicAgentError` in the server) so this
916
+ * field is safe to branch on across agent versions.
917
+ *
918
+ */
919
+ error_code?: string | null;
920
+ /**
921
+ * Free-form error message accompanying `error_code`.
922
+ */
923
+ error_message?: string | null;
924
+ /**
925
+ * Gate-denial detail on `gate_denied` rows. Mirrors the
926
+ * synchronous /send-mail 403 contract so a caller's
927
+ * GateDenial handler is the same across live denies and
928
+ * historical lookups. Null on every other status.
929
+ *
930
+ */
931
+ gates?: Array<GateDenial> | null;
932
+ /**
933
+ * Server-issued request identifier from the original
934
+ * /send-mail call. Surfaced as the `X-Request-Id`
935
+ * response header on the live send and recorded here
936
+ * for support escalation.
937
+ *
938
+ */
939
+ request_id?: string | null;
940
+ };
941
+ /**
942
+ * Full sent-email record, including `body_text` and
943
+ * `body_html`. Returned by /sent-emails/{id}.
944
+ *
945
+ */
946
+ type SentEmailDetail = SentEmailSummary & {
947
+ /**
948
+ * Plain-text body sent on the wire. Null when the
949
+ * send carried only an HTML body, or when bodies have
950
+ * been discarded post-send (`content_discarded_at`
951
+ * set).
952
+ *
953
+ */
954
+ body_text?: string | null;
955
+ /**
956
+ * HTML body sent on the wire. Null when the send
957
+ * carried only a plain-text body, or when bodies
958
+ * have been discarded post-send.
959
+ *
960
+ */
961
+ body_html?: string | null;
962
+ };
695
963
  /**
696
964
  * Body shape for `/emails/{id}/reply`. Intentionally narrow:
697
965
  * recipients (`to`), subject, and threading headers
@@ -736,6 +1004,21 @@ type SendMailResult = {
736
1004
  */
737
1005
  id: string;
738
1006
  status: SentEmailStatus;
1007
+ /**
1008
+ * Bare from-address actually written on the wire. Echoed
1009
+ * on every success branch so callers can confirm what
1010
+ * went out, particularly useful for the /emails/{id}/reply
1011
+ * path where `from` is server-derived from the inbound's
1012
+ * recipient when the caller doesn't override.
1013
+ *
1014
+ * For sends where the caller passed a from-header that
1015
+ * included a display name (e.g. `"Acme Support" <support@acme.test>`),
1016
+ * this field is the parsed bare address (`support@acme.test`).
1017
+ * The display name was sent on the wire intact; this field
1018
+ * just makes the address easy to compare against allowlists.
1019
+ *
1020
+ */
1021
+ from: string;
739
1022
  /**
740
1023
  * Message identifier assigned by Primitive's outbound relay, when available.
741
1024
  */
@@ -779,6 +1062,135 @@ type SendMailResult = {
779
1062
  */
780
1063
  idempotent_replay: boolean;
781
1064
  };
1065
+ /**
1066
+ * One recipient-scope rule describing a destination the caller
1067
+ * may send to. Discriminated on `type`. Each rule carries a
1068
+ * human-prose `description` field intended for display.
1069
+ *
1070
+ * Rule kinds are stable within an SDK release. A response
1071
+ * containing a `type` value not enumerated in this schema
1072
+ * means the server is running a newer version than the SDK;
1073
+ * upgrade the SDK to the release that matches the server's
1074
+ * schema. Strict-parsing SDKs (Go, Python) will raise a
1075
+ * decode error in that case rather than silently dropping
1076
+ * the unknown rule, since silent drops would let an outbound
1077
+ * agent reason from an incomplete view of its own permissions.
1078
+ *
1079
+ */
1080
+ type SendPermissionRule = ({
1081
+ type: 'any_recipient';
1082
+ } & SendPermissionAnyRecipient) | ({
1083
+ type: 'managed_zone';
1084
+ } & SendPermissionManagedZone) | ({
1085
+ type: 'your_domain';
1086
+ } & SendPermissionYourDomain) | ({
1087
+ type: 'address';
1088
+ } & SendPermissionAddress);
1089
+ /**
1090
+ * The caller can send to any recipient. When this rule is
1091
+ * present, every other rule in the response is redundant.
1092
+ *
1093
+ */
1094
+ type SendPermissionAnyRecipient = {
1095
+ type: 'any_recipient';
1096
+ /**
1097
+ * Human-prose summary of the rule.
1098
+ */
1099
+ description: string;
1100
+ };
1101
+ /**
1102
+ * The caller can send to any address at the named
1103
+ * Primitive-managed zone. Always emitted (no entitlement
1104
+ * required) because Primitive owns the zone and every mailbox
1105
+ * belongs to a Primitive customer by construction.
1106
+ *
1107
+ */
1108
+ type SendPermissionManagedZone = {
1109
+ type: 'managed_zone';
1110
+ /**
1111
+ * The managed apex domain. Sends are accepted to any
1112
+ * address at the apex itself or any subdomain (e.g.
1113
+ * `alice@primitive.email` and `alice@acme.primitive.email`
1114
+ * both match the `primitive.email` zone rule).
1115
+ *
1116
+ */
1117
+ zone: string;
1118
+ /**
1119
+ * Human-prose summary of the rule.
1120
+ */
1121
+ description: string;
1122
+ };
1123
+ /**
1124
+ * The caller can send to any address at one of their own
1125
+ * verified outbound domains. Emitted once per active row in
1126
+ * the org's `domains` table.
1127
+ *
1128
+ */
1129
+ type SendPermissionYourDomain = {
1130
+ type: 'your_domain';
1131
+ /**
1132
+ * A verified outbound domain owned by the caller's org.
1133
+ */
1134
+ domain: string;
1135
+ /**
1136
+ * Human-prose summary of the rule.
1137
+ */
1138
+ description: string;
1139
+ };
1140
+ /**
1141
+ * The caller can send to a specific address that has
1142
+ * authenticated inbound mail to the org. Emitted once per row
1143
+ * in the org's `known_send_addresses` table, capped at
1144
+ * `meta.address_cap`.
1145
+ *
1146
+ */
1147
+ type SendPermissionAddress = {
1148
+ type: 'address';
1149
+ /**
1150
+ * The bare email address this rule grants sends to.
1151
+ */
1152
+ address: string;
1153
+ /**
1154
+ * Most recent inbound email from this address that
1155
+ * authenticated successfully (DMARC pass + DKIM/SPF
1156
+ * alignment). Updated on each new authenticated receipt.
1157
+ *
1158
+ */
1159
+ last_received_at: string;
1160
+ /**
1161
+ * Total number of authenticated inbound emails from this
1162
+ * address. Increments only when `last_received_at` advances.
1163
+ *
1164
+ */
1165
+ received_count: number;
1166
+ /**
1167
+ * Human-prose summary of the rule.
1168
+ */
1169
+ description: string;
1170
+ };
1171
+ /**
1172
+ * Response metadata for /send-permissions. The `address_cap`
1173
+ * bounds the size of the `address` rule subset; orgs with more
1174
+ * than `address_cap` known addresses almost always also hold a
1175
+ * broader rule type (`any_recipient` or `your_domain`), so the
1176
+ * cap is a response-size bound rather than a meaningful
1177
+ * product limit.
1178
+ *
1179
+ */
1180
+ type SendPermissionsMeta = {
1181
+ /**
1182
+ * Maximum number of `address` rules included in `data`.
1183
+ */
1184
+ address_cap: number;
1185
+ /**
1186
+ * True when the org has more than `address_cap` known
1187
+ * addresses and the list was truncated. False when every
1188
+ * known address is represented or when the org holds no
1189
+ * address rules at all.
1190
+ *
1191
+ */
1192
+ truncated: boolean;
1193
+ };
782
1194
  type Endpoint = {
783
1195
  id: string;
784
1196
  org_id: string;
@@ -1926,6 +2338,29 @@ type ReplayDeliveryResponses = {
1926
2338
  };
1927
2339
  };
1928
2340
  type ReplayDeliveryResponse = ReplayDeliveryResponses[keyof ReplayDeliveryResponses];
2341
+ type GetSendPermissionsData = {
2342
+ body?: never;
2343
+ path?: never;
2344
+ query?: never;
2345
+ url: '/send-permissions';
2346
+ };
2347
+ type GetSendPermissionsErrors = {
2348
+ /**
2349
+ * Invalid or missing API key
2350
+ */
2351
+ 401: ErrorResponse;
2352
+ };
2353
+ type GetSendPermissionsError = GetSendPermissionsErrors[keyof GetSendPermissionsErrors];
2354
+ type GetSendPermissionsResponses = {
2355
+ /**
2356
+ * Send-permission rules for the caller's org
2357
+ */
2358
+ 200: SuccessEnvelope & {
2359
+ data: Array<SendPermissionRule>;
2360
+ meta: SendPermissionsMeta;
2361
+ };
2362
+ };
2363
+ type GetSendPermissionsResponse = GetSendPermissionsResponses[keyof GetSendPermissionsResponses];
1929
2364
  type SendEmailData = {
1930
2365
  body: SendMailInput;
1931
2366
  headers?: {
@@ -1981,8 +2416,115 @@ type SendEmailResponses = {
1981
2416
  };
1982
2417
  };
1983
2418
  type SendEmailResponse = SendEmailResponses[keyof SendEmailResponses];
2419
+ type ListSentEmailsData = {
2420
+ body?: never;
2421
+ path?: never;
2422
+ query?: {
2423
+ /**
2424
+ * Pagination cursor from a previous response's `meta.cursor` field.
2425
+ * Format: `{ISO-datetime}|{id}`
2426
+ *
2427
+ */
2428
+ cursor?: string;
2429
+ /**
2430
+ * Number of results per page
2431
+ */
2432
+ limit?: number;
2433
+ /**
2434
+ * Filter to rows in this status. Useful for polling
2435
+ * queued rows that haven't transitioned, auditing
2436
+ * gate-denied attempts, or listing only successful
2437
+ * deliveries.
2438
+ *
2439
+ */
2440
+ status?: SentEmailStatus;
2441
+ /**
2442
+ * Filter to the row matching a specific server-issued
2443
+ * `request_id`. The /send-mail response surfaces
2444
+ * `request_id` on every send; this lookup lets the
2445
+ * caller find the historical row for a given live call
2446
+ * without remembering its `id`.
2447
+ *
2448
+ */
2449
+ request_id?: string;
2450
+ /**
2451
+ * Filter to rows with the given `client_idempotency_key`.
2452
+ * Multiple rows can share a key (a retry that hit the
2453
+ * idempotent-replay path returns the same row, but a
2454
+ * retry with a DIFFERENT canonical payload under the
2455
+ * same key is rejected by /send-mail before the row is
2456
+ * written, so duplicates are bounded).
2457
+ *
2458
+ */
2459
+ idempotency_key?: string;
2460
+ /**
2461
+ * Inclusive lower bound on `created_at`.
2462
+ */
2463
+ date_from?: string;
2464
+ /**
2465
+ * Inclusive upper bound on `created_at`.
2466
+ */
2467
+ date_to?: string;
2468
+ };
2469
+ url: '/sent-emails';
2470
+ };
2471
+ type ListSentEmailsErrors = {
2472
+ /**
2473
+ * Invalid request parameters
2474
+ */
2475
+ 400: ErrorResponse;
2476
+ /**
2477
+ * Invalid or missing API key
2478
+ */
2479
+ 401: ErrorResponse;
2480
+ };
2481
+ type ListSentEmailsError = ListSentEmailsErrors[keyof ListSentEmailsErrors];
2482
+ type ListSentEmailsResponses = {
2483
+ /**
2484
+ * Page of sent-email summaries
2485
+ */
2486
+ 200: ListEnvelope & {
2487
+ data?: Array<SentEmailSummary>;
2488
+ };
2489
+ };
2490
+ type ListSentEmailsResponse = ListSentEmailsResponses[keyof ListSentEmailsResponses];
2491
+ type GetSentEmailData = {
2492
+ body?: never;
2493
+ path: {
2494
+ /**
2495
+ * Resource UUID
2496
+ */
2497
+ id: string;
2498
+ };
2499
+ query?: never;
2500
+ url: '/sent-emails/{id}';
2501
+ };
2502
+ type GetSentEmailErrors = {
2503
+ /**
2504
+ * Invalid request parameters
2505
+ */
2506
+ 400: ErrorResponse;
2507
+ /**
2508
+ * Invalid or missing API key
2509
+ */
2510
+ 401: ErrorResponse;
2511
+ /**
2512
+ * Resource not found
2513
+ */
2514
+ 404: ErrorResponse;
2515
+ };
2516
+ type GetSentEmailError = GetSentEmailErrors[keyof GetSentEmailErrors];
2517
+ type GetSentEmailResponses = {
2518
+ /**
2519
+ * Sent-email detail
2520
+ */
2521
+ 200: SuccessEnvelope & {
2522
+ data?: SentEmailDetail;
2523
+ };
2524
+ };
2525
+ type GetSentEmailResponse = GetSentEmailResponses[keyof GetSentEmailResponses];
1984
2526
  declare namespace sdk_gen_d_exports {
1985
- export { Options, addDomain, createEndpoint, createFilter, deleteDomain, deleteEmail, deleteEndpoint, deleteFilter, downloadAttachments, downloadRawEmail, getAccount, getEmail, getStorageStats, getWebhookSecret, listDeliveries, listDomains, listEmails, listEndpoints, listFilters, replayDelivery, replayEmailWebhooks, replyToEmail, rotateWebhookSecret, sendEmail, testEndpoint, updateAccount, updateDomain, updateEndpoint, updateFilter, verifyDomain };
2527
+ export { Options, addDomain, createEndpoint, createFilter, deleteDomain, deleteEmail, deleteEndpoint, deleteFilter, downloadAttachments, downloadRawEmail, getAccount, getEmail, getSendPermissions, getSentEmail, getStorageStats, getWebhookSecret, listDeliveries, listDomains, listEmails, listEndpoints, listFilters, listSentEmails, replayDelivery, replayEmailWebhooks, replyToEmail, rotateWebhookSecret, sendEmail, testEndpoint, updateAccount, updateDomain, updateEndpoint, updateFilter, verifyDomain };
1986
2528
  }
1987
2529
  type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options$1<TData, ThrowOnError, TResponse> & {
1988
2530
  /**
@@ -2067,11 +2609,15 @@ declare const updateDomain: <ThrowOnError extends boolean = false>(options: Opti
2067
2609
  */
2068
2610
  declare const verifyDomain: <ThrowOnError extends boolean = false>(options: Options<VerifyDomainData, ThrowOnError>) => RequestResult<VerifyDomainResponses, VerifyDomainErrors, ThrowOnError, "fields">;
2069
2611
  /**
2070
- * List emails
2612
+ * List inbound emails
2071
2613
  *
2072
- * Returns a paginated list of received emails. Supports filtering by
2073
- * domain, status, date range, and free-text search across subject,
2074
- * sender, and recipient fields.
2614
+ * Returns a paginated list of INBOUND emails received at your
2615
+ * verified domains. Outbound messages sent via /send-mail are not
2616
+ * included; this endpoint is the inbox view, not a unified
2617
+ * send/receive history.
2618
+ *
2619
+ * Supports filtering by domain, status, date range, and free-text
2620
+ * search across subject, sender, and recipient fields.
2075
2621
  *
2076
2622
  */
2077
2623
  declare const listEmails: <ThrowOnError extends boolean = false>(options?: Options<ListEmailsData, ThrowOnError>) => RequestResult<ListEmailsResponses, ListEmailsErrors, ThrowOnError, "fields">;
@@ -2216,6 +2762,42 @@ declare const listDeliveries: <ThrowOnError extends boolean = false>(options?: O
2216
2762
  *
2217
2763
  */
2218
2764
  declare const replayDelivery: <ThrowOnError extends boolean = false>(options: Options<ReplayDeliveryData, ThrowOnError>) => RequestResult<ReplayDeliveryResponses, ReplayDeliveryErrors, ThrowOnError, "fields">;
2765
+ /**
2766
+ * List send-permission rules
2767
+ *
2768
+ * Returns a flat list of rules describing every recipient the
2769
+ * caller may send to. Each rule has a `type`, a kind-specific
2770
+ * payload, and a human-readable `description`. If any rule
2771
+ * matches the recipient, /send-mail will accept the send under
2772
+ * the recipient-scope check.
2773
+ *
2774
+ * The endpoint is the answer to "where can I send" without
2775
+ * exposing internal entitlement names. Agents that don't
2776
+ * recognize a `type` can still read the `description` prose
2777
+ * and act on it.
2778
+ *
2779
+ * Rule kinds, ordered broadest-first so an agent can stop
2780
+ * scanning at the first match:
2781
+ *
2782
+ * 1. `any_recipient` (one entry, only when the org can send
2783
+ * anywhere): every other rule below it is redundant.
2784
+ * 2. `managed_zone` (always emitted, one per Primitive-managed
2785
+ * zone): sends to any address at *.primitive.email or
2786
+ * *.email.works always succeed; no entitlement required.
2787
+ * 3. `your_domain` (one per active verified outbound domain
2788
+ * owned by the org): sends to that domain are approved.
2789
+ * 4. `address` (one per address that has authenticated
2790
+ * inbound mail to the org, capped at `meta.address_cap`):
2791
+ * sends to that exact address are approved.
2792
+ *
2793
+ * The list is informational, not an authorization check.
2794
+ * /send-mail remains the source of truth on whether an
2795
+ * individual send will succeed (it also enforces the
2796
+ * from-address and the `send_mail` entitlement, which are
2797
+ * not recipient-scope concerns and are not represented here).
2798
+ *
2799
+ */
2800
+ declare const getSendPermissions: <ThrowOnError extends boolean = false>(options?: Options<GetSendPermissionsData, ThrowOnError>) => RequestResult<GetSendPermissionsResponses, GetSendPermissionsErrors, ThrowOnError, "fields">;
2219
2801
  /**
2220
2802
  * Send outbound email
2221
2803
  *
@@ -2225,6 +2807,41 @@ declare const replayDelivery: <ThrowOnError extends boolean = false>(options: Op
2225
2807
  *
2226
2808
  */
2227
2809
  declare const sendEmail: <ThrowOnError extends boolean = false>(options: Options<SendEmailData, ThrowOnError>) => RequestResult<SendEmailResponses, SendEmailErrors, ThrowOnError, "fields">;
2810
+ /**
2811
+ * List outbound sent emails
2812
+ *
2813
+ * Returns a paginated list of OUTBOUND emails the caller's
2814
+ * org has sent via /send-mail (and /emails/{id}/reply, which
2815
+ * forwards through /send-mail). Includes every recorded
2816
+ * attempt, including gate-denied attempts that the agent
2817
+ * never called and rows still in `queued` state.
2818
+ *
2819
+ * For inbound mail received at your verified domains, see
2820
+ * /emails. There is no unified send/receive history endpoint;
2821
+ * the two surfaces are intentionally separate because the
2822
+ * underlying tables, statuses, and lifecycle differ.
2823
+ *
2824
+ * Email bodies (`body_text`, `body_html`) are NOT included on
2825
+ * list rows so a 50-row page can't balloon into a multi-MB
2826
+ * response when sends are near the 5MB body cap. Use
2827
+ * /sent-emails/{id} to fetch a single row with bodies, or
2828
+ * cross-reference by `client_idempotency_key` if the caller
2829
+ * already has the body locally.
2830
+ *
2831
+ */
2832
+ declare const listSentEmails: <ThrowOnError extends boolean = false>(options?: Options<ListSentEmailsData, ThrowOnError>) => RequestResult<ListSentEmailsResponses, ListSentEmailsErrors, ThrowOnError, "fields">;
2833
+ /**
2834
+ * Get a sent email by id
2835
+ *
2836
+ * Returns the full sent-email record by id, including
2837
+ * `body_text` and `body_html` (omitted from the listing
2838
+ * endpoint to keep paginated responses small). Use this when
2839
+ * diagnosing a specific send, e.g. inspecting the receiver's
2840
+ * SMTP response on a `bounced` row or pulling the gate
2841
+ * denial detail on a `gate_denied` row.
2842
+ *
2843
+ */
2844
+ declare const getSentEmail: <ThrowOnError extends boolean = false>(options: Options<GetSentEmailData, ThrowOnError>) => RequestResult<GetSentEmailResponses, GetSentEmailErrors, ThrowOnError, "fields">;
2228
2845
  //#endregion
2229
2846
  //#region src/api/index.d.ts
2230
2847
  declare const DEFAULT_BASE_URL = "https://www.primitive.dev/api/v1";
@@ -2352,4 +2969,4 @@ declare function createPrimitiveClient(options?: PrimitiveClientOptions): Primit
2352
2969
  declare function client(options?: PrimitiveClientOptions): PrimitiveClient;
2353
2970
  declare const operations: typeof sdk_gen_d_exports;
2354
2971
  //#endregion
2355
- export { AddDomainResponse as $, ReplayDeliveryErrors as $n, UpdateEndpointResponses as $r, ErrorResponse as $t, getWebhookSecret as A, ListDomainsError as An, TestEndpointError as Ar, DeleteFilterData as At, sendEmail as B, ListEndpointsError as Bn, UpdateAccountResponse as Br, DownloadAttachmentsError as Bt, deleteEndpoint as C, Limit as Cn, SendEmailResponses as Cr, DeleteEmailResponse as Ct, getAccount as D, ListDeliveriesResponse as Dn, StorageStats as Dr, DeleteEndpointErrors as Dt, downloadRawEmail as E, ListDeliveriesErrors as En, SentEmailStatus as Er, DeleteEndpointError as Et, listFilters as F, ListEmailsError as Fn, UnverifiedDomain as Fr, DeliveryStatus as Ft, updateFilter as G, ListFiltersData as Gn, UpdateDomainInput as Gr, DownloadRawEmailError as Gt, updateAccount as H, ListEndpointsResponse as Hn, UpdateDomainData as Hr, DownloadAttachmentsResponse as Ht, replayDelivery as I, ListEmailsErrors as In, UpdateAccountData as Ir, DeliverySummary as It, AccountUpdated as J, ListFiltersResponse as Jn, UpdateEndpointData as Jr, DownloadRawEmailResponses as Jt, verifyDomain as K, ListFiltersError as Kn, UpdateDomainResponse as Kr, DownloadRawEmailErrors as Kt, replayEmailWebhooks as L, ListEmailsResponse as Ln, UpdateAccountError as Lr, Domain as Lt, listDomains as M, ListDomainsResponse as Mn, TestEndpointResponse as Mr, DeleteFilterErrors as Mt, listEmails as N, ListDomainsResponses as Nn, TestEndpointResponses as Nr, DeleteFilterResponse as Nt, getEmail as O, ListDeliveriesResponses as On, SuccessEnvelope as Or, DeleteEndpointResponse as Ot, listEndpoints as P, ListEmailsData as Pn, TestResult as Pr, DeleteFilterResponses as Pt, AddDomainInput as Q, ReplayDeliveryError as Qn, UpdateEndpointResponse as Qr, Endpoint as Qt, replyToEmail as R, ListEmailsResponses as Rn, UpdateAccountErrors as Rr, DomainVerifyResult as Rt, deleteEmail as S, GetWebhookSecretResponses as Sn, SendEmailResponse as Sr, DeleteEmailErrors as St, downloadAttachments as T, ListDeliveriesError as Tn, SendMailResult as Tr, DeleteEndpointData as Tt, updateDomain as U, ListEndpointsResponses as Un, UpdateDomainError as Ur, DownloadAttachmentsResponses as Ut, testEndpoint as V, ListEndpointsErrors as Vn, UpdateAccountResponses as Vr, DownloadAttachmentsErrors as Vt, updateEndpoint as W, ListEnvelope as Wn, UpdateDomainErrors as Wr, DownloadRawEmailData as Wt, AddDomainError as X, PaginationMeta as Xn, UpdateEndpointErrors as Xr, EmailDetailReply as Xt, AddDomainData as Y, ListFiltersResponses as Yn, UpdateEndpointError as Yr, EmailDetail as Yt, AddDomainErrors as Z, ReplayDeliveryData as Zn, UpdateEndpointInput as Zr, EmailSummary as Zt, Options as _, Options$1 as _i, GetStorageStatsResponses as _n, RotateWebhookSecretResponse as _r, DeleteDomainErrors as _t, PrimitiveApiError as a, UpdateFilterResponses as ai, GetAccountErrors as an, ReplayEmailWebhooksResponse as ar, CreateEndpointInput as at, createFilter as b, ResponseStyle as bi, GetWebhookSecretErrors as bn, SendEmailError as br, DeleteEmailData as bt, PrimitiveClientOptions as c, VerifyDomainError as ci, GetEmailData as cn, ReplyToEmailData as cr, CreateFilterData as ct, SendResult as d, VerifyDomainResponses as di, GetEmailResponse as dn, ReplyToEmailResponse as dr, CreateFilterInput as dt, UpdateFilterData as ei, Filter as en, ReplayDeliveryResponse as er, AddDomainResponses as et, SendThreadInput as f, WebhookSecret as fi, GetEmailResponses as fn, ReplyToEmailResponses as fr, CreateFilterResponse as ft, operations as g, CreateClientConfig as gi, GetStorageStatsResponse as gn, RotateWebhookSecretErrors as gr, DeleteDomainError as gt, createPrimitiveClient as h, Config as hi, GetStorageStatsErrors as hn, RotateWebhookSecretError as hr, DeleteDomainData as ht, PrimitiveApiClientOptions as i, UpdateFilterResponse as ii, GetAccountError as in, ReplayEmailWebhooksErrors as ir, CreateEndpointErrors as it, listDeliveries as j, ListDomainsErrors as jn, TestEndpointErrors as jr, DeleteFilterError as jt, getStorageStats as k, ListDomainsData as kn, TestEndpointData as kr, DeleteEndpointResponses as kt, ReplyInput as l, VerifyDomainErrors as li, GetEmailError as ln, ReplyToEmailError as lr, CreateFilterError as lt, createPrimitiveApiClient as m, ClientOptions$1 as mi, GetStorageStatsError as mn, RotateWebhookSecretData as mr, Cursor as mt, ForwardInput as n, UpdateFilterErrors as ni, GateFix as nn, ReplayEmailWebhooksData as nr, CreateEndpointData as nt, PrimitiveApiErrorDetails as o, VerifiedDomain as oi, GetAccountResponse as on, ReplayEmailWebhooksResponses as or, CreateEndpointResponse as ot, client as p, Client as pi, GetStorageStatsData as pn, ResourceId as pr, CreateFilterResponses as pt, Account as q, ListFiltersErrors as qn, UpdateDomainResponses as qr, DownloadRawEmailResponse as qt, PrimitiveApiClient as r, UpdateFilterInput as ri, GetAccountData as rn, ReplayEmailWebhooksError as rr, CreateEndpointError as rt, PrimitiveClient as s, VerifyDomainData as si, GetAccountResponses as sn, ReplayResult as sr, CreateEndpointResponses as st, DEFAULT_BASE_URL as t, UpdateFilterError as ti, GateDenial as tn, ReplayDeliveryResponses as tr, ClientOptions as tt, SendInput as u, VerifyDomainResponse as ui, GetEmailErrors as un, ReplyToEmailErrors as ur, CreateFilterErrors as ut, addDomain as v, RequestOptions as vi, GetWebhookSecretData as vn, RotateWebhookSecretResponses as vr, DeleteDomainResponse as vt, deleteFilter as w, ListDeliveriesData as wn, SendMailInput as wr, DeleteEmailResponses as wt, deleteDomain as x, Auth as xi, GetWebhookSecretResponse as xn, SendEmailErrors as xr, DeleteEmailError as xt, createEndpoint as y, RequestResult as yi, GetWebhookSecretError as yn, SendEmailData as yr, DeleteDomainResponses as yt, rotateWebhookSecret as z, ListEndpointsData as zn, UpdateAccountInput as zr, DownloadAttachmentsData as zt };
2972
+ export { AddDomainError as $, ListEndpointsError as $n, StorageStats as $r, EmailDetailReply as $t, getSentEmail as A, UpdateFilterResponse as Ai, GetStorageStatsResponses as An, ReplyToEmailResponses as Ar, DeleteEndpointErrors as At, replayEmailWebhooks as B, ClientOptions$1 as Bi, ListDeliveriesResponse as Bn, SendEmailResponse as Br, Domain as Bt, deleteEndpoint as C, UpdateEndpointInput as Ci, GetSentEmailErrors as Cn, ReplayEmailWebhooksResponse as Cr, DeleteEmailData as Ct, getAccount as D, UpdateFilterError as Di, GetStorageStatsError as Dn, ReplyToEmailError as Dr, DeleteEmailResponses as Dt, downloadRawEmail as E, UpdateFilterData as Ei, GetStorageStatsData as En, ReplyToEmailData as Er, DeleteEmailResponse as Et, listEmails as F, VerifyDomainErrors as Fi, GetWebhookSecretResponses as Fn, RotateWebhookSecretResponse as Fr, DeleteFilterErrors as Ft, updateAccount as G, RequestResult as Gi, ListDomainsResponse as Gn, SendPermissionAnyRecipient as Gr, DownloadAttachmentsResponse as Gt, rotateWebhookSecret as H, CreateClientConfig as Hi, ListDomainsData as Hn, SendMailInput as Hr, DownloadAttachmentsData as Ht, listEndpoints as I, VerifyDomainResponse as Ii, Limit as In, RotateWebhookSecretResponses as Ir, DeleteFilterResponse as It, updateFilter as J, ListEmailsError as Jn, SendPermissionYourDomain as Jr, DownloadRawEmailError as Jt, updateDomain as K, ResponseStyle as Ki, ListDomainsResponses as Kn, SendPermissionManagedZone as Kr, DownloadAttachmentsResponses as Kt, listFilters as L, VerifyDomainResponses as Li, ListDeliveriesData as Ln, SendEmailData as Lr, DeleteFilterResponses as Lt, getWebhookSecret as M, VerifiedDomain as Mi, GetWebhookSecretError as Mn, RotateWebhookSecretData as Mr, DeleteEndpointResponses as Mt, listDeliveries as N, VerifyDomainData as Ni, GetWebhookSecretErrors as Nn, RotateWebhookSecretError as Nr, DeleteFilterData as Nt, getEmail as O, UpdateFilterErrors as Oi, GetStorageStatsErrors as On, ReplyToEmailErrors as Or, DeleteEndpointData as Ot, listDomains as P, VerifyDomainError as Pi, GetWebhookSecretResponse as Pn, RotateWebhookSecretErrors as Pr, DeleteFilterError as Pt, AddDomainData as Q, ListEndpointsData as Qn, SentEmailSummary as Qr, EmailDetail as Qt, listSentEmails as R, WebhookSecret as Ri, ListDeliveriesError as Rn, SendEmailError as Rr, DeliveryStatus as Rt, deleteEmail as S, UpdateEndpointErrors as Si, GetSentEmailError as Sn, ReplayEmailWebhooksErrors as Sr, DeleteDomainResponses as St, downloadAttachments as T, UpdateEndpointResponses as Ti, GetSentEmailResponses as Tn, ReplayResult as Tr, DeleteEmailErrors as Tt, sendEmail as U, Options$1 as Ui, ListDomainsError as Un, SendMailResult as Ur, DownloadAttachmentsError as Ut, replyToEmail as V, Config as Vi, ListDeliveriesResponses as Vn, SendEmailResponses as Vr, DomainVerifyResult as Vt, testEndpoint as W, RequestOptions as Wi, ListDomainsErrors as Wn, SendPermissionAddress as Wr, DownloadAttachmentsErrors as Wt, Account as X, ListEmailsResponse as Xn, SentEmailDetail as Xr, DownloadRawEmailResponse as Xt, verifyDomain as Y, ListEmailsErrors as Yn, SendPermissionsMeta as Yr, DownloadRawEmailErrors as Yt, AccountUpdated as Z, ListEmailsResponses as Zn, SentEmailStatus as Zr, DownloadRawEmailResponses as Zt, Options as _, UpdateDomainInput as _i, GetSendPermissionsError as _n, ReplayDeliveryErrors as _r, Cursor as _t, PrimitiveApiError as a, TestEndpointResponses as ai, GateFix as an, ListFiltersError as ar, CreateEndpointData as at, createFilter as b, UpdateEndpointData as bi, GetSendPermissionsResponses as bn, ReplayEmailWebhooksData as br, DeleteDomainErrors as bt, PrimitiveClientOptions as c, UpdateAccountData as ci, GetAccountErrors as cn, ListFiltersResponses as cr, CreateEndpointInput as ct, SendResult as d, UpdateAccountInput as di, GetEmailData as dn, ListSentEmailsErrors as dr, CreateFilterData as dt, SuccessEnvelope as ei, EmailSummary as en, ListEndpointsErrors as er, AddDomainErrors as et, SendThreadInput as f, UpdateAccountResponse as fi, GetEmailError as fn, ListSentEmailsResponse as fr, CreateFilterError as ft, operations as g, UpdateDomainErrors as gi, GetSendPermissionsData as gn, ReplayDeliveryError as gr, CreateFilterResponses as gt, createPrimitiveClient as h, UpdateDomainError as hi, GetEmailResponses as hn, ReplayDeliveryData as hr, CreateFilterResponse as ht, PrimitiveApiClientOptions as i, TestEndpointResponse as ii, GateDenial as in, ListFiltersData as ir, ClientOptions as it, getStorageStats as j, UpdateFilterResponses as ji, GetWebhookSecretData as jn, ResourceId as jr, DeleteEndpointResponse as jt, getSendPermissions as k, UpdateFilterInput as ki, GetStorageStatsResponse as kn, ReplyToEmailResponse as kr, DeleteEndpointError as kt, ReplyInput as l, UpdateAccountError as li, GetAccountResponse as ln, ListSentEmailsData as lr, CreateEndpointResponse as lt, createPrimitiveApiClient as m, UpdateDomainData as mi, GetEmailResponse as mn, PaginationMeta as mr, CreateFilterInput as mt, ForwardInput as n, TestEndpointError as ni, ErrorResponse as nn, ListEndpointsResponses as nr, AddDomainResponse as nt, PrimitiveApiErrorDetails as o, TestResult as oi, GetAccountData as on, ListFiltersErrors as or, CreateEndpointError as ot, client as p, UpdateAccountResponses as pi, GetEmailErrors as pn, ListSentEmailsResponses as pr, CreateFilterErrors as pt, updateEndpoint as q, Auth as qi, ListEmailsData as qn, SendPermissionRule as qr, DownloadRawEmailData as qt, PrimitiveApiClient as r, TestEndpointErrors as ri, Filter as rn, ListEnvelope as rr, AddDomainResponses as rt, PrimitiveClient as s, UnverifiedDomain as si, GetAccountError as sn, ListFiltersResponse as sr, CreateEndpointErrors as st, DEFAULT_BASE_URL as t, TestEndpointData as ti, Endpoint as tn, ListEndpointsResponse as tr, AddDomainInput as tt, SendInput as u, UpdateAccountErrors as ui, GetAccountResponses as un, ListSentEmailsError as ur, CreateEndpointResponses as ut, addDomain as v, UpdateDomainResponse as vi, GetSendPermissionsErrors as vn, ReplayDeliveryResponse as vr, DeleteDomainData as vt, deleteFilter as w, UpdateEndpointResponse as wi, GetSentEmailResponse as wn, ReplayEmailWebhooksResponses as wr, DeleteEmailError as wt, deleteDomain as x, UpdateEndpointError as xi, GetSentEmailData as xn, ReplayEmailWebhooksError as xr, DeleteDomainResponse as xt, createEndpoint as y, UpdateDomainResponses as yi, GetSendPermissionsResponse as yn, ReplayDeliveryResponses as yr, DeleteDomainError as yt, replayDelivery as z, Client as zi, ListDeliveriesErrors as zn, SendEmailErrors as zr, DeliverySummary as zt };