@benclmnt/postmock 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +251 -0
- package/dist/seeds/conformance/00-core.d.ts +4 -0
- package/dist/seeds/conformance/00-core.js +12 -0
- package/dist/seeds/conformance/20-bounces.d.ts +3 -0
- package/dist/seeds/conformance/20-bounces.js +108 -0
- package/dist/seeds/conformance/40-messages.d.ts +3 -0
- package/dist/seeds/conformance/40-messages.js +144 -0
- package/dist/seeds/conformance/50-server-color.d.ts +8 -0
- package/dist/seeds/conformance/50-server-color.js +13 -0
- package/dist/seeds/conformance/70-account.d.ts +9 -0
- package/dist/seeds/conformance/70-account.js +29 -0
- package/dist/seeds/conformance/80-templates.d.ts +4 -0
- package/dist/seeds/conformance/80-templates.js +23 -0
- package/dist/seeds/conformance.d.ts +2 -0
- package/dist/seeds/conformance.js +3 -0
- package/dist/seeds/empty.d.ts +4 -0
- package/dist/seeds/empty.js +3 -0
- package/dist/seeds/lib/conformance.d.ts +16 -0
- package/dist/seeds/lib/conformance.js +18 -0
- package/dist/seeds/lib/history.d.ts +27 -0
- package/dist/seeds/lib/history.js +129 -0
- package/dist/seeds/lib/read-server.d.ts +10 -0
- package/dist/seeds/lib/read-server.js +10 -0
- package/dist/seeds/lib/template-server.d.ts +13 -0
- package/dist/seeds/lib/template-server.js +13 -0
- package/dist/src/api/account/authentication.d.ts +39 -0
- package/dist/src/api/account/authentication.js +97 -0
- package/dist/src/api/account/domains.d.ts +59 -0
- package/dist/src/api/account/domains.js +78 -0
- package/dist/src/api/account/paging.d.ts +12 -0
- package/dist/src/api/account/paging.js +35 -0
- package/dist/src/api/account/push.d.ts +14 -0
- package/dist/src/api/account/push.js +84 -0
- package/dist/src/api/account/routes.d.ts +1 -0
- package/dist/src/api/account/routes.js +288 -0
- package/dist/src/api/account/senders.d.ts +54 -0
- package/dist/src/api/account/senders.js +87 -0
- package/dist/src/api/account/servers.d.ts +40 -0
- package/dist/src/api/account/servers.js +148 -0
- package/dist/src/api/bounces/json.d.ts +25 -0
- package/dist/src/api/bounces/json.js +27 -0
- package/dist/src/api/bounces/routes.d.ts +1 -0
- package/dist/src/api/bounces/routes.js +127 -0
- package/dist/src/api/bulk/bulk.d.ts +43 -0
- package/dist/src/api/bulk/bulk.js +81 -0
- package/dist/src/api/bulk/routes.d.ts +1 -0
- package/dist/src/api/bulk/routes.js +252 -0
- package/dist/src/api/data-removals/routes.d.ts +1 -0
- package/dist/src/api/data-removals/routes.js +59 -0
- package/dist/src/api/email/json.d.ts +11 -0
- package/dist/src/api/email/json.js +33 -0
- package/dist/src/api/email/routes.d.ts +1 -0
- package/dist/src/api/email/routes.js +64 -0
- package/dist/src/api/inbound/routes.d.ts +1 -0
- package/dist/src/api/inbound/routes.js +40 -0
- package/dist/src/api/index.d.ts +1 -0
- package/dist/src/api/index.js +3 -0
- package/dist/src/api/message-streams/routes.d.ts +1 -0
- package/dist/src/api/message-streams/routes.js +211 -0
- package/dist/src/api/message-streams/streams.d.ts +28 -0
- package/dist/src/api/message-streams/streams.js +50 -0
- package/dist/src/api/messages/json.d.ts +149 -0
- package/dist/src/api/messages/json.js +114 -0
- package/dist/src/api/messages/query.d.ts +19 -0
- package/dist/src/api/messages/query.js +64 -0
- package/dist/src/api/messages/routes.d.ts +1 -0
- package/dist/src/api/messages/routes.js +203 -0
- package/dist/src/api/server/json.d.ts +26 -0
- package/dist/src/api/server/json.js +25 -0
- package/dist/src/api/server/routes.d.ts +1 -0
- package/dist/src/api/server/routes.js +17 -0
- package/dist/src/api/stats/aggregate.d.ts +58 -0
- package/dist/src/api/stats/aggregate.js +66 -0
- package/dist/src/api/stats/routes.d.ts +1 -0
- package/dist/src/api/stats/routes.js +72 -0
- package/dist/src/api/suppressions/routes.d.ts +1 -0
- package/dist/src/api/suppressions/routes.js +98 -0
- package/dist/src/api/templates/content.d.ts +21 -0
- package/dist/src/api/templates/content.js +39 -0
- package/dist/src/api/templates/routes.d.ts +1 -0
- package/dist/src/api/templates/routes.js +164 -0
- package/dist/src/api/templates/send.d.ts +13 -0
- package/dist/src/api/templates/send.js +105 -0
- package/dist/src/api/templates/templates.d.ts +100 -0
- package/dist/src/api/templates/templates.js +218 -0
- package/dist/src/api/templates/validate.d.ts +15 -0
- package/dist/src/api/templates/validate.js +77 -0
- package/dist/src/api/triggers/routes.d.ts +1 -0
- package/dist/src/api/triggers/routes.js +62 -0
- package/dist/src/api/webhooks/routes.d.ts +14 -0
- package/dist/src/api/webhooks/routes.js +192 -0
- package/dist/src/config.d.ts +17 -0
- package/dist/src/config.js +95 -0
- package/dist/src/control/app.d.ts +5 -0
- package/dist/src/control/app.js +42 -0
- package/dist/src/control/endpoints/account.d.ts +1 -0
- package/dist/src/control/endpoints/account.js +68 -0
- package/dist/src/control/endpoints/bulk.d.ts +1 -0
- package/dist/src/control/endpoints/bulk.js +29 -0
- package/dist/src/control/endpoints/core.d.ts +1 -0
- package/dist/src/control/endpoints/core.js +104 -0
- package/dist/src/control/endpoints/inbound.d.ts +1 -0
- package/dist/src/control/endpoints/inbound.js +61 -0
- package/dist/src/control/endpoints/recipients.d.ts +1 -0
- package/dist/src/control/endpoints/recipients.js +136 -0
- package/dist/src/control/endpoints/smtp.d.ts +1 -0
- package/dist/src/control/endpoints/smtp.js +74 -0
- package/dist/src/control/endpoints/tracking.d.ts +1 -0
- package/dist/src/control/endpoints/tracking.js +95 -0
- package/dist/src/control/endpoints/webhooks.d.ts +1 -0
- package/dist/src/control/endpoints/webhooks.js +36 -0
- package/dist/src/control/index.d.ts +1 -0
- package/dist/src/control/index.js +3 -0
- package/dist/src/control/registry.d.ts +25 -0
- package/dist/src/control/registry.js +19 -0
- package/dist/src/control/seed.d.ts +11 -0
- package/dist/src/control/seed.js +32 -0
- package/dist/src/control/seeding.d.ts +10 -0
- package/dist/src/control/seeding.js +27 -0
- package/dist/src/discover.d.ts +16 -0
- package/dist/src/discover.js +49 -0
- package/dist/src/errors.d.ts +49 -0
- package/dist/src/errors.js +701 -0
- package/dist/src/events.d.ts +49 -0
- package/dist/src/events.js +19 -0
- package/dist/src/http/app.d.ts +8 -0
- package/dist/src/http/app.js +51 -0
- package/dist/src/http/auth.d.ts +7 -0
- package/dist/src/http/auth.js +32 -0
- package/dist/src/http/faults.d.ts +8 -0
- package/dist/src/http/faults.js +33 -0
- package/dist/src/http/normalize.d.ts +57 -0
- package/dist/src/http/normalize.js +225 -0
- package/dist/src/http/respond.d.ts +23 -0
- package/dist/src/http/respond.js +37 -0
- package/dist/src/http/routes.d.ts +60 -0
- package/dist/src/http/routes.js +64 -0
- package/dist/src/inbound/deliver.d.ts +9 -0
- package/dist/src/inbound/deliver.js +34 -0
- package/dist/src/inbound/parse.d.ts +21 -0
- package/dist/src/inbound/parse.js +71 -0
- package/dist/src/inbound/receive.d.ts +17 -0
- package/dist/src/inbound/receive.js +89 -0
- package/dist/src/main.d.ts +2 -0
- package/dist/src/main.js +14 -0
- package/dist/src/mime/compose.d.ts +33 -0
- package/dist/src/mime/compose.js +58 -0
- package/dist/src/pipeline/addresses.d.ts +6 -0
- package/dist/src/pipeline/addresses.js +38 -0
- package/dist/src/pipeline/inactive.d.ts +8 -0
- package/dist/src/pipeline/inactive.js +20 -0
- package/dist/src/pipeline/submit.d.ts +138 -0
- package/dist/src/pipeline/submit.js +415 -0
- package/dist/src/plugins/message-events.d.ts +7 -0
- package/dist/src/plugins/message-events.js +76 -0
- package/dist/src/plugins/smtp.d.ts +15 -0
- package/dist/src/plugins/smtp.js +42 -0
- package/dist/src/plugins/stats.d.ts +7 -0
- package/dist/src/plugins/stats.js +78 -0
- package/dist/src/plugins/webhooks.d.ts +4 -0
- package/dist/src/plugins/webhooks.js +80 -0
- package/dist/src/plugins.d.ts +20 -0
- package/dist/src/plugins.js +9 -0
- package/dist/src/recipients/test-bounces.d.ts +15 -0
- package/dist/src/recipients/test-bounces.js +31 -0
- package/dist/src/recipients/transitions.d.ts +57 -0
- package/dist/src/recipients/transitions.js +279 -0
- package/dist/src/render/mustachio.d.ts +60 -0
- package/dist/src/render/mustachio.js +265 -0
- package/dist/src/runtime.d.ts +12 -0
- package/dist/src/runtime.js +11 -0
- package/dist/src/server.d.ts +25 -0
- package/dist/src/server.js +49 -0
- package/dist/src/smtp/auth.d.ts +35 -0
- package/dist/src/smtp/auth.js +66 -0
- package/dist/src/smtp/listener.d.ts +16 -0
- package/dist/src/smtp/listener.js +121 -0
- package/dist/src/smtp/mime.d.ts +36 -0
- package/dist/src/smtp/mime.js +181 -0
- package/dist/src/smtp/receive.d.ts +21 -0
- package/dist/src/smtp/receive.js +89 -0
- package/dist/src/smtp/reply.d.ts +14 -0
- package/dist/src/smtp/reply.js +24 -0
- package/dist/src/state/clock.d.ts +35 -0
- package/dist/src/state/clock.js +107 -0
- package/dist/src/state/ids.d.ts +6 -0
- package/dist/src/state/ids.js +7 -0
- package/dist/src/state/servers.d.ts +27 -0
- package/dist/src/state/servers.js +101 -0
- package/dist/src/state/store.d.ts +57 -0
- package/dist/src/state/store.js +98 -0
- package/dist/src/state/suppressions.d.ts +9 -0
- package/dist/src/state/suppressions.js +8 -0
- package/dist/src/state/types.d.ts +530 -0
- package/dist/src/state/types.js +41 -0
- package/dist/src/time.d.ts +11 -0
- package/dist/src/time.js +48 -0
- package/dist/src/tracking.d.ts +53 -0
- package/dist/src/tracking.js +150 -0
- package/dist/src/webhooks/deliver.d.ts +60 -0
- package/dist/src/webhooks/deliver.js +172 -0
- package/dist/src/webhooks/egress.d.ts +19 -0
- package/dist/src/webhooks/egress.js +40 -0
- package/dist/src/webhooks/outbound.d.ts +26 -0
- package/dist/src/webhooks/outbound.js +47 -0
- package/dist/src/webhooks/payloads.d.ts +111 -0
- package/dist/src/webhooks/payloads.js +128 -0
- package/package.json +55 -0
|
@@ -0,0 +1,701 @@
|
|
|
1
|
+
// The ErrorCode table of docs/02 §4.4, one row per documented row, in doc order.
|
|
2
|
+
// `message` rows: the doc text is used as the wire `Message`. It is INFERRED except where a comment
|
|
3
|
+
// cites an SDK text. Code spans become single quotes: the one SDK-quoted wire text (1226) uses 'ID'
|
|
4
|
+
// where the doc shows `ID` (docs/04 §4.4); the same rule for other codes is INFERRED.
|
|
5
|
+
// `summary` rows describe several wire messages; `apiError` and `errorBody` need an exact `message`.
|
|
6
|
+
export const ERROR_FAMILIES = [
|
|
7
|
+
"auth",
|
|
8
|
+
"global",
|
|
9
|
+
"sending",
|
|
10
|
+
"templates",
|
|
11
|
+
"servers",
|
|
12
|
+
"messages",
|
|
13
|
+
"inboundRules",
|
|
14
|
+
"streams",
|
|
15
|
+
"suppressions",
|
|
16
|
+
"senders",
|
|
17
|
+
"smtpTokens",
|
|
18
|
+
"stats",
|
|
19
|
+
"dataRemovals",
|
|
20
|
+
"webhooks",
|
|
21
|
+
];
|
|
22
|
+
export const ERROR_TABLE = [
|
|
23
|
+
[
|
|
24
|
+
10,
|
|
25
|
+
"auth",
|
|
26
|
+
[401],
|
|
27
|
+
"message",
|
|
28
|
+
"Request does not contain a valid Server or Account token, or the wrong token type was used for the endpoint.",
|
|
29
|
+
],
|
|
30
|
+
// Global
|
|
31
|
+
[100, "global", [503], "message", "The Postmark API is offline for maintenance."],
|
|
32
|
+
[
|
|
33
|
+
101,
|
|
34
|
+
"global",
|
|
35
|
+
[500],
|
|
36
|
+
"summary",
|
|
37
|
+
"You encountered an error that shouldn't have occurred. The response includes an 'Error ID' for support.",
|
|
38
|
+
],
|
|
39
|
+
// Sending
|
|
40
|
+
[
|
|
41
|
+
11,
|
|
42
|
+
"sending",
|
|
43
|
+
[422],
|
|
44
|
+
"summary",
|
|
45
|
+
"Multiple errors occurred. Inspect the 'Errors' property for more information.",
|
|
46
|
+
],
|
|
47
|
+
[12, "sending", [404], "message", "Bulk send not found."],
|
|
48
|
+
[13, "sending", [422], "message", "Invalid pagination key."],
|
|
49
|
+
[
|
|
50
|
+
14,
|
|
51
|
+
"sending",
|
|
52
|
+
[422],
|
|
53
|
+
"summary",
|
|
54
|
+
"This endpoint requires approval to access. Contact support to use the Bulk API.",
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
300,
|
|
58
|
+
"sending",
|
|
59
|
+
[422],
|
|
60
|
+
"summary",
|
|
61
|
+
"Send validation. Covers many messages — zero recipients, invalid address, missing 'TextBody'/'HtmlBody', and recipient, metadata, attachment, or header limits.",
|
|
62
|
+
],
|
|
63
|
+
// CAPTURED text: captures/20260916T231736Z-from-verification/01, /02. `{from}` is the bare
|
|
64
|
+
// address; for a named `From` that is INFERRED.
|
|
65
|
+
[
|
|
66
|
+
400,
|
|
67
|
+
"sending",
|
|
68
|
+
[422],
|
|
69
|
+
"message",
|
|
70
|
+
"The 'From' address you supplied ({from}) is not a Sender Signature on your account. Please add and confirm this address in order to be able to use it in the 'From' field of your messages.",
|
|
71
|
+
],
|
|
72
|
+
[402, "sending", [422], "message", "Invalid JSON."],
|
|
73
|
+
[403, "sending", [422], "summary", "Invalid request field(s)."],
|
|
74
|
+
// SDK text: sdk/postmark.js/test/unit/ErrorHandler.test.ts:113-116. Clients parse the addresses (docs/02 §4.1).
|
|
75
|
+
[
|
|
76
|
+
406,
|
|
77
|
+
"sending",
|
|
78
|
+
[422],
|
|
79
|
+
"message",
|
|
80
|
+
"You tried to send to recipient(s) that have been marked as inactive. Found inactive addresses: {addresses}. Inactive recipients are ones that have generated a hard bounce, a spam complaint, or a manual suppression.",
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
410,
|
|
84
|
+
"sending",
|
|
85
|
+
[422],
|
|
86
|
+
"message",
|
|
87
|
+
"You may only send up to 500 messages in a single batched request.",
|
|
88
|
+
],
|
|
89
|
+
[411, "sending", [422], "message", "Attachment file type not allowed."],
|
|
90
|
+
[
|
|
91
|
+
412,
|
|
92
|
+
"sending",
|
|
93
|
+
[422],
|
|
94
|
+
"message",
|
|
95
|
+
"While your account is pending approval, all recipient addresses must share the same domain as the From address.",
|
|
96
|
+
],
|
|
97
|
+
[413, "sending", [422], "message", "This account is not approved to send email."],
|
|
98
|
+
[422, "sending", [422], "message", "Invalid Server or Account."],
|
|
99
|
+
// SDK text: sdk/postmark-php/tests/PostmarkClientEmailTest.php:92-93.
|
|
100
|
+
[
|
|
101
|
+
1235,
|
|
102
|
+
"sending",
|
|
103
|
+
[422],
|
|
104
|
+
"message",
|
|
105
|
+
"The stream provided: '{stream}' does not exist on this server.",
|
|
106
|
+
],
|
|
107
|
+
[1236, "sending", [422], "message", "Sending is not supported for this stream type."],
|
|
108
|
+
[
|
|
109
|
+
1480,
|
|
110
|
+
"sending",
|
|
111
|
+
[422],
|
|
112
|
+
"summary",
|
|
113
|
+
"You are not authorized to send emails from your current IP address: 'IP Address'.",
|
|
114
|
+
],
|
|
115
|
+
// Templates
|
|
116
|
+
[
|
|
117
|
+
601,
|
|
118
|
+
"templates",
|
|
119
|
+
[422],
|
|
120
|
+
"summary",
|
|
121
|
+
"The source or destination server was not found (template push).",
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
1100,
|
|
125
|
+
"templates",
|
|
126
|
+
[422],
|
|
127
|
+
"summary",
|
|
128
|
+
"Template list paging, or an invalid 'TemplateType' or 'editorType' query parameter.",
|
|
129
|
+
],
|
|
130
|
+
[
|
|
131
|
+
1101,
|
|
132
|
+
"templates",
|
|
133
|
+
[422],
|
|
134
|
+
"summary",
|
|
135
|
+
"The request specifies neither 'TemplateId' nor 'TemplateAlias', or the referenced template, alias, or layout was not found.",
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
1105,
|
|
139
|
+
"templates",
|
|
140
|
+
[422],
|
|
141
|
+
"message",
|
|
142
|
+
"A server's active-template limit would be exceeded by this request.",
|
|
143
|
+
],
|
|
144
|
+
[1109, "templates", [422], "message", "No template data received."],
|
|
145
|
+
[
|
|
146
|
+
1120,
|
|
147
|
+
"templates",
|
|
148
|
+
[422],
|
|
149
|
+
"summary",
|
|
150
|
+
"A required field is missing — 'Name', one of 'TextBody'/'HtmlBody', 'Subject', or 'TemplateModel'.",
|
|
151
|
+
],
|
|
152
|
+
[
|
|
153
|
+
1121,
|
|
154
|
+
"templates",
|
|
155
|
+
[422],
|
|
156
|
+
"summary",
|
|
157
|
+
"A field is too long — 'Name', 'Alias', 'HtmlBody', 'TextBody', 'Subject', or 'TemplateModel'.",
|
|
158
|
+
],
|
|
159
|
+
[
|
|
160
|
+
1122,
|
|
161
|
+
"templates",
|
|
162
|
+
[422],
|
|
163
|
+
"summary",
|
|
164
|
+
"Invalid 'TemplateType', alias empty/invalid/in-use, unparseable body, or a reserved top-level 'TemplateModel' key.",
|
|
165
|
+
],
|
|
166
|
+
[
|
|
167
|
+
1123,
|
|
168
|
+
"templates",
|
|
169
|
+
[422],
|
|
170
|
+
"summary",
|
|
171
|
+
"Template/send mutual-exclusion rules (layout vs. subject/body, templated vs. non-templated).",
|
|
172
|
+
],
|
|
173
|
+
[
|
|
174
|
+
1124,
|
|
175
|
+
"templates",
|
|
176
|
+
[422],
|
|
177
|
+
"summary",
|
|
178
|
+
"No templates with aliases found to push, or the per-request push limit was exceeded.",
|
|
179
|
+
],
|
|
180
|
+
[
|
|
181
|
+
1125,
|
|
182
|
+
"templates",
|
|
183
|
+
[422],
|
|
184
|
+
"message",
|
|
185
|
+
"The template types don't match on the source and destination servers.",
|
|
186
|
+
],
|
|
187
|
+
[
|
|
188
|
+
1130,
|
|
189
|
+
"templates",
|
|
190
|
+
[422],
|
|
191
|
+
"message",
|
|
192
|
+
"The layout template cannot be deleted because dependent templates use it.",
|
|
193
|
+
],
|
|
194
|
+
[1131, "templates", [422], "summary", "Layout content-placeholder rules were not met."],
|
|
195
|
+
// Servers
|
|
196
|
+
[
|
|
197
|
+
600,
|
|
198
|
+
"servers",
|
|
199
|
+
[422],
|
|
200
|
+
"summary",
|
|
201
|
+
"Server-list paging — 'offset'/'count' required or integer; up to 500 servers per call.",
|
|
202
|
+
],
|
|
203
|
+
[
|
|
204
|
+
602,
|
|
205
|
+
"servers",
|
|
206
|
+
[422],
|
|
207
|
+
"message",
|
|
208
|
+
"The specified inbound domain is already registered or in use on another server.",
|
|
209
|
+
],
|
|
210
|
+
[603, "servers", [422], "message", "This server name already exists."],
|
|
211
|
+
[604, "servers", [422], "message", "You do not have permission to delete servers using the API."],
|
|
212
|
+
[605, "servers", [422], "message", "Unable to remove this server. Please contact support."],
|
|
213
|
+
[
|
|
214
|
+
606,
|
|
215
|
+
"servers",
|
|
216
|
+
[422],
|
|
217
|
+
"summary",
|
|
218
|
+
"A supplied hook URL (Inbound, Bounce, Open, Delivery, or Click) is not valid.",
|
|
219
|
+
],
|
|
220
|
+
[607, "servers", [422], "message", "Invalid server color."],
|
|
221
|
+
[
|
|
222
|
+
608,
|
|
223
|
+
"servers",
|
|
224
|
+
[422],
|
|
225
|
+
"summary",
|
|
226
|
+
"Server name is invalid or missing, or an inbound domain containing postmarkapp.com was used.",
|
|
227
|
+
],
|
|
228
|
+
[609, "servers", [422], "message", "No server data received."],
|
|
229
|
+
[
|
|
230
|
+
610,
|
|
231
|
+
"servers",
|
|
232
|
+
[422],
|
|
233
|
+
"message",
|
|
234
|
+
"We could not find an MX record pointing to the expected domain.",
|
|
235
|
+
],
|
|
236
|
+
[
|
|
237
|
+
611,
|
|
238
|
+
"servers",
|
|
239
|
+
[422],
|
|
240
|
+
"message",
|
|
241
|
+
"InboundSpamThreshold value is invalid. Use a number between 0 and 30.",
|
|
242
|
+
],
|
|
243
|
+
[612, "servers", [422], "message", "The supplied 'TrackLinks' option is not valid."],
|
|
244
|
+
[613, "servers", [422], "message", "The supplied 'DeliveryType' option is not valid."],
|
|
245
|
+
[
|
|
246
|
+
614,
|
|
247
|
+
"servers",
|
|
248
|
+
[422],
|
|
249
|
+
"summary",
|
|
250
|
+
"Entitlement limit reached (inbound, stats, users, servers, streams, or domains).",
|
|
251
|
+
],
|
|
252
|
+
[615, "servers", [422], "message", "Action is not supported."],
|
|
253
|
+
// Message activity, messages & bounces
|
|
254
|
+
[
|
|
255
|
+
700,
|
|
256
|
+
"messages",
|
|
257
|
+
[422],
|
|
258
|
+
"summary",
|
|
259
|
+
"Paging/parameter validation for messages, opens, clicks, and activity.",
|
|
260
|
+
],
|
|
261
|
+
[
|
|
262
|
+
701,
|
|
263
|
+
"messages",
|
|
264
|
+
[422],
|
|
265
|
+
"summary",
|
|
266
|
+
"This message was not found, or cannot be bypassed or retried.",
|
|
267
|
+
],
|
|
268
|
+
[
|
|
269
|
+
702,
|
|
270
|
+
"messages",
|
|
271
|
+
[422],
|
|
272
|
+
"message",
|
|
273
|
+
"Could not bypass this blocked message. Please contact support.",
|
|
274
|
+
],
|
|
275
|
+
[
|
|
276
|
+
703,
|
|
277
|
+
"messages",
|
|
278
|
+
[422],
|
|
279
|
+
"message",
|
|
280
|
+
"Could not retry this failed message. Please contact support.",
|
|
281
|
+
],
|
|
282
|
+
[
|
|
283
|
+
1000,
|
|
284
|
+
"messages",
|
|
285
|
+
[422],
|
|
286
|
+
"summary",
|
|
287
|
+
"Bounces query validation (non-negative, up to 500, count+offset, illegal bounce type).",
|
|
288
|
+
],
|
|
289
|
+
[
|
|
290
|
+
1001,
|
|
291
|
+
"messages",
|
|
292
|
+
[422],
|
|
293
|
+
"summary",
|
|
294
|
+
"The bounce was not found, or its dump is no longer available.",
|
|
295
|
+
],
|
|
296
|
+
[1002, "messages", [400], "message", "A 'bounceID' parameter is required."],
|
|
297
|
+
[
|
|
298
|
+
1003,
|
|
299
|
+
"messages",
|
|
300
|
+
[422],
|
|
301
|
+
"message",
|
|
302
|
+
"Due to the type of bounce, this address cannot be reactivated.",
|
|
303
|
+
],
|
|
304
|
+
// Inbound rules / triggers
|
|
305
|
+
[
|
|
306
|
+
800,
|
|
307
|
+
"inboundRules",
|
|
308
|
+
[422],
|
|
309
|
+
"summary",
|
|
310
|
+
"You may only request up to 500 triggers per call, plus parameter validation.",
|
|
311
|
+
],
|
|
312
|
+
[809, "inboundRules", [422], "message", "No trigger data received."],
|
|
313
|
+
[810, "inboundRules", [422], "message", "This inbound rule already exists."],
|
|
314
|
+
[
|
|
315
|
+
811,
|
|
316
|
+
"inboundRules",
|
|
317
|
+
[422],
|
|
318
|
+
"message",
|
|
319
|
+
"Unable to remove this inbound rule. Please contact support.",
|
|
320
|
+
],
|
|
321
|
+
[812, "inboundRules", [422], "message", "This inbound rule was not found."],
|
|
322
|
+
// Message Streams
|
|
323
|
+
[1220, "streams", [422], "message", "You do not have permission to use the message streams API."],
|
|
324
|
+
[
|
|
325
|
+
1221,
|
|
326
|
+
"streams",
|
|
327
|
+
[422],
|
|
328
|
+
"message",
|
|
329
|
+
"The 'MessageStreamType' associated with this request was invalid.",
|
|
330
|
+
],
|
|
331
|
+
[1222, "streams", [422], "message", "A valid 'ID' must be provided."],
|
|
332
|
+
[1223, "streams", [422], "message", "A valid 'Name' must be provided."],
|
|
333
|
+
[1224, "streams", [422], "message", "The 'Name' is too long."],
|
|
334
|
+
[
|
|
335
|
+
1225,
|
|
336
|
+
"streams",
|
|
337
|
+
[422],
|
|
338
|
+
"message",
|
|
339
|
+
"You have reached the maximum number of message streams for this server.",
|
|
340
|
+
],
|
|
341
|
+
// SDK text: sdk/postmark-php/tests/PostmarkClientSuppressionsTest.php:135 (docs/04 §4.4).
|
|
342
|
+
[1226, "streams", [422], "message", "The message stream for the provided 'ID' was not found."],
|
|
343
|
+
[
|
|
344
|
+
1227,
|
|
345
|
+
"streams",
|
|
346
|
+
[422],
|
|
347
|
+
"message",
|
|
348
|
+
"The 'ID' must be a non-empty string starting with a letter, up to 30 characters.",
|
|
349
|
+
],
|
|
350
|
+
[1228, "streams", [422], "message", "A server can only have one inbound stream."],
|
|
351
|
+
[
|
|
352
|
+
1229,
|
|
353
|
+
"streams",
|
|
354
|
+
[422],
|
|
355
|
+
"message",
|
|
356
|
+
"You cannot archive the default transactional and inbound streams.",
|
|
357
|
+
],
|
|
358
|
+
[1230, "streams", [422], "message", "The 'ID' provided already exists for this server."],
|
|
359
|
+
[1231, "streams", [422], "message", "The 'Description' is too long."],
|
|
360
|
+
[1232, "streams", [422], "message", "You cannot unarchive this message stream anymore."],
|
|
361
|
+
[1233, "streams", [422], "message", "The 'ID' must not start with the 'pm-' prefix."],
|
|
362
|
+
[1234, "streams", [422], "message", "The 'Description' must not contain HTML tags."],
|
|
363
|
+
[1237, "streams", [422], "message", "The 'ID' is reserved."],
|
|
364
|
+
[
|
|
365
|
+
1238,
|
|
366
|
+
"streams",
|
|
367
|
+
[422],
|
|
368
|
+
"message",
|
|
369
|
+
"You do not have permission to use Custom Unsubscribe Handling for this stream.",
|
|
370
|
+
],
|
|
371
|
+
[
|
|
372
|
+
1239,
|
|
373
|
+
"streams",
|
|
374
|
+
[422],
|
|
375
|
+
"message",
|
|
376
|
+
"The 'UnsubscribeHandlingType' provided is not supported for this stream type.",
|
|
377
|
+
],
|
|
378
|
+
[
|
|
379
|
+
1240,
|
|
380
|
+
"streams",
|
|
381
|
+
[422],
|
|
382
|
+
"message",
|
|
383
|
+
"The 'UnsubscribeHandlingType' associated with this request is invalid.",
|
|
384
|
+
],
|
|
385
|
+
[1241, "streams", [422], "message", "Stream is unable to be archived at this time."],
|
|
386
|
+
// Suppressions
|
|
387
|
+
[
|
|
388
|
+
1400,
|
|
389
|
+
"suppressions",
|
|
390
|
+
[422],
|
|
391
|
+
"message",
|
|
392
|
+
"Parameter 'count' should be an integer within the allowed range.",
|
|
393
|
+
],
|
|
394
|
+
[1401, "suppressions", [422], "message", "Parameter 'count' is required but was left out."],
|
|
395
|
+
[
|
|
396
|
+
1402,
|
|
397
|
+
"suppressions",
|
|
398
|
+
[422],
|
|
399
|
+
"message",
|
|
400
|
+
"Parameter 'offset' should be an integer greater than or equal to zero.",
|
|
401
|
+
],
|
|
402
|
+
[1403, "suppressions", [422], "message", "Parameter 'offset' is required but was left out."],
|
|
403
|
+
[1404, "suppressions", [422], "message", "Parameter 'SuppressionReason' is invalid."],
|
|
404
|
+
[1405, "suppressions", [422], "message", "Parameter 'Origin' is invalid."],
|
|
405
|
+
// Item text: refs/api_suppressions-api.md:158-161 (docs/04 §2.4).
|
|
406
|
+
[
|
|
407
|
+
1406,
|
|
408
|
+
"suppressions",
|
|
409
|
+
[200],
|
|
410
|
+
"message",
|
|
411
|
+
"You do not have the required authority to change this suppression.",
|
|
412
|
+
],
|
|
413
|
+
[1407, "suppressions", [422], "message", "Something went wrong when processing the request."],
|
|
414
|
+
[1408, "suppressions", [422, 200], "message", "An invalid email address was provided."],
|
|
415
|
+
[1409, "suppressions", [422], "message", "A proper request body must be provided."],
|
|
416
|
+
[
|
|
417
|
+
1410,
|
|
418
|
+
"suppressions",
|
|
419
|
+
[422],
|
|
420
|
+
"message",
|
|
421
|
+
"You cannot provide more than the maximum number of suppressions for this request.",
|
|
422
|
+
],
|
|
423
|
+
[
|
|
424
|
+
1411,
|
|
425
|
+
"suppressions",
|
|
426
|
+
[422],
|
|
427
|
+
"message",
|
|
428
|
+
"Parameter 'emailAddress' is required but was left out.",
|
|
429
|
+
],
|
|
430
|
+
// Sender Signatures & Domains
|
|
431
|
+
[
|
|
432
|
+
500,
|
|
433
|
+
"senders",
|
|
434
|
+
[422],
|
|
435
|
+
"summary",
|
|
436
|
+
"Signature/domain list paging ('count'/'offset' required or integer, up to 500).",
|
|
437
|
+
],
|
|
438
|
+
[
|
|
439
|
+
501,
|
|
440
|
+
"senders",
|
|
441
|
+
[422, 404, 500],
|
|
442
|
+
"summary",
|
|
443
|
+
"Signature not found (422/404), or the signature has no DKIM info (500).",
|
|
444
|
+
],
|
|
445
|
+
[502, "senders", [422], "message", "No update data or signature data received."],
|
|
446
|
+
[503, "senders", [422], "message", "You can't use public domain emails or public domains."],
|
|
447
|
+
[
|
|
448
|
+
504,
|
|
449
|
+
"senders",
|
|
450
|
+
[422],
|
|
451
|
+
"summary",
|
|
452
|
+
"This signature already exists, or a similar signature already exists.",
|
|
453
|
+
],
|
|
454
|
+
[505, "senders", [422], "message", "This DKIM is already being renewed."],
|
|
455
|
+
[506, "senders", [422], "message", "This Sender Signature has already been confirmed."],
|
|
456
|
+
[507, "senders", [422], "message", "You do not own this Sender Signature."],
|
|
457
|
+
[
|
|
458
|
+
508,
|
|
459
|
+
"senders",
|
|
460
|
+
[422],
|
|
461
|
+
"summary",
|
|
462
|
+
"This DKIM is not being renewed, or a key in a failed state cannot be rotated.",
|
|
463
|
+
],
|
|
464
|
+
[510, "senders", [422], "message", "This domain was not found."],
|
|
465
|
+
[511, "senders", [422], "message", "Invalid fields supplied."],
|
|
466
|
+
[512, "senders", [422], "message", "Domain already exists."],
|
|
467
|
+
[513, "senders", [422], "message", "You do not own this Domain."],
|
|
468
|
+
[514, "senders", [422], "message", "Name is a required field to create a Domain."],
|
|
469
|
+
[515, "senders", [422], "message", "Name field must be ≤ 255 characters."],
|
|
470
|
+
[516, "senders", [422], "message", "Name format is invalid."],
|
|
471
|
+
[520, "senders", [422], "message", "FromEmail is a required field to create a Sender Signature."],
|
|
472
|
+
[
|
|
473
|
+
521,
|
|
474
|
+
"senders",
|
|
475
|
+
[422],
|
|
476
|
+
"summary",
|
|
477
|
+
"A field is too long (confirmation note, Name, FromEmail, ReplyToEmail, ReturnPathDomain, or CustomTrackingDomain).",
|
|
478
|
+
],
|
|
479
|
+
[522, "senders", [422], "summary", "A value is not a valid email address, domain, or subdomain."],
|
|
480
|
+
[
|
|
481
|
+
523,
|
|
482
|
+
"senders",
|
|
483
|
+
[422],
|
|
484
|
+
"message",
|
|
485
|
+
"You need to add a CNAME record that points to the expected value.",
|
|
486
|
+
],
|
|
487
|
+
[614, "senders", [422], "summary", "Signature/domain entitlement limit reached."],
|
|
488
|
+
[
|
|
489
|
+
709,
|
|
490
|
+
"senders",
|
|
491
|
+
[500],
|
|
492
|
+
"message",
|
|
493
|
+
"DKIM verification failed due to invalid configuration. Please contact support.",
|
|
494
|
+
],
|
|
495
|
+
// SMTP Tokens
|
|
496
|
+
[1450, "smtpTokens", [422], "message", "Parameter 'serverId' is required but was left out."],
|
|
497
|
+
[1451, "smtpTokens", [422], "message", "This token could not be found."],
|
|
498
|
+
[1452, "smtpTokens", [422], "message", "A request body must be provided."],
|
|
499
|
+
[1453, "smtpTokens", [422], "message", "This server was not found."],
|
|
500
|
+
[
|
|
501
|
+
1454,
|
|
502
|
+
"smtpTokens",
|
|
503
|
+
[422],
|
|
504
|
+
"summary",
|
|
505
|
+
"A valid 'MessageStream' is required, or the specified stream does not exist.",
|
|
506
|
+
],
|
|
507
|
+
[
|
|
508
|
+
1455,
|
|
509
|
+
"smtpTokens",
|
|
510
|
+
[422],
|
|
511
|
+
"message",
|
|
512
|
+
"The request must contain a valid and existing 'ServerID'.",
|
|
513
|
+
],
|
|
514
|
+
[1456, "smtpTokens", [422], "message", "Token length must be within the allowed range."],
|
|
515
|
+
[1457, "smtpTokens", [422], "message", "Tokens cannot be used with inbound streams."],
|
|
516
|
+
[
|
|
517
|
+
1458,
|
|
518
|
+
"smtpTokens",
|
|
519
|
+
[422],
|
|
520
|
+
"message",
|
|
521
|
+
"A message stream's token limit would be exceeded by this request.",
|
|
522
|
+
],
|
|
523
|
+
[
|
|
524
|
+
1459,
|
|
525
|
+
"smtpTokens",
|
|
526
|
+
[422],
|
|
527
|
+
"message",
|
|
528
|
+
"A token cannot be issued for an archived stream scheduled for deletion.",
|
|
529
|
+
],
|
|
530
|
+
[1460, "smtpTokens", [422], "message", "SMTP is currently disabled for the specified server."],
|
|
531
|
+
// Statistics API
|
|
532
|
+
[
|
|
533
|
+
614,
|
|
534
|
+
"stats",
|
|
535
|
+
[422],
|
|
536
|
+
"message",
|
|
537
|
+
"You are not entitled to use the stats API. Upgrade to the next tier to add it.",
|
|
538
|
+
],
|
|
539
|
+
[900, "stats", [422], "message", "A parameter should be a date/time value."],
|
|
540
|
+
// Same text as streams 1226 (INFERRED).
|
|
541
|
+
[1226, "stats", [422], "message", "The message stream for the provided 'ID' was not found."],
|
|
542
|
+
[1500, "stats", [422], "message", "The 'FromDate' field cannot be older than one year ago."],
|
|
543
|
+
[
|
|
544
|
+
1501,
|
|
545
|
+
"stats",
|
|
546
|
+
[422],
|
|
547
|
+
"message",
|
|
548
|
+
"Parameter 'count' should be an integer within the allowed range.",
|
|
549
|
+
],
|
|
550
|
+
[1502, "stats", [422], "message", "Parameter 'FromDate' must be older than 'ToDate'."],
|
|
551
|
+
// GDPR API
|
|
552
|
+
[1300, "dataRemovals", [422], "summary", "Empty request, or an invalid offset or count."],
|
|
553
|
+
[1301, "dataRemovals", [422], "summary", "Missing or incorrect data removal request ID."],
|
|
554
|
+
[
|
|
555
|
+
1302,
|
|
556
|
+
"dataRemovals",
|
|
557
|
+
[422],
|
|
558
|
+
"message",
|
|
559
|
+
"You don't have permission to process or review data removal requests through the API.",
|
|
560
|
+
],
|
|
561
|
+
// Webhooks API
|
|
562
|
+
[
|
|
563
|
+
1350,
|
|
564
|
+
"webhooks",
|
|
565
|
+
[422],
|
|
566
|
+
"message",
|
|
567
|
+
"You cannot create a webhook using an archived 'MessageStream'.",
|
|
568
|
+
],
|
|
569
|
+
[1351, "webhooks", [422], "message", "You cannot create a webhook using an inbound stream."],
|
|
570
|
+
[1352, "webhooks", [422], "message", "The webhook for the provided 'ID' was not found."],
|
|
571
|
+
[
|
|
572
|
+
1353,
|
|
573
|
+
"webhooks",
|
|
574
|
+
[422],
|
|
575
|
+
"message",
|
|
576
|
+
"The webhook trigger is not supported on this message stream.",
|
|
577
|
+
],
|
|
578
|
+
[1354, "webhooks", [422], "message", "The request must contain a valid 'Url' field."],
|
|
579
|
+
[1355, "webhooks", [422], "message", "A request body must be provided."],
|
|
580
|
+
[
|
|
581
|
+
1356,
|
|
582
|
+
"webhooks",
|
|
583
|
+
[422],
|
|
584
|
+
"message",
|
|
585
|
+
"A request 'ID' must not be provided when creating a webhook.",
|
|
586
|
+
],
|
|
587
|
+
[
|
|
588
|
+
1357,
|
|
589
|
+
"webhooks",
|
|
590
|
+
[422],
|
|
591
|
+
"message",
|
|
592
|
+
"You cannot update the 'ID' or 'MessageStream' fields of a webhook.",
|
|
593
|
+
],
|
|
594
|
+
[1358, "webhooks", [422], "message", "You must provide a valid 'HttpHeader' 'Name'."],
|
|
595
|
+
[
|
|
596
|
+
1359,
|
|
597
|
+
"webhooks",
|
|
598
|
+
[422],
|
|
599
|
+
"message",
|
|
600
|
+
"You have reached the maximum number of webhooks for this stream.",
|
|
601
|
+
],
|
|
602
|
+
[1360, "webhooks", [422], "message", "You cannot update the integration."],
|
|
603
|
+
[1361, "webhooks", [422], "message", "Invalid value provided for a field."],
|
|
604
|
+
[
|
|
605
|
+
1362,
|
|
606
|
+
"webhooks",
|
|
607
|
+
[422],
|
|
608
|
+
"message",
|
|
609
|
+
"Invalid value provided for 'status'. Must be one of: verified, unverified.",
|
|
610
|
+
],
|
|
611
|
+
[
|
|
612
|
+
1363,
|
|
613
|
+
"webhooks",
|
|
614
|
+
[422],
|
|
615
|
+
"message",
|
|
616
|
+
"The 'Status' field cannot be provided when creating or updating a webhook.",
|
|
617
|
+
],
|
|
618
|
+
[
|
|
619
|
+
1364,
|
|
620
|
+
"webhooks",
|
|
621
|
+
[422],
|
|
622
|
+
"summary",
|
|
623
|
+
"Webhook verification failed; nothing was saved. Fix the endpoint and retry, or send '?verify=false' to save it unverified.",
|
|
624
|
+
],
|
|
625
|
+
];
|
|
626
|
+
/** A Postmark error response. The HTTP app turns it into the envelope (docs/02 §4.1). */
|
|
627
|
+
export class ApiError extends Error {
|
|
628
|
+
status;
|
|
629
|
+
body;
|
|
630
|
+
constructor(status, body) {
|
|
631
|
+
super(`${status} ErrorCode ${body.ErrorCode}: ${body.Message}`);
|
|
632
|
+
this.status = status;
|
|
633
|
+
this.body = body;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
function row(code, family) {
|
|
637
|
+
const rows = ERROR_TABLE.filter((r) => r[0] === code && (family === undefined || r[1] === family));
|
|
638
|
+
const [only, ...rest] = rows;
|
|
639
|
+
if (only === undefined)
|
|
640
|
+
throw new Error(`ErrorCode ${code} is not in docs/02 §4.4`);
|
|
641
|
+
if (rest.length > 0)
|
|
642
|
+
throw new Error(`ErrorCode ${code} needs a family`);
|
|
643
|
+
return only;
|
|
644
|
+
}
|
|
645
|
+
function render(template, params) {
|
|
646
|
+
const used = new Set();
|
|
647
|
+
const text = template.replace(/\{(\w+)\}/g, (_, name) => {
|
|
648
|
+
const value = params[name];
|
|
649
|
+
if (value === undefined)
|
|
650
|
+
throw new Error(`missing message param '${name}'`);
|
|
651
|
+
used.add(name);
|
|
652
|
+
return value;
|
|
653
|
+
});
|
|
654
|
+
const unused = Object.keys(params).filter((name) => !used.has(name));
|
|
655
|
+
if (unused.length > 0)
|
|
656
|
+
throw new Error(`unused message params: ${unused.join(", ")}`);
|
|
657
|
+
return text;
|
|
658
|
+
}
|
|
659
|
+
/** Whether the docs/02 §4.4 row of `code` is a summary that needs an exact message. */
|
|
660
|
+
export const isSummaryRow = (code, family) => row(code, family)[3] === "summary";
|
|
661
|
+
/** `{ErrorCode, Message}` for a response body or a batch item. */
|
|
662
|
+
export function errorBody(code, options = {}) {
|
|
663
|
+
const [, , , wording, text] = row(code, options.family);
|
|
664
|
+
if (options.message !== undefined)
|
|
665
|
+
return { ErrorCode: code, Message: options.message };
|
|
666
|
+
if (wording === "summary") {
|
|
667
|
+
throw new Error(`ErrorCode ${code} has a summary row in docs/02 §4.4; pass the exact message`);
|
|
668
|
+
}
|
|
669
|
+
return { ErrorCode: code, Message: render(text, options.params ?? {}) };
|
|
670
|
+
}
|
|
671
|
+
/** An HTTP error for `code`. `status` is required when the code uses several statuses. */
|
|
672
|
+
export function apiError(code, options = {}) {
|
|
673
|
+
const statuses = row(code, options.family)[2].filter((s) => s !== 200);
|
|
674
|
+
const [first, ...others] = statuses;
|
|
675
|
+
if (first === undefined)
|
|
676
|
+
throw new Error(`ErrorCode ${code} only appears inside a 200 body`);
|
|
677
|
+
const status = options.status ?? (others.length === 0 ? first : undefined);
|
|
678
|
+
if (status === undefined || !statuses.includes(status)) {
|
|
679
|
+
throw new Error(`ErrorCode ${code} needs a status from ${statuses.join(", ")}`);
|
|
680
|
+
}
|
|
681
|
+
for (const key of ["ErrorCode", "Message"]) {
|
|
682
|
+
if (options.extra !== undefined && key in options.extra)
|
|
683
|
+
throw new Error(`extra may not set ${key}`);
|
|
684
|
+
}
|
|
685
|
+
return new ApiError(status, { ...errorBody(code, options), ...options.extra });
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* The HTTP error for a body `errorBody` built earlier, such as a send rejection. The code may sit
|
|
689
|
+
* under several families; every row of it must use the same single status.
|
|
690
|
+
*/
|
|
691
|
+
export function apiErrorOf(body) {
|
|
692
|
+
const rows = ERROR_TABLE.filter((r) => r[0] === body.ErrorCode);
|
|
693
|
+
if (rows.length === 0)
|
|
694
|
+
throw new Error(`ErrorCode ${body.ErrorCode} is not in docs/02 §4.4`);
|
|
695
|
+
const statuses = new Set(rows.flatMap((r) => r[2]).filter((s) => s !== 200));
|
|
696
|
+
const [status, ...others] = statuses;
|
|
697
|
+
if (status === undefined || others.length > 0) {
|
|
698
|
+
throw new Error(`ErrorCode ${body.ErrorCode} has no single HTTP status`);
|
|
699
|
+
}
|
|
700
|
+
return new ApiError(status, body);
|
|
701
|
+
}
|