Skip to main content

Scenario

Your SendGrid single sends have device and geography breakdowns — you know that mobile opens are 68% in North America and desktop dominates in EMEA. But those numbers don’t translate into messaging decisions. This job pulls stat breakdowns for recent single sends, identifies behavioral patterns by device type and region, then updates your Mavera personas with engagement context. Now your personas know that “Enterprise EMEA” reads on desktop during business hours and prefers detailed content, while “SMB NA” reads on mobile and needs scannable formatting. Flow: SendGrid /v3/marketing/stats/singlesends with device/geo breakdowns → Aggregate patterns → Mavera PATCH /api/v1/personas/{id} or POST /api/v1/personas → Personas with behavioral layer

Architecture

Code

Example Output

Error Handling

SendGrid returns 429 with X-RateLimit-Reset header. The code retries after 2s. For bulk stat pulls (50+ sends), spread requests with 150ms delays.
Stats endpoints require start_date and end_date in YYYY-MM-DD format. Max range varies by plan. Free plans retain 3 days of stats; Pro retains 7 days.
The /browsers/stats endpoint may return empty data if link tracking is disabled. Enable click tracking in Settings → Tracking.