@messagebird/sdk 0.29.0 → 0.31.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 CHANGED
@@ -67,7 +67,7 @@ for await (const message of bird.email.list()) {
67
67
  ## WhatsApp
68
68
 
69
69
  ```ts
70
- await bird.whatsapp.send({ to, template }); // resolves when accepted (202); Bird picks the sender from the template's category
70
+ await bird.whatsapp.send({ to, template }); // resolves when accepted (202); `from` is required except for a Bird-managed template
71
71
  await bird.whatsapp.get(messageId); // delivery status + failure detail
72
72
 
73
73
  // `await` yields the first page; `for await` walks every message across pages.
@@ -78,6 +78,22 @@ for await (const message of bird.whatsapp.list()) {
78
78
  const { data } = await bird.whatsapp.listEvents(messageId); // full lifecycle timeline, not paginated
79
79
  ```
80
80
 
81
+ ## Lookup
82
+
83
+ Every answer is billed. A phone number lookup bills once for the base answer plus once per **delivered** property; an email lookup bills once per answered address. Nothing is billed for a failed lookup, and nothing is billed for a property that came back unanswered, so read `status` before you read a value.
84
+
85
+ ```ts
86
+ const number = await bird.lookup.phoneNumber({ phone_number, type: ["score"] });
87
+ number.country_code; // base answer: always present, always billed
88
+ if (number.score?.status === "ok") number.score.value; // only `ok` carries a value, and only `ok` is billed
89
+
90
+ const address = await bird.lookup.email({ email });
91
+ address.result; // valid | neutral | risky | undeliverable | typo: an open vocabulary
92
+ address.delivery_confidence; // 0-100, always present: the safe fallback for a verdict you don't know
93
+ ```
94
+
95
+ Pass an `Idempotency-Key` so a retry replays the stored answer instead of buying a second one.
96
+
81
97
  ## Webhooks
82
98
 
83
99
  `unwrap` verifies a delivery's Standard Webhooks signature and returns a typed, discriminated event. **Pass the raw request body** — never the parsed JSON. Set the signing secret once via `webhooks: { secret }` on the client (or pass `{ secret }` per call).
@@ -111,7 +127,7 @@ try {
111
127
  html: "<p>My first Bird email.</p>",
112
128
  });
113
129
  } catch (err) {
114
- if (err instanceof BirdRateLimitError) console.log(`rate limited retry in ${err.retryAfter}s`);
130
+ if (err instanceof BirdRateLimitError) console.log(`rate limited; retry in ${err.retryAfter}s`);
115
131
  else if (err instanceof BirdValidationError) console.error(err.details);
116
132
  else if (err instanceof BirdAPIError) console.error(err.code, err.requestId);
117
133
  else throw err;