@postshiba/node 0.1.0 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0
4
+
5
+ Adds the rest of the API catalog: bulk send (`emails.sendBulk`, `listBulk`, `getBulk`), IP pools, outbound messages and retention, DKIM signing, recipients, analytics, status, planned sends, support tickets, ShieldShiba sites, and new actions on clusters, network, sending domains, tenants, inboxes, SMTP credentials, webhooks, and suppressions. List methods take only the query options you set.
6
+
3
7
  ## 0.1.0
4
8
 
5
9
  Initial Node.js client. Published to npm as `@postshiba/node` (compiled ESM). `postshiba` is a thin alias of the same version.
package/README.md CHANGED
@@ -52,6 +52,40 @@ await postshiba.emails.sendOnCluster("NmQpXr", body, {
52
52
  })
53
53
  ```
54
54
 
55
+ ## Send in bulk
56
+
57
+ Send up to 1,000 `messages` in one request. Each message has `to`, an optional `name`, `variables`, and `unique_args`. Liquid such as `{{ name }}` works in `subject`, `html`, `text`, `reply_to`, and header values.
58
+
59
+ ```ts
60
+ await postshiba.emails.sendBulk({
61
+ from: "Party <hello@mail.example.com>",
62
+ subject: "{{ name }}, you're invited",
63
+ html: "<p>RSVP at {{ rsvp_url }}</p>",
64
+ text: "RSVP at {{ rsvp_url }}",
65
+ reply_to: "rsvp+{{ guest_id }}@inbox.example.com",
66
+ headers: {
67
+ "List-Unsubscribe": "<{{ unsubscribe_url }}>",
68
+ "List-Unsubscribe-Post": "List-Unsubscribe=One-Click",
69
+ },
70
+ unique_args: { event_id: "evt_1" },
71
+ reference: "invites-2026-11-28",
72
+ messages: [
73
+ {
74
+ to: "ada@example.com",
75
+ name: "Ada",
76
+ variables: {
77
+ guest_id: "g1",
78
+ rsvp_url: "https://example.com/r/g1",
79
+ unsubscribe_url: "https://example.com/u/g1",
80
+ },
81
+ unique_args: { invite_id: "inv_1" },
82
+ },
83
+ ],
84
+ })
85
+ ```
86
+
87
+ Bulk send takes no `Idempotency-Key`. Set `reference`, and if a request times out, check `emails.listBulk({ reference })` before you retry. Pass `clusterId` as the second argument to send `X-Capsule-Cluster-Id`.
88
+
55
89
  ## NestJS
56
90
 
57
91
  The Nest entry is a module and an injectable token, not a mailer. Import `@postshiba/node` without Nest. Import `@postshiba/node/nest` only in Nest apps.
@@ -116,6 +150,9 @@ await postshiba.emails.send({
116
150
  to: ["you@example.com"],
117
151
  template: { id: "welcome", variables: { name: "Ada" } },
118
152
  })
153
+ await postshiba.emails.sendBulk(bulkBody, { clusterId: "NmQpXr" })
154
+ await postshiba.emails.listBulk({ reference: "invites-2026-11-28" })
155
+ await postshiba.emails.getBulk("bLkSnD")
119
156
  ```
120
157
 
121
158
  ### Clusters
@@ -131,6 +168,8 @@ await postshiba.clusters.delete("NmQpXr")
131
168
  await postshiba.clusters.boost("NmQpXr", { sku: "small_to_large" })
132
169
  await postshiba.clusters.extendBoost("NmQpXr", { idempotency_key: "extend-1" })
133
170
  await postshiba.clusters.cancelBoost("NmQpXr")
