// 1. Create a customer
const customer = await fetch('https://app.kapso.ai/api/v1/customers', {
method: 'POST',
headers: { 'X-API-Key': 'YOUR_API_KEY' },
body: JSON.stringify({
customer: {
name: 'Acme Corporation',
external_customer_id: 'customer-123'
}
})
});
// 2. Generate setup link
const setupLink = await fetch(`https://app.kapso.ai/api/v1/customers/${customerId}/setup_links`, {
method: 'POST',
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
// 3. Customer clicks link and connects WhatsApp
// Share setupLink.data.url with your customer
// 4. Send messages on their behalf
const message = await fetch('https://app.kapso.ai/api/v1/whatsapp_messages', {
method: 'POST',
headers: { 'X-API-Key': 'YOUR_API_KEY' },
body: JSON.stringify({
customer_id: customerId, // Or use whatsapp_config_id for specific config
message: {
phone_number: '+1234567890',
content: 'Your appointment is tomorrow at 2 PM'
}
})
});