Node.js fetch example
const apiKey = process.env.SENDWICH_API_KEY;
const response = await fetch('https://sendwich.dev/api/v1/message', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
from: 'Acme ',
to: ['customer@example.com'],
subject: 'Password reset',
html: 'Reset your password using the secure link.
',
text: 'Reset your password using the secure link.',
}),
});
if (!response.ok) {
throw new Error(`Sendwich request failed: ${response.status} ${await response.text()}`);
}