Polling Events
If your agent runs behind a firewall, in a worker process without a public URL, or prefers pull-based consumption, set the agent’s delivery mode to Poll.
Both webhooks and polling read from the exact same events outbox, oldest first. In poll mode, no webhook_deliveries rows are created.
Polling Loop
Call GET /api/v1/events with after=<cursor> and persist the returned cursor (or next_cursor) after processing each batch:
import time, requests
cursor = None
while True:
resp = requests.get(
"https://app.msend.dev/api/v1/events",
headers={"Authorization": f"Bearer {API_KEY}"},
params={"after": cursor, "limit": 50} if cursor else {"limit": 50},
).json()
for event in resp["data"]:
handle(event)
cursor = resp.get("cursor") or resp.get("next_cursor") or cursor
time.sleep(1)limitdefaults to50and accepts up to200.- If you are using an organization-wide API key, pass
agent_id=agt_xxxas a query parameter. msendretains agent events for at least 7 days even when a shorter retention period is configured, giving polling agents time to catch up after downtime.
Last updated on