@primitivedotdev/sdk 0.20.0 → 0.21.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.
@@ -22,7 +22,11 @@ export const openapiDocument = {
22
22
  "servers": [
23
23
  {
24
24
  "url": "https://www.primitive.dev/api/v1",
25
- "description": "Production"
25
+ "description": "Primary API host (PRIMITIVE_API_BASE_URL_1). Carries every operation\nexcept attachment-supporting send. Vercel-backed; request body is\ncapped at 4.5 MB by the platform.\n"
26
+ },
27
+ {
28
+ "url": "https://api.primitive.dev/v1",
29
+ "description": "Attachments-supporting send host (PRIMITIVE_API_BASE_URL_2).\nCloudflare Worker with a ~30 MiB raw request body cap (before\nbase64 encoding). Today only `/send-mail` is hosted here; future\nlarge-body operations will migrate here over time. SDK clients\nroute /send-mail to this server automatically.\n"
26
30
  }
27
31
  ],
28
32
  "security": [
@@ -877,6 +881,230 @@ export const openapiDocument = {
877
881
  }
878
882
  }
879
883
  },
884
+ "/emails/search": {
885
+ "get": {
886
+ "operationId": "searchEmails",
887
+ "summary": "Search inbound emails",
888
+ "description": "Searches inbound emails with structured filters and optional\nfull-text matching across parsed email fields. This endpoint is\noptimized for filtered inbox views and CLI polling workflows:\ncallers that only need new accepted mail can pass\n`sort=received_at_asc`, `snippet=false`, `include_facets=false`,\nand a `date_from` timestamp.\n\n`q`, `subject`, and `body` use the same English full-text index\nas the web inbox search. Structured filters such as `from`, `to`,\n`domain_id`, status, attachment presence, and spam score bounds\nare combined with the text query.\n",
889
+ "tags": [
890
+ "Emails"
891
+ ],
892
+ "parameters": [
893
+ {
894
+ "name": "q",
895
+ "in": "query",
896
+ "schema": {
897
+ "type": "string",
898
+ "maxLength": 500
899
+ },
900
+ "description": "Full-text search DSL query."
901
+ },
902
+ {
903
+ "name": "from",
904
+ "in": "query",
905
+ "schema": {
906
+ "type": "string",
907
+ "maxLength": 255
908
+ },
909
+ "description": "Filter by sender address or sender domain."
910
+ },
911
+ {
912
+ "name": "to",
913
+ "in": "query",
914
+ "schema": {
915
+ "type": "string",
916
+ "maxLength": 255
917
+ },
918
+ "description": "Filter by recipient address or recipient domain."
919
+ },
920
+ {
921
+ "name": "subject",
922
+ "in": "query",
923
+ "schema": {
924
+ "type": "string",
925
+ "maxLength": 500
926
+ },
927
+ "description": "Full-text search restricted to the subject field."
928
+ },
929
+ {
930
+ "name": "body",
931
+ "in": "query",
932
+ "schema": {
933
+ "type": "string",
934
+ "maxLength": 2000
935
+ },
936
+ "description": "Full-text search restricted to the parsed text body."
937
+ },
938
+ {
939
+ "name": "domain_id",
940
+ "in": "query",
941
+ "schema": {
942
+ "type": "string",
943
+ "format": "uuid"
944
+ },
945
+ "description": "Filter by domain ID."
946
+ },
947
+ {
948
+ "name": "status",
949
+ "in": "query",
950
+ "schema": {
951
+ "$ref": "#/components/schemas/EmailStatus"
952
+ },
953
+ "description": "Filter by inbound email lifecycle status."
954
+ },
955
+ {
956
+ "name": "date_from",
957
+ "in": "query",
958
+ "schema": {
959
+ "type": "string",
960
+ "format": "date-time"
961
+ },
962
+ "description": "Filter emails received on or after this timestamp."
963
+ },
964
+ {
965
+ "name": "date_to",
966
+ "in": "query",
967
+ "schema": {
968
+ "type": "string",
969
+ "format": "date-time"
970
+ },
971
+ "description": "Filter emails received on or before this timestamp."
972
+ },
973
+ {
974
+ "name": "has_attachment",
975
+ "in": "query",
976
+ "schema": {
977
+ "type": "string",
978
+ "enum": [
979
+ "true",
980
+ "false"
981
+ ]
982
+ },
983
+ "description": "Filter by whether the email has one or more attachments."
984
+ },
985
+ {
986
+ "name": "spam_score_lt",
987
+ "in": "query",
988
+ "schema": {
989
+ "type": "number"
990
+ },
991
+ "description": "Filter to emails with spam score below this value."
992
+ },
993
+ {
994
+ "name": "spam_score_gte",
995
+ "in": "query",
996
+ "schema": {
997
+ "type": "number"
998
+ },
999
+ "description": "Filter to emails with spam score greater than or equal to this value."
1000
+ },
1001
+ {
1002
+ "name": "sort",
1003
+ "in": "query",
1004
+ "schema": {
1005
+ "type": "string",
1006
+ "enum": [
1007
+ "relevance",
1008
+ "received_at_desc",
1009
+ "received_at_asc"
1010
+ ]
1011
+ },
1012
+ "description": "Sort mode. Defaults to relevance when a text query is present,\notherwise `received_at_desc`.\n"
1013
+ },
1014
+ {
1015
+ "name": "cursor",
1016
+ "in": "query",
1017
+ "schema": {
1018
+ "type": "string",
1019
+ "maxLength": 200
1020
+ },
1021
+ "description": "Opaque pagination cursor from a previous search response."
1022
+ },
1023
+ {
1024
+ "$ref": "#/components/parameters/Limit"
1025
+ },
1026
+ {
1027
+ "name": "snippet",
1028
+ "in": "query",
1029
+ "schema": {
1030
+ "type": "string",
1031
+ "enum": [
1032
+ "true",
1033
+ "false"
1034
+ ],
1035
+ "default": "true"
1036
+ },
1037
+ "description": "Include subject/body highlight snippets when text search is active."
1038
+ },
1039
+ {
1040
+ "name": "include_facets",
1041
+ "in": "query",
1042
+ "schema": {
1043
+ "type": "string",
1044
+ "enum": [
1045
+ "true",
1046
+ "false"
1047
+ ],
1048
+ "default": "true"
1049
+ },
1050
+ "description": "Include facet counts for sender, domain, status, and attachment presence."
1051
+ }
1052
+ ],
1053
+ "responses": {
1054
+ "200": {
1055
+ "description": "Search results",
1056
+ "content": {
1057
+ "application/json": {
1058
+ "schema": {
1059
+ "allOf": [
1060
+ {
1061
+ "$ref": "#/components/schemas/SuccessEnvelope"
1062
+ },
1063
+ {
1064
+ "type": "object",
1065
+ "properties": {
1066
+ "data": {
1067
+ "type": "array",
1068
+ "items": {
1069
+ "$ref": "#/components/schemas/EmailSearchResult"
1070
+ }
1071
+ },
1072
+ "meta": {
1073
+ "$ref": "#/components/schemas/EmailSearchMeta"
1074
+ },
1075
+ "facets": {
1076
+ "$ref": "#/components/schemas/EmailSearchFacets"
1077
+ }
1078
+ },
1079
+ "required": [
1080
+ "data",
1081
+ "meta"
1082
+ ]
1083
+ }
1084
+ ]
1085
+ }
1086
+ }
1087
+ }
1088
+ },
1089
+ "400": {
1090
+ "$ref": "#/components/responses/ValidationError"
1091
+ },
1092
+ "401": {
1093
+ "$ref": "#/components/responses/Unauthorized"
1094
+ },
1095
+ "504": {
1096
+ "description": "Search query timed out",
1097
+ "content": {
1098
+ "application/json": {
1099
+ "schema": {
1100
+ "$ref": "#/components/schemas/ErrorResponse"
1101
+ }
1102
+ }
1103
+ }
1104
+ }
1105
+ }
1106
+ }
1107
+ },
880
1108
  "/emails/{id}": {
881
1109
  "parameters": [
882
1110
  {
@@ -1881,7 +2109,17 @@ export const openapiDocument = {
1881
2109
  "post": {
1882
2110
  "operationId": "sendEmail",
1883
2111
  "summary": "Send outbound email",
1884
- "description": "Sends an outbound email through Primitive's outbound relay. By default\nthe request returns once the relay accepts the message for delivery.\nSet `wait: true` to wait for the first downstream SMTP delivery outcome.\n",
2112
+ "description": "Sends an outbound email through Primitive's outbound relay. By default\nthe request returns once the relay accepts the message for delivery.\nSet `wait: true` to wait for the first downstream SMTP delivery outcome.\n\n**Host routing.** /send-mail is served by the attachments-\nsupporting host (`https://api.primitive.dev/v1`) so the\nrequest body can carry inline attachments up to ~30 MiB raw.\nThe primary host (`https://www.primitive.dev/api/v1`) also\naccepts /send-mail for attachment-free sends; sends WITH\nattachments to the primary host return 413\n`attachments_unsupported_on_this_endpoint`. The typed SDKs\nroute /send-mail to the attachments host automatically.\n",
2113
+ "servers": [
2114
+ {
2115
+ "url": "https://api.primitive.dev/v1",
2116
+ "description": "Attachments-supporting send host (recommended)"
2117
+ },
2118
+ {
2119
+ "url": "https://www.primitive.dev/api/v1",
2120
+ "description": "Primary host (attachment-free sends only)"
2121
+ }
2122
+ ],
1885
2123
  "tags": [
1886
2124
  "Sending"
1887
2125
  ],
@@ -2945,6 +3183,7 @@ export const openapiDocument = {
2945
3183
  "outbound_relay_failed",
2946
3184
  "discard_not_enabled",
2947
3185
  "inbound_not_repliable",
3186
+ "search_timeout",
2948
3187
  "authorization_pending",
2949
3188
  "slow_down",
2950
3189
  "access_denied",
@@ -3647,6 +3886,162 @@ export const openapiDocument = {
3647
3886
  "webhook_attempt_count"
3648
3887
  ]
3649
3888
  },
3889
+ "EmailSearchHighlights": {
3890
+ "type": "object",
3891
+ "properties": {
3892
+ "subject": {
3893
+ "type": "array",
3894
+ "items": {
3895
+ "type": "string"
3896
+ },
3897
+ "description": "Subject snippets with matching terms highlighted."
3898
+ },
3899
+ "body": {
3900
+ "type": "array",
3901
+ "items": {
3902
+ "type": "string"
3903
+ },
3904
+ "description": "Body snippets with matching terms highlighted."
3905
+ }
3906
+ },
3907
+ "required": [
3908
+ "subject",
3909
+ "body"
3910
+ ]
3911
+ },
3912
+ "EmailSearchResult": {
3913
+ "allOf": [
3914
+ {
3915
+ "$ref": "#/components/schemas/EmailSummary"
3916
+ },
3917
+ {
3918
+ "type": "object",
3919
+ "properties": {
3920
+ "attachment_count": {
3921
+ "type": "integer",
3922
+ "description": "Number of parsed attachments on the email."
3923
+ },
3924
+ "from_known_address": {
3925
+ "type": "boolean",
3926
+ "description": "Whether the parsed From address is known to this org from prior authenticated inbound mail."
3927
+ },
3928
+ "score": {
3929
+ "type": "number",
3930
+ "description": "Relevance score. Present only when sorting by relevance."
3931
+ },
3932
+ "highlights": {
3933
+ "$ref": "#/components/schemas/EmailSearchHighlights"
3934
+ }
3935
+ },
3936
+ "required": [
3937
+ "attachment_count",
3938
+ "from_known_address"
3939
+ ]
3940
+ }
3941
+ ]
3942
+ },
3943
+ "EmailSearchMeta": {
3944
+ "type": "object",
3945
+ "properties": {
3946
+ "total": {
3947
+ "type": "integer",
3948
+ "description": "Total number of matching records, capped when `total_capped` is true."
3949
+ },
3950
+ "total_capped": {
3951
+ "type": "boolean",
3952
+ "description": "Whether `total` was capped instead of counted exactly."
3953
+ },
3954
+ "limit": {
3955
+ "type": "integer",
3956
+ "description": "Page size used for this request."
3957
+ },
3958
+ "cursor": {
3959
+ "type": [
3960
+ "string",
3961
+ "null"
3962
+ ],
3963
+ "description": "Cursor for the next search page, or null if no more results."
3964
+ },
3965
+ "sort": {
3966
+ "type": "string",
3967
+ "enum": [
3968
+ "relevance",
3969
+ "received_at_desc",
3970
+ "received_at_asc"
3971
+ ],
3972
+ "description": "Sort mode used for the result page."
3973
+ }
3974
+ },
3975
+ "required": [
3976
+ "total",
3977
+ "total_capped",
3978
+ "limit",
3979
+ "cursor",
3980
+ "sort"
3981
+ ]
3982
+ },
3983
+ "EmailSearchFacetBucket": {
3984
+ "type": "object",
3985
+ "properties": {
3986
+ "value": {
3987
+ "type": [
3988
+ "string",
3989
+ "null"
3990
+ ]
3991
+ },
3992
+ "count": {
3993
+ "type": "integer"
3994
+ }
3995
+ },
3996
+ "required": [
3997
+ "value",
3998
+ "count"
3999
+ ]
4000
+ },
4001
+ "EmailSearchFacets": {
4002
+ "type": "object",
4003
+ "properties": {
4004
+ "by_sender": {
4005
+ "type": "array",
4006
+ "items": {
4007
+ "$ref": "#/components/schemas/EmailSearchFacetBucket"
4008
+ }
4009
+ },
4010
+ "by_domain": {
4011
+ "type": "array",
4012
+ "items": {
4013
+ "$ref": "#/components/schemas/EmailSearchFacetBucket"
4014
+ }
4015
+ },
4016
+ "by_status": {
4017
+ "type": "array",
4018
+ "items": {
4019
+ "$ref": "#/components/schemas/EmailSearchFacetBucket"
4020
+ }
4021
+ },
4022
+ "has_attachment": {
4023
+ "type": "object",
4024
+ "properties": {
4025
+ "true": {
4026
+ "type": "integer"
4027
+ },
4028
+ "false": {
4029
+ "type": "integer"
4030
+ }
4031
+ },
4032
+ "required": [
4033
+ "true",
4034
+ "false"
4035
+ ]
4036
+ }
4037
+ },
4038
+ "required": [
4039
+ "by_sender",
4040
+ "by_domain",
4041
+ "by_status",
4042
+ "has_attachment"
4043
+ ]
4044
+ },
3650
4045
  "EmailDetail": {
3651
4046
  "type": "object",
3652
4047
  "properties": {