How to Integrate 1lookup with Custom Webhooks
Direct API integration for developers. Build custom validation workflows in any programming language with maximum flexibility.
Full Control
Maximum Performance
Quick Start Examples
Node.js / Express
// Webhook endpoint to validate emails from form submissions
app.post('/webhook/validate-email', async (req, res) => {
const { email } = req.body;
try {
const response = await fetch('https://app.1lookup.io/api/v1/email', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ email })
});
const result = await response.json();
// Process based on validation results
if (result.data.classification.is_deliverable) {
// Add to mailing list
await addToMailingList(email);
} else {
// Flag for review
await flagForReview(email, result.data);
}
res.json({ success: true, validation: result.data });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
Python / Flask
import requests
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/webhook/validate-phone', methods=['POST'])
def validate_phone():
data = request.get_json()
phone_number = data.get('phone_number')
# Call 1lookup API
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
response = requests.post(
'https://app.1lookup.io/api/v1/phone',
json={'phone_number': phone_number},
headers=headers
)
result = response.json()
# Check if phone is valid and not spam
if result['data']['classification']['is_valid']:
spam_check = requests.post(
'https://app.1lookup.io/api/v1/phone-spam',
json={'phone_number': phone_number},
headers=headers
).json()
if spam_check['data']['analysis']['spam_score'] < 50:
# Safe to send SMS
send_welcome_sms(phone_number)
return jsonify({'success': True, 'data': result['data']})
PHP
<?php
// Webhook handler for IP validation
$input = json_decode(file_get_contents('php://input'), true);
$ip_address = $input['ip_address'];
// Configure API request
$ch = curl_init('https://app.1lookup.io/api/v1/ip');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'ip_address' => $ip_address
]));
$response = curl_exec($ch);
$result = json_decode($response, true);
// Check for VPN/Proxy
if ($result['data']['security']['is_vpn'] ||
$result['data']['security']['is_proxy']) {
// Block suspicious traffic
logSuspiciousActivity($ip_address, $result['data']);
} else {
// Allow normal traffic
processNormalRequest($ip_address);
}
header('Content-Type: application/json');
echo json_encode(['success' => true, 'validated' => true]);
Common Webhook Patterns
Form Validation
Validate data when users submit forms on your website
- • Receive form submission via webhook
- • Call 1lookup API to validate
- • Return validation status to frontend
- • Process or reject based on results
Batch Processing
Process CSV uploads or database imports
- • Receive batch data via webhook
- • Iterate through records
- • Validate each entry with 1lookup
- • Return summary report
Real-time Enrichment
Enrich data as it enters your system
- • Intercept new data entries
- • Enrich with 1lookup data
- • Add metadata to records
- • Update database with results
Event-Driven Actions
Trigger actions based on validation results
- • Validate on specific events
- • Route to different handlers
- • Send notifications if needed
- • Update user status
Webhook Best Practices
1
Implement Retry Logic
Add exponential backoff for failed requests to handle temporary API issues gracefully.
2
Secure Your Webhooks
Validate webhook signatures and use HTTPS to prevent unauthorized access.
3
Handle Errors Gracefully
Log errors, monitor webhook health, and have fallback mechanisms for critical flows.
4
Cache Results
Store validation results locally to reduce API calls and improve performance.
Ready to build custom integrations?
Get your API key and start building powerful webhook integrations today