const response = await fetch(`${process.env.SAKAWAVE_BASE_URL}/v1/customers`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SAKAWAVE_API_KEY}`,
'Content-Type': 'application/json',
'X-Request-ID': 'get_started_customer_001',
},
body: JSON.stringify({
type: 'individual',
jurisdiction: 'NG',
externalReference: 'cust_1001',
email: 'ada@example.com',
phoneNumber: '+2348012345678',
address: {
line1: '14 Marina Road',
city: 'Lagos',
state: 'Lagos',
postalCode: '100001',
country: 'NG',
},
firstName: 'Ada',
lastName: 'Okafor',
}),
});
const customer = await response.json();
if (!response.ok) {
throw new Error(`${response.status}: ${customer.code} — ${customer.message}`);
}
console.log(customer.id);