@open-send/sdk 0.0.0-stage → 1.0.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.
- package/LICENSE +22 -0
- package/README.md +143 -2
- package/dist/index.cjs +1793 -0
- package/dist/index.d.cts +4303 -0
- package/dist/index.d.mts +4303 -0
- package/dist/index.mjs +1751 -0
- package/package.json +48 -4
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1751 @@
|
|
|
1
|
+
// constants/client.ts
|
|
2
|
+
var OPENSEND_VERSION = "1.0.0";
|
|
3
|
+
var OPENSEND_AGENT = `opensend-node/${OPENSEND_VERSION}`;
|
|
4
|
+
var OPENSEND_KEY_ENV = "OPENSEND_API_KEY";
|
|
5
|
+
var OPENSEND_URL_ENV = "OPENSEND_API_URL";
|
|
6
|
+
var OPENSEND_DEFAULT_URL = "https://api.opensend.sh";
|
|
7
|
+
var OPENSEND_TIMEOUT_MS = 30000;
|
|
8
|
+
var OPENSEND_BODY_VERBS = ["POST", "PATCH", "PUT"];
|
|
9
|
+
var OPENSEND_PATH_PARAM = /:([A-Za-z][A-Za-z0-9]*)/g;
|
|
10
|
+
var OPENSEND_TRAILING_SLASHES = /\/+$/;
|
|
11
|
+
var OPENSEND_ID_FIELD = "id";
|
|
12
|
+
var OPENSEND_JSON_TYPE = "application/json";
|
|
13
|
+
var OPENSEND_IDEMPOTENCY_HEADER = "idempotency-key";
|
|
14
|
+
var OPENSEND_REQUEST_ID_HEADER = "x-request-id";
|
|
15
|
+
var OPENSEND_TIMEOUT_NAME = "TimeoutError";
|
|
16
|
+
var OPENSEND_ERROR_NAME = "OpenSendError";
|
|
17
|
+
var OPENSEND_ERROR_CODES = {
|
|
18
|
+
MISSING_KEY: "missing_api_key",
|
|
19
|
+
MISSING_PARAMETER: "missing_parameter",
|
|
20
|
+
NETWORK: "network_error",
|
|
21
|
+
TIMEOUT: "timeout",
|
|
22
|
+
UNEXPECTED: "unexpected_response",
|
|
23
|
+
INVALID_SIGNATURE: "invalid_signature",
|
|
24
|
+
ABORTED: "aborted",
|
|
25
|
+
INVALID_OPTION: "invalid_option",
|
|
26
|
+
BROWSER: "browser_refused"
|
|
27
|
+
};
|
|
28
|
+
var OPENSEND_MISSING_KEY = "Give an API key: new OpenSend(key), or set OPENSEND_API_KEY.";
|
|
29
|
+
var OPENSEND_NETWORK_MESSAGE = "The API could not be reached.";
|
|
30
|
+
var OPENSEND_TIMEOUT_MESSAGE = "The API did not answer in time.";
|
|
31
|
+
var OPENSEND_UNEXPECTED_MESSAGE = "The API answered with something unexpected.";
|
|
32
|
+
var OPENSEND_ABORTED_MESSAGE = "The call was given up before the API answered.";
|
|
33
|
+
var OPENSEND_INVALID_ADDRESS = "Give the API an address that starts with https://, or http:// on this computer.";
|
|
34
|
+
var OPENSEND_INVALID_TIMEOUT = "Give timeoutMs as a whole number of milliseconds, from 1 to 2147483647.";
|
|
35
|
+
var OPENSEND_HTTPS_SCHEME = "https:";
|
|
36
|
+
var OPENSEND_HTTP_SCHEME = "http:";
|
|
37
|
+
var OPENSEND_LOOPBACK_NAMES = ["localhost", "127.0.0.1", "[::1]"];
|
|
38
|
+
var OPENSEND_TIMEOUT_MAX = 2147483647;
|
|
39
|
+
var OPENSEND_BROWSER_GLOBALS = ["window", "document"];
|
|
40
|
+
var OPENSEND_BROWSER_REFUSED = "The SDK runs on a server. In a web page anyone could read your API key, so call your own server from the page and the SDK from there.";
|
|
41
|
+
var OPENSEND_SIGNATURE_NO_SECRET = "No signing secret was given, so the signature cannot be checked. Pass the secret of your webhook endpoint.";
|
|
42
|
+
var opensendMissingParameter = (name, method) => `${method} needs ${name}.`;
|
|
43
|
+
var OPENSEND_DOT_SEGMENTS = [".", ".."];
|
|
44
|
+
var opensendDotParameter = (name, method) => `${method} cannot take . or .. as ${name}.`;
|
|
45
|
+
var OPENSEND_SIGNATURE_HEADER = "opensend-signature";
|
|
46
|
+
var OPENSEND_SIGNATURE_TIME = "t";
|
|
47
|
+
var OPENSEND_SIGNATURE_VERSION = "v1";
|
|
48
|
+
var OPENSEND_SIGNATURE_PART = ",";
|
|
49
|
+
var OPENSEND_SIGNATURE_PAIR = "=";
|
|
50
|
+
var OPENSEND_SIGNATURE_TOLERANCE_S = 300;
|
|
51
|
+
var OPENSEND_MS_PER_SECOND = 1000;
|
|
52
|
+
var OPENSEND_HMAC = { name: "HMAC", hash: "SHA-256" };
|
|
53
|
+
var OPENSEND_HMAC_USES = ["sign"];
|
|
54
|
+
var OPENSEND_HEX_RADIX = 16;
|
|
55
|
+
var OPENSEND_HEX_PAD = 2;
|
|
56
|
+
var OPENSEND_SIGNATURE_MISSING = "The webhook has no signature, or one that cannot be read.";
|
|
57
|
+
var OPENSEND_SIGNATURE_OLD = "The webhook is too old, or the clocks are too far apart.";
|
|
58
|
+
var OPENSEND_SIGNATURE_WRONG = "The signature does not match: the secret is wrong or the body was changed.";
|
|
59
|
+
var OPENSEND_SIGNATURE_BODY = "The webhook body is not the JSON of an event.";
|
|
60
|
+
|
|
61
|
+
// constants/methods.ts
|
|
62
|
+
var OPENSEND_EFFECTS = {
|
|
63
|
+
READ: "read",
|
|
64
|
+
WRITE: "write",
|
|
65
|
+
SEND: "send",
|
|
66
|
+
DESTROY: "destroy"
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// constants/methods.generated.ts
|
|
70
|
+
var OPENSEND_METHODS = [
|
|
71
|
+
{
|
|
72
|
+
name: "emails.send",
|
|
73
|
+
namespace: "emails",
|
|
74
|
+
call: "send",
|
|
75
|
+
verb: "POST",
|
|
76
|
+
path: "/v1/emails",
|
|
77
|
+
title: "Send email",
|
|
78
|
+
description: "Sends one email to up to fifty addresses, from an address on a verified domain of the workspace. It takes cc, bcc, a reply address, headers, tags, attachments, a published template with its variables and a time to send at. With an idempotency key (the field, or the Idempotency-Key header) a repeat within a day answers with the first email. Sent with a test key, or to test addresses only, the email belongs to the sandbox: its `mode` is `test`, it reaches nobody and what happens to it is simulated.",
|
|
79
|
+
effect: OPENSEND_EFFECTS.SEND,
|
|
80
|
+
tool: "emails_send",
|
|
81
|
+
idOnly: false
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "emails.batch",
|
|
85
|
+
namespace: "emails",
|
|
86
|
+
call: "batch",
|
|
87
|
+
verb: "POST",
|
|
88
|
+
path: "/v1/emails/batch",
|
|
89
|
+
title: "Send emails in a batch",
|
|
90
|
+
description: "Sends up to a hundred emails in one request. Every email is checked first and one that is refused refuses the whole batch, unless `validation` is `permissive`: then the rest are sent and the refused one is listed with its reason. After that each email is accepted or refused by itself, and the answer says which.",
|
|
91
|
+
effect: OPENSEND_EFFECTS.SEND,
|
|
92
|
+
tool: "emails_batch",
|
|
93
|
+
idOnly: false
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "emails.update",
|
|
97
|
+
namespace: "emails",
|
|
98
|
+
call: "update",
|
|
99
|
+
verb: "PATCH",
|
|
100
|
+
path: "/v1/emails/:id",
|
|
101
|
+
title: "Reschedule email",
|
|
102
|
+
description: "Moves an email that is still scheduled to another time, at most 30 days ahead.",
|
|
103
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
104
|
+
tool: "emails_update",
|
|
105
|
+
idOnly: false
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "emails.cancel",
|
|
109
|
+
namespace: "emails",
|
|
110
|
+
call: "cancel",
|
|
111
|
+
verb: "POST",
|
|
112
|
+
path: "/v1/emails/:id/cancel",
|
|
113
|
+
title: "Cancel email",
|
|
114
|
+
description: "Cancels an email that is still scheduled, so it is never sent.",
|
|
115
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
116
|
+
tool: "emails_cancel",
|
|
117
|
+
idOnly: true
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "emails.get",
|
|
121
|
+
namespace: "emails",
|
|
122
|
+
call: "get",
|
|
123
|
+
verb: "GET",
|
|
124
|
+
path: "/v1/emails/:id",
|
|
125
|
+
title: "Retrieve email",
|
|
126
|
+
description: "One email with its body and every event that has happened to it.",
|
|
127
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
128
|
+
tool: "emails_get",
|
|
129
|
+
idOnly: true
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "emails.list",
|
|
133
|
+
namespace: "emails",
|
|
134
|
+
call: "list",
|
|
135
|
+
verb: "GET",
|
|
136
|
+
path: "/v1/emails",
|
|
137
|
+
title: "List emails",
|
|
138
|
+
description: "The emails the workspace has sent, newest first, by status, time and search.",
|
|
139
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
140
|
+
tool: "emails_list",
|
|
141
|
+
idOnly: false
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "broadcasts.create",
|
|
145
|
+
namespace: "broadcasts",
|
|
146
|
+
call: "create",
|
|
147
|
+
verb: "POST",
|
|
148
|
+
path: "/v1/broadcasts",
|
|
149
|
+
title: "Create broadcast",
|
|
150
|
+
description: "Creates a draft broadcast for one audience. Nothing is sent until you send it.",
|
|
151
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
152
|
+
tool: "broadcasts_create",
|
|
153
|
+
idOnly: false
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "broadcasts.update",
|
|
157
|
+
namespace: "broadcasts",
|
|
158
|
+
call: "update",
|
|
159
|
+
verb: "PATCH",
|
|
160
|
+
path: "/v1/broadcasts/:id",
|
|
161
|
+
title: "Update broadcast",
|
|
162
|
+
description: "Changes the name, audience, subject, sender, reply address or message of a broadcast that has not started sending.",
|
|
163
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
164
|
+
tool: "broadcasts_update",
|
|
165
|
+
idOnly: false
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "broadcasts.send",
|
|
169
|
+
namespace: "broadcasts",
|
|
170
|
+
call: "send",
|
|
171
|
+
verb: "POST",
|
|
172
|
+
path: "/v1/broadcasts/:id/send",
|
|
173
|
+
title: "Send broadcast",
|
|
174
|
+
description: "Schedules a broadcast for now, or for a later time, to everyone subscribed to its audience.",
|
|
175
|
+
effect: OPENSEND_EFFECTS.SEND,
|
|
176
|
+
tool: "broadcasts_send",
|
|
177
|
+
idOnly: false
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: "broadcasts.test",
|
|
181
|
+
namespace: "broadcasts",
|
|
182
|
+
call: "test",
|
|
183
|
+
verb: "POST",
|
|
184
|
+
path: "/v1/broadcasts/:id/test",
|
|
185
|
+
title: "Send test of broadcast",
|
|
186
|
+
description: 'Sends the broadcast as it is saved now to the addresses you give, with "[Test]" before the subject, and leaves the broadcast as it is. It needs a sender, a subject and a message. It is a real email and counts as one. A test key may send it to test addresses only, and the email is then simulated.',
|
|
187
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
188
|
+
tool: "broadcasts_test",
|
|
189
|
+
idOnly: false
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "broadcasts.duplicate",
|
|
193
|
+
namespace: "broadcasts",
|
|
194
|
+
call: "duplicate",
|
|
195
|
+
verb: "POST",
|
|
196
|
+
path: "/v1/broadcasts/:id/duplicate",
|
|
197
|
+
title: "Duplicate broadcast",
|
|
198
|
+
description: "Copies a broadcast into a new draft: its audience, sender, subject and message. It works on one that was already sent, and the copy is not scheduled.",
|
|
199
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
200
|
+
tool: "broadcasts_duplicate",
|
|
201
|
+
idOnly: false
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: "broadcasts.get",
|
|
205
|
+
namespace: "broadcasts",
|
|
206
|
+
call: "get",
|
|
207
|
+
verb: "GET",
|
|
208
|
+
path: "/v1/broadcasts/:id",
|
|
209
|
+
title: "Retrieve broadcast",
|
|
210
|
+
description: "One broadcast with its audience, its schedule and how many it reached.",
|
|
211
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
212
|
+
tool: "broadcasts_get",
|
|
213
|
+
idOnly: true
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
name: "broadcasts.list",
|
|
217
|
+
namespace: "broadcasts",
|
|
218
|
+
call: "list",
|
|
219
|
+
verb: "GET",
|
|
220
|
+
path: "/v1/broadcasts",
|
|
221
|
+
title: "List broadcasts",
|
|
222
|
+
description: "The broadcasts of the workspace, newest first, by status and audience.",
|
|
223
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
224
|
+
tool: "broadcasts_list",
|
|
225
|
+
idOnly: false
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: "broadcasts.remove",
|
|
229
|
+
namespace: "broadcasts",
|
|
230
|
+
call: "remove",
|
|
231
|
+
verb: "DELETE",
|
|
232
|
+
path: "/v1/broadcasts/:id",
|
|
233
|
+
title: "Delete broadcast",
|
|
234
|
+
description: "Deletes a broadcast. A scheduled one is never sent.",
|
|
235
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
236
|
+
tool: "broadcasts_remove",
|
|
237
|
+
idOnly: true
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: "audiences.create",
|
|
241
|
+
namespace: "audiences",
|
|
242
|
+
call: "create",
|
|
243
|
+
verb: "POST",
|
|
244
|
+
path: "/v1/audiences",
|
|
245
|
+
title: "Create audience",
|
|
246
|
+
description: "Creates an empty audience that contacts can join and broadcasts can be sent to.",
|
|
247
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
248
|
+
tool: "audiences_create",
|
|
249
|
+
idOnly: false
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: "audiences.list",
|
|
253
|
+
namespace: "audiences",
|
|
254
|
+
call: "list",
|
|
255
|
+
verb: "GET",
|
|
256
|
+
path: "/v1/audiences",
|
|
257
|
+
title: "List audiences",
|
|
258
|
+
description: "The audiences of the workspace with how many contacts each holds.",
|
|
259
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
260
|
+
tool: "audiences_list",
|
|
261
|
+
idOnly: false
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: "audiences.get",
|
|
265
|
+
namespace: "audiences",
|
|
266
|
+
call: "get",
|
|
267
|
+
verb: "GET",
|
|
268
|
+
path: "/v1/audiences/:id",
|
|
269
|
+
title: "Retrieve audience",
|
|
270
|
+
description: "One audience with how many contacts it holds.",
|
|
271
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
272
|
+
tool: "audiences_get",
|
|
273
|
+
idOnly: true
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
name: "audiences.update",
|
|
277
|
+
namespace: "audiences",
|
|
278
|
+
call: "update",
|
|
279
|
+
verb: "PATCH",
|
|
280
|
+
path: "/v1/audiences/:id",
|
|
281
|
+
title: "Rename audience",
|
|
282
|
+
description: "Gives an audience another name. Its contacts and its broadcasts stay as they are.",
|
|
283
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
284
|
+
tool: "audiences_update",
|
|
285
|
+
idOnly: false
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
name: "audiences.remove",
|
|
289
|
+
namespace: "audiences",
|
|
290
|
+
call: "remove",
|
|
291
|
+
verb: "DELETE",
|
|
292
|
+
path: "/v1/audiences/:id",
|
|
293
|
+
title: "Delete audience",
|
|
294
|
+
description: "Deletes an audience. Its contacts stay in the workspace and in their other audiences.",
|
|
295
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
296
|
+
tool: "audiences_remove",
|
|
297
|
+
idOnly: true
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: "audiences.join",
|
|
301
|
+
namespace: "audiences",
|
|
302
|
+
call: "join",
|
|
303
|
+
verb: "POST",
|
|
304
|
+
path: "/v1/audiences/:id/contacts/:contact",
|
|
305
|
+
title: "Add contact to audience",
|
|
306
|
+
description: "Puts a contact of the workspace into an audience. A contact can be in many, and one that is already in it stays as it is.",
|
|
307
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
308
|
+
tool: "audiences_join",
|
|
309
|
+
idOnly: false
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: "audiences.leave",
|
|
313
|
+
namespace: "audiences",
|
|
314
|
+
call: "leave",
|
|
315
|
+
verb: "DELETE",
|
|
316
|
+
path: "/v1/audiences/:id/contacts/:contact",
|
|
317
|
+
title: "Remove contact from audience",
|
|
318
|
+
description: "Takes a contact out of one audience. The contact stays in the workspace and in their other audiences.",
|
|
319
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
320
|
+
tool: "audiences_leave",
|
|
321
|
+
idOnly: false
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
name: "templates.create",
|
|
325
|
+
namespace: "templates",
|
|
326
|
+
call: "create",
|
|
327
|
+
verb: "POST",
|
|
328
|
+
path: "/v1/templates",
|
|
329
|
+
title: "Create template",
|
|
330
|
+
description: "Creates a draft template: a subject and HTML, and when you want them a plain text version, a sender, a reply address and defaults for its variables. Give `design` to build it from blocks, or `starter` to begin with a ready-made one. Its alias is made from its name unless you give one.",
|
|
331
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
332
|
+
tool: "templates_create",
|
|
333
|
+
idOnly: false
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: "templates.get",
|
|
337
|
+
namespace: "templates",
|
|
338
|
+
call: "get",
|
|
339
|
+
verb: "GET",
|
|
340
|
+
path: "/v1/templates/:id",
|
|
341
|
+
title: "Get template",
|
|
342
|
+
description: "One template with its subject, HTML, plain text, sender and defaults.",
|
|
343
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
344
|
+
tool: "templates_get",
|
|
345
|
+
idOnly: true
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
name: "templates.list",
|
|
349
|
+
namespace: "templates",
|
|
350
|
+
call: "list",
|
|
351
|
+
verb: "GET",
|
|
352
|
+
path: "/v1/templates",
|
|
353
|
+
title: "List templates",
|
|
354
|
+
description: "The templates of the workspace, newest first, by status and search.",
|
|
355
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
356
|
+
tool: "templates_list",
|
|
357
|
+
idOnly: false
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
name: "templates.update",
|
|
361
|
+
namespace: "templates",
|
|
362
|
+
call: "update",
|
|
363
|
+
verb: "PATCH",
|
|
364
|
+
path: "/v1/templates/:id",
|
|
365
|
+
title: "Update template",
|
|
366
|
+
description: "Changes a template: its name, alias, subject, HTML, plain text, sender, reply address or the defaults of its variables. What was published keeps being sent until the template is published again.",
|
|
367
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
368
|
+
tool: "templates_update",
|
|
369
|
+
idOnly: false
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
name: "templates.edit",
|
|
373
|
+
namespace: "templates",
|
|
374
|
+
call: "edit",
|
|
375
|
+
verb: "POST",
|
|
376
|
+
path: "/v1/templates/:id/edit",
|
|
377
|
+
title: "Edit template design",
|
|
378
|
+
description: "Changes single blocks of a template built from blocks, in place of sending its whole design: add a block, change its fields, its style, its phone style or its dark mode colours, move it, take it out or copy it, or change the style, the dark mode colours, the preview, the fonts or the CSS of the whole message. The operations run in order, and when one is refused nothing is saved. The HTML and the plain text are made from the design again.",
|
|
379
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
380
|
+
tool: "templates_edit",
|
|
381
|
+
idOnly: false
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
name: "templates.publish",
|
|
385
|
+
namespace: "templates",
|
|
386
|
+
call: "publish",
|
|
387
|
+
verb: "POST",
|
|
388
|
+
path: "/v1/templates/:id/publish",
|
|
389
|
+
title: "Publish template",
|
|
390
|
+
description: "Publishes a template as it is now, so emails can use it. Later edits are not sent until it is published again.",
|
|
391
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
392
|
+
tool: "templates_publish",
|
|
393
|
+
idOnly: true
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
name: "templates.test",
|
|
397
|
+
namespace: "templates",
|
|
398
|
+
call: "test",
|
|
399
|
+
verb: "POST",
|
|
400
|
+
path: "/v1/templates/:id/test",
|
|
401
|
+
title: "Send test of template",
|
|
402
|
+
description: 'Sends the template as it is saved now, published or not, to the addresses you give, with "[Test]" before the subject. It needs a subject and a message. It is a real email and counts as one. A test key may send it to test addresses only, and the email is then simulated.',
|
|
403
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
404
|
+
tool: "templates_test",
|
|
405
|
+
idOnly: false
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
name: "templates.render",
|
|
409
|
+
namespace: "templates",
|
|
410
|
+
call: "render",
|
|
411
|
+
verb: "POST",
|
|
412
|
+
path: "/v1/templates/render",
|
|
413
|
+
title: "Render template design",
|
|
414
|
+
description: "Turns a design, the blocks a template can be built from, into the HTML and the plain text an email gets from it. Nothing is saved and nothing is sent. Give values for variables to see the message filled in.",
|
|
415
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
416
|
+
tool: "templates_render",
|
|
417
|
+
idOnly: false
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
name: "templates.duplicate",
|
|
421
|
+
namespace: "templates",
|
|
422
|
+
call: "duplicate",
|
|
423
|
+
verb: "POST",
|
|
424
|
+
path: "/v1/templates/:id/duplicate",
|
|
425
|
+
title: "Duplicate template",
|
|
426
|
+
description: "Copies a template as it is saved now into a new draft, with a free alias. The copy is not published.",
|
|
427
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
428
|
+
tool: "templates_duplicate",
|
|
429
|
+
idOnly: false
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
name: "templates.versions",
|
|
433
|
+
namespace: "templates",
|
|
434
|
+
call: "versions",
|
|
435
|
+
verb: "GET",
|
|
436
|
+
path: "/v1/templates/:id/versions",
|
|
437
|
+
title: "List template versions",
|
|
438
|
+
description: "The versions of one template, newest first. Every publish that changes something makes one, and the last 50 are kept.",
|
|
439
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
440
|
+
tool: "templates_versions",
|
|
441
|
+
idOnly: false
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
name: "templates.version",
|
|
445
|
+
namespace: "templates",
|
|
446
|
+
call: "version",
|
|
447
|
+
verb: "GET",
|
|
448
|
+
path: "/v1/templates/:id/versions/:version",
|
|
449
|
+
title: "Get template version",
|
|
450
|
+
description: "One version of a template with everything it holds: the subject, the HTML, the plain text, the sender, the reply address and the defaults.",
|
|
451
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
452
|
+
tool: "templates_version",
|
|
453
|
+
idOnly: false
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
name: "templates.restore",
|
|
457
|
+
namespace: "templates",
|
|
458
|
+
call: "restore",
|
|
459
|
+
verb: "POST",
|
|
460
|
+
path: "/v1/templates/:id/versions/:version/restore",
|
|
461
|
+
title: "Restore template version",
|
|
462
|
+
description: "Copies a version back into the template as the copy you edit. What is published keeps being sent until you publish again.",
|
|
463
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
464
|
+
tool: "templates_restore",
|
|
465
|
+
idOnly: false
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
name: "templates.remove",
|
|
469
|
+
namespace: "templates",
|
|
470
|
+
call: "remove",
|
|
471
|
+
verb: "DELETE",
|
|
472
|
+
path: "/v1/templates/:id",
|
|
473
|
+
title: "Delete template",
|
|
474
|
+
description: "Deletes a template. Emails already sent with it keep their content.",
|
|
475
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
476
|
+
tool: "templates_remove",
|
|
477
|
+
idOnly: true
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
name: "templates.starters",
|
|
481
|
+
namespace: "templates",
|
|
482
|
+
call: "starters",
|
|
483
|
+
verb: "GET",
|
|
484
|
+
path: "/v1/template-starters",
|
|
485
|
+
title: "List template starters",
|
|
486
|
+
description: "The ready-made templates a new template can start from, by kind and search. Each has a name, what it is for, the subject it starts with and the looks it can be drawn in. Its variables and its message come with `templates.starter`.",
|
|
487
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
488
|
+
tool: "templates_starters",
|
|
489
|
+
idOnly: false
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
name: "templates.starter",
|
|
493
|
+
namespace: "templates",
|
|
494
|
+
call: "starter",
|
|
495
|
+
verb: "GET",
|
|
496
|
+
path: "/v1/template-starters/:id",
|
|
497
|
+
title: "Get template starter",
|
|
498
|
+
description: "One ready-made template drawn in one of its looks: its blocks, the defaults of its variables, and the HTML and the plain text it makes with those defaults filled in. Nothing is saved. To make a template from it, pass its id as `starter` to `templates.create`.",
|
|
499
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
500
|
+
tool: "templates_starter",
|
|
501
|
+
idOnly: false
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
name: "automations.create",
|
|
505
|
+
namespace: "automations",
|
|
506
|
+
call: "create",
|
|
507
|
+
verb: "POST",
|
|
508
|
+
path: "/v1/automations",
|
|
509
|
+
title: "Create automation",
|
|
510
|
+
description: "Creates a draft automation: what starts it, its steps and its rules. Nothing runs until it is published.",
|
|
511
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
512
|
+
tool: "automations_create",
|
|
513
|
+
idOnly: false
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
name: "automations.update",
|
|
517
|
+
namespace: "automations",
|
|
518
|
+
call: "update",
|
|
519
|
+
verb: "PATCH",
|
|
520
|
+
path: "/v1/automations/:id",
|
|
521
|
+
title: "Update automation",
|
|
522
|
+
description: "Changes the copy you edit: the name, what starts it, its steps or its rules. What is running stays as it was until you publish.",
|
|
523
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
524
|
+
tool: "automations_update",
|
|
525
|
+
idOnly: false
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
name: "automations.publish",
|
|
529
|
+
namespace: "automations",
|
|
530
|
+
call: "publish",
|
|
531
|
+
verb: "POST",
|
|
532
|
+
path: "/v1/automations/:id/publish",
|
|
533
|
+
title: "Publish automation",
|
|
534
|
+
description: "Makes the copy you edit the one that runs, as a new version, and starts a draft. People already in it finish the version they entered on. It is refused while something is missing, and the answer says what.",
|
|
535
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
536
|
+
tool: "automations_publish",
|
|
537
|
+
idOnly: true
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
name: "automations.pause",
|
|
541
|
+
namespace: "automations",
|
|
542
|
+
call: "pause",
|
|
543
|
+
verb: "POST",
|
|
544
|
+
path: "/v1/automations/:id/pause",
|
|
545
|
+
title: "Pause automation",
|
|
546
|
+
description: "Pauses an active automation, so nobody new enters. The people already in it are held where they are, finish, or are taken out, as you choose.",
|
|
547
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
548
|
+
tool: "automations_pause",
|
|
549
|
+
idOnly: false
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
name: "automations.resume",
|
|
553
|
+
namespace: "automations",
|
|
554
|
+
call: "resume",
|
|
555
|
+
verb: "POST",
|
|
556
|
+
path: "/v1/automations/:id/resume",
|
|
557
|
+
title: "Resume automation",
|
|
558
|
+
description: "Starts a paused automation again. The people who were held go on from where they stopped.",
|
|
559
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
560
|
+
tool: "automations_resume",
|
|
561
|
+
idOnly: true
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
name: "automations.test",
|
|
565
|
+
namespace: "automations",
|
|
566
|
+
call: "test",
|
|
567
|
+
verb: "POST",
|
|
568
|
+
path: "/v1/automations/:id/test",
|
|
569
|
+
title: "Test automation",
|
|
570
|
+
description: 'Walks the copy you edit once, now, for one address. Its emails are really sent, with "[Test]" before the subject. Waits are skipped, a wait for an event takes its `no` path, and steps that change contacts or call webhooks are skipped. Nothing is counted.',
|
|
571
|
+
effect: OPENSEND_EFFECTS.SEND,
|
|
572
|
+
tool: "automations_test",
|
|
573
|
+
idOnly: false
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
name: "automations.enroll",
|
|
577
|
+
namespace: "automations",
|
|
578
|
+
call: "enroll",
|
|
579
|
+
verb: "POST",
|
|
580
|
+
path: "/v1/automations/:id/enroll",
|
|
581
|
+
title: "Enrol in automation",
|
|
582
|
+
description: "Starts a run of an active automation for one person, whatever its trigger is. The rule for entering again still holds.",
|
|
583
|
+
effect: OPENSEND_EFFECTS.SEND,
|
|
584
|
+
tool: "automations_enroll",
|
|
585
|
+
idOnly: false
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
name: "automations.duplicate",
|
|
589
|
+
namespace: "automations",
|
|
590
|
+
call: "duplicate",
|
|
591
|
+
verb: "POST",
|
|
592
|
+
path: "/v1/automations/:id/duplicate",
|
|
593
|
+
title: "Duplicate automation",
|
|
594
|
+
description: "Copies the automation you edit into a new draft, with its trigger, steps and rules.",
|
|
595
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
596
|
+
tool: "automations_duplicate",
|
|
597
|
+
idOnly: false
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
name: "automations.get",
|
|
601
|
+
namespace: "automations",
|
|
602
|
+
call: "get",
|
|
603
|
+
verb: "GET",
|
|
604
|
+
path: "/v1/automations/:id",
|
|
605
|
+
title: "Retrieve automation",
|
|
606
|
+
description: "One automation: the copy you edit with what is missing in it, and what happened at each step.",
|
|
607
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
608
|
+
tool: "automations_get",
|
|
609
|
+
idOnly: true
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
name: "automations.list",
|
|
613
|
+
namespace: "automations",
|
|
614
|
+
call: "list",
|
|
615
|
+
verb: "GET",
|
|
616
|
+
path: "/v1/automations",
|
|
617
|
+
title: "List automations",
|
|
618
|
+
description: "The automations of the workspace, newest first, by status and search, each with what its runs have done.",
|
|
619
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
620
|
+
tool: "automations_list",
|
|
621
|
+
idOnly: false
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
name: "automations.remove",
|
|
625
|
+
namespace: "automations",
|
|
626
|
+
call: "remove",
|
|
627
|
+
verb: "DELETE",
|
|
628
|
+
path: "/v1/automations/:id",
|
|
629
|
+
title: "Delete automation",
|
|
630
|
+
description: "Deletes an automation with its versions. The runs still going end at their next step.",
|
|
631
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
632
|
+
tool: "automations_remove",
|
|
633
|
+
idOnly: true
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
name: "runs.list",
|
|
637
|
+
namespace: "runs",
|
|
638
|
+
call: "list",
|
|
639
|
+
verb: "GET",
|
|
640
|
+
path: "/v1/automations/:automationId/runs",
|
|
641
|
+
title: "List runs",
|
|
642
|
+
description: "The runs of one automation, newest first: one for each time a person went through it, by status and address.",
|
|
643
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
644
|
+
tool: "runs_list",
|
|
645
|
+
idOnly: false
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
name: "runs.get",
|
|
649
|
+
namespace: "runs",
|
|
650
|
+
call: "get",
|
|
651
|
+
verb: "GET",
|
|
652
|
+
path: "/v1/automations/:automationId/runs/:id",
|
|
653
|
+
title: "Retrieve run",
|
|
654
|
+
description: "One run with the data that started it and what each step did.",
|
|
655
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
656
|
+
tool: "runs_get",
|
|
657
|
+
idOnly: false
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
name: "runs.cancel",
|
|
661
|
+
namespace: "runs",
|
|
662
|
+
call: "cancel",
|
|
663
|
+
verb: "POST",
|
|
664
|
+
path: "/v1/automations/:automationId/runs/:id/cancel",
|
|
665
|
+
title: "Cancel run",
|
|
666
|
+
description: "Takes one person out of an automation. Emails already sent are not recalled.",
|
|
667
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
668
|
+
tool: "runs_cancel",
|
|
669
|
+
idOnly: false
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
name: "runs.retry",
|
|
673
|
+
namespace: "runs",
|
|
674
|
+
call: "retry",
|
|
675
|
+
verb: "POST",
|
|
676
|
+
path: "/v1/automations/:automationId/runs/:id/retry",
|
|
677
|
+
title: "Retry run",
|
|
678
|
+
description: "Lets a run that failed go on from the step it failed at, on the version it entered with. An email it failed to send is really sent this time. It is refused for a run that did not fail.",
|
|
679
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
680
|
+
tool: "runs_retry",
|
|
681
|
+
idOnly: false
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
name: "events.send",
|
|
685
|
+
namespace: "events",
|
|
686
|
+
call: "send",
|
|
687
|
+
verb: "POST",
|
|
688
|
+
path: "/v1/events/send",
|
|
689
|
+
title: "Send event",
|
|
690
|
+
description: "Tells the workspace that something happened to one person. Every active automation that listens for the event starts a run, runs that wait for it go on, and runs it is an exit for end. The answer says how many of each.",
|
|
691
|
+
effect: OPENSEND_EFFECTS.SEND,
|
|
692
|
+
tool: "events_send",
|
|
693
|
+
idOnly: false
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
name: "events.create",
|
|
697
|
+
namespace: "events",
|
|
698
|
+
call: "create",
|
|
699
|
+
verb: "POST",
|
|
700
|
+
path: "/v1/events",
|
|
701
|
+
title: "Define event",
|
|
702
|
+
description: "Defines an event before it is sent, with the types its data has to carry. An event that is sent without being defined defines itself, with no types.",
|
|
703
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
704
|
+
tool: "events_create",
|
|
705
|
+
idOnly: false
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
name: "events.list",
|
|
709
|
+
namespace: "events",
|
|
710
|
+
call: "list",
|
|
711
|
+
verb: "GET",
|
|
712
|
+
path: "/v1/events",
|
|
713
|
+
title: "List events",
|
|
714
|
+
description: "The events the workspace knows, newest first, each with how often it was sent and when last.",
|
|
715
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
716
|
+
tool: "events_list",
|
|
717
|
+
idOnly: false
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
name: "events.get",
|
|
721
|
+
namespace: "events",
|
|
722
|
+
call: "get",
|
|
723
|
+
verb: "GET",
|
|
724
|
+
path: "/v1/events/:id",
|
|
725
|
+
title: "Retrieve event",
|
|
726
|
+
description: "One event by its id or its name, with the latest times it was sent and what each one set off.",
|
|
727
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
728
|
+
tool: "events_get",
|
|
729
|
+
idOnly: true
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
name: "events.update",
|
|
733
|
+
namespace: "events",
|
|
734
|
+
call: "update",
|
|
735
|
+
verb: "PATCH",
|
|
736
|
+
path: "/v1/events/:id",
|
|
737
|
+
title: "Update event",
|
|
738
|
+
description: "Changes the types the data of an event has to carry, or clears them.",
|
|
739
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
740
|
+
tool: "events_update",
|
|
741
|
+
idOnly: false
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
name: "events.remove",
|
|
745
|
+
namespace: "events",
|
|
746
|
+
call: "remove",
|
|
747
|
+
verb: "DELETE",
|
|
748
|
+
path: "/v1/events/:id",
|
|
749
|
+
title: "Delete event",
|
|
750
|
+
description: "Forgets an event and its types. Automations that listen for its name keep listening, what was received stays listed for ninety days, and sending it again defines it again.",
|
|
751
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
752
|
+
tool: "events_remove",
|
|
753
|
+
idOnly: true
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
name: "metrics.get",
|
|
757
|
+
namespace: "metrics",
|
|
758
|
+
call: "get",
|
|
759
|
+
verb: "GET",
|
|
760
|
+
path: "/v1/metrics",
|
|
761
|
+
title: "Retrieve metrics",
|
|
762
|
+
description: "Volume, delivery and engagement for a period: totals, rates, one row a day and one row a domain.",
|
|
763
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
764
|
+
tool: "metrics_get",
|
|
765
|
+
idOnly: false
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
name: "domains.create",
|
|
769
|
+
namespace: "domains",
|
|
770
|
+
call: "create",
|
|
771
|
+
verb: "POST",
|
|
772
|
+
path: "/v1/domains",
|
|
773
|
+
title: "Add domain",
|
|
774
|
+
description: "Adds a domain to the workspace and returns the DNS records to publish before it can send.",
|
|
775
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
776
|
+
tool: "domains_create",
|
|
777
|
+
idOnly: false
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
name: "domains.verify",
|
|
781
|
+
namespace: "domains",
|
|
782
|
+
call: "verify",
|
|
783
|
+
verb: "POST",
|
|
784
|
+
path: "/v1/domains/:id/verify",
|
|
785
|
+
title: "Verify domain",
|
|
786
|
+
description: "Looks up every DNS record of the domain and marks each one verified or still pending.",
|
|
787
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
788
|
+
tool: "domains_verify",
|
|
789
|
+
idOnly: true
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
name: "domains.get",
|
|
793
|
+
namespace: "domains",
|
|
794
|
+
call: "get",
|
|
795
|
+
verb: "GET",
|
|
796
|
+
path: "/v1/domains/:id",
|
|
797
|
+
title: "Retrieve domain",
|
|
798
|
+
description: "One domain with its DNS records and the history of its checks.",
|
|
799
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
800
|
+
tool: "domains_get",
|
|
801
|
+
idOnly: true
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
name: "domains.list",
|
|
805
|
+
namespace: "domains",
|
|
806
|
+
call: "list",
|
|
807
|
+
verb: "GET",
|
|
808
|
+
path: "/v1/domains",
|
|
809
|
+
title: "List domains",
|
|
810
|
+
description: "The domains of the workspace, newest first, with their status and region.",
|
|
811
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
812
|
+
tool: "domains_list",
|
|
813
|
+
idOnly: false
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
name: "domains.update",
|
|
817
|
+
namespace: "domains",
|
|
818
|
+
call: "update",
|
|
819
|
+
verb: "PATCH",
|
|
820
|
+
path: "/v1/domains/:id",
|
|
821
|
+
title: "Update domain",
|
|
822
|
+
description: "Switches open tracking and click tracking on or off for a domain.",
|
|
823
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
824
|
+
tool: "domains_update",
|
|
825
|
+
idOnly: false
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
name: "domains.remove",
|
|
829
|
+
namespace: "domains",
|
|
830
|
+
call: "remove",
|
|
831
|
+
verb: "DELETE",
|
|
832
|
+
path: "/v1/domains/:id",
|
|
833
|
+
title: "Delete domain",
|
|
834
|
+
description: "Removes a domain from the workspace. Mail can no longer be sent from it.",
|
|
835
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
836
|
+
tool: "domains_remove",
|
|
837
|
+
idOnly: true
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
name: "apiKeys.create",
|
|
841
|
+
namespace: "apiKeys",
|
|
842
|
+
call: "create",
|
|
843
|
+
verb: "POST",
|
|
844
|
+
path: "/v1/api-keys",
|
|
845
|
+
title: "Create API key",
|
|
846
|
+
description: "Creates an API key. The token is in this answer and is never shown again, so store it now. A key with sending access can be limited to one domain: it then sends from that domain only. With `mode: test` the key belongs to the sandbox: what it sends is simulated and reaches nobody.",
|
|
847
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
848
|
+
tool: "api_keys_create",
|
|
849
|
+
idOnly: false
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
name: "apiKeys.enroll",
|
|
853
|
+
namespace: "apiKeys",
|
|
854
|
+
call: "enroll",
|
|
855
|
+
verb: "POST",
|
|
856
|
+
path: "/v1/api-keys/enroll",
|
|
857
|
+
title: "Enroll existing API key",
|
|
858
|
+
description: "Makes a key you already use at Resend work here, so a program that holds it only needs a new address. The key is checked with Resend, kept as a hash like any other key, and gets the access it has there unless you narrow it.",
|
|
859
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
860
|
+
tool: "api_keys_enroll",
|
|
861
|
+
idOnly: false
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
name: "apiKeys.list",
|
|
865
|
+
namespace: "apiKeys",
|
|
866
|
+
call: "list",
|
|
867
|
+
verb: "GET",
|
|
868
|
+
path: "/v1/api-keys",
|
|
869
|
+
title: "List API keys",
|
|
870
|
+
description: "The API keys of the workspace, with what each may do and when it was last used.",
|
|
871
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
872
|
+
tool: "api_keys_list",
|
|
873
|
+
idOnly: false
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
name: "apiKeys.remove",
|
|
877
|
+
namespace: "apiKeys",
|
|
878
|
+
call: "remove",
|
|
879
|
+
verb: "DELETE",
|
|
880
|
+
path: "/v1/api-keys/:id",
|
|
881
|
+
title: "Revoke API key",
|
|
882
|
+
description: "Revokes an API key at once. Requests that use it are refused from then on.",
|
|
883
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
884
|
+
tool: "api_keys_remove",
|
|
885
|
+
idOnly: true
|
|
886
|
+
},
|
|
887
|
+
{
|
|
888
|
+
name: "webhooks.create",
|
|
889
|
+
namespace: "webhooks",
|
|
890
|
+
call: "create",
|
|
891
|
+
verb: "POST",
|
|
892
|
+
path: "/v1/webhooks",
|
|
893
|
+
title: "Add webhook",
|
|
894
|
+
description: "Adds an endpoint that is told about the events you pick. The signing secret is in this answer and is never shown again.",
|
|
895
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
896
|
+
tool: "webhooks_create",
|
|
897
|
+
idOnly: false
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
name: "webhooks.list",
|
|
901
|
+
namespace: "webhooks",
|
|
902
|
+
call: "list",
|
|
903
|
+
verb: "GET",
|
|
904
|
+
path: "/v1/webhooks",
|
|
905
|
+
title: "List webhooks",
|
|
906
|
+
description: "The endpoints of the workspace with the events each one receives.",
|
|
907
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
908
|
+
tool: "webhooks_list",
|
|
909
|
+
idOnly: false
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
name: "webhooks.update",
|
|
913
|
+
namespace: "webhooks",
|
|
914
|
+
call: "update",
|
|
915
|
+
verb: "PATCH",
|
|
916
|
+
path: "/v1/webhooks/:id",
|
|
917
|
+
title: "Update webhook",
|
|
918
|
+
description: "Changes the address, the events or whether an endpoint is switched on.",
|
|
919
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
920
|
+
tool: "webhooks_update",
|
|
921
|
+
idOnly: false
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
name: "webhooks.remove",
|
|
925
|
+
namespace: "webhooks",
|
|
926
|
+
call: "remove",
|
|
927
|
+
verb: "DELETE",
|
|
928
|
+
path: "/v1/webhooks/:id",
|
|
929
|
+
title: "Delete webhook",
|
|
930
|
+
description: "Deletes an endpoint. It is told about nothing from then on.",
|
|
931
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
932
|
+
tool: "webhooks_remove",
|
|
933
|
+
idOnly: true
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
name: "webhooks.test",
|
|
937
|
+
namespace: "webhooks",
|
|
938
|
+
call: "test",
|
|
939
|
+
verb: "POST",
|
|
940
|
+
path: "/v1/webhooks/:id/test",
|
|
941
|
+
title: "Send test event",
|
|
942
|
+
description: "Posts one signed sample event to an endpoint and answers with what the endpoint said.",
|
|
943
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
944
|
+
tool: "webhooks_test",
|
|
945
|
+
idOnly: true
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
name: "webhooks.deliveries",
|
|
949
|
+
namespace: "webhooks",
|
|
950
|
+
call: "deliveries",
|
|
951
|
+
verb: "GET",
|
|
952
|
+
path: "/v1/webhooks/:id/deliveries",
|
|
953
|
+
title: "List webhook deliveries",
|
|
954
|
+
description: "What was posted to an endpoint, newest first, with the answer and the tries.",
|
|
955
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
956
|
+
tool: "webhooks_deliveries",
|
|
957
|
+
idOnly: false
|
|
958
|
+
},
|
|
959
|
+
{
|
|
960
|
+
name: "imports.inspect",
|
|
961
|
+
namespace: "imports",
|
|
962
|
+
call: "inspect",
|
|
963
|
+
verb: "POST",
|
|
964
|
+
path: "/v1/imports/inspect",
|
|
965
|
+
title: "Look into another account",
|
|
966
|
+
description: "Counts what a key can read in a Resend account: domains, contacts, templates, webhooks and the rest, and says which of them an import brings over. It reads and changes nothing, there or here, and the key is not kept.",
|
|
967
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
968
|
+
tool: "imports_inspect",
|
|
969
|
+
idOnly: false
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
name: "imports.create",
|
|
973
|
+
namespace: "imports",
|
|
974
|
+
call: "create",
|
|
975
|
+
verb: "POST",
|
|
976
|
+
path: "/v1/imports",
|
|
977
|
+
title: "Start import",
|
|
978
|
+
description: "Brings a Resend account over: its domains, suppression list, segments as audiences, contacts, templates, draft broadcasts and webhooks, and the names of its API keys. It runs in the background and can be run again: what is already here is left alone. Nothing arrives in a state that sends, and the key is kept sealed only while the import runs.",
|
|
979
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
980
|
+
tool: "imports_create",
|
|
981
|
+
idOnly: false
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
name: "imports.get",
|
|
985
|
+
namespace: "imports",
|
|
986
|
+
call: "get",
|
|
987
|
+
verb: "GET",
|
|
988
|
+
path: "/v1/imports/:id",
|
|
989
|
+
title: "Retrieve import",
|
|
990
|
+
description: "One import with where it stands and its report so far.",
|
|
991
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
992
|
+
tool: "imports_get",
|
|
993
|
+
idOnly: true
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
name: "imports.list",
|
|
997
|
+
namespace: "imports",
|
|
998
|
+
call: "list",
|
|
999
|
+
verb: "GET",
|
|
1000
|
+
path: "/v1/imports",
|
|
1001
|
+
title: "List imports",
|
|
1002
|
+
description: "The imports of the workspace, newest first, each with its report.",
|
|
1003
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1004
|
+
tool: "imports_list",
|
|
1005
|
+
idOnly: false
|
|
1006
|
+
},
|
|
1007
|
+
{
|
|
1008
|
+
name: "imports.cancel",
|
|
1009
|
+
namespace: "imports",
|
|
1010
|
+
call: "cancel",
|
|
1011
|
+
verb: "POST",
|
|
1012
|
+
path: "/v1/imports/:id/cancel",
|
|
1013
|
+
title: "Cancel import",
|
|
1014
|
+
description: "Stops an import that is queued or running and wipes its key. What it already brought over stays.",
|
|
1015
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
1016
|
+
tool: "imports_cancel",
|
|
1017
|
+
idOnly: true
|
|
1018
|
+
},
|
|
1019
|
+
{
|
|
1020
|
+
name: "images.add",
|
|
1021
|
+
namespace: "images",
|
|
1022
|
+
call: "add",
|
|
1023
|
+
verb: "POST",
|
|
1024
|
+
path: "/v1/images",
|
|
1025
|
+
title: "Add image",
|
|
1026
|
+
description: "Copies the image at an address and answers with where the copy is served. Emails then link the copy in place of that address. The same address twice answers with the copy that is there, and an image that failed is tried again.",
|
|
1027
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
1028
|
+
tool: "images_add",
|
|
1029
|
+
idOnly: false
|
|
1030
|
+
},
|
|
1031
|
+
{
|
|
1032
|
+
name: "images.upload",
|
|
1033
|
+
namespace: "images",
|
|
1034
|
+
call: "upload",
|
|
1035
|
+
verb: "POST",
|
|
1036
|
+
path: "/v1/images/upload",
|
|
1037
|
+
title: "Upload image",
|
|
1038
|
+
description: "Stores an image file and answers with the address it is served at, which is the address to write in an email. It takes a PNG, JPEG, GIF or WebP file of 5 MB at most, sent as Base64, and reads the kind from the file itself. The same file twice answers with the image that is there.",
|
|
1039
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
1040
|
+
tool: "images_upload",
|
|
1041
|
+
idOnly: false
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
name: "images.list",
|
|
1045
|
+
namespace: "images",
|
|
1046
|
+
call: "list",
|
|
1047
|
+
verb: "GET",
|
|
1048
|
+
path: "/v1/images",
|
|
1049
|
+
title: "List images",
|
|
1050
|
+
description: "The images of the workspace, copied from an address or uploaded, newest first, by status and search.",
|
|
1051
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1052
|
+
tool: "images_list",
|
|
1053
|
+
idOnly: false
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
name: "images.get",
|
|
1057
|
+
namespace: "images",
|
|
1058
|
+
call: "get",
|
|
1059
|
+
verb: "GET",
|
|
1060
|
+
path: "/v1/images/:id",
|
|
1061
|
+
title: "Retrieve image",
|
|
1062
|
+
description: "One image: where it came from, whether it is ready and where it is served.",
|
|
1063
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1064
|
+
tool: "images_get",
|
|
1065
|
+
idOnly: true
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
name: "images.remove",
|
|
1069
|
+
namespace: "images",
|
|
1070
|
+
call: "remove",
|
|
1071
|
+
verb: "DELETE",
|
|
1072
|
+
path: "/v1/images/:id",
|
|
1073
|
+
title: "Delete image",
|
|
1074
|
+
description: "Deletes the stored file and forgets the image. Emails that were already sent stop showing it, because they link that file. A copied image that a template or a broadcast still uses is copied again the next time that one is saved. An uploaded image has no address to copy it from: it comes back, at the same address, when the same file is uploaded again.",
|
|
1075
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
1076
|
+
tool: "images_remove",
|
|
1077
|
+
idOnly: true
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
name: "billing.plans",
|
|
1081
|
+
namespace: "billing",
|
|
1082
|
+
call: "plans",
|
|
1083
|
+
verb: "GET",
|
|
1084
|
+
path: "/v1/billing/plans",
|
|
1085
|
+
title: "List plans",
|
|
1086
|
+
description: "The plans, what each allows in a month, what it costs by the month and by the year, what emails past a limit cost, and which one the workspace is on.",
|
|
1087
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1088
|
+
tool: "billing_plans",
|
|
1089
|
+
idOnly: false
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
name: "billing.checkout",
|
|
1093
|
+
namespace: "billing",
|
|
1094
|
+
call: "checkout",
|
|
1095
|
+
verb: "POST",
|
|
1096
|
+
path: "/v1/billing/checkout",
|
|
1097
|
+
title: "Start checkout",
|
|
1098
|
+
description: "Answers with the address of a checkout page for a plan, paid by the month or by the year. The plan changes once it is paid.",
|
|
1099
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
1100
|
+
tool: "billing_checkout",
|
|
1101
|
+
idOnly: false
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
name: "billing.portal",
|
|
1105
|
+
namespace: "billing",
|
|
1106
|
+
call: "portal",
|
|
1107
|
+
verb: "POST",
|
|
1108
|
+
path: "/v1/billing/portal",
|
|
1109
|
+
title: "Open billing portal",
|
|
1110
|
+
description: "Answers with the address of the page where the card, the plan and past invoices are managed.",
|
|
1111
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
1112
|
+
tool: "billing_portal",
|
|
1113
|
+
idOnly: false
|
|
1114
|
+
},
|
|
1115
|
+
{
|
|
1116
|
+
name: "billing.invoices",
|
|
1117
|
+
namespace: "billing",
|
|
1118
|
+
call: "invoices",
|
|
1119
|
+
verb: "GET",
|
|
1120
|
+
path: "/v1/billing/invoices",
|
|
1121
|
+
title: "List invoices",
|
|
1122
|
+
description: "What the workspace has been charged, newest first.",
|
|
1123
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1124
|
+
tool: "billing_invoices",
|
|
1125
|
+
idOnly: false
|
|
1126
|
+
},
|
|
1127
|
+
{
|
|
1128
|
+
name: "contacts.create",
|
|
1129
|
+
namespace: "contacts",
|
|
1130
|
+
call: "create",
|
|
1131
|
+
verb: "POST",
|
|
1132
|
+
path: "/v1/contacts",
|
|
1133
|
+
title: "Add contact",
|
|
1134
|
+
description: "Adds one person to the workspace, and to the audiences you name. They are subscribed unless you say otherwise. An address that is already a contact is refused: add that contact to an audience instead.",
|
|
1135
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
1136
|
+
tool: "contacts_create",
|
|
1137
|
+
idOnly: false
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
name: "contacts.list",
|
|
1141
|
+
namespace: "contacts",
|
|
1142
|
+
call: "list",
|
|
1143
|
+
verb: "GET",
|
|
1144
|
+
path: "/v1/contacts",
|
|
1145
|
+
title: "List contacts",
|
|
1146
|
+
description: "The people of the workspace, or of one audience, newest first, by address, name and status.",
|
|
1147
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1148
|
+
tool: "contacts_list",
|
|
1149
|
+
idOnly: false
|
|
1150
|
+
},
|
|
1151
|
+
{
|
|
1152
|
+
name: "contacts.get",
|
|
1153
|
+
namespace: "contacts",
|
|
1154
|
+
call: "get",
|
|
1155
|
+
verb: "GET",
|
|
1156
|
+
path: "/v1/contacts/:id",
|
|
1157
|
+
title: "Retrieve contact",
|
|
1158
|
+
description: "One person, by id or by address, with their properties, the audiences they are in and what they chose for each topic.",
|
|
1159
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1160
|
+
tool: "contacts_get",
|
|
1161
|
+
idOnly: true
|
|
1162
|
+
},
|
|
1163
|
+
{
|
|
1164
|
+
name: "contacts.update",
|
|
1165
|
+
namespace: "contacts",
|
|
1166
|
+
call: "update",
|
|
1167
|
+
verb: "PATCH",
|
|
1168
|
+
path: "/v1/contacts/:id",
|
|
1169
|
+
title: "Update contact",
|
|
1170
|
+
description: "Changes the name or the properties of a contact, or subscribes and unsubscribes them. It holds in every audience they are in.",
|
|
1171
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
1172
|
+
tool: "contacts_update",
|
|
1173
|
+
idOnly: false
|
|
1174
|
+
},
|
|
1175
|
+
{
|
|
1176
|
+
name: "contacts.remove",
|
|
1177
|
+
namespace: "contacts",
|
|
1178
|
+
call: "remove",
|
|
1179
|
+
verb: "DELETE",
|
|
1180
|
+
path: "/v1/contacts/:id",
|
|
1181
|
+
title: "Delete contact",
|
|
1182
|
+
description: "Removes a person from the workspace and from every audience, for good.",
|
|
1183
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
1184
|
+
tool: "contacts_remove",
|
|
1185
|
+
idOnly: true
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
name: "contactProperties.create",
|
|
1189
|
+
namespace: "contactProperties",
|
|
1190
|
+
call: "create",
|
|
1191
|
+
verb: "POST",
|
|
1192
|
+
path: "/v1/contact-properties",
|
|
1193
|
+
title: "Create contact property",
|
|
1194
|
+
description: "Names a value every contact can hold, with its type and what to use when a contact has none. From then on a value of another type is refused, and a broadcast fills `{{key}}` with the value or the fallback.",
|
|
1195
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
1196
|
+
tool: "contact_properties_create",
|
|
1197
|
+
idOnly: false
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
name: "contactProperties.list",
|
|
1201
|
+
namespace: "contactProperties",
|
|
1202
|
+
call: "list",
|
|
1203
|
+
verb: "GET",
|
|
1204
|
+
path: "/v1/contact-properties",
|
|
1205
|
+
title: "List contact properties",
|
|
1206
|
+
description: "The properties of the workspace, newest first, with their types and fallbacks.",
|
|
1207
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1208
|
+
tool: "contact_properties_list",
|
|
1209
|
+
idOnly: false
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
name: "contactProperties.get",
|
|
1213
|
+
namespace: "contactProperties",
|
|
1214
|
+
call: "get",
|
|
1215
|
+
verb: "GET",
|
|
1216
|
+
path: "/v1/contact-properties/:id",
|
|
1217
|
+
title: "Retrieve contact property",
|
|
1218
|
+
description: "One property with its type and its fallback.",
|
|
1219
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1220
|
+
tool: "contact_properties_get",
|
|
1221
|
+
idOnly: true
|
|
1222
|
+
},
|
|
1223
|
+
{
|
|
1224
|
+
name: "contactProperties.update",
|
|
1225
|
+
namespace: "contactProperties",
|
|
1226
|
+
call: "update",
|
|
1227
|
+
verb: "PATCH",
|
|
1228
|
+
path: "/v1/contact-properties/:id",
|
|
1229
|
+
title: "Update contact property",
|
|
1230
|
+
description: "Changes the fallback of a property. Its key and its type stay as they are.",
|
|
1231
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
1232
|
+
tool: "contact_properties_update",
|
|
1233
|
+
idOnly: false
|
|
1234
|
+
},
|
|
1235
|
+
{
|
|
1236
|
+
name: "contactProperties.remove",
|
|
1237
|
+
namespace: "contactProperties",
|
|
1238
|
+
call: "remove",
|
|
1239
|
+
verb: "DELETE",
|
|
1240
|
+
path: "/v1/contact-properties/:id",
|
|
1241
|
+
title: "Delete contact property",
|
|
1242
|
+
description: "Deletes a property. The values contacts hold under its key stay on them, with no type and no fallback.",
|
|
1243
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
1244
|
+
tool: "contact_properties_remove",
|
|
1245
|
+
idOnly: true
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
name: "topics.create",
|
|
1249
|
+
namespace: "topics",
|
|
1250
|
+
call: "create",
|
|
1251
|
+
verb: "POST",
|
|
1252
|
+
path: "/v1/topics",
|
|
1253
|
+
title: "Create topic",
|
|
1254
|
+
description: "Makes a kind of mail readers can say yes or no to, such as product news. A broadcast sent on a topic only reaches the contacts who get that topic.",
|
|
1255
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
1256
|
+
tool: "topics_create",
|
|
1257
|
+
idOnly: false
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
name: "topics.list",
|
|
1261
|
+
namespace: "topics",
|
|
1262
|
+
call: "list",
|
|
1263
|
+
verb: "GET",
|
|
1264
|
+
path: "/v1/topics",
|
|
1265
|
+
title: "List topics",
|
|
1266
|
+
description: "The topics of the workspace, newest first. Name a contact to see what that contact gets.",
|
|
1267
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1268
|
+
tool: "topics_list",
|
|
1269
|
+
idOnly: false
|
|
1270
|
+
},
|
|
1271
|
+
{
|
|
1272
|
+
name: "topics.get",
|
|
1273
|
+
namespace: "topics",
|
|
1274
|
+
call: "get",
|
|
1275
|
+
verb: "GET",
|
|
1276
|
+
path: "/v1/topics/:id",
|
|
1277
|
+
title: "Retrieve topic",
|
|
1278
|
+
description: "One topic with what holds for a contact who never chose.",
|
|
1279
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1280
|
+
tool: "topics_get",
|
|
1281
|
+
idOnly: true
|
|
1282
|
+
},
|
|
1283
|
+
{
|
|
1284
|
+
name: "topics.update",
|
|
1285
|
+
namespace: "topics",
|
|
1286
|
+
call: "update",
|
|
1287
|
+
verb: "PATCH",
|
|
1288
|
+
path: "/v1/topics/:id",
|
|
1289
|
+
title: "Update topic",
|
|
1290
|
+
description: "Changes the name, the description or who sees a topic. What holds for a contact who never chose cannot be changed.",
|
|
1291
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
1292
|
+
tool: "topics_update",
|
|
1293
|
+
idOnly: false
|
|
1294
|
+
},
|
|
1295
|
+
{
|
|
1296
|
+
name: "topics.remove",
|
|
1297
|
+
namespace: "topics",
|
|
1298
|
+
call: "remove",
|
|
1299
|
+
verb: "DELETE",
|
|
1300
|
+
path: "/v1/topics/:id",
|
|
1301
|
+
title: "Delete topic",
|
|
1302
|
+
description: "Deletes a topic. It is refused while a broadcast that has not been sent uses it, so nobody who opted out gets that mail.",
|
|
1303
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
1304
|
+
tool: "topics_remove",
|
|
1305
|
+
idOnly: true
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
name: "suppressions.create",
|
|
1309
|
+
namespace: "suppressions",
|
|
1310
|
+
call: "create",
|
|
1311
|
+
verb: "POST",
|
|
1312
|
+
path: "/v1/suppressions",
|
|
1313
|
+
title: "Suppress an address",
|
|
1314
|
+
description: "Adds an address to the suppression list, so nothing is sent to it any more.",
|
|
1315
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
1316
|
+
tool: "suppressions_create",
|
|
1317
|
+
idOnly: false
|
|
1318
|
+
},
|
|
1319
|
+
{
|
|
1320
|
+
name: "suppressions.list",
|
|
1321
|
+
namespace: "suppressions",
|
|
1322
|
+
call: "list",
|
|
1323
|
+
verb: "GET",
|
|
1324
|
+
path: "/v1/suppressions",
|
|
1325
|
+
title: "List suppressed addresses",
|
|
1326
|
+
description: "The addresses the workspace does not send to: the ones that bounced, the ones that complained and the ones added by hand. Newest first, a page at a time: pass next as cursor for the following page.",
|
|
1327
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1328
|
+
tool: "suppressions_list",
|
|
1329
|
+
idOnly: false
|
|
1330
|
+
},
|
|
1331
|
+
{
|
|
1332
|
+
name: "suppressions.remove",
|
|
1333
|
+
namespace: "suppressions",
|
|
1334
|
+
call: "remove",
|
|
1335
|
+
verb: "DELETE",
|
|
1336
|
+
path: "/v1/suppressions/:id",
|
|
1337
|
+
title: "Remove a suppressed address",
|
|
1338
|
+
description: "Takes an address off the suppression list, so it can be sent to again. One that complained may not be removable.",
|
|
1339
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
1340
|
+
tool: "suppressions_remove",
|
|
1341
|
+
idOnly: true
|
|
1342
|
+
},
|
|
1343
|
+
{
|
|
1344
|
+
name: "inbound.list",
|
|
1345
|
+
namespace: "inbound",
|
|
1346
|
+
call: "list",
|
|
1347
|
+
verb: "GET",
|
|
1348
|
+
path: "/v1/inbound",
|
|
1349
|
+
title: "List received emails",
|
|
1350
|
+
description: "The mail that arrived at the domains of the workspace, newest first. A test key may not read it.",
|
|
1351
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1352
|
+
tool: "inbound_list",
|
|
1353
|
+
idOnly: false
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
name: "inbound.get",
|
|
1357
|
+
namespace: "inbound",
|
|
1358
|
+
call: "get",
|
|
1359
|
+
verb: "GET",
|
|
1360
|
+
path: "/v1/inbound/:id",
|
|
1361
|
+
title: "Retrieve received email",
|
|
1362
|
+
description: "One received email with its text, its HTML and the names of its attachments. A test key may not read it.",
|
|
1363
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1364
|
+
tool: "inbound_get",
|
|
1365
|
+
idOnly: true
|
|
1366
|
+
},
|
|
1367
|
+
{
|
|
1368
|
+
name: "logs.list",
|
|
1369
|
+
namespace: "logs",
|
|
1370
|
+
call: "list",
|
|
1371
|
+
verb: "GET",
|
|
1372
|
+
path: "/v1/logs",
|
|
1373
|
+
title: "List logs",
|
|
1374
|
+
description: "Every request an API key has made, newest first, by method, outcome and time.",
|
|
1375
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1376
|
+
tool: "logs_list",
|
|
1377
|
+
idOnly: false
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
name: "logs.get",
|
|
1381
|
+
namespace: "logs",
|
|
1382
|
+
call: "get",
|
|
1383
|
+
verb: "GET",
|
|
1384
|
+
path: "/v1/logs/:id",
|
|
1385
|
+
title: "Retrieve log",
|
|
1386
|
+
description: "One request: what was asked, what was answered and how long it took.",
|
|
1387
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1388
|
+
tool: "logs_get",
|
|
1389
|
+
idOnly: true
|
|
1390
|
+
},
|
|
1391
|
+
{
|
|
1392
|
+
name: "workspace.get",
|
|
1393
|
+
namespace: "workspace",
|
|
1394
|
+
call: "get",
|
|
1395
|
+
verb: "GET",
|
|
1396
|
+
path: "/v1/workspace",
|
|
1397
|
+
title: "Retrieve workspace",
|
|
1398
|
+
description: "The workspace this credential acts for: its plan, every limit with what is used, and who is asking.",
|
|
1399
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1400
|
+
tool: "workspace_get",
|
|
1401
|
+
idOnly: false
|
|
1402
|
+
},
|
|
1403
|
+
{
|
|
1404
|
+
name: "workspace.update",
|
|
1405
|
+
namespace: "workspace",
|
|
1406
|
+
call: "update",
|
|
1407
|
+
verb: "PATCH",
|
|
1408
|
+
path: "/v1/workspace",
|
|
1409
|
+
title: "Update workspace",
|
|
1410
|
+
description: "Renames the workspace, sets where invoices go, sets the reply address its messages get by default, switches image hosting on or off, or replaces the page a recipient sees after they unsubscribe.",
|
|
1411
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
1412
|
+
tool: "workspace_update",
|
|
1413
|
+
idOnly: false
|
|
1414
|
+
},
|
|
1415
|
+
{
|
|
1416
|
+
name: "members.invite",
|
|
1417
|
+
namespace: "members",
|
|
1418
|
+
call: "invite",
|
|
1419
|
+
verb: "POST",
|
|
1420
|
+
path: "/v1/members",
|
|
1421
|
+
title: "Invite member",
|
|
1422
|
+
description: "Invites a person to the workspace by email, with the role they will hold.",
|
|
1423
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
1424
|
+
tool: "members_invite",
|
|
1425
|
+
idOnly: false
|
|
1426
|
+
},
|
|
1427
|
+
{
|
|
1428
|
+
name: "members.list",
|
|
1429
|
+
namespace: "members",
|
|
1430
|
+
call: "list",
|
|
1431
|
+
verb: "GET",
|
|
1432
|
+
path: "/v1/members",
|
|
1433
|
+
title: "List members",
|
|
1434
|
+
description: "The people in the workspace and the invitations still waiting for an answer.",
|
|
1435
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1436
|
+
tool: "members_list",
|
|
1437
|
+
idOnly: false
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
name: "members.update",
|
|
1441
|
+
namespace: "members",
|
|
1442
|
+
call: "update",
|
|
1443
|
+
verb: "PATCH",
|
|
1444
|
+
path: "/v1/members/:id",
|
|
1445
|
+
title: "Update member",
|
|
1446
|
+
description: "Changes the role of a person, or sends an invitation again.",
|
|
1447
|
+
effect: OPENSEND_EFFECTS.WRITE,
|
|
1448
|
+
tool: "members_update",
|
|
1449
|
+
idOnly: false
|
|
1450
|
+
},
|
|
1451
|
+
{
|
|
1452
|
+
name: "members.remove",
|
|
1453
|
+
namespace: "members",
|
|
1454
|
+
call: "remove",
|
|
1455
|
+
verb: "DELETE",
|
|
1456
|
+
path: "/v1/members/:id",
|
|
1457
|
+
title: "Remove member",
|
|
1458
|
+
description: "Removes a person, or withdraws an invitation, from the workspace.",
|
|
1459
|
+
effect: OPENSEND_EFFECTS.DESTROY,
|
|
1460
|
+
tool: "members_remove",
|
|
1461
|
+
idOnly: true
|
|
1462
|
+
},
|
|
1463
|
+
{
|
|
1464
|
+
name: "server.get",
|
|
1465
|
+
namespace: "server",
|
|
1466
|
+
call: "get",
|
|
1467
|
+
verb: "GET",
|
|
1468
|
+
path: "/v1/server",
|
|
1469
|
+
title: "Retrieve server settings",
|
|
1470
|
+
description: "The settings of a server a team hosts itself: whether anybody may sign up, and what each workspace on it may use.",
|
|
1471
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1472
|
+
tool: "server_get",
|
|
1473
|
+
idOnly: false
|
|
1474
|
+
},
|
|
1475
|
+
{
|
|
1476
|
+
name: "account.get",
|
|
1477
|
+
namespace: "account",
|
|
1478
|
+
call: "get",
|
|
1479
|
+
verb: "GET",
|
|
1480
|
+
path: "/v1/account",
|
|
1481
|
+
title: "Retrieve account",
|
|
1482
|
+
description: "Who is asking and every workspace they can open. For a person it also joins any workspace they were invited to.",
|
|
1483
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1484
|
+
tool: "account_get",
|
|
1485
|
+
idOnly: false
|
|
1486
|
+
},
|
|
1487
|
+
{
|
|
1488
|
+
name: "methods.list",
|
|
1489
|
+
namespace: "methods",
|
|
1490
|
+
call: "list",
|
|
1491
|
+
verb: "GET",
|
|
1492
|
+
path: "/v1/methods",
|
|
1493
|
+
title: "List methods",
|
|
1494
|
+
description: "Everything this API can do: each method with its route, its tool name, the scope it needs and a sample input.",
|
|
1495
|
+
effect: OPENSEND_EFFECTS.READ,
|
|
1496
|
+
tool: "methods_list",
|
|
1497
|
+
idOnly: false
|
|
1498
|
+
},
|
|
1499
|
+
{
|
|
1500
|
+
name: "ask.send",
|
|
1501
|
+
namespace: "ask",
|
|
1502
|
+
call: "send",
|
|
1503
|
+
verb: "POST",
|
|
1504
|
+
path: "/v1/ask",
|
|
1505
|
+
title: "Ask the assistant",
|
|
1506
|
+
description: "Answers a question about the workspace by looking it up with the methods of this API. A change is never carried out by asking: the answer holds the change it proposes, and sending that back as run carries it out.",
|
|
1507
|
+
effect: OPENSEND_EFFECTS.SEND,
|
|
1508
|
+
tool: null,
|
|
1509
|
+
idOnly: false
|
|
1510
|
+
}
|
|
1511
|
+
];
|
|
1512
|
+
|
|
1513
|
+
// lib/errors.ts
|
|
1514
|
+
class OpenSendError extends Error {
|
|
1515
|
+
status;
|
|
1516
|
+
code;
|
|
1517
|
+
type;
|
|
1518
|
+
requestId;
|
|
1519
|
+
constructor(message, detail, options) {
|
|
1520
|
+
super(message, options);
|
|
1521
|
+
this.name = OPENSEND_ERROR_NAME;
|
|
1522
|
+
this.status = detail.status;
|
|
1523
|
+
this.code = detail.code;
|
|
1524
|
+
this.type = detail.type;
|
|
1525
|
+
this.requestId = detail.requestId;
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
// lib/request.ts
|
|
1530
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1531
|
+
var failed = (message, code, cause) => new OpenSendError(message, { status: null, code, type: null, requestId: null }, cause === undefined ? undefined : { cause });
|
|
1532
|
+
var stopped = (cause, own, timeout) => {
|
|
1533
|
+
if (own?.aborted)
|
|
1534
|
+
return failed(OPENSEND_ABORTED_MESSAGE, OPENSEND_ERROR_CODES.ABORTED, cause);
|
|
1535
|
+
const late = timeout?.aborted || cause instanceof Error && cause.name === OPENSEND_TIMEOUT_NAME;
|
|
1536
|
+
return late ? failed(OPENSEND_TIMEOUT_MESSAGE, OPENSEND_ERROR_CODES.TIMEOUT, cause) : failed(OPENSEND_NETWORK_MESSAGE, OPENSEND_ERROR_CODES.NETWORK, cause);
|
|
1537
|
+
};
|
|
1538
|
+
var queryOf = (input) => {
|
|
1539
|
+
const params = new URLSearchParams;
|
|
1540
|
+
for (const [name, value] of Object.entries(input)) {
|
|
1541
|
+
if (value === undefined || value === null)
|
|
1542
|
+
continue;
|
|
1543
|
+
if (Array.isArray(value)) {
|
|
1544
|
+
for (const item of value)
|
|
1545
|
+
params.append(name, String(item));
|
|
1546
|
+
continue;
|
|
1547
|
+
}
|
|
1548
|
+
params.set(name, isRecord(value) ? JSON.stringify(value) : String(value));
|
|
1549
|
+
}
|
|
1550
|
+
const text = params.toString();
|
|
1551
|
+
return text ? `?${text}` : "";
|
|
1552
|
+
};
|
|
1553
|
+
var requestOf = (method, args) => {
|
|
1554
|
+
const [first, second, third] = args;
|
|
1555
|
+
const named = typeof first === "string";
|
|
1556
|
+
const bare = named && method.idOnly;
|
|
1557
|
+
const given = named ? bare ? undefined : second : first;
|
|
1558
|
+
const input = {
|
|
1559
|
+
...isRecord(given) ? given : {},
|
|
1560
|
+
...named ? { [OPENSEND_ID_FIELD]: first } : {}
|
|
1561
|
+
};
|
|
1562
|
+
const last = named && !bare ? third : second;
|
|
1563
|
+
const options = isRecord(last) ? last : {};
|
|
1564
|
+
const path = method.path.replace(OPENSEND_PATH_PARAM, (_whole, name) => {
|
|
1565
|
+
const value = input[name];
|
|
1566
|
+
if (value === undefined || value === null || value === "") {
|
|
1567
|
+
throw failed(opensendMissingParameter(name, method.name), OPENSEND_ERROR_CODES.MISSING_PARAMETER);
|
|
1568
|
+
}
|
|
1569
|
+
if (OPENSEND_DOT_SEGMENTS.includes(String(value))) {
|
|
1570
|
+
throw failed(opensendDotParameter(name, method.name), OPENSEND_ERROR_CODES.MISSING_PARAMETER);
|
|
1571
|
+
}
|
|
1572
|
+
delete input[name];
|
|
1573
|
+
return encodeURIComponent(String(value));
|
|
1574
|
+
});
|
|
1575
|
+
const sends = OPENSEND_BODY_VERBS.includes(method.verb);
|
|
1576
|
+
return {
|
|
1577
|
+
verb: method.verb,
|
|
1578
|
+
path,
|
|
1579
|
+
query: sends ? "" : queryOf(input),
|
|
1580
|
+
body: sends ? JSON.stringify(input) : null,
|
|
1581
|
+
options
|
|
1582
|
+
};
|
|
1583
|
+
};
|
|
1584
|
+
var refusalOf = async (answer) => {
|
|
1585
|
+
const requestId = answer.headers.get(OPENSEND_REQUEST_ID_HEADER);
|
|
1586
|
+
let body = {};
|
|
1587
|
+
try {
|
|
1588
|
+
body = await answer.json();
|
|
1589
|
+
} catch {
|
|
1590
|
+
body = {};
|
|
1591
|
+
}
|
|
1592
|
+
return new OpenSendError(body.error?.message ?? OPENSEND_UNEXPECTED_MESSAGE, {
|
|
1593
|
+
status: answer.status,
|
|
1594
|
+
code: body.error?.code ?? OPENSEND_ERROR_CODES.UNEXPECTED,
|
|
1595
|
+
type: body.error?.type ?? null,
|
|
1596
|
+
requestId: body.error?.requestId ?? requestId
|
|
1597
|
+
});
|
|
1598
|
+
};
|
|
1599
|
+
var sent = async (config, method, args) => {
|
|
1600
|
+
const request = requestOf(method, args);
|
|
1601
|
+
const own = request.options.signal;
|
|
1602
|
+
let timeout;
|
|
1603
|
+
let answer;
|
|
1604
|
+
try {
|
|
1605
|
+
timeout = AbortSignal.timeout(config.timeoutMs);
|
|
1606
|
+
answer = await config.fetch(`${config.baseUrl}${request.path}${request.query}`, {
|
|
1607
|
+
method: request.verb,
|
|
1608
|
+
headers: {
|
|
1609
|
+
authorization: `Bearer ${config.apiKey}`,
|
|
1610
|
+
accept: OPENSEND_JSON_TYPE,
|
|
1611
|
+
"user-agent": config.agent ?? OPENSEND_AGENT,
|
|
1612
|
+
...request.body === null ? {} : { "content-type": OPENSEND_JSON_TYPE },
|
|
1613
|
+
...request.options.idempotencyKey ? { [OPENSEND_IDEMPOTENCY_HEADER]: request.options.idempotencyKey } : {}
|
|
1614
|
+
},
|
|
1615
|
+
body: request.body,
|
|
1616
|
+
signal: own ? AbortSignal.any([timeout, own]) : timeout
|
|
1617
|
+
});
|
|
1618
|
+
} catch (cause) {
|
|
1619
|
+
throw stopped(cause, own, timeout);
|
|
1620
|
+
}
|
|
1621
|
+
if (!answer.ok)
|
|
1622
|
+
throw await refusalOf(answer);
|
|
1623
|
+
try {
|
|
1624
|
+
return await answer.json();
|
|
1625
|
+
} catch (cause) {
|
|
1626
|
+
if (own?.aborted || timeout.aborted)
|
|
1627
|
+
throw stopped(cause, own, timeout);
|
|
1628
|
+
throw new OpenSendError(OPENSEND_UNEXPECTED_MESSAGE, {
|
|
1629
|
+
status: answer.status,
|
|
1630
|
+
code: OPENSEND_ERROR_CODES.UNEXPECTED,
|
|
1631
|
+
type: null,
|
|
1632
|
+
requestId: answer.headers.get(OPENSEND_REQUEST_ID_HEADER)
|
|
1633
|
+
}, { cause });
|
|
1634
|
+
}
|
|
1635
|
+
};
|
|
1636
|
+
|
|
1637
|
+
// lib/client.ts
|
|
1638
|
+
var fromEnv = (name) => {
|
|
1639
|
+
try {
|
|
1640
|
+
return typeof process === "undefined" ? undefined : process.env[name];
|
|
1641
|
+
} catch {
|
|
1642
|
+
return;
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
var missing = (message, code) => new OpenSendError(message, { status: null, code, type: null, requestId: null });
|
|
1646
|
+
var invalid = (message) => missing(message, OPENSEND_ERROR_CODES.INVALID_OPTION);
|
|
1647
|
+
var addressOf = (given) => {
|
|
1648
|
+
if (!given)
|
|
1649
|
+
return OPENSEND_DEFAULT_URL;
|
|
1650
|
+
const url = URL.canParse(given) ? new URL(given) : null;
|
|
1651
|
+
const safe = url !== null && (url.protocol === OPENSEND_HTTPS_SCHEME || url.protocol === OPENSEND_HTTP_SCHEME && OPENSEND_LOOPBACK_NAMES.includes(url.hostname));
|
|
1652
|
+
if (!safe)
|
|
1653
|
+
throw invalid(OPENSEND_INVALID_ADDRESS);
|
|
1654
|
+
return given;
|
|
1655
|
+
};
|
|
1656
|
+
var timeoutOf = (value) => {
|
|
1657
|
+
if (value === undefined)
|
|
1658
|
+
return OPENSEND_TIMEOUT_MS;
|
|
1659
|
+
if (!Number.isInteger(value) || value < 1 || value > OPENSEND_TIMEOUT_MAX) {
|
|
1660
|
+
throw invalid(OPENSEND_INVALID_TIMEOUT);
|
|
1661
|
+
}
|
|
1662
|
+
return value;
|
|
1663
|
+
};
|
|
1664
|
+
var inBrowser = () => OPENSEND_BROWSER_GLOBALS.every((name) => (name in globalThis));
|
|
1665
|
+
var configOf = (apiKey, options) => {
|
|
1666
|
+
if (inBrowser())
|
|
1667
|
+
throw missing(OPENSEND_BROWSER_REFUSED, OPENSEND_ERROR_CODES.BROWSER);
|
|
1668
|
+
const key = (apiKey ?? fromEnv(OPENSEND_KEY_ENV) ?? "").trim();
|
|
1669
|
+
if (!key)
|
|
1670
|
+
throw missing(OPENSEND_MISSING_KEY, OPENSEND_ERROR_CODES.MISSING_KEY);
|
|
1671
|
+
const given = (options.baseUrl ?? fromEnv(OPENSEND_URL_ENV) ?? "").trim().replace(OPENSEND_TRAILING_SLASHES, "");
|
|
1672
|
+
return {
|
|
1673
|
+
apiKey: key,
|
|
1674
|
+
baseUrl: addressOf(given),
|
|
1675
|
+
fetch: options.fetch ?? ((input, init) => fetch(input, init)),
|
|
1676
|
+
timeoutMs: timeoutOf(options.timeoutMs)
|
|
1677
|
+
};
|
|
1678
|
+
};
|
|
1679
|
+
var namespacesOf = (config) => {
|
|
1680
|
+
const namespaces = {};
|
|
1681
|
+
for (const method of OPENSEND_METHODS) {
|
|
1682
|
+
const calls = namespaces[method.namespace] ?? {};
|
|
1683
|
+
calls[method.call] = (...args) => sent(config, method, args);
|
|
1684
|
+
namespaces[method.namespace] = calls;
|
|
1685
|
+
}
|
|
1686
|
+
return namespaces;
|
|
1687
|
+
};
|
|
1688
|
+
var createOpenSend = (apiKey, options = {}) => namespacesOf(configOf(apiKey, options));
|
|
1689
|
+
|
|
1690
|
+
class OpenSendBase {
|
|
1691
|
+
constructor(apiKey, options = {}) {
|
|
1692
|
+
Object.assign(this, namespacesOf(configOf(apiKey, options)));
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
class OpenSend extends OpenSendBase {
|
|
1697
|
+
}
|
|
1698
|
+
// lib/webhooks.ts
|
|
1699
|
+
var refused = (message) => new OpenSendError(message, {
|
|
1700
|
+
status: null,
|
|
1701
|
+
code: OPENSEND_ERROR_CODES.INVALID_SIGNATURE,
|
|
1702
|
+
type: null,
|
|
1703
|
+
requestId: null
|
|
1704
|
+
});
|
|
1705
|
+
var hexOf = (bytes) => [...new Uint8Array(bytes)].map((byte) => byte.toString(OPENSEND_HEX_RADIX).padStart(OPENSEND_HEX_PAD, "0")).join("");
|
|
1706
|
+
var sameText = (left, right) => {
|
|
1707
|
+
if (left.length !== right.length)
|
|
1708
|
+
return false;
|
|
1709
|
+
let difference = 0;
|
|
1710
|
+
for (let index = 0;index < left.length; index += 1) {
|
|
1711
|
+
difference |= left.charCodeAt(index) ^ right.charCodeAt(index);
|
|
1712
|
+
}
|
|
1713
|
+
return difference === 0;
|
|
1714
|
+
};
|
|
1715
|
+
var isEvent = (value) => typeof value === "object" && value !== null && ("id" in value) && ("type" in value) && typeof value.id === "string" && typeof value.type === "string";
|
|
1716
|
+
var verifyWebhook = async (check) => {
|
|
1717
|
+
const parts = (check.signature ?? "").split(OPENSEND_SIGNATURE_PART).map((part) => part.trim().split(OPENSEND_SIGNATURE_PAIR));
|
|
1718
|
+
const seconds = parts.find(([name]) => name === OPENSEND_SIGNATURE_TIME)?.[1] ?? "";
|
|
1719
|
+
const given = parts.flatMap(([name, value]) => name === OPENSEND_SIGNATURE_VERSION && value ? [value] : []);
|
|
1720
|
+
const at = Number(seconds);
|
|
1721
|
+
if (!seconds || !Number.isFinite(at) || given.length === 0) {
|
|
1722
|
+
throw refused(OPENSEND_SIGNATURE_MISSING);
|
|
1723
|
+
}
|
|
1724
|
+
const tolerance = check.toleranceSeconds ?? OPENSEND_SIGNATURE_TOLERANCE_S;
|
|
1725
|
+
const drift = Math.abs((check.now ?? Date.now()) / OPENSEND_MS_PER_SECOND - at);
|
|
1726
|
+
if (drift > tolerance)
|
|
1727
|
+
throw refused(OPENSEND_SIGNATURE_OLD);
|
|
1728
|
+
if (!check.secret)
|
|
1729
|
+
throw refused(OPENSEND_SIGNATURE_NO_SECRET);
|
|
1730
|
+
const key = await crypto.subtle.importKey("raw", new TextEncoder().encode(check.secret), OPENSEND_HMAC, false, OPENSEND_HMAC_USES);
|
|
1731
|
+
const expected = hexOf(await crypto.subtle.sign(OPENSEND_HMAC.name, key, new TextEncoder().encode(`${seconds}.${check.payload}`)));
|
|
1732
|
+
if (!given.some((signature) => sameText(signature, expected))) {
|
|
1733
|
+
throw refused(OPENSEND_SIGNATURE_WRONG);
|
|
1734
|
+
}
|
|
1735
|
+
let event;
|
|
1736
|
+
try {
|
|
1737
|
+
event = JSON.parse(check.payload);
|
|
1738
|
+
} catch {
|
|
1739
|
+
throw refused(OPENSEND_SIGNATURE_BODY);
|
|
1740
|
+
}
|
|
1741
|
+
if (!isEvent(event))
|
|
1742
|
+
throw refused(OPENSEND_SIGNATURE_BODY);
|
|
1743
|
+
return event;
|
|
1744
|
+
};
|
|
1745
|
+
export {
|
|
1746
|
+
verifyWebhook,
|
|
1747
|
+
createOpenSend,
|
|
1748
|
+
OpenSendError,
|
|
1749
|
+
OpenSend,
|
|
1750
|
+
OPENSEND_SIGNATURE_HEADER
|
|
1751
|
+
};
|