import SendookAPI from '@sendook/node';// Using default API URL (https://api.sendook.com)const client = new SendookAPI('your_api_secret');// Using custom API URL (for self-hosted instances)const client = new SendookAPI('your_api_secret', 'https://your-api.com');
Keep your API secret secure and never commit it to version control. Use environment variables to store sensitive credentials.
const result = await client.inbox.message.send({ inboxId: 'inbox_id', to: ['[email protected]'], subject: 'Welcome to Sendook', text: 'Thanks for signing up!', html: '<h1>Thanks for signing up!</h1>'});
const result = await client.inbox.message.reply({ inboxId: 'inbox_id', messageId: 'message_id', text: 'Thanks for your message!', html: '<p>Thanks for your message!</p>'});
// List all messages in an inboxconst messages = await client.inbox.message.list('inbox_id');// Search messages with queryconst results = await client.inbox.message.list( 'inbox_id', 'subject:invoice');
import express from 'express';import SendookAPI from '@sendook/node';const app = express();const client = new SendookAPI(process.env.SENDOOK_API_SECRET!);app.post('/webhooks/email', express.json(), async (req, res) => { const { event, data } = req.body; if (event === 'message.received') { console.log('New message received:', data.messageId); // Auto-reply to the message await client.inbox.message.reply({ inboxId: data.inboxId, messageId: data.messageId, text: 'Thanks for your message! We\'ll get back to you soon.', html: '<p>Thanks for your message! We\'ll get back to you soon.</p>' }); } res.status(200).send('OK');});app.listen(3000);