Quickstart: send your first iMessage with the API
Make an API key, send a first iMessage from your bubblr line with one request, and receive the reply through a signed webhook.
This takes about ten minutes. You need a bubblr line and a team admin account in the app. The examples use curl
and the TypeScript SDK; any language that speaks HTTP works.
1. Make an API key
In the app, open Developers → API keys and create a key with the scopes messages:read, messages:send and
webhooks:manage. The key (sk_live_…) is shown once: put it in your secrets, not in your code.
export BUBBLR_API_KEY=sk_live_…Check it works, and see what it may do:
curl https://api.bubblr.io/v1/me -H "Authorization: Bearer $BUBBLR_API_KEY"{ "object": "api_key_identity", "key_id": "key_6Nd1rM8pWc", "scopes": ["messages:read", "messages:send", "webhooks:manage"], "profile_ids": null, "draft_only": false, "tenant_id": "ten_4Ls9bH3vQk" }2. Find your line
Each line is a profile with an id (prf_…):
curl https://api.bubblr.io/v1/profiles -H "Authorization: Bearer $BUBBLR_API_KEY"{ "data": [{ "id": "prf_2Wq8nT4kLm", "object": "profile", "label": "Front desk", "phone_number": "+14155550123", "state": "working", … }], "has_more": false }state: working means it can send right now.
3. Send a message
POST /v1/profiles/{profile_id}/messages with the person's number and the text. Every send needs an
Idempotency-Key header: any unique string, such as a UUID. If your request times out and you retry it with the same
key, the message still goes out once.
curl -X POST https://api.bubblr.io/v1/profiles/prf_2Wq8nT4kLm/messages \
-H "Authorization: Bearer $BUBBLR_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"to": "+14155550142", "text": "Hi Hannah, your table for 4 is confirmed for 7 PM."}'The same with the SDK (npm install @bubblr/sdk), which makes the idempotency key for you:
import { Bubblr } from "@bubblr/sdk";
const bubblr = new Bubblr(); // reads BUBBLR_API_KEY
const message = await bubblr.messages.send({
profile_id: "prf_2Wq8nT4kLm",
to: "+14155550142",
text: "Hi Hannah, your table for 4 is confirmed for 7 PM.",
});The answer is 202 Accepted with the message, status: "queued". It goes out as iMessage when the person has
iMessage, and as a text message otherwise. US and Canadian numbers work in any format: (415) 555-0142 and
+14155550142 are the same person.
4. Follow it
The message moves through queued → sent → delivered → read (read receipts are iMessage only). Poll it:
curl https://api.bubblr.io/v1/profiles/prf_2Wq8nT4kLm/messages/msg_9KxT3vQ7Pa -H "Authorization: Bearer $BUBBLR_API_KEY"Polling is fine for a test. For real use, let bubblr tell you.
5. Receive the reply by webhook
Create a webhook for the events you want. Your URL must be public https://:
curl -X POST https://api.bubblr.io/v1/webhooks \
-H "Authorization: Bearer $BUBBLR_API_KEY" -H "Content-Type: application/json" \
-d '{"url": "https://example.com/hooks/bubblr", "events": ["message.received", "message.delivered", "message.failed"]}'The answer includes secret (whsec_…), shown only this once. Every delivery carries an X-Signature header made
with it; check it before trusting the body. With the SDK and Express:
import express from "express";
import { verifyWebhook } from "@bubblr/sdk";
const app = express();
app.post("/hooks/bubblr", express.raw({ type: "application/json" }), async (req, res) => {
const event = await verifyWebhook({ payload: req.body, signature: req.get("x-signature"), secret: process.env.BUBBLR_WEBHOOK_SECRET! });
if (event.type === "message.received") {
const { message } = event.data as { message: { chat_handle: string; text: string } };
console.log(`${message.chat_handle} wrote: ${message.text}`);
}
res.sendStatus(200);
});
app.listen(3000);Answer with any 2xx within 10 seconds. Anything else is retried, up to 6 attempts over about 10 minutes. To try your
endpoint without waiting for a reply, send a test event: POST /v1/webhooks/{webhook_id}/test.
Now reply to the message on your phone: a message.received event arrives at your endpoint with the text.
Next
- Messages and chats: photos and files, reactions, typing, search, reading a conversation.
- Webhooks and events: every event type, retries, and checking signatures without the SDK.
- Guardrails and rate limits: before an agent sends on its own.
- API reference.