open-index/open-npm huggingface dataset:
npm package: @sendable-dev/sdk
Description: TypeScript SDK for Sendable.
Latest version: 0.1.0

# @sendable-dev/sdk

TypeScript SDK for Sendable.

## Install

```bash
npm install @sendable-dev/sdk
```

## Requirements

This SDK is intended for trusted Node.js or Bun backends.

- Use the raw request body when verifying webhooks
- Media decrypt helpers require a valid WhatsApp media `url` and `mediaKey`
- `webhookSecret` should be the Svix `whsec_...` signing secret from Sendable

## Quick Start

```ts
import { Sendable } from '@sendable-dev/sdk'

const sendable = new Sendable({
	apiKey: process.env.SENDABLE_API_KEY!,
	apiKeyScope: 'session',
	baseUrl: process.env.SENDABLE_API_URL,
})

const message = await sendable.messages.send({
	chatId: '6281234567890@s.whatsapp.net',
	text: { content: 'Hello from Sendable' },
})
```

## Verify Webhooks

```ts
import express from 'express'
import { Sendable } from '@sendable-dev/sdk'

const sendable = new Sendable({
	apiKey: process.env.SENDABLE_API_KEY!,
	apiKeyScope: 'session',
	webhookSecret: process.env.SENDABLE_WEBHOOK_SECRET,
})

const app = express()

app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => {
	const payload = req.body.toString()

	try {
		const event = await sendable.webhooks.verifyAndParse(payload, req.headers)
		console.log(event.type, event.data)
		return res.sendStatus(200)
	} catch {
		return res.status(401).send('Invalid signature')
	}
})
```

## Decrypt Media

The SDK also includes local media decrypt helpers for trusted Node/Bun backends:

```ts
import { decryptWhatsAppMedia, decryptWebhookMedia } from '@sendable-dev/sdk'
```

- `decryptWhatsAppMedia(...)` for direct media metadata input
- `decryptWebhookMedia(...)` for full Sendable webhook events or `event.data`

Example from a verified webhook event:

```ts
import { decryptWebhookMedia } from '@sendable-dev/sdk'

const media = await decryptWebhookMedia(event)
await Bun.write(media.fileName, media.data)
```

Supported media types:

- `image`
- `video`
- `audio`
- `document`
- `sticker`

## Documentation

- SDK Quickstart: https://sendable.dev/docs/quickstart/nodejs/sdk
- Webhooks: https://sendable.dev/docs/webhooks
- Webhook Events: https://sendable.dev/docs/webhook-events
- API Reference: https://sendable.dev/docs/api-reference