Brevo API Integration

Event-driven Brevo contact sync and transactional email inside a WordPress application workflow.

ROLEIntegration developerEvents, templates and delivery
SCOPEContact sync, transactional mail, PDF attachment and resend toolingWordPress and Brevo
STACK PATTERNSWordPress / PHP / Brevo API / Gravity FormsREST and event hooks
STATUS
Production integration
Client work, anonymized
01 · CONTEXT AND TRUST BOUNDARIES

Messaging tied to application state

A payment and application platform needed Brevo contact updates and transactional email tied to existing form and payment events. The integration had to keep one contact record, choose the right template and support a document link or attachment. Staff also needed a manual resend path when a message had to be sent again.

CORE CONSTRAINT

The event is the source of truth. Email is a downstream effect.

02 · SYSTEM REQUIREMENTS

Constraints that shaped the design

C-01 · EVENTS

Event driven. Messages follow form and payment state changes.

C-02 · CONTACTS

One contact record. Each applicant maps to one Brevo contact.

C-03 · TEMPLATES

Template controlled. Copy lives in Brevo templates.

C-04 · DELIVERY

Attachments. Some messages include a generated PDF.

03 · TOPOLOGY AND NODES

WordPress events to Brevo delivery

EVENT TO MESSAGE · CONTACT SYNC
TEMPLATE DRIVEN
EVENT AND DELIVERY PATH

Form event → Payment event → Mapper → Brevo API → Template → Admin. Form and payment hooks map the applicant, update the Brevo contact and choose the template. The send result is recorded for staff, and a resend can be triggered from the entry screen.

04 · LIFECYCLE FLOWS

Three messaging paths

Submission received

SUCCESS
  1. 01Applicant submits a form.
  2. 02The integration maps email and name.
  3. 03Brevo creates or updates the contact.
  4. 04The lifecycle attribute changes to submitted.
  5. 05The confirmation template is sent.

Delivery retry

RECOVERY
  1. 01A Brevo request returns an error.
  2. 02The send path records the failure on the application entry.
  3. 03The application record remains available.
  4. 04An administrator can resend from the entry screen.
  5. 05The contact lifecycle flag remains independent of the send attempt.

Payment completed twice

IDEMPOTENT
  1. 01The same applicant submits another form.
  2. 02The email matches an existing Brevo contact.
  3. 03The contact is updated instead of duplicated.
  4. 04The lifecycle attributes retain the latest state.
  5. 05No second contact record is created.
05 · ARCHITECTURAL DECISION RECORDS

Evaluated options and trade-offs

ADR-001 · D1

Trigger model

ACCEPTED & DEPLOYED
OPTIONS EVALUATED

A) Poll Brevo

B) Push on WordPress events

CHOSEN DECISION

Push on WordPress events

ARCHITECTURE
RATIONALE

Form and payment hooks already know when the state changed.

ENGINEERING TRADE-OFF

Delivery failures need their own retry path.

ADR-002 · D2

Contact model

ACCEPTED & DEPLOYED
OPTIONS EVALUATED

A) Local list only

B) Brevo contact sync

CHOSEN DECISION

Brevo contact sync

CRM
RATIONALE

The team needed lifecycle segments and a single contact record.

ENGINEERING TRADE-OFF

Contact fields must stay mapped.

ADR-003 · D3

Message content

ACCEPTED & DEPLOYED
OPTIONS EVALUATED

A) Hard-coded HTML

B) Brevo templates

CHOSEN DECISION

Brevo templates

CONTENT
RATIONALE

Templates let the team change copy without a plugin release.

ENGINEERING TRADE-OFF

Template IDs and variables become configuration.

06 · SECURITY CONTROLS

Integration boundaries

1. API key

Stored in site settings

2. Server calls

No key in the browser

3. Capability

Admin resend requires entry edit permission

4. Nonce

Resend requests are validated

5. Contact upsert

Email is the match key

6. Entry notes

Sends leave an operational record

07 · OUTCOMES

What the integration delivers

WHAT HOLDS TRUE
  • Contacts are created or updated from form state.
  • SUBMITTED and PURCHASED flags track lifecycle state.
  • Templates are chosen per form or feed.
  • PDF links or attachments support document delivery.
  • Staff can resend a message from the entry screen.
What I would improve (Engineering Self-Critique)
  • Add a durable delivery log with retry status.
  • Move scheduled sends to a queue with visibility.
  • Add contract tests for template variables.
08 · RETROSPECTIVE

Transferable engineering principles

PRINCIPLE 01

Treat email as a side effect of a domain event.

PRINCIPLE 02

Keep message copy in the tool that owns it.

Continue reading

UP NEXT IN ARCHITECTURE DOSSIERS

Next Case Study → Cross-Domain Payment Proxy Architecture

A reusable cross-site payment bridge with signed server-to-server calls and tokenized capture.

Architecture & Payment Infrastructure
Open to New Work

Need a system architected like this?

Available for architecture advisory, custom PHP payment gateway bridges and resilient distributed workflows.

PORT: 443/TLS·LOCATION: Rajkot, India / Remote·STATUS: Available for Eng Interviews
UTC+5:30 · P99 RESPONSE: < 24H