Integration Patterns
Common patterns for integrating Vera into your application. All patterns use the same enrichment API — the difference is when and how you trigger enrichment.
Pattern 1: Background Enrichment (Recommended)
Enrich in the background after user actions — don't block the user experience.
// User submits a form → save immediately → enrich in background
app.post('/api/leads', async (req, res) => {
const { name, email, message } = req.body;
const domain = extractDomain(email);
// Save lead immediately
const lead = await db.leads.create({ name, email, message, domain });
res.json({ success: true });
// Enrich in background (fire and forget)
if (domain) {
enrichInBackground(lead.id, domain);
}
});
async function enrichInBackground(leadId, domain) {
try {
const response = await fetch('https://api.veraenrich.com/enrich', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.VERA_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ url: domain })
});
const { jobId } = await response.json();
// Poll for results
const data = await pollForResults(jobId);
// Update lead with enriched data
await db.leads.update(leadId, {
company: data.name,
industry: data.industry,
employeeCount: data.employeeCount,
enrichedAt: new Date()
});
} catch (error) {
console.error(`Enrichment failed for ${domain}:`, error.message);
}
}
When to use: Form submissions, user signups, webhook triggers — any flow where enrichment shouldn't delay the response.
Pattern 2: Blocking Enrichment
Wait for enrichment before responding. Use only when enriched data is required immediately.
app.post('/api/enrich-and-respond', async (req, res) => {
const { domain } = req.body;
const response = await fetch('https://api.veraenrich.com/enrich', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.VERA_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ url: domain })
});
const { jobId } = await response.json();
const data = await pollForResults(jobId); // 10-15 second wait
res.json({ company: data });
});
Blocking adds 10-15 seconds to response time. Only use when the user explicitly expects to wait (e.g., a "lookup" feature).
Pattern 3: Cache-First
Check your cache before calling Vera to save quota and reduce latency:
async function getCompanyData(domain) {
// 1. Check cache
const cached = await redis.get(`company:${domain}`);
if (cached) return JSON.parse(cached);
// 2. Check database
const existing = await db.companies.findByDomain(domain);
if (existing && !isStale(existing.enrichedAt)) return existing;
// 3. Enrich via Vera
const data = await enrichCompany(domain);
// 4. Cache result
await redis.setex(`company:${domain}`, 86400, JSON.stringify(data));
await db.companies.upsert(data);
return data;
}
function isStale(enrichedAt) {
const daysSinceEnrichment = (Date.now() - enrichedAt) / (1000 * 60 * 60 * 24);
return daysSinceEnrichment > 30;
}
Helper: Domain Extraction
Extract company domains from email addresses:
function extractDomain(email) {
if (!email || !email.includes('@')) return null;
const domain = email.split('@')[1].toLowerCase();
const personal = ['gmail.com', 'yahoo.com', 'hotmail.com', 'outlook.com', 'icloud.com'];
return personal.includes(domain) ? null : domain;
}
The pollForResults function used above is covered in the Enrichment Guide.
Choosing a Pattern
| Pattern | Latency | Best For |
|---|---|---|
| Background | 0 (async) | Form submissions, signups, webhooks |
| Blocking | 10-15s | Lookup tools, admin panels |
| Cache-first | 0-15s | High-traffic pages, repeated lookups |
Most applications should use Background + Cache-first together.
Need Help?
- Support Guide
- Email: hi@veraenrich.com
- In-app chat (bottom right in dashboard)