Skip to main content
Each example is a single file you can run with Node.js 18 or later. They are Node only; the API is plain HTTPS and JSON, so the same calls work from any language, and the API reference shows each request in cURL, JavaScript, Python, Go, Ruby and PHP. Set BLUJAY_API_KEY (and, for webhooks, BLUJAY_WEBHOOK_SECRET) in your environment first.

Reply to incoming messages

A webhook receiver that verifies each event and answers a new direct message with an acknowledgement. Subscribe it to message.received. It sends the reply before it answers the webhook. If the send fails with a retryable error, the receiver returns 503, so Blujay delivers the event again later (up to 10 attempts). Using the event ID as the Idempotency-Key means a redelivered event never sends a second reply. Acknowledge once per conversation, not once per message: the example remembers the last acknowledgement per chat and stays quiet for 12 hours after it, so a contact’s “thanks” doesn’t get another acknowledgement. Every acknowledgement also counts toward the 6 texts in a row the contact must respond to.
reply-bot.mjs
For anything slower than a single API call, store the event in your own database first, acknowledge, and do the work from a job queue that retries. See Webhooks and Receive messages.

Send a batch safely

Sends a first message to a list of people, one at a time, from the first number that can send. Before each send it checks the number’s live limits.new_contacts.remaining_today and queue.remaining and stops when either reaches zero, and it also stops on a 429. Each recipient’s idempotency key makes the script safe to run again: finished sends are never repeated.
batch-send.mjs
See Sending rules and Sending best practices before sending to many people.

Next steps

Verify signatures

The signature check used above, explained.

Phone numbers and limits

The live fields the batch script reads.

Build with AI

Have your assistant review your integration.