A Cloudflare Worker that keeps Webround newsletter subscribers in sync with a Brevo contact list, bidirectionally.
Webround → Brevo: when a customer subscribes or unsubscribes on the storefront, Webround fires a webhook to this Worker, which adds or removes them from the configured Brevo list.
Brevo → Webround: when a contact unsubscribes from a Brevo email or is deleted, Brevo fires a webhook to this Worker, which sets newsletter=false on the matching Webround customer.
If needed, before enabling the real-time sync, run the bulk import script to align the existing Webround subscribers with your Brevo list:
# fill in your values in .env
npx ts-node scripts/bulk-import.tsThe script fetches all newsletter subscribers from Webround page by page and pushes them to Brevo in batches of 150. Running it multiple times is safe: updateExistingContacts=true prevents duplicates.
In wrangler.jsonc, set:
{
"WR_API_URL": "https://commerce-api.webround.com/",
"WR_STORE_ID": "your-store-id",
"WR_USER_ID": "your-user-id",
"BREVO_LIST_ID": "your-list-id"
}Create a secrets.json file (never commit this):
{
"WR_API_KEY": "your-wr-api-key",
"BREVO_API_KEY": "your-brevo-api-key",
"BREVO_WEBHOOK_SECRET": "your-brevo-webhook-secret",
"WR_WEBHOOK_SECRET": "your-wr-webhook-secret"
}Or set them one by one via the Wrangler CLI:
wrangler secret put WR_API_KEY
wrangler secret put BREVO_API_KEY
wrangler secret put BREVO_WEBHOOK_SECRET
wrangler secret put WR_WEBHOOK_SECRETmake deployWebround: add a webhook pointing to https://your-worker.workers.dev/webhook/wr and subscribe to store.customer.newsletter.subscribed and store.customer.newsletter.unsubscribed.
Brevo: add a webhook pointing to https://your-worker.workers.dev/webhook/brevo, subscribe to unsubscribe and contactDeleted, and set the x-brevo-secret header to the value you used for BREVO_WEBHOOK_SECRET.
| Variable | Type | Description |
|---|---|---|
WR_API_URL |
var | Webround API base URL |
WR_STORE_ID |
var | Webround store ID |
WR_USER_ID |
var | Webround admin user ID |
BREVO_LIST_ID |
var | Brevo list ID to sync |
WR_API_KEY |
secret | Webround API key |
BREVO_API_KEY |
secret | Brevo API key |
BREVO_WEBHOOK_SECRET |
secret | Shared secret for Brevo webhook validation |
WR_WEBHOOK_SECRET |
secret | Shared secret for Webround webhook validation |
- Cloudflare Workers
- Brevo API
- Webround an API-first e-commerce platform