# iMessage Node.js & TypeScript SDK

> Use Blooio’s official, fully typed Node.js and TypeScript SDK to send and receive iMessages, verify webhooks, and access the Blooio REST API.

Source: https://blooio.com/integrations/api/imessage-node-sdk

## Summary

The Blooio Node.js SDK is the official TypeScript client for the Blooio REST API. It is published on npm as `@blooio/sdk` and supports async/await, automatic retries with exponential backoff and jitter, typed webhook events, and webhook signature verification.

The SDK uses the Fetch API and is designed for backend and edge environments. Keep API keys in trusted server-side environment variables, not browser code.

## Installation

```bash
npm install @blooio/sdk
# or
pnpm add @blooio/sdk
# or
yarn add @blooio/sdk
```

## Send an iMessage

```typescript
import { Blooio } from "@blooio/sdk";

const blooio = new Blooio({ apiKey: process.env.BLOOIO_API_KEY });

await blooio.chats.sendMessage({
  phone: "+15551234567",
  body: "Hey Alex — thanks for booking a demo. Reply with any questions.",
});
```

## Verify Webhooks

Import `verifyWebhook` from `@blooio/sdk`, then provide the raw request body, the `x-blooio-signature` request header, and your webhook secret. The function returns the parsed event or throws if the signature is invalid.

```typescript
import express from "express";
import { Blooio, verifyWebhook } from "@blooio/sdk";

const app = express();

app.post(
  "/webhooks/blooio",
  express.raw({ type: "application/json" }),
  (req, res) => {
    const event = verifyWebhook({
      body: req.body,
      signature: req.header("x-blooio-signature") ?? "",
      secret: process.env.BLOOIO_WEBHOOK_SECRET,
    });

    if (event.type === "message.received") {
      console.log("Inbound iMessage:", event.data.body);
    }

    res.sendStatus(200);
  },
);
```

## SDK Features

- TypeScript types for endpoints, payloads, and webhook events
- Async/await interface
- Automatic retries with exponential backoff and jitter
- Webhook signature verification
- Helpers compatible with Express, Fastify, Hono, and Next.js route handlers
- Streaming helpers for large inbound media downloads
- One-to-one coverage of the Blooio REST API
- MIT-licensed open-source project

## Runtime Support

The SDK works in environments that support the Fetch API:

- Node.js 18 and later
- Bun
- Deno
- Cloudflare Workers
- Vercel Edge Functions

## API Examples

The typed client includes methods that mirror the REST API, including:

- Send messages with `blooio.chats.sendMessage`
- Send attachments with `blooio.chats.sendAttachment`
- Send polls with `blooio.polls.sendPoll`
- Create FaceTime invites with `blooio.facetime.invite`
- Verify and process inbound webhook events

## Links

- HTML page: https://blooio.com/integrations/api/imessage-node-sdk
- TypeScript SDK repository: https://github.com/Blooio/blooio-typescript-sdk
- REST API overview: https://blooio.com/integrations/api.md
- Integrations overview: https://blooio.com/integrations.md
- Pricing: https://blooio.com/pricing.md
- Documentation: https://docs.blooio.com
- LLM site index: https://blooio.com/llms.txt
