const res = await fetch('https://api.torpedo.co.mz/api/v1/emails/batch', {
method: 'POST',
headers: {
'X-API-Key': process.env.TORPEDO_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
emails: [
{
from: 'Acme <hello@myapp.com>',
to: 'alice@example.com',
subject: 'Welcome to Acme',
html: '<h1>Welcome, Alice!</h1>',
},
{
from: 'Acme <hello@myapp.com>',
to: 'bob@example.com',
subject: 'Welcome to Acme',
html: '<h1>Welcome, Bob!</h1>',
},
],
}),
})
const { data } = await res.json()
// data is an array in the same order as the input
// [{ id: '...', status: 'queued' }, { id: '...', status: 'queued' }]