// email marketing and newsletters
Via APICampaign Monitor email verification with pingutil
Campaign Monitor lists accept every address that comes through your forms and the API, so dead mailboxes and typos wait until the next campaign to bounce. A list webhook for the Subscribe event posts new subscribers to your endpoint in batches, pingutil checks them with the batch endpoint, and the API unsubscribes invalid addresses or writes a custom field you can segment on.
Where it connects: Campaign Monitor list webhook (Subscribe event, JSON payload) plus the API v3.3 subscriber update and unsubscribe endpoints
What goes wrong without it
- Our agency sends for several clients and one client's bad signups can make a campaign report look terrible.
- Subscribers added through the API from our app are never checked, and some of them were typed on a phone.
- We want to segment out risky contacts before sending without asking someone to clean the list every month.
What you can do with Campaign Monitor and pingutil
Verify webhook batches in one call
Campaign Monitor batches Subscribe events, up to 1,000 per request. The handler sends them to /v1/verify/batch 50 at a time instead of one request per address.
Segment on a verification field
Write a VerificationStatus custom field so a segment can exclude risky and unknown subscribers from campaigns where bounces matter.
Remove invalid addresses per client list
Each list has its own webhook, so you can turn verification on only for the clients or lists that need it.
Set it up
- 1
Create a custom field called VerificationStatus on the list and note your Campaign Monitor API key and list ID.
- 2
Deploy the endpoint below.
- 3
Create the webhook with POST https://api.createsend.com/api/v3.3/lists/{listid}/webhooks.json using Events ["Subscribe"], your Url and PayloadFormat json, then activate it.
- 4
Use the webhook test endpoint or add a test subscriber, and check that the custom field is filled in.
- 5
Build a segment where VerificationStatus is valid for your most bounce-sensitive sends.
import os
import threading
from urllib.parse import quote
import requests
from flask import Flask, request
app = Flask(__name__)
CM = "https://api.createsend.com/api/v3.3"
CM_AUTH = (os.environ["CM_API_KEY"], "x") # API key as basic auth username
def verify_batch(emails):
try:
r = requests.post(
"https://pingutil.com/v1/verify/batch",
headers={"Authorization": "Bearer " + os.environ["PINGUTIL_KEY"]},
json={"emails": emails},
timeout=60,
)
return r.json()["results"] if r.ok else [] # quota or error: fail open
except requests.RequestException:
return []
def handle(list_id, emails):
for i in range(0, len(emails), 50):
for v in verify_batch(emails[i : i + 50]):
email = v["input"]
if v["status"] == "invalid":
requests.post(f"{CM}/subscribers/{list_id}/unsubscribe.json", auth=CM_AUTH,
json={"EmailAddress": email}, timeout=15)
requests.put(
f"{CM}/subscribers/{list_id}.json?email={quote(email)}",
auth=CM_AUTH,
json={
"EmailAddress": email,
"CustomFields": [{"Key": "VerificationStatus", "Value": v["status"]}],
"ConsentToTrack": "Unchanged",
},
timeout=15,
)
@app.post("/hooks/campaign-monitor/<secret>")
def cm_hook(secret):
if secret != os.environ["HOOK_SECRET"]:
return "", 401
payload = request.get_json(force=True)
emails = [e["EmailAddress"] for e in payload.get("Events", []) if e.get("Type") == "Subscribe"]
if emails:
threading.Thread(target=handle, args=(payload["ListID"], emails), daemon=True).start()
return "", 200What to do with each result
| pingutil result | Action in Campaign Monitor |
|---|---|
| status: "invalid" | Unsubscribe the address on that list and set VerificationStatus to invalid. |
| status: "risky" (accept_all, role_based) | Set VerificationStatus to risky; exclude it from bounce-sensitive segments. |
| status: "unknown" | Set VerificationStatus to unknown and re-check before the next large send. |
| status: "valid" | Set VerificationStatus to valid; include in the main segment. |
Limits to plan for
- For confirmed opt-in lists, the Subscribe event fires only after the subscriber clicks the confirmation link, so unconfirmed addresses are not checked.
- Imports also fire Subscribe events. A large import can exceed pingutil's default 300 verified addresses per account per day (3,000 a month); the code then leaves the rest unchecked. Verify imports before uploading instead. Those are Free plan limits; Enterprise has custom limits.
- Campaign Monitor deactivates a webhook after errors sustained for more than a week, so return 200 even when pingutil is unavailable, as the handler does.
Campaign Monitor documentation
- www.campaignmonitor.com/api/v3-3/webhooks/
- www.campaignmonitor.com/api/v3-3/lists/
- www.campaignmonitor.com/api/v3-3/subscribers/
Campaign Monitor is a trademark of its owner. This integration uses Campaign Monitor's documented extension points; it is not an official Campaign Monitor app.
Common questions
- Does unsubscribing add the address to the suppression list?
- It does when the list is set to add unsubscribers to the suppression list. Deleting a subscriber instead does not suppress it, so the same bad address could be added again.
- Can I run this for several client accounts?
- Yes. Create one webhook per list and include the client or list in the URL path so the handler knows which API key to use.
Stop bad addresses in Campaign Monitor today
Sign in with your email, create an API key and paste it into the step above. Test on a few real addresses first: the live demo shows exactly what your Campaign Monitor setup will receive.