171
+ await postshiba.clusters.reactivate("NmQpXr")
172
+ await postshiba.clusters.setAutoBoost("NmQpXr", { sku: "small_to_medium", monthly_limit: 3 })
134
173
  ```
135
174
 
136
175
  ### Network
@@ -142,6 +181,21 @@ await postshiba.network.assign({ ip_address_id: "IpQwEr", cluster_id: "NmQpXr" }
142
181
  await postshiba.network.unassign({ ip_address_id: "IpQwEr", cluster_id: "NmQpXr" })
143
182
  await postshiba.network.switch({ ip_address_id: "IpQwEr", cluster_id: "NmQpXr" })
144
183
  await postshiba.network.release({ ip_address_id: "IpQwEr" })
184
+ await postshiba.network.warmup({ ip_address_id: "IpQwEr", warmup_mode: "slow" })
185
+ ```
186
+
187
+ ### IP pools
188
+
189
+ ```ts
190
+ await postshiba.ipPools.list({ classification: "bulk" })
191
+ await postshiba.ipPools.get("PoOlIp")
192
+ await postshiba.ipPools.create({ name: "site_123", classification: "bulk", warmup_overflow: true })
193
+ await postshiba.ipPools.update("PoOlIp", { name: "site_123_bulk", warmup_overflow: false })
194
+ await postshiba.ipPools.delete("PoOlIp")
195
+ await postshiba.ipPools.addIp("PoOlIp", { ip_address_id: "IpQwEr", weight: 100 })
196
+ await postshiba.ipPools.removeIp("PoOlIp", { ip_address_id: "IpQwEr" })
197
+ await postshiba.ipPools.attach("PoOlIp", { cluster_id: "NmQpXr" })
198
+ await postshiba.ipPools.detach("PoOlIp", { cluster_id: "NmQpXr" })
145
199
  ```
146
200
 
147
201
  ### Sending domains
@@ -157,14 +211,23 @@ await postshiba.sendingDomains.suspend("HsVtYk")
157
211
  await postshiba.sendingDomains.resume("HsVtYk")
158
212
  await postshiba.sendingDomains.makePrimary("HsVtYk")
159
213
  await postshiba.sendingDomains.delete("HsVtYk")
214
+ await postshiba.sendingDomains.flushQueue("HsVtYk")
215
+ await postshiba.sendingDomains.move("HsVtYk", { sending_domain: { tenant_id: "WbLcFd" } })
216
+ const started = await postshiba.sendingDomains.canISendThis("HsVtYk")
217
+ await postshiba.sendingDomains.canISendThisResult("HsVtYk", token)
160
218
  ```
161
219
 
220
+ `canISendThisResult` requires `token`.
221
+
162
222
  ### Tenants
163
223
 
164
224
  ```ts
165
225
  await postshiba.tenants.list()
166
226
  await postshiba.tenants.get("WbLcFd")
167
227
  await postshiba.tenants.create({ tenant: { name: "Acme Florist" } })
228
+ await postshiba.tenants.update("WbLcFd", { tenant: { suppress_hard_bounces: false } })
229
+ await postshiba.tenants.suspend("WbLcFd")
230
+ await postshiba.tenants.resume("WbLcFd")
168
231
  await postshiba.tenants.delete("WbLcFd")
169
232
  ```
170
233
 
@@ -181,6 +244,7 @@ await postshiba.inboxes.create({
181
244
  forward_to: "you@example.com",
182
245
  },
183
246
  })
247
+ await postshiba.inboxes.update("PqRzMn", { inbox: { webhook_url: "https://hooks.example.com/mail", webhook_format: "json" } })
184
248
  await postshiba.inboxes.verify("PqRzMn")
185
249
  await postshiba.inboxes.delete("PqRzMn")
186
250
  ```
@@ -193,6 +257,58 @@ await postshiba.messages.get("PqRzMn", "GxTyVu")
193
257
  await postshiba.messages.downloadAttachment("PqRzMn", "GxTyVu", 1)
