@whatsapi.sh/sdk 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/LICENSE +21 -0
- package/README.md +149 -0
- package/dist/client.d.ts +35 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +169 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +40 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +42 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/contract.d.ts +318 -0
- package/dist/generated/contract.d.ts.map +1 -0
- package/dist/generated/contract.js +32 -0
- package/dist/generated/contract.js.map +1 -0
- package/dist/generated/operations.d.ts +240 -0
- package/dist/generated/operations.d.ts.map +1 -0
- package/dist/generated/operations.js +285 -0
- package/dist/generated/operations.js.map +1 -0
- package/dist/generated/params.d.ts +177 -0
- package/dist/generated/params.d.ts.map +1 -0
- package/dist/generated/params.js +7 -0
- package/dist/generated/params.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/webhooks.d.ts +28 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +73 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +47 -0
- package/src/client.ts +204 -0
- package/src/errors.ts +71 -0
- package/src/generated/contract.ts +402 -0
- package/src/generated/operations.ts +371 -0
- package/src/generated/params.ts +203 -0
- package/src/index.ts +11 -0
- package/src/webhooks.ts +96 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
/** Canonical error codes. The web client can switch on these / map them to i18n. */
|
|
2
|
+
export type ErrorCode = "VALIDATION_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "FORBIDDEN" | "NOT_FOUND" | "CONFLICT" | "PAYMENT_REQUIRED" | "RATE_LIMIT_EXCEEDED" | "QUOTA_EXCEEDED" | "NUMBER_NOT_CONNECTED" | "PAIRING_COOLDOWN" | "OTP_INVALID" | "GATEWAY_ERROR" | "GATEWAY_TIMEOUT" | "INTERNAL_ERROR" | "SERVICE_UNAVAILABLE";
|
|
3
|
+
export type PlanId = "free" | "starter" | "pro" | "scale";
|
|
4
|
+
/** A number's lifecycle: created (no session) → connected (session live) →
|
|
5
|
+
* disconnected (dropped) / banned (restriction signal — see docs/QUIRKS.md). */
|
|
6
|
+
export type NumberStatus = "pairing" | "connected" | "disconnected" | "banned";
|
|
7
|
+
/** A WhatsApp number (a paired session), server-projected — never carries the
|
|
8
|
+
* gateway instance id or token. */
|
|
9
|
+
export interface NumberDto {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
phone: string | null;
|
|
13
|
+
status: NumberStatus;
|
|
14
|
+
connectedAt: string | null;
|
|
15
|
+
historySync: boolean;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
}
|
|
18
|
+
/** Answer to POST /numbers/:id/pair. `state` tells the client what to render:
|
|
19
|
+
* "pairing" (show the QR/linking code, or poll again when both are absent —
|
|
20
|
+
* wuzapi can take ~5s to mint a QR after connect), "connected" (already live). */
|
|
21
|
+
export interface PairNumberDto {
|
|
22
|
+
mode: "qr" | "code";
|
|
23
|
+
state: "pairing" | "connected";
|
|
24
|
+
/** Base64 QR (mode qr, when ready). */
|
|
25
|
+
qrCode?: string;
|
|
26
|
+
/** XXXX-XXXX linking code (mode code). */
|
|
27
|
+
linkingCode?: string;
|
|
28
|
+
/** True when the QR is the cached one from an earlier generation. */
|
|
29
|
+
isCached: boolean;
|
|
30
|
+
/** Epoch ms of generation — the client resumes its countdown from this. */
|
|
31
|
+
generatedAt?: number;
|
|
32
|
+
/** Seconds until a NEW QR may be generated (0 when fresh). */
|
|
33
|
+
remainingCooldown: number;
|
|
34
|
+
}
|
|
35
|
+
/** POST /v1/numbers/{id}/unpair — the slot stays, the WhatsApp session is gone. */
|
|
36
|
+
export interface UnpairedNumberDto {
|
|
37
|
+
id: string;
|
|
38
|
+
status: "disconnected";
|
|
39
|
+
}
|
|
40
|
+
/** DELETE /v1/numbers/{id} — the slot itself is gone, and the plan's seat is free. */
|
|
41
|
+
export interface DeletedNumberDto {
|
|
42
|
+
id: string;
|
|
43
|
+
deleted: true;
|
|
44
|
+
}
|
|
45
|
+
/** A message WhatsApp accepted. `sent` is the only success state the send call
|
|
46
|
+
* can report — delivered/read arrive later on the `message.status` webhook. */
|
|
47
|
+
export interface MessageDto {
|
|
48
|
+
/** WhatsApp's message id — the same id the status webhooks carry. */
|
|
49
|
+
id: string;
|
|
50
|
+
/** E.164 recipient the message actually went to. */
|
|
51
|
+
to: string;
|
|
52
|
+
/** Id of the number that sent it (useful when the account has several). */
|
|
53
|
+
from: string;
|
|
54
|
+
status: "sent";
|
|
55
|
+
timestamp: string;
|
|
56
|
+
/** Messages left in this month's PLAN quota after this send — so a client can
|
|
57
|
+
* show a meter without a second call. Hits 0 while sends keep working if the
|
|
58
|
+
* account has credits: the two pools are reported separately on purpose. */
|
|
59
|
+
quotaRemaining: number;
|
|
60
|
+
/** Purchased messages left (packs never expire). Sends spill here once
|
|
61
|
+
* `quotaRemaining` is 0, so a client that stops at `quotaRemaining === 0`
|
|
62
|
+
* and ignores this one stops earlier than it had to. */
|
|
63
|
+
creditRemaining: number;
|
|
64
|
+
}
|
|
65
|
+
/** One recipient's outcome inside a batch. `skipped` is not a failure of its
|
|
66
|
+
* own: something systemic (the session died, the meter refused) stopped the
|
|
67
|
+
* run, and these are the recipients never attempted — send them again once the
|
|
68
|
+
* reason on the batch is cleared. */
|
|
69
|
+
export interface BatchResultDto {
|
|
70
|
+
to: string;
|
|
71
|
+
status: "sent" | "failed" | "skipped";
|
|
72
|
+
/** Present on `sent`. */
|
|
73
|
+
id?: string;
|
|
74
|
+
/** Present on `failed` and `skipped` — the same code the single-send
|
|
75
|
+
* endpoint would have answered with. */
|
|
76
|
+
error?: {
|
|
77
|
+
code: ErrorCode;
|
|
78
|
+
message: string;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** POST /v1/messages/batch. Always a 200 with per-recipient outcomes: a batch
|
|
82
|
+
* where 24 of 25 landed is neither a success nor a failure, and collapsing it
|
|
83
|
+
* into one status code would throw away the only part that matters. */
|
|
84
|
+
export interface BatchMessageDto {
|
|
85
|
+
sent: number;
|
|
86
|
+
failed: number;
|
|
87
|
+
skipped: number;
|
|
88
|
+
/** Why the run stopped early, when it did. */
|
|
89
|
+
stoppedBecause?: {
|
|
90
|
+
code: ErrorCode;
|
|
91
|
+
message: string;
|
|
92
|
+
};
|
|
93
|
+
results: BatchResultDto[];
|
|
94
|
+
/** Messages left in this month's plan quota after the batch. */
|
|
95
|
+
quotaRemaining: number;
|
|
96
|
+
/** Purchased messages left after the batch — see `MessageDto.creditRemaining`. */
|
|
97
|
+
creditRemaining: number;
|
|
98
|
+
}
|
|
99
|
+
/** POST /v1/chats/{phone}/typing. Free, so there is no quota to report — it
|
|
100
|
+
* echoes what it did, and `to` is the address the indicator went to. */
|
|
101
|
+
export interface TypingDto {
|
|
102
|
+
to: string;
|
|
103
|
+
state: "composing" | "paused";
|
|
104
|
+
}
|
|
105
|
+
/** POST /v1/chats/{phone}/read — the ids that now carry blue ticks. */
|
|
106
|
+
export interface MarkReadDto {
|
|
107
|
+
to: string;
|
|
108
|
+
messageIds: string[];
|
|
109
|
+
}
|
|
110
|
+
/** POST /v1/otp — the code is returned to the CALLER (that's the whole point of
|
|
111
|
+
* the endpoint: send it and hand it back so the app can verify however it
|
|
112
|
+
* likes). Only its hash is stored. */
|
|
113
|
+
export interface OtpDto {
|
|
114
|
+
code: string;
|
|
115
|
+
expiresAt: string;
|
|
116
|
+
to: string;
|
|
117
|
+
/** The WhatsApp message that carried the code. */
|
|
118
|
+
messageId: string;
|
|
119
|
+
}
|
|
120
|
+
/** POST /v1/otp/check succeeds or throws OTP_INVALID — never `{ verified: false }`.
|
|
121
|
+
* A verification primitive that answers 200 to a wrong code is one forgotten
|
|
122
|
+
* `if` away from letting anyone in. */
|
|
123
|
+
export interface OtpCheckDto {
|
|
124
|
+
verified: true;
|
|
125
|
+
to: string;
|
|
126
|
+
}
|
|
127
|
+
/** GET /v1/numbers/check/{phone} — is this phone on WhatsApp? */
|
|
128
|
+
export interface NumberCheckDto {
|
|
129
|
+
/** E.164 of the variant WhatsApp actually matched: a Brazilian mobile may be
|
|
130
|
+
* registered with or without the 9th digit, and we check both. */
|
|
131
|
+
e164: string;
|
|
132
|
+
hasWhatsApp: boolean;
|
|
133
|
+
/** The address to send to. Null when the number isn't on WhatsApp. */
|
|
134
|
+
jid: string | null;
|
|
135
|
+
avatarUrl: string | null;
|
|
136
|
+
/** False when WhatsApp couldn't be reached and `hasWhatsApp` is an optimistic
|
|
137
|
+
* assumption — a check outage must never block sends to real recipients
|
|
138
|
+
* (docs/QUIRKS.md — number-check fail-open). */
|
|
139
|
+
verified: boolean;
|
|
140
|
+
}
|
|
141
|
+
/** GET /v1/usage — this month's spend against the plan, plus the per-key split. */
|
|
142
|
+
export interface UsageDto {
|
|
143
|
+
plan: PlanId;
|
|
144
|
+
/** "2026-08" (America/Sao_Paulo). */
|
|
145
|
+
month: string;
|
|
146
|
+
monthUsed: number;
|
|
147
|
+
monthLimit: number;
|
|
148
|
+
dayUsed: number;
|
|
149
|
+
dayLimit: number;
|
|
150
|
+
sendsPerMinute: number;
|
|
151
|
+
creditBalance: number;
|
|
152
|
+
/** When the monthly counter rolls over. */
|
|
153
|
+
resetAt: string;
|
|
154
|
+
/** Per-key breakdown, newest first. Revoked keys stay listed — their usage
|
|
155
|
+
* still counts toward the account total, and a month's spend that vanished
|
|
156
|
+
* when a key was rotated would look like a billing error. `revoked` is what
|
|
157
|
+
* tells the two apart. */
|
|
158
|
+
keys: {
|
|
159
|
+
id: string;
|
|
160
|
+
name: string;
|
|
161
|
+
prefix: string;
|
|
162
|
+
used: number;
|
|
163
|
+
revoked: boolean;
|
|
164
|
+
}[];
|
|
165
|
+
}
|
|
166
|
+
/** Every event an endpoint can subscribe to.
|
|
167
|
+
*
|
|
168
|
+
* Deliberately FIVE, normalized out of wuzapi's ~50 provider events: an
|
|
169
|
+
* inbound message, a status change on one we sent, and the three moments a
|
|
170
|
+
* number's session changes hands. Everything else (presence, chat presence,
|
|
171
|
+
* history sync, group metadata) is either noise to an API customer or
|
|
172
|
+
* privacy-sensitive, and is dropped at the ingestion boundary. */
|
|
173
|
+
export declare const WEBHOOK_EVENT_TYPES: readonly ["message.created", "message.status", "number.connected", "number.disconnected", "number.logged_out"];
|
|
174
|
+
export type WebhookEventType = (typeof WEBHOOK_EVENT_TYPES)[number];
|
|
175
|
+
/** The synthetic event `POST /v1/webhooks/test` fires. Not subscribable — it is
|
|
176
|
+
* always delivered, because its whole job is proving the wiring works. */
|
|
177
|
+
export declare const WEBHOOK_TEST_EVENT = "ping";
|
|
178
|
+
export declare const WEBHOOK_DELIVERY_STATUSES: readonly ["pending", "delivered", "failed"];
|
|
179
|
+
export type WebhookDeliveryStatus = (typeof WEBHOOK_DELIVERY_STATUSES)[number];
|
|
180
|
+
/** The body of every delivery. `id` is also the `x-whatsapi-delivery` header:
|
|
181
|
+
* retries reuse it, so a receiver that has seen an id can safely drop the
|
|
182
|
+
* repeat. */
|
|
183
|
+
export interface WebhookEnvelope<T = unknown> {
|
|
184
|
+
id: string;
|
|
185
|
+
type: WebhookEventType | typeof WEBHOOK_TEST_EVENT;
|
|
186
|
+
/** ISO 8601, when we built the event — not when we sent it. */
|
|
187
|
+
timestamp: string;
|
|
188
|
+
data: T;
|
|
189
|
+
}
|
|
190
|
+
/** The sending/receiving number, on every event. Enough to route without a
|
|
191
|
+
* lookup, never the gateway instance or token. */
|
|
192
|
+
export interface WebhookNumberRef {
|
|
193
|
+
id: string;
|
|
194
|
+
name: string;
|
|
195
|
+
phone: string | null;
|
|
196
|
+
}
|
|
197
|
+
export type InboundMessageType = "text" | "image" | "video" | "audio" | "document" | "location" | "contact" | "sticker" | "reaction" | "poll" | "other";
|
|
198
|
+
/** `message.created`. Media arrives as metadata only: the gateway runs with
|
|
199
|
+
* `-skipmedia`, so the bytes stay on WhatsApp's servers until asked for. */
|
|
200
|
+
export interface MessageCreatedEvent {
|
|
201
|
+
number: WebhookNumberRef;
|
|
202
|
+
message: {
|
|
203
|
+
id: string;
|
|
204
|
+
/** The conversation: a phone number for a 1:1 chat, a group JID for a group. */
|
|
205
|
+
chat: string;
|
|
206
|
+
/** Who wrote it — the same as `chat` outside groups. */
|
|
207
|
+
from: string;
|
|
208
|
+
/** True when the message was sent BY this number (from the linked phone,
|
|
209
|
+
* or by an earlier API call) rather than to it. */
|
|
210
|
+
fromMe: boolean;
|
|
211
|
+
isGroup: boolean;
|
|
212
|
+
/** The sender's WhatsApp display name, when they publish one. */
|
|
213
|
+
pushName?: string;
|
|
214
|
+
timestamp: string;
|
|
215
|
+
type: InboundMessageType;
|
|
216
|
+
/** Text body, for text messages. */
|
|
217
|
+
text?: string;
|
|
218
|
+
/** Caption, for media that carries one. */
|
|
219
|
+
caption?: string;
|
|
220
|
+
media?: {
|
|
221
|
+
mimeType?: string;
|
|
222
|
+
fileName?: string;
|
|
223
|
+
/** Audio/video length in seconds. */
|
|
224
|
+
seconds?: number;
|
|
225
|
+
bytes?: number;
|
|
226
|
+
/** True for a voice note rather than an audio file. */
|
|
227
|
+
voice?: boolean;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
/** `message.status`. WhatsApp acks in batches, so one event can settle several
|
|
232
|
+
* message ids at once. */
|
|
233
|
+
export interface MessageStatusEvent {
|
|
234
|
+
number: WebhookNumberRef;
|
|
235
|
+
/** Ids as returned by the send call. */
|
|
236
|
+
messageIds: string[];
|
|
237
|
+
/** The chat the acks came from. */
|
|
238
|
+
chat: string;
|
|
239
|
+
status: "delivered" | "read" | "played";
|
|
240
|
+
timestamp: string;
|
|
241
|
+
}
|
|
242
|
+
/** `number.connected` · `number.disconnected` · `number.logged_out`. */
|
|
243
|
+
export interface NumberStatusEvent {
|
|
244
|
+
number: WebhookNumberRef;
|
|
245
|
+
/** Why the session ended, when the provider said — "server", "logged_out",
|
|
246
|
+
* "connection_failure", "ban". Absent on connect. */
|
|
247
|
+
reason?: string;
|
|
248
|
+
}
|
|
249
|
+
/** `ping` — what the test-fire delivers. Not subscribable; see WEBHOOK_TEST_EVENT. */
|
|
250
|
+
export interface PingEvent {
|
|
251
|
+
message: string;
|
|
252
|
+
}
|
|
253
|
+
/** Which payload rides with which event. The map is what makes `WebhookEvent`
|
|
254
|
+
* below a discriminated union — narrow on `type` and `data` narrows with it —
|
|
255
|
+
* and it is load-bearing on the producing side too: the emitter's input is
|
|
256
|
+
* typed from it, so an event can never be published with the wrong shape. */
|
|
257
|
+
export interface WebhookPayloads {
|
|
258
|
+
"message.created": MessageCreatedEvent;
|
|
259
|
+
"message.status": MessageStatusEvent;
|
|
260
|
+
"number.connected": NumberStatusEvent;
|
|
261
|
+
"number.disconnected": NumberStatusEvent;
|
|
262
|
+
"number.logged_out": NumberStatusEvent;
|
|
263
|
+
ping: PingEvent;
|
|
264
|
+
}
|
|
265
|
+
/** Every delivery, as the receiver sees it:
|
|
266
|
+
*
|
|
267
|
+
* if (event.type === "message.created") event.data.message.text
|
|
268
|
+
*/
|
|
269
|
+
export type WebhookEvent = {
|
|
270
|
+
[K in keyof WebhookPayloads]: WebhookEnvelope<WebhookPayloads[K]> & {
|
|
271
|
+
type: K;
|
|
272
|
+
};
|
|
273
|
+
}[keyof WebhookPayloads];
|
|
274
|
+
export interface WebhookEndpointDto {
|
|
275
|
+
url: string;
|
|
276
|
+
events: WebhookEventType[];
|
|
277
|
+
enabled: boolean;
|
|
278
|
+
/** Set when WE turned the endpoint off: "failures" after a long run of dead
|
|
279
|
+
* deliveries. null while it is healthy. */
|
|
280
|
+
disabledReason: string | null;
|
|
281
|
+
/** Failed deliveries in a row. Resets on the first success. */
|
|
282
|
+
consecutiveFailures: number;
|
|
283
|
+
createdAt: string;
|
|
284
|
+
updatedAt: string;
|
|
285
|
+
}
|
|
286
|
+
/** The answer to `PUT /v1/webhooks`. `secret` is present ONLY when one was just
|
|
287
|
+
* minted (first registration, or `rotateSecret: true`) — it is never
|
|
288
|
+
* retrievable afterwards, exactly like an API key. */
|
|
289
|
+
export interface SavedWebhookDto {
|
|
290
|
+
secret: string | null;
|
|
291
|
+
record: WebhookEndpointDto;
|
|
292
|
+
}
|
|
293
|
+
export interface WebhookDeliveryDto {
|
|
294
|
+
/** Also the `x-whatsapi-delivery` header of the POST. */
|
|
295
|
+
id: string;
|
|
296
|
+
event: string;
|
|
297
|
+
status: WebhookDeliveryStatus;
|
|
298
|
+
attempts: number;
|
|
299
|
+
/** The HTTP status the endpoint answered, when it answered at all. */
|
|
300
|
+
responseStatus: number | null;
|
|
301
|
+
error: string | null;
|
|
302
|
+
createdAt: string;
|
|
303
|
+
deliveredAt: string | null;
|
|
304
|
+
}
|
|
305
|
+
/** The synchronous outcome of `POST /v1/webhooks/test`. */
|
|
306
|
+
export interface WebhookTestResultDto {
|
|
307
|
+
ok: boolean;
|
|
308
|
+
status: number | null;
|
|
309
|
+
error: string | null;
|
|
310
|
+
/** The delivery it was recorded as — it shows up in the delivery list too. */
|
|
311
|
+
deliveryId: string;
|
|
312
|
+
}
|
|
313
|
+
/** DELETE /v1/webhooks. `false` when there was nothing registered to delete —
|
|
314
|
+
* the end state is the same either way, so it is not an error. */
|
|
315
|
+
export interface DeletedWebhookDto {
|
|
316
|
+
deleted: boolean;
|
|
317
|
+
}
|
|
318
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/generated/contract.ts"],"names":[],"mappings":"AAOA,oFAAoF;AACpF,MAAM,MAAM,SAAS,GACf,kBAAkB,GAClB,cAAc,GACd,eAAe,GACf,WAAW,GACX,WAAW,GACX,UAAU,GAIV,kBAAkB,GAGlB,qBAAqB,GACrB,gBAAgB,GAGhB,sBAAsB,GAItB,kBAAkB,GAClB,a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AC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;uDAEuD;AACvD,MAAM,WAAW,eAAe;IAC5B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,kBAAkB,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IAC/B,yDAAyD;IACzD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,qBAAqB,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,2DAA2D;AAC3D,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,8EAA8E;IAC9E,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;mEACmE;AACnE,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// GENERATED FILE — do not edit. Run `bun run sdk:gen`.
|
|
2
|
+
// Source: packages/shared/src/http/index.ts, packages/shared/src/billing/catalog.ts, packages/shared/src/dto/index.ts, packages/shared/src/webhooks/index.ts
|
|
3
|
+
//
|
|
4
|
+
// The shapes the API speaks, lifted from the server's own contract.
|
|
5
|
+
// ── from packages/shared/src/webhooks/index.ts ───────────────────────
|
|
6
|
+
/** Every event an endpoint can subscribe to.
|
|
7
|
+
*
|
|
8
|
+
* Deliberately FIVE, normalized out of wuzapi's ~50 provider events: an
|
|
9
|
+
* inbound message, a status change on one we sent, and the three moments a
|
|
10
|
+
* number's session changes hands. Everything else (presence, chat presence,
|
|
11
|
+
* history sync, group metadata) is either noise to an API customer or
|
|
12
|
+
* privacy-sensitive, and is dropped at the ingestion boundary. */
|
|
13
|
+
export const WEBHOOK_EVENT_TYPES = [
|
|
14
|
+
/** Someone messaged one of your numbers. The payload carries the text (or
|
|
15
|
+
* the media's metadata), never the media bytes. */
|
|
16
|
+
"message.created",
|
|
17
|
+
/** WhatsApp reported delivery/read/played for messages you sent. */
|
|
18
|
+
"message.status",
|
|
19
|
+
/** A number's WhatsApp session came up and can send again. */
|
|
20
|
+
"number.connected",
|
|
21
|
+
/** A number's session dropped and did not come back on its own — it needs
|
|
22
|
+
* re-pairing. */
|
|
23
|
+
"number.disconnected",
|
|
24
|
+
/** WhatsApp logged the number out or restricted it. Sends will fail until
|
|
25
|
+
* it is paired again; see the 24h restriction window in the docs. */
|
|
26
|
+
"number.logged_out",
|
|
27
|
+
];
|
|
28
|
+
/** The synthetic event `POST /v1/webhooks/test` fires. Not subscribable — it is
|
|
29
|
+
* always delivered, because its whole job is proving the wiring works. */
|
|
30
|
+
export const WEBHOOK_TEST_EVENT = "ping";
|
|
31
|
+
export const WEBHOOK_DELIVERY_STATUSES = ["pending", "delivered", "failed"];
|
|
32
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/generated/contract.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,6JAA6J;AAC7J,EAAE;AACF,oEAAoE;AA4MpE,wEAAwE;AAExE;;;;;;mEAMmE;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B;wDACoD;IACpD,iBAAiB;IACjB,oEAAoE;IACpE,gBAAgB;IAChB,8DAA8D;IAC9D,kBAAkB;IAClB;sBACkB;IAClB,qBAAqB;IACrB;0EACsE;IACtE,mBAAmB;CACb,CAAC;AAIX;2EAC2E;AAC3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAEzC,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAU,CAAC"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import type { RequestSpec } from "../client.ts";
|
|
2
|
+
import type { BatchMessageDto, DeletedNumberDto, DeletedWebhookDto, MarkReadDto, MessageDto, NumberCheckDto, NumberDto, OtpCheckDto, OtpDto, PairNumberDto, SavedWebhookDto, TypingDto, UnpairedNumberDto, UsageDto, WebhookDeliveryDto, WebhookEndpointDto, WebhookTestResultDto } from "./contract.ts";
|
|
3
|
+
import type { CheckNumberParams, CheckOtpParams, CreateNumberParams, DeleteNumberParams, ListWebhookDeliveriesParams, MarkReadParams, NumberStatusParams, PairNumberParams, SendBatchParams, SendContactParams, SendLocationParams, SendMediaParams, SendMessageParams, SendOtpParams, SetWebhookParams, TypingParams, UnpairNumberParams } from "./params.ts";
|
|
4
|
+
/** The version this client reports in `x-whatsapi-client`. */
|
|
5
|
+
export declare const SDK_VERSION = "0.1.0";
|
|
6
|
+
/** The hosted API. */
|
|
7
|
+
export declare const DEFAULT_BASE_URL = "https://api.whatsapi.sh/v1";
|
|
8
|
+
export declare abstract class GeneratedOperations {
|
|
9
|
+
protected abstract request<T>(spec: RequestSpec, params?: object): Promise<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Send a WhatsApp message
|
|
12
|
+
*
|
|
13
|
+
* Send a text message to a phone number over WhatsApp. Counts as one message against the
|
|
14
|
+
* account's monthly quota. The reply carries WhatsApp's message id — delivery and read
|
|
15
|
+
* receipts arrive later on the account's webhook, not here.
|
|
16
|
+
*
|
|
17
|
+
* `POST /messages`
|
|
18
|
+
*/
|
|
19
|
+
sendMessage(params: SendMessageParams): Promise<MessageDto>;
|
|
20
|
+
/**
|
|
21
|
+
* Send a photo, video, voice note or file
|
|
22
|
+
*
|
|
23
|
+
* Send media over WhatsApp from a public URL or base64 data. `type` picks the bubble the
|
|
24
|
+
* recipient sees: `image` and `video` support a caption, `document` is a file attachment named
|
|
25
|
+
* by `fileName`, and `audio` becomes a voice note when the file is ogg/opus — any other audio
|
|
26
|
+
* format is sent as a playable attachment instead, because WhatsApp will not render a voice
|
|
27
|
+
* note that is not opus. Files are capped at 16MB, and `url` beats `base64` for anything
|
|
28
|
+
* sizeable. Counts as one message.
|
|
29
|
+
*
|
|
30
|
+
* `POST /messages/media`
|
|
31
|
+
*/
|
|
32
|
+
sendMedia(params: SendMediaParams): Promise<MessageDto>;
|
|
33
|
+
/**
|
|
34
|
+
* Send one text to many recipients
|
|
35
|
+
*
|
|
36
|
+
* Send the same text to up to 25 recipients in one call — one message, and one message's worth
|
|
37
|
+
* of quota, per recipient. The answer reports each recipient separately: a batch where some
|
|
38
|
+
* land and some do not is the normal case, not an error. If something systemic stops the run
|
|
39
|
+
* (the number drops its session, the quota or rate limit refuses) the remaining recipients
|
|
40
|
+
* come back as `skipped` rather than being attempted, so they can be sent again once that is
|
|
41
|
+
* cleared. Sends inside a batch leave back-to-back, so keep lists small and space calls
|
|
42
|
+
* minutes apart — pacing keeps your number off WhatsApp's spam radar (see the avoiding-bans
|
|
43
|
+
* guide). Paid plans only.
|
|
44
|
+
*
|
|
45
|
+
* `POST /messages/batch`
|
|
46
|
+
*/
|
|
47
|
+
sendBatch(params: SendBatchParams): Promise<BatchMessageDto>;
|
|
48
|
+
/**
|
|
49
|
+
* Send a location pin
|
|
50
|
+
*
|
|
51
|
+
* Send a map pin over WhatsApp. Counts as one message.
|
|
52
|
+
*
|
|
53
|
+
* `POST /messages/location`
|
|
54
|
+
*/
|
|
55
|
+
sendLocation(params: SendLocationParams): Promise<MessageDto>;
|
|
56
|
+
/**
|
|
57
|
+
* Send a contact card
|
|
58
|
+
*
|
|
59
|
+
* Send a contact card (vCard) over WhatsApp, so the recipient can save the number with one
|
|
60
|
+
* tap. Counts as one message.
|
|
61
|
+
*
|
|
62
|
+
* `POST /messages/contact`
|
|
63
|
+
*/
|
|
64
|
+
sendContact(params: SendContactParams): Promise<MessageDto>;
|
|
65
|
+
/**
|
|
66
|
+
* Send a verification code
|
|
67
|
+
*
|
|
68
|
+
* Generate a 6-digit code, send it over WhatsApp and return it. Returning the code is
|
|
69
|
+
* deliberate: verify it yourself, or hand it back to check_otp and keep nothing. Codes expire
|
|
70
|
+
* in 5 minutes by default and one number can only be sent a new code once a minute. Counts as
|
|
71
|
+
* one message.
|
|
72
|
+
*
|
|
73
|
+
* `POST /otp`
|
|
74
|
+
*/
|
|
75
|
+
sendOtp(params: SendOtpParams): Promise<OtpDto>;
|
|
76
|
+
/**
|
|
77
|
+
* Check a verification code
|
|
78
|
+
*
|
|
79
|
+
* Verify a code sent with send_otp and consume it, so it can never be used twice. A wrong or
|
|
80
|
+
* expired code answers 400 OTP_INVALID — deliberately an error, not a `verified: false`, so a
|
|
81
|
+
* missing check at the caller can never read as success. Five wrong guesses kill the code.
|
|
82
|
+
* Free.
|
|
83
|
+
*
|
|
84
|
+
* `POST /otp/check`
|
|
85
|
+
*/
|
|
86
|
+
checkOtp(params: CheckOtpParams): Promise<OtpCheckDto>;
|
|
87
|
+
/**
|
|
88
|
+
* List your WhatsApp numbers
|
|
89
|
+
*
|
|
90
|
+
* Every WhatsApp number on the account with its connection status. Start here when you do not
|
|
91
|
+
* know which number to send from, or to check whether one needs re-pairing. Free.
|
|
92
|
+
*
|
|
93
|
+
* `GET /numbers`
|
|
94
|
+
*/
|
|
95
|
+
listNumbers(): Promise<NumberDto[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Add a WhatsApp number
|
|
98
|
+
*
|
|
99
|
+
* Create a new WhatsApp number slot on the account and return it. This is step one of two: the
|
|
100
|
+
* slot starts `disconnected` and cannot send until pair_number links a real WhatsApp account
|
|
101
|
+
* to it. How many can exist at once is what the plan sells. Free.
|
|
102
|
+
*
|
|
103
|
+
* `POST /numbers`
|
|
104
|
+
*/
|
|
105
|
+
createNumber(params: CreateNumberParams): Promise<NumberDto>;
|
|
106
|
+
/**
|
|
107
|
+
* Check whether a phone is on WhatsApp
|
|
108
|
+
*
|
|
109
|
+
* Ask WhatsApp whether a phone number has an account, and get its profile picture when it
|
|
110
|
+
* does. Brazilian mobiles are checked with and without the extra 9 and the answer reports the
|
|
111
|
+
* form that actually matched. If WhatsApp cannot be reached the answer assumes yes and sets
|
|
112
|
+
* `verified: false` — an outage must not block sends to real people. Free.
|
|
113
|
+
*
|
|
114
|
+
* `GET /numbers/check/:phone`
|
|
115
|
+
*/
|
|
116
|
+
checkNumber(params: CheckNumberParams): Promise<NumberCheckDto>;
|
|
117
|
+
/**
|
|
118
|
+
* Get one number's status
|
|
119
|
+
*
|
|
120
|
+
* One number's current state: `connected` (ready to send), `pairing` (waiting for a scan),
|
|
121
|
+
* `disconnected` (session dropped — pair it again) or `banned` (WhatsApp restricted it; wait
|
|
122
|
+
* out the 24h window before reconnecting). Free.
|
|
123
|
+
*
|
|
124
|
+
* `GET /numbers/:id`
|
|
125
|
+
*/
|
|
126
|
+
numberStatus(params: NumberStatusParams): Promise<NumberDto>;
|
|
127
|
+
/**
|
|
128
|
+
* Pair a number with WhatsApp
|
|
129
|
+
*
|
|
130
|
+
* Start (or resume) linking a WhatsApp account to one of your numbers. `qr` returns a QR code
|
|
131
|
+
* to scan from WhatsApp → Linked devices; `code` returns an 8-character linking code to type
|
|
132
|
+
* there instead, and needs the phone number being linked. A QR lives ~90 seconds and a new one
|
|
133
|
+
* can only be minted every few minutes, so call again to poll: `state: "pairing"` with no code
|
|
134
|
+
* yet simply means it is still being minted. Free.
|
|
135
|
+
*
|
|
136
|
+
* `POST /numbers/:id/pair`
|
|
137
|
+
*/
|
|
138
|
+
pairNumber(params: PairNumberParams): Promise<PairNumberDto>;
|
|
139
|
+
/**
|
|
140
|
+
* Disconnect a number from WhatsApp
|
|
141
|
+
*
|
|
142
|
+
* Log the linked WhatsApp account out of this number, keeping the number itself. Use it to
|
|
143
|
+
* link a different phone: a connected number cannot be re-paired until it is unpaired. Free.
|
|
144
|
+
*
|
|
145
|
+
* `POST /numbers/:id/unpair`
|
|
146
|
+
*/
|
|
147
|
+
unpairNumber(params: UnpairNumberParams): Promise<UnpairedNumberDto>;
|
|
148
|
+
/**
|
|
149
|
+
* Delete a number
|
|
150
|
+
*
|
|
151
|
+
* Remove a number from the account for good, logging its WhatsApp session out on the way. This
|
|
152
|
+
* frees a slot against the plan's limit. Messages already sent are unaffected, and the usage
|
|
153
|
+
* they cost stays on the bill. Free, and not reversible.
|
|
154
|
+
*
|
|
155
|
+
* `DELETE /numbers/:id`
|
|
156
|
+
*/
|
|
157
|
+
deleteNumber(params: DeleteNumberParams): Promise<DeletedNumberDto>;
|
|
158
|
+
/**
|
|
159
|
+
* Show the typing indicator
|
|
160
|
+
*
|
|
161
|
+
* Show (or clear) the “typing…” indicator in a chat. Free — it is not a message. WhatsApp
|
|
162
|
+
* clears it on its own after a few seconds, so call it again for a long reply.
|
|
163
|
+
*
|
|
164
|
+
* `POST /chats/:phone/typing`
|
|
165
|
+
*/
|
|
166
|
+
typing(params: TypingParams): Promise<TypingDto>;
|
|
167
|
+
/**
|
|
168
|
+
* Mark messages as read
|
|
169
|
+
*
|
|
170
|
+
* Put blue ticks on messages your number received in a chat. Free. Message ids come from the
|
|
171
|
+
* inbound webhook.
|
|
172
|
+
*
|
|
173
|
+
* `POST /chats/:phone/read`
|
|
174
|
+
*/
|
|
175
|
+
markRead(params: MarkReadParams): Promise<MarkReadDto>;
|
|
176
|
+
/**
|
|
177
|
+
* Get your webhook endpoint
|
|
178
|
+
*
|
|
179
|
+
* The endpoint events are being POSTed to, which ones it is subscribed to, and whether it is
|
|
180
|
+
* still healthy. `null` when none is registered. `disabledReason: "failures"` means we stopped
|
|
181
|
+
* delivering after a long run of dead attempts — fix the endpoint and set it again (or fire a
|
|
182
|
+
* test) to switch it back on. Free.
|
|
183
|
+
*
|
|
184
|
+
* `GET /webhooks`
|
|
185
|
+
*/
|
|
186
|
+
getWebhook(): Promise<WebhookEndpointDto | null>;
|
|
187
|
+
/**
|
|
188
|
+
* Register your webhook endpoint
|
|
189
|
+
*
|
|
190
|
+
* Point whatsapi.sh at an https URL and start receiving events there. The answer carries the
|
|
191
|
+
* signing secret ONCE, on first registration: keep it — every delivery is signed with it in
|
|
192
|
+
* the `x-whatsapi-signature` header (`t=<unix>,v1=<hmac-sha256 of "<t>.<body>">`), and that
|
|
193
|
+
* signature is how you know a request is really from us. Calling this again updates the URL or
|
|
194
|
+
* the subscription and keeps the same secret unless you ask to rotate it. Saving also
|
|
195
|
+
* re-enables an endpoint we had disabled. Free.
|
|
196
|
+
*
|
|
197
|
+
* `PUT /webhooks`
|
|
198
|
+
*/
|
|
199
|
+
setWebhook(params: SetWebhookParams): Promise<SavedWebhookDto>;
|
|
200
|
+
/**
|
|
201
|
+
* Fire a test event at your endpoint
|
|
202
|
+
*
|
|
203
|
+
* Send a `ping` event to your registered endpoint right now and wait for the answer, so you
|
|
204
|
+
* can verify the URL and your signature check without waiting for a real message. The result
|
|
205
|
+
* is the actual outcome: `ok: false` carries the HTTP status your server answered, or why we
|
|
206
|
+
* could not reach it. A successful ping also revives an endpoint we had auto-disabled. Free.
|
|
207
|
+
*
|
|
208
|
+
* `POST /webhooks/test`
|
|
209
|
+
*/
|
|
210
|
+
testWebhook(): Promise<WebhookTestResultDto>;
|
|
211
|
+
/**
|
|
212
|
+
* Recent webhook deliveries
|
|
213
|
+
*
|
|
214
|
+
* The last deliveries we attempted, newest first — what we sent, what your endpoint answered,
|
|
215
|
+
* and how many attempts it took. This is the answer to “the event never arrived”. Deliveries
|
|
216
|
+
* are kept for a week. Free.
|
|
217
|
+
*
|
|
218
|
+
* `GET /webhooks/deliveries`
|
|
219
|
+
*/
|
|
220
|
+
listWebhookDeliveries(params?: ListWebhookDeliveriesParams): Promise<WebhookDeliveryDto[]>;
|
|
221
|
+
/**
|
|
222
|
+
* Remove your webhook endpoint
|
|
223
|
+
*
|
|
224
|
+
* Stop sending events and forget the endpoint, its secret and its delivery history.
|
|
225
|
+
* Registering again mints a new secret. Free.
|
|
226
|
+
*
|
|
227
|
+
* `DELETE /webhooks`
|
|
228
|
+
*/
|
|
229
|
+
deleteWebhook(): Promise<DeletedWebhookDto>;
|
|
230
|
+
/**
|
|
231
|
+
* Check quota and usage
|
|
232
|
+
*
|
|
233
|
+
* Messages sent this month against the plan quota, today against the daily fair-use cap, the
|
|
234
|
+
* leftover credit balance, and the per-key breakdown. Read this before a bulk send. Free.
|
|
235
|
+
*
|
|
236
|
+
* `GET /usage`
|
|
237
|
+
*/
|
|
238
|
+
getUsage(): Promise<UsageDto>;
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/generated/operations.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EACR,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,cAAc,EACd,SAAS,EACT,WAAW,EACX,MAAM,EACN,aAAa,EACb,eAAe,EACf,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACvB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACR,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,EAC3B,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EACrB,MAAM,aAAa,CAAC;AAErB,8DAA8D;AAC9D,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,sBAAsB;AACtB,eAAO,MAAM,gBAAgB,+BAA+B,CAAC;AAE7D,8BAAsB,mBAAmB;IACrC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