Sending notifications
POST /api/v1/notifications: fields, targeting, scheduling, A/B tests, merge tags and cancelling a scheduled send.
POST /api/v1/notifications — accepts the send and answers 202; delivery happens in the background. With no targeting fields it goes to every subscriber of the website the API key belongs to. Until the account's email address is verified it answers 403 email_not_verified (test sends to your own test devices still work).
curl -X POST https://relaybell.com/api/v1/notifications \
-H "Authorization: Bearer rb_live_xxxxx" -H "Content-Type: application/json" \
-d '{
"title": "Flash sale 🔥",
"body": "30% off ends tonight — {name|there}!",
"url": "https://shop.example/sale"
}'Response (202):
{ "ok": true, "notificationId": "5b0c2f7e-1d7a-4c3e-9a51-2f8e6b1d0c42", "status": "queued" }status is "queued" when sending starts now, or "scheduled" when it waits — for a future sendAt, or because your quiet hours are on (the send is held until they end). A send to everyone from an account less than 7 days old that would reach more than 5,000 browsers answers "held_for_review" with a message: our team checks a new account's first large sends before they go out (usually within a working day), and you can cancel it meanwhile. A narrower broadcast from such an account can be held the same way just before it goes out. Sends to specific people are never held. Keep notificationId: it is how the send appears in /stats and in webhooks, and how you cancel it.
| Field | Description |
|---|---|
title * | Notification title. Required — without it the answer is 400 title_required. Supports merge tags such as {name|there} (the subscriber's name tag, or the text after | when it's empty). |
body | Message text. Supports merge tags. |
url | Page opened when the notification is clicked. Left out, your Default link (Settings → Messages → Links) is used. Your UTM tags, if set, are added. Supports merge tags. |
icon | Small image (URL) shown next to the text. Left out, your Default notification logo (Settings → General) is used. |
image | Large picture (URL). Shown mainly by Chrome and Edge on Windows and Android; Safari, Firefox and Macs leave it out. |
badge | Small one-colour icon (URL of a PNG with a transparent background, about 96×96 px) shown in the Android status bar. |
requireInteraction | true keeps the notification on screen until the person clicks or closes it, instead of it fading after a few seconds. Chrome and Edge on computers honour it; Safari and Firefox ignore it. |
tag | A label of your choice. A new notification with the same tag replaces one that is still showing instead of stacking beside it — useful for updates like “Your order is out for delivery”. |
actions | Up to 2 buttons: [{action,title,url}]. Each needs a title; action defaults to btn1/btn2; url is kept only when it is an http(s) link. |
externalId | Send to one of your own users: the user id you gave the browser SDK (externalId in init(), or identify()). It reaches every subscribed browser linked to that id. The id must match exactly (case matters). See Send to one user. |
externalIds | The same for a list: ["user_1", "user_2"]. Used instead of externalId when both are sent. If every id is empty, the answer is 400 external_ids_empty — it never falls back to sending to everyone. |
transactional | true for a message a person is waiting for (order update, sign-in alert, a reply): it goes out straight away even during your quiet hours, skips the daily frequency cap, and is never listed in the public on-site inbox (showInbox()). Use it for messages to particular people, not for marketing. |
sendAnyway | true sends this notification to everyone it targets even when Smart limits apply to your broadcasts, past each person's limits (the dashboard's Send to everyone anyway). Default false; anything other than true or false answers 400 invalid_send_anyway. It has no effect when Smart limits are off, or when they leave broadcasts alone (the default). |
segmentId / filters | Target a saved segment, or inline filters in the segment filter format. A segment that isn't in this project answers 400 segment_not_found; one deleted before a scheduled send goes out makes that send fail (error: "segment_missing") — it never falls back to everyone. Only one way of choosing people is used per send: segmentId first, then filters, then externalIds/externalId — so don't combine them. |
topicId | Only subscribers of a topic — its id or its slug (e.g. "tech-news", any case). Combines with the fields above. An unknown topic answers 400 unknown_topic. |
excludeSegmentId / excludeFilters | Leave a segment (or the people matching inline filters) out of this send. excludeSegmentId wins when both are sent; an unknown one answers 400 segment_not_found. |
sendAt | ISO 8601 time to schedule the send (status "scheduled"). A time in the past, or one that can't be read, sends now. A send with sendAt isn't moved by quiet hours. |
perTimezone + localTime | Deliver at a local time ("H:MM" or "HH:MM", e.g. "09:00") in each subscriber's time zone. sendAt is ignored, and without a valid localTime it sends normally. |
smartTime | Deliver at each subscriber's most-active hour. sendAt is ignored. |
resend | Send once more to people who got this and didn't click or buy: { "afterHours": 24, "title": "...", "body": "..." }. afterHours is 12 to 168, counted from the last delivery. title and body are optional. Not with abTest, ab or transactional. |
ttl | How long (seconds) the push service keeps trying to reach a device that is offline. Default 24 hours, maximum 28 days. |
translations | { "es": {title,body}, ... } — keyed by two-letter language, picked by each subscriber's browser language; others get the main text. |
ab | A/B test: { "b": { title, body, url, image } } — each browser gets version A or B (fields left out of B come from A). Ignored unless b has at least one field. |
recommend | Which items the recommendation tags ({rec.*}) pick: { "type": "product" }, "article", "course", "listing" or "any". Left out (or "auto"): your website's main type — products if it has any, else articles. Any other type answers 400 invalid_recommend. See What a send recommends. |
ai | AI tailors the wording for each person: { "personalize": true, "tone": "friendly", "holdout": 10 }. Each person gets a version written around their interests by the AI on relaybell's own servers; holdout% (0–50, default 10) get your original for comparison. tone: friendly, urgent, playful or professional (left out: keep yours). Any failure sends your original, on time. A wrong shape answers 400 invalid_ai. See AI-written wording and AI writing. |
abTest | Auto-winner, with ab: { autoWinner:true, testPercent:20, afterHours:4 } — sends both versions to testPercent% (1–90, default 20), then after afterHours (1–168, default 4) sends the version with the higher click rate to the rest (with no clicks yet, the rest get the normal A/B split). |
Don't want to write the copy yourself? The composer's Write with AI button (Write it for me, Improve my text) writes it with AI, and POST /api/v1/ai/write does the same from the API: see AI writing. The AI never adds prices, discounts, dates or links you didn't give it.
Merge tags (personalization)
Write {key} or {key|fallback} in a send's title, body, url, image or buttons (actions title and url), and each subscriber gets their own value. An empty or unknown value becomes the fallback (the text after |), or nothing when there is none. Keys are letters, digits, _, . and -, and are case-sensitive.
| Tag | Value |
|---|---|
{external_id} | The user id linked to the subscriber (externalId). |
{url} | The last page of your site the subscriber was on when they subscribed or were last updated. |
{language} | The browser's language, e.g. en-GB. |
{country} | The subscriber's 2-letter, upper-case country code (ISO 3166-1, e.g. IN), worked out from the visitor's IP address when the browser subscribes or is saved again; empty when unknown. It can't be set from the SDK — use a tag for that. |
{KEY} | Any of the subscriber's tags (tags in init(), setTags(), an import or a bulk label), e.g. {name|there} or {plan}. A tag with the same name as a built-in one wins. |
{rec.title}, {rec.url}, {rec.image}, {rec.price}, {rec.category}, {rec.brand}, {rec.summary} | A product — or an article, course or listing, depending on the send's recommend type — picked for this subscriber from your catalog; {rec.summary} is an article's short summary. {rec2.…} and {rec3.…} are the second and third pick. See Recommendation tags. Any other rec field answers 400 invalid_merge_tag. |
Tags are filled in when any of the copy contains one: the main fields, the A/B version B, the buttons or the translations. A url (or button link) that doesn't come out as a web address or a path on your site (/sale) opens your Default link instead; an image that doesn't is left out; a title that comes out empty becomes your website's name. With UTM tags on, they are added to a {rec.url} link once it is filled in.
In automation, journey and product alert messages the same {key|fallback} syntax takes its values from the event's properties instead (for example {product}, {url}) — not from the subscriber. The recommendation tags ({rec.…}) are the exception in automations and journeys: they are kept and filled in for the recipient when the push goes out, with the type set in the automation's or step's action.recommend.
Safe retries (Idempotency-Key)
A network error can leave you unsure whether a send was accepted. Send an Idempotency-Key header with POST /api/v1/notifications — any value of 1–255 visible ASCII characters, no spaces, unique per send (a UUID works well) — and retry with the same key. The first request makes the send; any later one from the same website with that key sends nothing and answers 202 with the first send's notificationId and its current status, plus "idempotentReplay": true and the header Idempotent-Replayed: true. A replay uses none of the hourly send budget. Keys are remembered for good, per website. A malformed key answers 400 invalid_idempotency_key; drafts ("draft": true) ignore the header.
curl -X POST https://relaybell.com/api/v1/notifications \
-H "Authorization: Bearer $RELAYBELL_API_KEY" \
-H "Idempotency-Key: 6f1c2a0e-9b7d-4e1a-a1f3-2c9d8e7b6a51" \
-H "Content-Type: application/json" \
-d '{"title":"Your order has shipped","externalId":"user_123","transactional":true}'Email campaigns
POST /api/v1/email-campaigns (scope send) sends a one-off email to your email list: audience { "type": "all" } (every subscribed email contact) or { "type": "segment", "segmentId": "…" }, sendAt to schedule it (up to 90 days ahead), and content (subject required; preheader, heading, text, button, url on your website, an https image, products: ["recs"] or up to 4 catalog product addresses in pick, style). It answers 201 { campaign, estimate }. The estimate says how many contacts it reaches and over how many days the daily email limit spreads it. Without a postal address in Settings → Email, real sending answers 409 postal_address_missing. Links and pictures must be https://; words still carrying a starter tip answer 400 starter_instruction_left. With notificationId (a push sent with it) the email follows the push: its time when the push is delayed, the approval when it's held for review (waiting, waitReason: push_review), and 409 push_not_sent when the push won't go out.
POST /api/v1/email-campaigns/estimate: the estimate alone (reach,perDay,days,startsTomorrow,resumesAt: when the rest continue once a day's share is used, 9:00 the next day in the website's time zone).GET /api/v1/email-campaignsandGET /api/v1/email-campaigns/:id: status (draft,scheduled,waiting,sending,paused_daily_limit,done,cancelled) and numbers (delivered, opened, clicked, conversions, revenue, unsubscribed, bounced).POST /api/v1/email-campaigns/:id/cancel: emails not sent yet never go.- Drafts:
POST /api/v1/email-campaignswith"draft": truesaves one (no subject needed yet, never sends, doesn't count toward the 20 campaigns a day);PUT /api/v1/email-campaigns/:idchanges it,POST /api/v1/email-campaigns/:id/sendsends or schedules it with every check above,DELETE /api/v1/email-campaigns/:iddeletes it.
More in Email → Email campaigns.
Cancel a scheduled send
POST /api/v1/notifications/:id/cancel — stops a send that is still "scheduled" (a future sendAt, or one held for quiet hours) or "held_for_review". Answers 200 { "ok": true, "canceled": true }. A send that has already started (including a per-time-zone or smart-time send, which starts at once), has finished, was already canceled, doesn't exist or belongs to another website answers 404 { "error": "not_scheduled" }.
curl -X POST https://relaybell.com/api/v1/notifications/5b0c2f7e-1d7a-4c3e-9a51-2f8e6b1d0c42/cancel \
-H "Authorization: Bearer rb_live_xxxxx"