194
258
  ```
195
259
 
260
+ ### Outbound messages
261
+
262
+ ```ts
263
+ await postshiba.outboundMessages.list({ q: "ada@example.com", before: "OuTbMs", limit: 50 })
264
+ await postshiba.outboundMessages.get("OuTbMs")
265
+ const eml = await postshiba.outboundMessages.raw("OuTbMs")
266
+ await postshiba.outboundMessages.downloadAttachment("OuTbMs", 1)
267
+ await postshiba.outboundRetention.get()
268
+ await postshiba.outboundRetention.update({ team: { outbound_retention_days: 45 } })
269
+ ```
270
+
271
+ `raw` returns the `message/rfc822` source as a string. `downloadAttachment` returns an `ArrayBuffer`.
272
+
273
+ ### DKIM signing
274
+
275
+ ```ts
276
+ await postshiba.dkimSigning.get()
277
+ await postshiba.dkimSigning.update({ team: { sign_with_primary_domain: false } })
278
+ ```
279
+
280
+ ### Recipients, analytics, and status
281
+
282
+ ```ts
283
+ await postshiba.recipients.get("ada@example.com")
284
+ await postshiba.analytics.get({ since: "2026-09-15T12:00:00Z", until: "2026-09-16T12:00:00Z", dimension: "mx_provider" })
285
+ await postshiba.status.get()
286
+ ```
287
+
288
+ `analytics.get` also takes `minProcessed`, `compare`, `compareSince`, and `compareUntil`, sent as `min_processed`, `compare`, `compare_since`, and `compare_until`. Only the options you set are sent.
289
+
290
+ ### Planned sends
291
+
292
+ ```ts
293
+ await postshiba.plannedSends.list()
294
+ await postshiba.plannedSends.get("PlAnSd")
295
+ await postshiba.plannedSends.create({
296
+ planned_send: { cluster_id: "NmQpXr", volume_per_hour: 500, scheduled_for: "2026-09-21T09:00:00Z", name: "Launch" },
297
+ })
298
+ await postshiba.plannedSends.cancel("PlAnSd")
299
+ ```
300
+
301
+ ### Support tickets
302
+
303
+ ```ts
304
+ await postshiba.supportTickets.list({ all: true })
305
+ await postshiba.supportTickets.get("SuPtKt")
306
+ await postshiba.supportTickets.create({
307
+ support_ticket: { subject: "Forwarded mail bounces with SPF fail", category: "receiving", body: "..." },
308
+ })
309
+ await postshiba.supportTickets.reply("SuPtKt", { support_ticket_message: { body: "It still bounces." } })
310
+ ```
311
+
196
312
  ### Events
197
313
 
198
314
  ```ts
@@ -206,6 +322,7 @@ await postshiba.events.get("JkLmNp")
206
322
  ```ts
207
323
  await postshiba.smtpCredentials.create("NmQpXr", { smtp_credential: { tenant_id: "WbLcFd" } })
208
324
  await postshiba.smtpCredentials.delete("NmQpXr", "RvWsXq")
325
+ await postshiba.smtpCredentials.enable("NmQpXr", "RvWsXq")
209
326
  ```
210
327
 
211
328
  Create returns `password`. Delete does not.
@@ -226,6 +343,7 @@ await postshiba.webhooks.update("CdFgHj", {
226
343
  webhook_endpoint: { enabled: false, event_types: ["delivered", "bounce"] },
227
344
  })
228
345
  await postshiba.webhooks.delete("CdFgHj")
346
+ await postshiba.webhooks.sendTest("CdFgHj")
229
347
  ```
230
348
 
231
349
  List and update omit `secret`. Get and create return it.
@@ -258,6 +376,12 @@ await postshiba.suppressions.list()
258
376
  await postshiba.suppressions.create({ suppression: { email: "blocked@example.com", tenant_id: "WbLcFd" } })
259
377
  await postshiba.suppressions.import({ emails: ["blocked@example.com", "old@example.com"], tenant_id: "WbLcFd" })
260
378
  await postshiba.suppressions.delete("YtReWq")
379
+ await postshiba.suppressions.bulkDelete({
380
+ emails: ["blocked@example.com", "old@example.com"],
381
+ reason: "bounce",
382
+ tenant_id: "WbLcFd",
383
+ before: "2026-02-01T00:00:00Z",
384
+ })
261
385
  ```
262
386
 
263
387
  ### Firewall
