{"_id":"360dialog-whatsapp-sdk","_rev":"2-3499d21ba0caf71601ae3cc39be3c84d","name":"360dialog-whatsapp-sdk","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.0":{"name":"360dialog-whatsapp-sdk","version":"1.0.0","keywords":["360dialog","whatsapp","whatsapp-business-api","cloud-api","sdk","typescript","bun","meta-business-agent","rcs"],"author":{"name":"Pedro Viana"},"license":"GPL-3.0-only","_id":"360dialog-whatsapp-sdk@1.0.0","maintainers":[{"name":"eusouoviana","email":"pitter@unfolding.cx"}],"homepage":"https://github.com/pedrogmbh/360dialog-whatsapp-sdk#readme","bugs":{"url":"https://github.com/pedrogmbh/360dialog-whatsapp-sdk/issues"},"dist":{"shasum":"eaa0c683ed1cceb4da94ea8ef04802cf332a2463","tarball":"https://registry.npmjs.org/360dialog-whatsapp-sdk/-/360dialog-whatsapp-sdk-1.0.0.tgz","fileCount":215,"integrity":"sha512-+oUpIrKyHyfSS3KXlgG8pzD7pl4To4fN1Olyu8ez+dqvnXvVQzfBH0oKSpSTpU3a/o7Dx7jjXpNuw1bEObDhKg==","signatures":[{"sig":"MEUCIQClfXRdREdSc1F9giwnV9hR9kKXsAn0kcmSVckaokiHZgIgZNctfeJ7/J/rKMZvEjSeKWdJ6u0TixGJ6k2nbRRCZqQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1775988},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"src/index.ts","engines":{"node":">=18"},"exports":{".":{"bun":"./src/index.ts","types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"},"./package.json":"./package.json"},"gitHead":"3fb7bb020a39d1e5f02de3148c9e103d232f093b","scripts":{"test":"bun test","build":"rm -rf dist && bun build ./src/index.ts --outdir dist --target node --format esm --sourcemap=external --packages external && tsc -p tsconfig.build.json","smoke":"bun run scripts/smoke.ts","generate":"bun run openapi:fetch && bun run generate:types","typecheck":"tsc --noEmit -p .","openapi:fetch":"bun run scripts/fetch-openapi.ts","generate:types":"bun run scripts/generate-types.ts","prepublishOnly":"bun run typecheck && bun test && bun run build","coverage:report":"bun run scripts/coverage-report.ts"},"_npmUser":{"name":"eusouoviana","email":"pitter@unfolding.cx"},"repository":{"url":"git+https://github.com/pedrogmbh/360dialog-whatsapp-sdk.git","type":"git"},"_npmVersion":"12.0.2","description":"TypeScript SDK for the 360dialog WhatsApp Business API (Messaging API, Marketing Messages, Templates, Flows, Media, Groups, Calling, RCS, Meta Business Agent API and more).","directories":{},"_nodeVersion":"26.7.0","dependencies":{"axios":"^1.19.0","luxon":"^3.7.2","lodash":"^4.18.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","@types/node":"^26.2.0","@types/luxon":"^3.7.4"},"peerDependencies":{"typescript":"^7"},"_npmOperationalInternal":{"tmp":"tmp/360dialog-whatsapp-sdk_1.0.0_1787255508393_0.3952832632088048","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"360dialog-whatsapp-sdk","version":"1.0.5","description":"TypeScript SDK for the 360dialog WhatsApp Business API (Messaging API, Marketing Messages, Templates, Flows, Media, Groups, Calling, RCS, Meta Business Agent API and more).","license":"GPL-3.0-only","author":{"name":"Pedro Viana"},"repository":{"type":"git","url":"git+https://github.com/pedrogmbh/360dialog-whatsapp-sdk.git"},"homepage":"https://github.com/pedrogmbh/360dialog-whatsapp-sdk#readme","bugs":{"url":"https://github.com/pedrogmbh/360dialog-whatsapp-sdk/issues"},"type":"module","module":"src/index.ts","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","bun":"./src/index.ts","import":"./dist/index.js","default":"./dist/index.js"},"./package.json":"./package.json"},"engines":{"node":">=18"},"publishConfig":{"access":"public"},"keywords":["360dialog","whatsapp","whatsapp-business-api","cloud-api","sdk","typescript","bun","meta-business-agent","rcs"],"scripts":{"openapi:fetch":"bun run scripts/fetch-openapi.ts","generate:types":"bun run scripts/generate-types.ts","generate":"bun run openapi:fetch && bun run generate:types","coverage:report":"bun run scripts/coverage-report.ts","typecheck":"tsc --noEmit -p .","test":"bun test","build":"rm -rf dist && bun build ./src/index.ts --outdir dist --target node --format esm --sourcemap=external --packages external && tsc -p tsconfig.build.json","prepublishOnly":"bun run typecheck && bun test && bun run build","smoke":"bun run scripts/smoke.ts"},"devDependencies":{"@types/bun":"latest","@types/luxon":"^3.7.4","@types/node":"^26.2.0"},"peerDependencies":{"typescript":"^7"},"dependencies":{"axios":"^1.19.0","lodash":"^4.18.1","luxon":"^3.7.2"},"gitHead":"fd1665c0ae5b2980bed6d3771f78fbcf0d10c29c","_id":"360dialog-whatsapp-sdk@1.0.5","_nodeVersion":"26.7.0","_npmVersion":"12.0.2","dist":{"integrity":"sha512-ju1DqNJwIw/eLsB6luyXTPx6vctA9fUmqp9yV0OQ4yr+0a9Id09k0Q2sxhtu4BRDdOu+0UVYtD5Rgtv+OYvEpg==","shasum":"2dbe90c58d4efe1a75cf7b54bf8b2432c3fbea78","tarball":"https://registry.npmjs.org/360dialog-whatsapp-sdk/-/360dialog-whatsapp-sdk-1.0.5.tgz","fileCount":215,"unpackedSize":1776842,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/360dialog-whatsapp-sdk@1.0.5","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHKB+yyRfp6XAPB6nQ0P5chj5KHU7c8+ySyUnvZJBV/aAiACO5vE0VnEEJYH6nn6WpjbvEs/7AM26j+US4na8Xvjpg=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:bfa883c1-924d-4b72-90fa-3804aa0380de"}},"directories":{},"maintainers":[{"name":"eusouoviana","email":"pitter@unfolding.cx"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/360dialog-whatsapp-sdk_1.0.5_1787257936790_0.11232077058421064"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-20T19:51:48.126Z","modified":"2026-08-20T20:32:17.370Z","1.0.0":"2026-08-20T19:51:48.605Z","1.0.5":"2026-08-20T20:32:17.016Z"},"bugs":{"url":"https://github.com/pedrogmbh/360dialog-whatsapp-sdk/issues"},"author":{"name":"Pedro Viana"},"license":"GPL-3.0-only","homepage":"https://github.com/pedrogmbh/360dialog-whatsapp-sdk#readme","keywords":["360dialog","whatsapp","whatsapp-business-api","cloud-api","sdk","typescript","bun","meta-business-agent","rcs"],"repository":{"type":"git","url":"git+https://github.com/pedrogmbh/360dialog-whatsapp-sdk.git"},"description":"TypeScript SDK for the 360dialog WhatsApp Business API (Messaging API, Marketing Messages, Templates, Flows, Media, Groups, Calling, RCS, Meta Business Agent API and more).","maintainers":[{"name":"eusouoviana","email":"pitter@unfolding.cx"}],"readme":"# 360dialog-whatsapp-sdk\n\nA fully-typed TypeScript SDK for the [360dialog](https://www.360dialog.com/) WhatsApp Business Platform.\nIt covers every API documented in the\n[360dialog client documentation](https://docs.360dialog.com/docs/llms.txt) — the\n**Messaging API** (messages, marketing messages, templates, flows, media, groups,\ncalling, profile, business username, contact book, block users, payments, business\ncompliance, conversational components, encryption, RCS, health) and the\n**Meta Business Agent API** (onboarding, knowledge base, connectors, operate) —\nplus the sandbox. Webhooks and Inbox are intentionally out of scope\n(see [COVERAGE.md](./COVERAGE.md) for the endpoint-by-endpoint matrix).\n\n- Built for [Bun](https://bun.com) and Node.js ≥ 18 (ESM), transport via `axios`.\n- Types are generated from the OpenAPI fragments published in the 360dialog docs\n  (`openapi/*.json`, refreshable with one command) and enriched with hand-written\n  payload types for every documented message type.\n- Every documented operation is exercised by the test suite (`bun test`), which fails\n  if an endpoint goes uncovered.\n\n## Install\n\n```bash\nbun add 360dialog-whatsapp-sdk\n# or: npm install 360dialog-whatsapp-sdk\n```\n\n## Quick start\n\n```ts\nimport { Dialog360Client } from \"360dialog-whatsapp-sdk\";\n\nconst client = new Dialog360Client({ apiKey: process.env.D360_API_KEY! });\n\n// Free-form text\nawait client.messages.sendText(\"4915112345678\", \"Hello from 360dialog 👋\");\n\n// Template\nawait client.messages.sendTemplate(\"4915112345678\", {\n  name: \"order_update\",\n  language: { code: \"en_US\" },\n  components: [{ type: \"body\", parameters: [{ type: \"text\", text: \"#1234\" }] }],\n});\n\n// Interactive buttons\nawait client.messages.sendInteractive(\"4915112345678\", {\n  type: \"button\",\n  body: { text: \"Confirm your appointment?\" },\n  action: {\n    buttons: [\n      { type: \"reply\", reply: { id: \"yes\", title: \"Yes\" } },\n      { type: \"reply\", reply: { id: \"no\", title: \"No\" } },\n    ],\n  },\n});\n\n// Any documented payload (fully typed – see `OutboundMessage`)\nawait client.messages.send({\n  messaging_product: \"whatsapp\",\n  to: \"4915112345678\",\n  type: \"location\",\n  location: { latitude: 52.52, longitude: 13.405, name: \"Berlin\" },\n});\n```\n\n### Client options\n\n```ts\nconst client = new Dialog360Client({\n  apiKey: \"…\",                       // D360-API-KEY of the channel (or env WA_360DIALOG_API_KEY)\n  baseUrl: \"https://waba-v2.360dialog.io\", // default (or env WA_360DIALOG_API_URL)\n  sandbox: false,                    // true → https://waba-sandbox.360dialog.io\n  timeoutMs: 30_000,                 // per-request timeout\n  headers: { \"X-Trace\": \"abc\" },     // extra headers on every request\n  axios: myAxiosInstance,            // bring your own axios (proxies, interceptors, retries)\n  userAgent: null,                   // customise / disable the User-Agent header\n  businessAgent: { apiVersion: \"2.0.0\" }, // X-API-Version for the Meta Business Agent API\n});\n```\n\nEvery method accepts an optional trailing `CallOptions` argument:\n`{ signal?: AbortSignal; timeoutMs?: number; headers?: Record<string, string> }`.\n\n### Environment variables\n\nInstead of passing `apiKey`/`baseUrl`, set them in the environment (see\n[`.env.example`](./.env.example); Bun loads `.env` automatically, on Node use\n`node --env-file=.env`):\n\n```bash\nWA_360DIALOG_API_KEY=your-channel-api-key\nWA_360DIALOG_API_URL=            # optional – empty = production, or https://waba-sandbox.360dialog.io\n```\n\n```ts\nconst client = Dialog360Client.fromEnv();      // or: new Dialog360Client() / createClient()\nconst sandbox = Dialog360Client.fromEnv({ sandbox: true }); // overrides always win\n```\n\nExplicit options take precedence over the environment. `bun run smoke` performs a\nlive `GET /health_status` with those credentials (optionally sending a text:\n`bun run smoke <phone> \"hi\"`).\n\n### Sandbox\n\n```ts\nconst sandbox = new Dialog360Client({ apiKey: SANDBOX_KEY, sandbox: true });\nawait sandbox.sandbox.sendMessage({\n  messaging_product: \"whatsapp\",\n  to: \"<YOUR_PHONE_NUMBER>\",\n  type: \"text\",\n  text: { body: \"Hello world\" },\n});\n```\n\n## Resources\n\n| `client.…` | API | Docs |\n| --- | --- | --- |\n| `health` | Meta stack health status | [Health](https://docs.360dialog.com/docs/messaging-api/api-reference/health) |\n| `messages` | Send messages, mark as read, typing indicators, group pins | [Messages](https://docs.360dialog.com/docs/messaging-api/api-reference/messages) |\n| `marketingMessages` | Marketing Messages (MM Lite) API – send, datasets, conversion events, ad insights, template analytics | [Marketing Messages](https://docs.360dialog.com/docs/messaging-api/api-reference/marketing-messages) |\n| `templates` | Message templates (list/create/edit/delete/archive/compare, template library, legacy v1 endpoints) | [Templates](https://docs.360dialog.com/docs/messaging-api/api-reference/templates) |\n| `flows` | WhatsApp Flows (CRUD, assets, preview, publish, deprecate) | [Flows](https://docs.360dialog.com/docs/messaging-api/api-reference/flows) |\n| `media` | Upload / download / delete media, resumable upload sessions | [Media](https://docs.360dialog.com/docs/messaging-api/api-reference/media), [Media Uploads](https://docs.360dialog.com/docs/messaging-api/api-reference/media-uploads) |\n| `groups` | Groups API | [Groups](https://docs.360dialog.com/docs/messaging-api/api-reference/groups) |\n| `calling` | Calling API (call actions, permissions, settings) | [Calling](https://docs.360dialog.com/docs/messaging-api/api-reference/calling) |\n| `profile` | WhatsApp Business profile | [Profile](https://docs.360dialog.com/docs/messaging-api/api-reference/profile) |\n| `businessUsername` | Business usernames | [Business Username](https://docs.360dialog.com/docs/messaging-api/api-reference/business-username) |\n| `contactBook` | Contact book (BSUID) | [Contact Book](https://docs.360dialog.com/docs/messaging-api/api-reference/contact-book) |\n| `blockUsers` | Block / unblock users | [Block Users](https://docs.360dialog.com/docs/messaging-api/api-reference/block-users) |\n| `payments` | Payment configurations | [Payments](https://docs.360dialog.com/docs/messaging-api/api-reference/payments) |\n| `businessCompliance` | Business compliance info | [Business Compliance](https://docs.360dialog.com/docs/messaging-api/api-reference/business-compliance) |\n| `conversationalComponents` | Welcome messages, commands, ice breakers | [Conversational Components](https://docs.360dialog.com/docs/messaging-api/api-reference/conversational-components) |\n| `encryption` | Business public key (Flows endpoint encryption) | [Encryption](https://docs.360dialog.com/docs/messaging-api/api-reference/encryption) |\n| `rcs` | RCS messages, events, capability checks, logs, reports, templates | [RCS](https://docs.360dialog.com/docs/messaging-api/api-reference/rcs) |\n| `businessAgent` | Meta Business Agent API (`onboarding`, `businessInfo`, `faq`, `files`, `websites`, `skills`, `connectors`, `connectorTools`, `operate`) | [API Ref](https://docs.360dialog.com/docs/mba/api-ref) |\n| `sandbox` | Sandbox messaging | [Sandbox](https://docs.360dialog.com/docs/get-started/sandbox) |\n\n### Examples\n\n```ts\n// Templates\nconst { data: templates } = await client.templates.list({ limit: 50 });\nawait client.templates.create({\n  name: \"welcome\",\n  category: \"UTILITY\",\n  language: \"en_US\",\n  components: [{ type: \"BODY\", text: \"Welcome {{1}}!\", example: { body_text: [[\"Ada\"]] } }],\n});\n\n// Media\nconst { id } = await client.media.upload({ file: await Bun.file(\"./photo.jpg\").arrayBuffer(), contentType: \"image/jpeg\", filename: \"photo.jpg\" });\nawait client.messages.sendImage(\"4915112345678\", { id, caption: \"📸\" });\nconst { url } = await client.media.get(id!);\nconst { data: bytes, contentType } = await client.media.download(url!);\n\n// Flows\nconst flow = await client.flows.create({ name: \"Lead form\", categories: [\"LEAD_GENERATION\"] });\nawait client.flows.uploadFlowJson(flow.id!, { file: { version: \"7.0\", screens: [] } });\nawait client.flows.publish(flow.id!);\n\n// Groups\nconst group = await client.groups.create({ subject: \"VIP customers\" });\nconst { invite_link } = await client.groups.getInviteLink(group.id!);\n\n// Meta Business Agent\nawait client.businessAgent.onboarding.createOnboardingSession(\"whatsapp\");\nawait client.businessAgent.faq.create({ question: \"Opening hours?\", answer: \"9–5, Mon–Fri.\" });\nconst eligibility = await client.businessAgent.onboarding.getEligibility();\n```\n\n## Error handling\n\n```ts\nimport { Dialog360ApiError, Dialog360NetworkError, Dialog360TimeoutError } from \"360dialog-whatsapp-sdk\";\n\ntry {\n  await client.messages.sendText(\"…\", \"…\");\n} catch (err) {\n  if (err instanceof Dialog360ApiError) {\n    err.status;      // HTTP status\n    err.code;        // Meta/WhatsApp error code (e.g. 131047)\n    err.details;     // Meta Graph-style { message, type, code, error_data, fbtrace_id }\n    err.problem;     // RFC 7807 details (Meta Business Agent API)\n    err.body;        // raw response body\n    err.isRateLimited;\n  } else if (err instanceof Dialog360TimeoutError) {\n    // retry…\n  } else if (err instanceof Dialog360NetworkError) {\n    // DNS / connection problem\n  }\n}\n```\n\n## Types\n\n- Hand-written payload types for `POST /messages`: `OutboundMessage` and friends\n  (`TextMessageRequest`, `InteractiveContent`, `TemplateContent`, `Contact`, …) —\n  everything documented under *Message Types*, *Interactive*, *Payments*, *Calling*,\n  *Groups* and *Typing Indicators*.\n- Generated types, namespaced per resource, e.g. `Templates.MessageTemplate`,\n  `Flows.CreateFlowRequest`, `Groups.GetGroupInfoResponse`, `Rcs.RcsMessageRequest`,\n  `BusinessAgent.Faq.BizAIOmniChannelKnowledgeFAQRequest`.\n- `messagingOperations` / `businessAgentOperations`: registry of every documented\n  operation (`operationId → { method, path, … }`).\n\n## Keeping up with the docs\n\n```bash\nbun run generate          # re-fetch llms.txt + API reference pages → openapi/*.json → src/generated/**\nbun run typecheck         # tsc\nbun test                  # unit tests + coverage test (fails if an operation is not covered)\nbun run coverage:report   # regenerate COVERAGE.md\nbun run build             # dist/ (ESM bundle + .d.ts)\n```\n\nIf 360dialog documents a new endpoint, `bun test` will fail on the coverage\nsuite until a method (and a `test/coverage/*` entry) is added for it.\n\n## License\n\nGPL-3.0-only. See [LICENSE](./LICENSE).\n","readmeFilename":"README.md"}