@agentisend/sdk-node 0.1.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/README.md +97 -0
- package/dist/cli/args.d.ts +24 -0
- package/dist/cli/args.js +71 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/commands.d.ts +29 -0
- package/dist/cli/commands.js +147 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/config.d.ts +31 -0
- package/dist/cli/config.js +73 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/doctor.d.ts +36 -0
- package/dist/cli/doctor.js +161 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/listen.d.ts +28 -0
- package/dist/cli/listen.js +140 -0
- package/dist/cli/listen.js.map +1 -0
- package/dist/cli/main.d.ts +14 -0
- package/dist/cli/main.js +369 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/output.d.ts +40 -0
- package/dist/cli/output.js +35 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/scheduled-at.d.ts +19 -0
- package/dist/cli/scheduled-at.js +108 -0
- package/dist/cli/scheduled-at.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +17 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +426 -0
- package/dist/client.js +542 -0
- package/dist/client.js.map +1 -0
- package/dist/compat-resend.d.ts +194 -0
- package/dist/compat-resend.js +233 -0
- package/dist/compat-resend.js.map +1 -0
- package/dist/errors.d.ts +82 -0
- package/dist/errors.js +92 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +499 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +8 -0
- package/dist/version.js +9 -0
- package/dist/version.js.map +1 -0
- package/dist/webhook-signing.d.ts +64 -0
- package/dist/webhook-signing.js +125 -0
- package/dist/webhook-signing.js.map +1 -0
- package/package.json +65 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
import type { ApiKey, AutomationRun, ReceivedAttachment, ReceivedEmail, SentAttachment, RequestLogEntry, EventDefinition, EventFieldType, ApiKeyPermission, BatchItemResult, CreatedApiKey, CreatedWebhookEndpoint, DeadLetter, Deleted, Domain, DomainRegion, LegacyDomainRegion, Email, EventType, Limit, LimitPeriod, ListEmailsQuery, ListQuery, ExplainReport, Page, PreflightReport, ReplayResult, ContactTopic, SendEmailPayload, ServiceStatus, SuppressionBatchItem, AuditEntry, TeamInvite, TeamMember, Topic, BillingPlan, TrustStanding, WebhookEndpoint } from './types.js';
|
|
2
|
+
export declare const DEFAULT_BASE_URL = "https://api.agentisend.com";
|
|
3
|
+
export interface FetchResponse {
|
|
4
|
+
status: number;
|
|
5
|
+
headers: {
|
|
6
|
+
get(name: string): string | null;
|
|
7
|
+
};
|
|
8
|
+
text(): Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
export type FetchLike = (url: string, init: {
|
|
11
|
+
method: string;
|
|
12
|
+
headers: Record<string, string>;
|
|
13
|
+
body?: string;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}) => Promise<FetchResponse>;
|
|
16
|
+
export interface ClientOptions {
|
|
17
|
+
/** Defaults to AGENTISEND_BASE_URL, then https://api.agentisend.com. */
|
|
18
|
+
baseUrl?: string;
|
|
19
|
+
/** Injected for tests and for runtimes without a global fetch. */
|
|
20
|
+
fetch?: FetchLike;
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
userAgent?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface RequestOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Makes a mutating call safe to retry: the same key with the same body
|
|
27
|
+
* replays the original response instead of doing the work twice. Supported on
|
|
28
|
+
* EVERY mutating endpoint, not just sends.
|
|
29
|
+
*/
|
|
30
|
+
idempotencyKey?: string;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Build an idempotency key in the shape that debugs well: `<what>/<which>`,
|
|
35
|
+
* e.g. `welcome-email/user_123`. Stable across retries by construction, because
|
|
36
|
+
* it is derived from the thing being done rather than from the moment.
|
|
37
|
+
*/
|
|
38
|
+
export declare function idempotencyKey(action: string, subject: string | number): string;
|
|
39
|
+
interface RawRequest {
|
|
40
|
+
method: string;
|
|
41
|
+
path: string;
|
|
42
|
+
query?: Record<string, string | number | undefined>;
|
|
43
|
+
body?: unknown;
|
|
44
|
+
options?: RequestOptions;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A thin typed client. It adds authentication, JSON, the idempotency header and
|
|
48
|
+
* error shaping — and nothing else. Everything it can do is something the HTTP
|
|
49
|
+
* API can do, which is the property that lets an agent use either one.
|
|
50
|
+
*/
|
|
51
|
+
export declare class AgentiSend {
|
|
52
|
+
readonly baseUrl: string;
|
|
53
|
+
private readonly apiKey;
|
|
54
|
+
private readonly fetchImpl;
|
|
55
|
+
private readonly timeoutMs;
|
|
56
|
+
private readonly userAgent;
|
|
57
|
+
constructor(apiKey?: string, options?: ClientOptions);
|
|
58
|
+
request<T>(raw: RawRequest): Promise<T>;
|
|
59
|
+
readonly emails: {
|
|
60
|
+
send: (payload: SendEmailPayload, options?: RequestOptions) => Promise<{
|
|
61
|
+
id: string;
|
|
62
|
+
}>;
|
|
63
|
+
/** Up to 500 items. Each one succeeds or fails on its own — read data[i].status. */
|
|
64
|
+
batch: (payloads: SendEmailPayload[], options?: RequestOptions) => Promise<{
|
|
65
|
+
data: BatchItemResult[];
|
|
66
|
+
}>;
|
|
67
|
+
get: (id: string) => Promise<Email>;
|
|
68
|
+
list: (query?: ListEmailsQuery) => Promise<Page<Email>>;
|
|
69
|
+
/** M5.10 — what this email carried, after it was sent. */
|
|
70
|
+
attachments: (id: string) => Promise<Page<SentAttachment>>;
|
|
71
|
+
/** Stop a scheduled or queued email. Sent mail is history, not cancellable. */
|
|
72
|
+
cancel: (id: string, options?: RequestOptions) => Promise<{
|
|
73
|
+
id: string;
|
|
74
|
+
status: string;
|
|
75
|
+
}>;
|
|
76
|
+
/** Move an email to a new time. Works from scheduled AND canceled. */
|
|
77
|
+
reschedule: (id: string, scheduledAt: string, options?: RequestOptions) => Promise<{
|
|
78
|
+
id: string;
|
|
79
|
+
status: string;
|
|
80
|
+
scheduled_at: string;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* What happened to one message and the calls that fix it — each action
|
|
84
|
+
* carries the method, path and body to send, so remediation is executed
|
|
85
|
+
* rather than interpreted.
|
|
86
|
+
*/
|
|
87
|
+
explain: (id: string) => Promise<ExplainReport>;
|
|
88
|
+
/** Run every gate without sending or spending. Free, always. */
|
|
89
|
+
preflight: (payload: SendEmailPayload) => Promise<PreflightReport>;
|
|
90
|
+
/**
|
|
91
|
+
* Move a scheduled email. The same act as `reschedule`, under the verb a
|
|
92
|
+
* Resend integration already calls (M5.5).
|
|
93
|
+
*/
|
|
94
|
+
update: (id: string, payload: {
|
|
95
|
+
scheduled_at: string;
|
|
96
|
+
}, options?: RequestOptions) => Promise<{
|
|
97
|
+
id: string;
|
|
98
|
+
status: string;
|
|
99
|
+
scheduled_at: string;
|
|
100
|
+
}>;
|
|
101
|
+
};
|
|
102
|
+
readonly apiKeys: {
|
|
103
|
+
create: (payload: {
|
|
104
|
+
name: string;
|
|
105
|
+
permission: ApiKeyPermission;
|
|
106
|
+
domain_scope?: string | null;
|
|
107
|
+
}, options?: RequestOptions) => Promise<CreatedApiKey>;
|
|
108
|
+
list: (query?: ListQuery) => Promise<Page<ApiKey>>;
|
|
109
|
+
/** Rename or re-scope a key. The token is unchanged (M5.5). */
|
|
110
|
+
update: (id: string, payload: {
|
|
111
|
+
name?: string;
|
|
112
|
+
domain_scope?: string | null;
|
|
113
|
+
scopes?: string[];
|
|
114
|
+
}, options?: RequestOptions) => Promise<ApiKey>;
|
|
115
|
+
delete: (id: string, options?: RequestOptions) => Promise<Deleted>;
|
|
116
|
+
};
|
|
117
|
+
readonly domains: {
|
|
118
|
+
create: (payload: {
|
|
119
|
+
name: string;
|
|
120
|
+
region?: DomainRegion | LegacyDomainRegion;
|
|
121
|
+
tracking?: boolean;
|
|
122
|
+
tracking_subdomain?: string;
|
|
123
|
+
}, options?: RequestOptions) => Promise<Domain>;
|
|
124
|
+
list: (query?: ListQuery) => Promise<Page<Domain>>;
|
|
125
|
+
get: (id: string) => Promise<Domain>;
|
|
126
|
+
verify: (id: string, options?: RequestOptions) => Promise<Domain>;
|
|
127
|
+
/** A8 + P3b: click/open tracking, or a new tracking_subdomain. Never removed. */
|
|
128
|
+
update: (id: string, payload: {
|
|
129
|
+
click_tracking?: boolean;
|
|
130
|
+
open_tracking?: boolean;
|
|
131
|
+
tracking_subdomain?: string;
|
|
132
|
+
}, options?: RequestOptions) => Promise<Domain>;
|
|
133
|
+
delete: (id: string, options?: RequestOptions) => Promise<Deleted>;
|
|
134
|
+
};
|
|
135
|
+
readonly webhooks: {
|
|
136
|
+
create: (payload: {
|
|
137
|
+
url: string;
|
|
138
|
+
events?: EventType[];
|
|
139
|
+
svix_compat?: boolean;
|
|
140
|
+
}, options?: RequestOptions) => Promise<CreatedWebhookEndpoint>;
|
|
141
|
+
list: (query?: ListQuery) => Promise<Page<WebhookEndpoint>>;
|
|
142
|
+
get: (id: string) => Promise<WebhookEndpoint>;
|
|
143
|
+
update: (id: string, payload: {
|
|
144
|
+
url?: string;
|
|
145
|
+
events?: EventType[];
|
|
146
|
+
disabled?: boolean;
|
|
147
|
+
svix_compat?: boolean;
|
|
148
|
+
}, options?: RequestOptions) => Promise<WebhookEndpoint>;
|
|
149
|
+
delete: (id: string, options?: RequestOptions) => Promise<Deleted>;
|
|
150
|
+
/** Re-send past events. Pass `since`, `event_id`, or both. */
|
|
151
|
+
replay: (id: string, range: {
|
|
152
|
+
since?: string;
|
|
153
|
+
event_id?: string;
|
|
154
|
+
}, options?: RequestOptions) => Promise<ReplayResult>;
|
|
155
|
+
deadLetters: (id: string, query?: {
|
|
156
|
+
limit?: number;
|
|
157
|
+
cursor?: string;
|
|
158
|
+
}) => Promise<Page<DeadLetter>>;
|
|
159
|
+
};
|
|
160
|
+
readonly limits: {
|
|
161
|
+
list: (query?: ListQuery) => Promise<Page<Limit>>;
|
|
162
|
+
get: (apiKeyId: string) => Promise<Limit>;
|
|
163
|
+
update: (apiKeyId: string, payload: {
|
|
164
|
+
budget_per_period?: number | null;
|
|
165
|
+
period?: LimitPeriod;
|
|
166
|
+
rate_ceiling_per_minute?: number | null;
|
|
167
|
+
}, options?: RequestOptions) => Promise<Limit>;
|
|
168
|
+
/** Stops the key sending, immediately. Takes effect on its next request. */
|
|
169
|
+
kill: (apiKeyId: string, reason?: string, options?: RequestOptions) => Promise<Limit>;
|
|
170
|
+
resume: (apiKeyId: string, options?: RequestOptions) => Promise<Limit>;
|
|
171
|
+
};
|
|
172
|
+
/** M5.5 — the rest of the verb surface a Resend integration calls. */
|
|
173
|
+
/**
|
|
174
|
+
* M5.9 — what this account called, and what came back. The two filters that
|
|
175
|
+
* make a log useful: a date range and a status.
|
|
176
|
+
*/
|
|
177
|
+
readonly logs: {
|
|
178
|
+
list: (query?: ListQuery & {
|
|
179
|
+
since?: string;
|
|
180
|
+
until?: string;
|
|
181
|
+
status?: number;
|
|
182
|
+
status_class?: "2xx" | "4xx" | "5xx";
|
|
183
|
+
method?: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
184
|
+
route?: string;
|
|
185
|
+
error_code?: string;
|
|
186
|
+
api_key_id?: string;
|
|
187
|
+
}) => Promise<Page<RequestLogEntry>>;
|
|
188
|
+
get: (id: string) => Promise<RequestLogEntry>;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* M5.8 — mail sent TO your domains. Bodies come back as strings exactly as
|
|
192
|
+
* they arrived; nothing here renders or executes them.
|
|
193
|
+
*/
|
|
194
|
+
readonly receiving: {
|
|
195
|
+
list: (query?: ListQuery & {
|
|
196
|
+
to?: string;
|
|
197
|
+
from?: string;
|
|
198
|
+
since?: string;
|
|
199
|
+
until?: string;
|
|
200
|
+
}) => Promise<Page<ReceivedEmail>>;
|
|
201
|
+
get: (id: string) => Promise<ReceivedEmail>;
|
|
202
|
+
attachments: (id: string) => Promise<Page<ReceivedAttachment>>;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* M5.7 — the custom-event registry. Declaring an event's fields turns a
|
|
206
|
+
* mistyped payload from a silent 202 into a 400 that names the field.
|
|
207
|
+
*/
|
|
208
|
+
readonly events: {
|
|
209
|
+
ingest: (payload: {
|
|
210
|
+
name: string;
|
|
211
|
+
contact_id?: string;
|
|
212
|
+
data?: Record<string, unknown>;
|
|
213
|
+
}, options?: RequestOptions) => Promise<{
|
|
214
|
+
fired: number;
|
|
215
|
+
}>;
|
|
216
|
+
list: (query?: ListQuery) => Promise<Page<EventDefinition>>;
|
|
217
|
+
get: (id: string) => Promise<EventDefinition>;
|
|
218
|
+
update: (id: string, payload: {
|
|
219
|
+
description?: string | null;
|
|
220
|
+
schema?: Record<string, EventFieldType>;
|
|
221
|
+
strict?: boolean;
|
|
222
|
+
}, options?: RequestOptions) => Promise<EventDefinition>;
|
|
223
|
+
delete: (id: string, options?: RequestOptions) => Promise<Deleted>;
|
|
224
|
+
};
|
|
225
|
+
/** M5.6 — what an automation actually did, after it did it. */
|
|
226
|
+
readonly automations: {
|
|
227
|
+
create: (payload: {
|
|
228
|
+
name: string;
|
|
229
|
+
trigger: Record<string, unknown>;
|
|
230
|
+
steps: Record<string, unknown>[];
|
|
231
|
+
}, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
232
|
+
list: (query?: ListQuery) => Promise<Page<Record<string, unknown>>>;
|
|
233
|
+
get: (id: string) => Promise<Record<string, unknown>>;
|
|
234
|
+
update: (id: string, payload: Record<string, unknown>, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
235
|
+
enable: (id: string, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
236
|
+
disable: (id: string, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
237
|
+
versions: (id: string) => Promise<Page<Record<string, unknown>>>;
|
|
238
|
+
runs: (automationId: string, query?: ListQuery & {
|
|
239
|
+
status?: "running" | "succeeded" | "failed";
|
|
240
|
+
}) => Promise<Page<AutomationRun>>;
|
|
241
|
+
run: (automationId: string, runId: string) => Promise<AutomationRun>;
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* M5.29 — the rest of each group.
|
|
245
|
+
*
|
|
246
|
+
* M5.5 filled the verbs a Resend integration calls and left the groups
|
|
247
|
+
* half-built: `contacts` could update but not create, `templates` could
|
|
248
|
+
* duplicate but not publish. A client that answers four of a resource's six
|
|
249
|
+
* verbs sends the caller back to raw fetch for the other two, which is the
|
|
250
|
+
* same as having none.
|
|
251
|
+
*/
|
|
252
|
+
readonly contacts: {
|
|
253
|
+
create: (payload: {
|
|
254
|
+
email: string;
|
|
255
|
+
properties?: Record<string, unknown>;
|
|
256
|
+
}, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
257
|
+
list: (query?: ListQuery & {
|
|
258
|
+
email?: string;
|
|
259
|
+
}) => Promise<Page<Record<string, unknown>>>;
|
|
260
|
+
get: (id: string) => Promise<Record<string, unknown>>;
|
|
261
|
+
delete: (id: string, options?: RequestOptions) => Promise<Deleted>;
|
|
262
|
+
/** Edit by id. Properties merge; an explicit null removes one. */
|
|
263
|
+
update: (id: string, payload: {
|
|
264
|
+
email?: string;
|
|
265
|
+
status?: "active" | "unsubscribed";
|
|
266
|
+
properties?: Record<string, unknown>;
|
|
267
|
+
}, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
268
|
+
};
|
|
269
|
+
readonly broadcasts: {
|
|
270
|
+
create: (payload: Record<string, unknown>, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
271
|
+
list: (query?: ListQuery) => Promise<Page<Record<string, unknown>>>;
|
|
272
|
+
get: (id: string) => Promise<Record<string, unknown>>;
|
|
273
|
+
update: (id: string, payload: Record<string, unknown>, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
274
|
+
send: (id: string, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
275
|
+
/** Archive, not delete: a sent broadcast is history worth keeping (F14). */
|
|
276
|
+
archive: (id: string, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
277
|
+
messages: (id: string, query?: ListQuery) => Promise<Page<Record<string, unknown>>>;
|
|
278
|
+
/** Cancel a scheduled broadcast: it returns to draft, editable again. */
|
|
279
|
+
cancel: (id: string, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
280
|
+
};
|
|
281
|
+
readonly templates: {
|
|
282
|
+
create: (payload: {
|
|
283
|
+
name: string;
|
|
284
|
+
subject: string;
|
|
285
|
+
content: unknown;
|
|
286
|
+
variables?: unknown[];
|
|
287
|
+
}, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
288
|
+
list: (query?: ListQuery) => Promise<Page<Record<string, unknown>>>;
|
|
289
|
+
get: (id: string) => Promise<Record<string, unknown>>;
|
|
290
|
+
update: (id: string, payload: Record<string, unknown>, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
291
|
+
/** Snapshot the draft as an immutable version. Nothing already sent changes. */
|
|
292
|
+
publish: (id: string, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
293
|
+
render: (id: string, values?: Record<string, unknown>, versionNumber?: number) => Promise<{
|
|
294
|
+
rendered: string;
|
|
295
|
+
}>;
|
|
296
|
+
versions: (id: string) => Promise<Page<Record<string, unknown>>>;
|
|
297
|
+
/** Copy a template into a fresh editable draft, history not included. */
|
|
298
|
+
duplicate: (id: string, payload?: {
|
|
299
|
+
name?: string;
|
|
300
|
+
}, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
301
|
+
};
|
|
302
|
+
readonly suppressions: {
|
|
303
|
+
list: (query?: ListQuery) => Promise<Page<Record<string, unknown>>>;
|
|
304
|
+
add: (payload: {
|
|
305
|
+
email: string;
|
|
306
|
+
level?: "address" | "domain";
|
|
307
|
+
}, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
308
|
+
remove: (id: string, options?: RequestOptions) => Promise<Deleted>;
|
|
309
|
+
/** Up to 500 at a time. Each item succeeds or fails on its own. */
|
|
310
|
+
batchAdd: (emails: string[], level?: "address" | "domain", options?: RequestOptions) => Promise<{
|
|
311
|
+
data: SuppressionBatchItem[];
|
|
312
|
+
}>;
|
|
313
|
+
batchRemove: (emails: string[], options?: RequestOptions) => Promise<{
|
|
314
|
+
data: SuppressionBatchItem[];
|
|
315
|
+
}>;
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* F6 — segments are rule-based and evaluated live, so `members` is the
|
|
319
|
+
* current answer rather than a stored list that drifts.
|
|
320
|
+
*/
|
|
321
|
+
readonly segments: {
|
|
322
|
+
create: (payload: {
|
|
323
|
+
name: string;
|
|
324
|
+
rules?: Record<string, unknown>[];
|
|
325
|
+
}, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
326
|
+
list: (query?: ListQuery) => Promise<Page<Record<string, unknown>>>;
|
|
327
|
+
get: (id: string) => Promise<Record<string, unknown>>;
|
|
328
|
+
update: (id: string, payload: Record<string, unknown>, options?: RequestOptions) => Promise<Record<string, unknown>>;
|
|
329
|
+
delete: (id: string, options?: RequestOptions) => Promise<Deleted>;
|
|
330
|
+
members: (id: string) => Promise<Page<Record<string, unknown>>>;
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* M4.9 — this account's own history. `action` takes a family (`api_key`) or
|
|
334
|
+
* an exact name (`api_key.rotated`); `from`/`to` are ISO instants.
|
|
335
|
+
*/
|
|
336
|
+
readonly auditLog: {
|
|
337
|
+
list: (query?: ListQuery & {
|
|
338
|
+
actor?: string;
|
|
339
|
+
action?: string;
|
|
340
|
+
from?: string;
|
|
341
|
+
to?: string;
|
|
342
|
+
}) => Promise<Page<AuditEntry>>;
|
|
343
|
+
};
|
|
344
|
+
/**
|
|
345
|
+
* M4.8 — team, roles and invites. Three roles where Resend has two, and
|
|
346
|
+
* seats that are capped by plan and never billed per seat.
|
|
347
|
+
*/
|
|
348
|
+
readonly team: {
|
|
349
|
+
/** Your own role on this account, and what the plan allows. */
|
|
350
|
+
me: () => Promise<{
|
|
351
|
+
user_id: string | null;
|
|
352
|
+
email: string | null;
|
|
353
|
+
role: "owner" | "admin" | "viewer" | null;
|
|
354
|
+
seats: {
|
|
355
|
+
plan: string;
|
|
356
|
+
used: number;
|
|
357
|
+
limit: number;
|
|
358
|
+
billed_per_seat: false;
|
|
359
|
+
};
|
|
360
|
+
}>;
|
|
361
|
+
listMembers: (query?: ListQuery) => Promise<Page<TeamMember>>;
|
|
362
|
+
setRole: (id: string, role: "owner" | "admin" | "viewer", options?: RequestOptions) => Promise<TeamMember>;
|
|
363
|
+
removeMember: (id: string, options?: RequestOptions) => Promise<{
|
|
364
|
+
id: string;
|
|
365
|
+
removed: true;
|
|
366
|
+
}>;
|
|
367
|
+
listInvites: (query?: ListQuery) => Promise<Page<TeamInvite>>;
|
|
368
|
+
/** Membership starts when they accept, so this returns the pending invitation. */
|
|
369
|
+
invite: (payload: {
|
|
370
|
+
email: string;
|
|
371
|
+
role?: "owner" | "admin" | "viewer";
|
|
372
|
+
}, options?: RequestOptions) => Promise<TeamInvite>;
|
|
373
|
+
cancelInvite: (id: string, options?: RequestOptions) => Promise<{
|
|
374
|
+
id: string;
|
|
375
|
+
cancelled: true;
|
|
376
|
+
}>;
|
|
377
|
+
/** Needs a signed-in session as the invited address, not an API key. */
|
|
378
|
+
acceptInvite: (token: string, options?: RequestOptions) => Promise<{
|
|
379
|
+
account_id: string;
|
|
380
|
+
account_name: string;
|
|
381
|
+
role: "owner" | "admin" | "viewer";
|
|
382
|
+
member_id: string;
|
|
383
|
+
}>;
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* M5.4 — subscription topics. A topic is what `topic_id` on a send names,
|
|
387
|
+
* and what the one-click header on that send turns off.
|
|
388
|
+
*/
|
|
389
|
+
readonly topics: {
|
|
390
|
+
create: (payload: {
|
|
391
|
+
name: string;
|
|
392
|
+
description?: string;
|
|
393
|
+
default_subscribed?: boolean;
|
|
394
|
+
}, options?: RequestOptions) => Promise<Topic>;
|
|
395
|
+
list: (query?: ListQuery) => Promise<Page<Topic>>;
|
|
396
|
+
get: (id: string) => Promise<Topic>;
|
|
397
|
+
update: (id: string, payload: {
|
|
398
|
+
name?: string;
|
|
399
|
+
description?: string | null;
|
|
400
|
+
default_subscribed?: boolean;
|
|
401
|
+
}, options?: RequestOptions) => Promise<Topic>;
|
|
402
|
+
delete: (id: string, options?: RequestOptions) => Promise<Deleted>;
|
|
403
|
+
/** Every topic with this contact's standing on it. */
|
|
404
|
+
forContact: (contactId: string) => Promise<Page<ContactTopic>>;
|
|
405
|
+
/** Record answers. Absolute — nothing is inferred from what is left out. */
|
|
406
|
+
setForContact: (contactId: string, topics: {
|
|
407
|
+
topic_id: string;
|
|
408
|
+
subscribed: boolean;
|
|
409
|
+
}[], options?: RequestOptions) => Promise<Page<ContactTopic>>;
|
|
410
|
+
};
|
|
411
|
+
/** Public per-component health — the same document the status page renders. */
|
|
412
|
+
readonly status: () => Promise<ServiceStatus>;
|
|
413
|
+
readonly trust: {
|
|
414
|
+
/** What the platform currently thinks of this account, in a shape an agent can branch on. */
|
|
415
|
+
standing: () => Promise<TrustStanding>;
|
|
416
|
+
};
|
|
417
|
+
readonly billing: {
|
|
418
|
+
/**
|
|
419
|
+
* The plan this key's account runs under: tier, entitlements, subscription
|
|
420
|
+
* state, and what can be bought. Read-only by design — a key can learn its
|
|
421
|
+
* budget comes from Starter; only a signed-in human in the console can buy.
|
|
422
|
+
*/
|
|
423
|
+
plan: () => Promise<BillingPlan>;
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
export {};
|