@@ -269,6 +393,19 @@ await postshiba.firewall.addEntry({ firewall_entry: { list: "deny", value: "mail
269
393
  await postshiba.firewall.deleteEntry("BnMkLo")
270
394
  ```
271
395
 
396
+ ### ShieldShiba sites
397
+
398
+ ```ts
399
+ await postshiba.shieldSites.list()
400
+ await postshiba.shieldSites.get("ShLdSt")
401
+ await postshiba.shieldSites.create({
402
+ shield_site: { name: "Signup", allowed_hostnames: "acme.com, app.acme.com", block_hosting: true, block_free_email: false },
403
+ })
404
+ await postshiba.shieldSites.update("ShLdSt", { shield_site: { block_free_email: true } })
405
+ await postshiba.shieldSites.rotateSecret("ShLdSt")
406
+ await postshiba.shieldSites.delete("ShLdSt")
407
+ ```
408
+
272
409
  ## Verify webhooks
273
410
 
274
411
  HMAC-SHA256 of `{timestamp}.{rawBody}` against `X-Capsule-Signature`. A `sha256=` prefix is stripped.
package/dist/index.d.ts CHANGED
@@ -11,6 +11,31 @@ export type ClusterSendOptions = {
11
11
  idempotencyKey?: string;
12
12
  sandbox?: boolean;
13
13
  };
14
+ export type QueryValue = string | number | boolean | null | undefined;
15
+ export type Query = Record<string, QueryValue>;
16
+ export type BulkListOptions = {
17
+ reference?: string;
18
+ };
19
+ export type IpPoolListOptions = {
20
+ classification?: string;
21
+ };
22
+ export type OutboundMessageListOptions = {
23
+ q?: string;
24
+ before?: string;
25
+ limit?: number;
26
+ };
27
+ export type AnalyticsOptions = {
28
+ since?: string;
29
+ until?: string;
30
+ dimension?: string;
31
+ minProcessed?: number;
32
+ compare?: boolean;
33
+ compareSince?: string;
34
+ compareUntil?: string;
35
+ };
36
+ export type SupportTicketListOptions = {
37
+ all?: boolean;
38
+ };
14
39
  export declare class PostShibaError extends Error {
15
40
  readonly error: string;
16
41
  readonly field: string | null;
@@ -32,6 +57,9 @@ export declare class PostShiba {
32
57
  };
33
58
  readonly emails: {
34
59
  send: (body: Json, options?: SendOptions) => Promise<unknown>;
60
+ sendBulk: (body: Json, options?: SendOptions) => Promise<unknown>;
61
+ listBulk: (options?: BulkListOptions) => Promise<unknown>;
62
+ getBulk: (id: Id) => Promise<unknown>;
35
63
  sendOnCluster: (clusterId: Id, body: Json, options?: ClusterSendOptions) => Promise<unknown>;
36
64
  };
37
65
  readonly clusters: {
@@ -45,6 +73,8 @@ export declare class PostShiba {
45
73
  boost: (id: Id, body: Json) => Promise<unknown>;
46
74
  extendBoost: (id: Id, body: Json) => Promise<unknown>;
47
75
  cancelBoost: (id: Id) => Promise<unknown>;
76
+ reactivate: (id: Id) => Promise<unknown>;
77
+ setAutoBoost: (id: Id, body: Json) => Promise<unknown>;
48
78
  };
49
79
  readonly network: {
50
80
  list: () => Promise<unknown>;
@@ -53,6 +83,18 @@ export declare class PostShiba {
53
83
  unassign: (body: Json) => Promise<unknown>;
54
84
  switch: (body: Json) => Promise<unknown>;
55
85
  release: (body: Json) => Promise<unknown>;
86
+ warmup: (body: Json) => Promise<unknown>;
87
+ };
88
+ readonly ipPools: {
89
+ list: (options?: IpPoolListOptions) => Promise<unknown>;
90
+ get: (id: Id) => Promise<unknown>;
91
+ create: (body: Json) => Promise<unknown>;
92
+ update: (id: Id, body: Json) => Promise<unknown>;
93
+ delete: (id: Id) => Promise<unknown>;
94
+ addIp: (id: Id, body: Json) => Promise<unknown>;
95
+ removeIp: (id: Id, body: Json) => Promise<unknown>;
96
+ attach: (id: Id, body: Json) => Promise<unknown>;
97
+ detach: (id: Id, body: Json) => Promise<unknown>;
56
98
  };
57
99
  readonly sendingDomains: {
58
100
  list: () => Promise<unknown>;
@@ -65,17 +107,25 @@ export declare class PostShiba {
65
107
  resume: (id: Id) => Promise<unknown>;
66
108
  makePrimary: (id: Id) => Promise<unknown>;
67
109
  delete: (id: Id) => Promise<unknown>;
110
+ flushQueue: (id: Id) => Promise<unknown>;
111
+ move: (id: Id, body: Json) => Promise<unknown>;
112
+ canISendThis: (id: Id) => Promise<unknown>;
113
+ canISendThisResult: (id: Id, token: string) => Promise<unknown>;
68
114
  };
69
115
  readonly tenants: {
70
116
  list: () => Promise<unknown>;
71
117
  get: (id: Id) => Promise<unknown>;
72
118
  create: (body: Json) => Promise<unknown>;
119
+ update: (id: Id, body: Json) => Promise<unknown>;
120
+ suspend: (id: Id) => Promise<unknown>;
121
+ resume: (id: Id) => Promise<unknown>;
73
122
  delete: (id: Id) => Promise<unknown>;
74
123
  };
75
124
  readonly inboxes: {
76
125
  list: () => Promise<unknown>;
77
126
  get: (id: Id) => Promise<unknown>;
78
127
  create: (body: Json) => Promise<unknown>;
128
+ update: (id: Id, body: Json) => Promise<unknown>;
79
129
  verify: (id: Id) => Promise<unknown>;
80
130
  delete: (id: Id) => Promise<unknown>;
81
131
  };
@@ -84,6 +134,49 @@ export declare class PostShiba {
84
134
  get: (inboxId: Id, id: Id) => Promise<unknown>;
85
135
  downloadAttachment: (inboxId: Id, id: Id, index: number) => Promise<unknown>;
86
136
  };
137
+ readonly outboundMessages: {
138
+ list: (options?: OutboundMessageListOptions) => Promise<unknown>;
139
+ get: (id: Id) => Promise<unknown>;
140
+ raw: (id: Id) => Promise<string>;
141
+ downloadAttachment: (id: Id, index: number) => Promise<unknown>;
142
+ };
143
+ readonly outboundRetention: {
144
+ get: () => Promise<unknown>;
145
+ update: (body: Json) => Promise<unknown>;
146
+ };
147
+ readonly dkimSigning: {
148
+ get: () => Promise<unknown>;
149
+ update: (body: Json) => Promise<unknown>;
150
+ };
151
+ readonly recipients: {
152
+ get: (email: string) => Promise<unknown>;
153
+ };
154
+ readonly analytics: {
155
+ get: (options?: AnalyticsOptions) => Promise<unknown>;
156
+ };
157
+ readonly status: {
158
+ get: () => Promise<unknown>;
159
+ };
160
+ readonly plannedSends: {
161
+ list: () => Promise<unknown>;
162
+ get: (id: Id) => Promise<unknown>;
163
+ create: (body: Json) => Promise<unknown>;
164
+ cancel: (id: Id) => Promise<unknown>;
165
+ };
166
+ readonly supportTickets: {
167
+ list: (options?: SupportTicketListOptions) => Promise<unknown>;
168
+ get: (id: Id) => Promise<unknown>;
169
+ create: (body: Json) => Promise<unknown>;
170
+ reply: (id: Id, body: Json) => Promise<unknown>;
171
+ };
172
+ readonly shieldSites: {
173
+ list: () => Promise<unknown>;
174
+ get: (id: Id) => Promise<unknown>;
175
+ create: (body: Json) => Promise<unknown>;
176
+ update: (id: Id, body: Json) => Promise<unknown>;
177
+ rotateSecret: (id: Id) => Promise<unknown>;
178
+ delete: (id: Id) => Promise<unknown>;
179
+ };
87
180
  readonly events: {
88
181
  listTeam: () => Promise<unknown>;
89
182
  list: (clusterId: Id) => Promise<unknown>;
@@ -92,6 +185,7 @@ export declare class PostShiba {
92
185
  readonly smtpCredentials: {
93
186
  create: (clusterId: Id, body: Json) => Promise<unknown>;
94
187
  delete: (clusterId: Id, id: Id) => Promise<unknown>;
188
+ enable: (clusterId: Id, id: Id) => Promise<unknown>;
95
189
  };
96
190
  readonly webhooks: {
97
191
  list: () => Promise<unknown>;
@@ -99,6 +193,7 @@ export declare class PostShiba {
99
193
  create: (body: Json) => Promise<unknown>;
100
194
  update: (id: Id, body: Json) => Promise<unknown>;
101
195
  delete: (id: Id) => Promise<unknown>;
196
+ sendTest: (id: Id) => Promise<unknown>;
102
197
  verify: (rawBody: string, timestamp: string, signature: string, secret: string) => boolean;
103
198
  };
104
199
  readonly templates: {
@@ -114,6 +209,7 @@ export declare class PostShiba {
114
209
  list: () => Promise<unknown>;
115
210
  create: (body: Json) => Promise<unknown>;
116
211
  import: (body: Json) => Promise<unknown>;
212
+ bulkDelete: (body: Json) => Promise<unknown>;
117
213
  delete: (id: Id) => Promise<unknown>;
118
214
  };
119
215
  readonly firewall: {
package/dist/index.js CHANGED
@@ -19,6 +19,25 @@ function parseJson(text) {
19
19
  return text;
20
20
  }
21
21
  }
22
+ function queryString(query) {
23
+ if (!query)
24
+ return "";
25
+ const params = new URLSearchParams();
26
+ for (const [key, value] of Object.entries(query)) {
27
+ if (value === undefined || value === null)
28
+ continue;
29
+ params.append(key, String(value));
30
+ }
31
+ const encoded = params.toString();
32
+ return encoded ? `?${encoded}` : "";
33
+ }
34
+ function clusterHeaders(options) {
35
+ const headers = {};
36
+ if (options.clusterId !== undefined && options.clusterId !== null && options.clusterId !== "") {
37
+ headers["X-Capsule-Cluster-Id"] = String(options.clusterId);
38
+ }
39
+ return headers;
40
+ }
22
41
  function asErrorPayload(value) {
23
42
  if (value && typeof value === "object")
24
43
  return value;
@@ -40,7 +59,8 @@ export class PostShiba {
40
59
  return this.teamId;
41
60
  }
42
61
  async request(method, path, opts = {}) {
43
- const resolved = opts.team ? `/api/v1/teams/${this.requireTeamId()}${path}` : path;
62
+ const base = opts.team ? `/api/v1/teams/${this.requireTeamId()}${path}` : path;
63
+ const resolved = `${base}${queryString(opts.query)}`;
44
64
  const headers = {
45
65
  Authorization: `Bearer ${this.apiKey}`,
46
66
  Accept: "application/json",
@@ -63,19 +83,18 @@ export class PostShiba {
63
83
  }
64
84
  if (opts.binary)
65
85
  return res.arrayBuffer();
86
+ if (opts.text)
87
+ return res.text();
66
88
  return parseJson(await res.text());
67
89
  }
68
90
  users = {
69
91
  me: () => this.request("GET", "/api/v1/users/me"),
70
92
  };
71
93
  emails = {
72
- send: (body, options = {}) => {
73
- const headers = {};
74
- if (options.clusterId !== undefined && options.clusterId !== null && options.clusterId !== "") {
75
- headers["X-Capsule-Cluster-Id"] = String(options.clusterId);
76
- }
77
- return this.request("POST", "/api/v1/emails", { body, headers });
78
- },
94
+ send: (body, options = {}) => this.request("POST", "/api/v1/emails", { body, headers: clusterHeaders(options) }),
95
+ sendBulk: (body, options = {}) => this.request("POST", "/api/v1/emails/bulk", { body, headers: clusterHeaders(options) }),
96
+ listBulk: (options = {}) => this.request("GET", "/api/v1/emails/bulk", { query: options }),
97
+ getBulk: (id) => this.request("GET", `/api/v1/emails/bulk/${id}`),
79
98
  sendOnCluster: (clusterId, body, options = {}) => {
80
99
  const payload = options.sandbox ? { ...body, sandbox: true } : body;
81
100
  const headers = {};
@@ -95,6 +114,8 @@ export class PostShiba {
95
114
  boost: (id, body) => this.request("POST", `/api/v1/clusters/${id}/boost`, { body }),
96
115
  extendBoost: (id, body) => this.request("POST", `/api/v1/clusters/${id}/extend_boost`, { body }),
97
116
  cancelBoost: (id) => this.request("POST", `/api/v1/clusters/${id}/cancel_boost`),
117
+ reactivate: (id) => this.request("POST", `/api/v1/clusters/${id}/reactivate`),
118
+ setAutoBoost: (id, body) => this.request("PATCH", `/api/v1/clusters/${id}/auto_boost`, { body }),
98
119
  };
99
120
  network = {
100
121
  list: () => this.request("GET", "/network", { team: true }),
@@ -103,6 +124,18 @@ export class PostShiba {
103
124
  unassign: (body) => this.request("POST", "/network/unassign", { body, team: true }),
104
125
  switch: (body) => this.request("POST", "/network/switch", { body, team: true }),
105
126
  release: (body) => this.request("POST", "/network/release", { body, team: true }),
127
+ warmup: (body) => this.request("POST", "/network/warmup", { body, team: true }),
128
+ };
129
+ ipPools = {
130
+ list: (options = {}) => this.request("GET", "/ip_pools", { team: true, query: options }),
131
+ get: (id) => this.request("GET", `/api/v1/ip_pools/${id}`),
132
+ create: (body) => this.request("POST", "/ip_pools", { body, team: true }),
133
+ update: (id, body) => this.request("PATCH", `/api/v1/ip_pools/${id}`, { body }),
134
+ delete: (id) => this.request("DELETE", `/api/v1/ip_pools/${id}`),
135
+ addIp: (id, body) => this.request("POST", `/api/v1/ip_pools/${id}/add_ip`, { body }),
136
+ removeIp: (id, body) => this.request("POST", `/api/v1/ip_pools/${id}/remove_ip`, { body }),
137
+ attach: (id, body) => this.request("POST", `/api/v1/ip_pools/${id}/attach`, { body }),
138
+ detach: (id, body) => this.request("POST", `/api/v1/ip_pools/${id}/detach`, { body }),
106
139
  };
107
140
  sendingDomains = {
108
141
  list: () => this.request("GET", "/sending_domains", { team: true }),
@@ -115,17 +148,29 @@ export class PostShiba {
115
148
  resume: (id) => this.request("POST", `/api/v1/sending_domains/${id}/resume`),
116
149
  makePrimary: (id) => this.request("POST", `/api/v1/sending_domains/${id}/make_primary`),
117
150
  delete: (id) => this.request("DELETE", `/api/v1/sending_domains/${id}`),
151
+ flushQueue: (id) => this.request("POST", `/api/v1/sending_domains/${id}/flush_queue`),
152
+ move: (id, body) => this.request("POST", `/api/v1/sending_domains/${id}/move`, { body }),
153
+ canISendThis: (id) => this.request("POST", `/api/v1/sending_domains/${id}/can_i_send_this`),
154
+ canISendThisResult: (id, token) => {
155
+ if (!token)
156
+ return Promise.reject(new Error("token is required"));
157
+ return this.request("GET", `/api/v1/sending_domains/${id}/can_i_send_this`, { query: { token } });
158
+ },
118
159
  };
119
160
  tenants = {
120
161
  list: () => this.request("GET", "/tenants", { team: true }),
121
162
  get: (id) => this.request("GET", `/api/v1/tenants/${id}`),
122
163
  create: (body) => this.request("POST", "/tenants", { body, team: true }),
164
+ update: (id, body) => this.request("PATCH", `/api/v1/tenants/${id}`, { body }),
165
+ suspend: (id) => this.request("POST", `/api/v1/tenants/${id}/suspend`),
166
+ resume: (id) => this.request("POST", `/api/v1/tenants/${id}/resume`),
123
167
  delete: (id) => this.request("DELETE", `/api/v1/tenants/${id}`),
124
168
  };
125
169
  inboxes = {
126
170
  list: () => this.request("GET", "/inboxes", { team: true }),
127
171
  get: (id) => this.request("GET", `/api/v1/inboxes/${id}`),
128
172
  create: (body) => this.request("POST", "/inboxes", { body, team: true }),
173
+ update: (id, body) => this.request("PATCH", `/api/v1/inboxes/${id}`, { body }),
129
174
  verify: (id) => this.request("POST", `/api/v1/inboxes/${id}/verify`),
130
175
  delete: (id) => this.request("DELETE", `/api/v1/inboxes/${id}`),
131
176
  };
@@ -134,6 +179,64 @@ export class PostShiba {
134
179
  get: (inboxId, id) => this.request("GET", `/api/v1/inboxes/${inboxId}/inbound_messages/${id}`),
135
180
  downloadAttachment: (inboxId, id, index) => this.request("GET", `/api/v1/inboxes/${inboxId}/inbound_messages/${id}/attachments/${index}`, { binary: true }),
136
181
  };
182
+ outboundMessages = {
183
+ list: (options = {}) => this.request("GET", "/outbound_messages", { team: true, query: options }),
184
+ get: (id) => this.request("GET", `/api/v1/outbound_messages/${id}`),
185
+ raw: (id) => this.request("GET", `/api/v1/outbound_messages/${id}/raw`, { text: true }),
186
+ downloadAttachment: (id, index) => this.request("GET", `/api/v1/outbound_messages/${id}/attachments/${index}`, { binary: true }),
187
+ };
188
+ outboundRetention = {
189
+ get: () => this.request("GET", "/outbound_retention", { team: true }),
190
+ update: (body) => this.request("PATCH", "/outbound_retention", { body, team: true }),
191
+ };
192
+ dkimSigning = {
193
+ get: () => this.request("GET", "/dkim_signing", { team: true }),
194
+ update: (body) => this.request("PATCH", "/dkim_signing", { body, team: true }),
195
+ };
196
+ recipients = {
197
+ get: (email) => {
198
+ if (!email)
199
+ return Promise.reject(new Error("email is required"));
200
+ return this.request("GET", "/recipients", { team: true, query: { email } });
201
+ },
202
+ };
203
+ analytics = {
204
+ get: (options = {}) => this.request("GET", "/analytics", {
205
+ team: true,
206
+ query: {
207
+ since: options.since,
208
+ until: options.until,
209
+ dimension: options.dimension,
210
+ min_processed: options.minProcessed,
211
+ compare: options.compare,
212
+ compare_since: options.compareSince,
213
+ compare_until: options.compareUntil,
214
+ },
215
+ }),
216
+ };
217
+ status = {
218
+ get: () => this.request("GET", "/status", { team: true }),
219
+ };
220
+ plannedSends = {
221
+ list: () => this.request("GET", "/planned_sends", { team: true }),
222
+ get: (id) => this.request("GET", `/api/v1/planned_sends/${id}`),
223
+ create: (body) => this.request("POST", "/planned_sends", { body, team: true }),
224
+ cancel: (id) => this.request("DELETE", `/api/v1/planned_sends/${id}`),
225
+ };
226
+ supportTickets = {
227
+ list: (options = {}) => this.request("GET", "/support_tickets", { team: true, query: options }),
228
+ get: (id) => this.request("GET", `/api/v1/support_tickets/${id}`),
229
+ create: (body) => this.request("POST", "/support_tickets", { body, team: true }),
230
+ reply: (id, body) => this.request("POST", `/api/v1/support_tickets/${id}/reply`, { body }),
231
+ };
232
+ shieldSites = {
233
+ list: () => this.request("GET", "/shield_sites", { team: true }),
234
+ get: (id) => this.request("GET", `/api/v1/shield_sites/${id}`),
235
+ create: (body) => this.request("POST", "/shield_sites", { body, team: true }),
236
+ update: (id, body) => this.request("PATCH", `/api/v1/shield_sites/${id}`, { body }),
237
+ rotateSecret: (id) => this.request("POST", `/api/v1/shield_sites/${id}/rotate_secret`),
238
+ delete: (id) => this.request("DELETE", `/api/v1/shield_sites/${id}`),
239
+ };
137
240
  events = {
138
241
  listTeam: () => this.request("GET", "/message_events", { team: true }),
139
242
  list: (clusterId) => this.request("GET", `/clusters/${clusterId}/message_events`, { team: true }),
@@ -142,6 +245,7 @@ export class PostShiba {
142
245
  smtpCredentials = {
143
246
  create: (clusterId, body) => this.request("POST", `/clusters/${clusterId}/smtp_credentials`, { body, team: true }),
144
247
  delete: (clusterId, id) => this.request("DELETE", `/clusters/${clusterId}/smtp_credentials/${id}`, { team: true }),
248
+ enable: (clusterId, id) => this.request("POST", `/clusters/${clusterId}/smtp_credentials/${id}/enable`, { team: true }),
145
249
  };
146
250
  webhooks = {
147
251
  list: () => this.request("GET", "/webhook_endpoints", { team: true }),
@@ -149,6 +253,7 @@ export class PostShiba {
149
253
  create: (body) => this.request("POST", "/webhook_endpoints", { body, team: true }),
150
254
  update: (id, body) => this.request("PATCH", `/api/v1/webhook_endpoints/${id}`, { body }),
151
255
  delete: (id) => this.request("DELETE", `/api/v1/webhook_endpoints/${id}`),
256
+ sendTest: (id) => this.request("POST", `/api/v1/webhook_endpoints/${id}/send_test`),
152
257
  verify: (rawBody, timestamp, signature, secret) => verifySignature(rawBody, timestamp, signature, secret),
153
258
  };
154
259
  templates = {
@@ -164,6 +269,7 @@ export class PostShiba {
164
269
  list: () => this.request("GET", "/suppressions", { team: true }),
165
270
  create: (body) => this.request("POST", "/suppressions", { body, team: true }),
166
271
  import: (body) => this.request("POST", "/suppressions/import", { body, team: true }),
272
+ bulkDelete: (body) => this.request("POST", "/suppressions/bulk_delete", { body, team: true }),
167
273
  delete: (id) => this.request("DELETE", `/api/v1/suppressions/${id}`),
168
274
  };
169
275
  firewall = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postshiba/node",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "PostShiba API client",
5
5
  "license": "MIT",
6
6
  "author": "PostShiba",