Integration Guide
This guide walks you through integrating Aegis into a typical web application.
Architecture
┌─────────────┐ ┌─────────────┐ ┌─────────────────┐
│ Client │────▶│ Your API │────▶│ Aegis API │
│ (Browser) │ │ (Backend) │ │ (aegis-dig.com) │
└─────────────┘ └─────────────┘ └─────────────────┘
│
▼
┌─────────────┐
│ Serasa │
│ Boa Vista │
│ Quod │
└─────────────┘
Server-Side Only
WARNING
Never call the Aegis API directly from client-side code. Always proxy through your backend to protect your API key.
Complete Example
Backend (Node.js)
javascript
import { Aegis } from '@aegis-tech/sdk';
const aegis = new Aegis({
apiKey: process.env.AEGIS_API_KEY,
});
app.post('/api/verify', async (req, res) => {
try {
const result = await aegis.verify.cpf({
cpf: req.body.cpf,
name: req.body.name,
});
if (result.riskLevel === 'low') {
await approveUser(result.requestId);
} else {
await flagForReview(result.requestId);
}
res.json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
});
Frontend
javascript
const response = await fetch('/api/verify', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ cpf: '12345678901', name: 'João Silva' }),
});
const result = await response.json();
console.log(result.status); // 'verified'