@emalia/sdk
v1.0.0
Published
Official Emalia email marketing SDK for Node.js
Maintainers
Readme
@emalia/sdk
Official Node.js SDK for Emalia — email marketing platform.
Installation
npm install @emalia/sdkQuick Start
import { Emalia } from '@emalia/sdk';
const emalia = new Emalia({
apiKey: 'ema_your_api_key_here',
});
// Send an email
const result = await emalia.send({
to: '[email protected]',
plantilla_id: 'template-uuid',
variables: { nombre: 'Juan' },
});
// Create a contact
await emalia.contacts.create({
email: '[email protected]',
nombre: 'Juan Perez',
lista_id: 'list-uuid',
});
// List campaigns
const campaigns = await emalia.campaigns.list();API Reference
Initialize
const emalia = new Emalia({
apiKey: 'ema_xxx', // Required - your API key
baseUrl: 'https://...', // Optional - defaults to https://emaliamail.com
});Send Email
await emalia.send({
to: '[email protected]',
subject: 'Welcome!',
html: '<h1>Hello {{nombre}}</h1>',
variables: { nombre: 'Juan' },
tags: ['bienvenida'],
});Send Batch
await emalia.sendBatch({
plantilla_id: 'template-uuid',
destinatarios: [
{ email: '[email protected]', nombre: 'Ana' },
{ email: '[email protected]', nombre: 'Bruno' },
],
});Contacts
// List contacts
const { data } = await emalia.contacts.list({ page: 1, search: 'juan' });
// Create contact
await emalia.contacts.create({
email: '[email protected]',
nombre: 'New User',
lista_id: 'list-uuid',
tags: ['cliente'],
});Lists
const { data } = await emalia.lists.list();
await emalia.lists.create({ nombre: 'VIP Clients', color: '#D65444' });Tags
const { data } = await emalia.tags.list();
await emalia.tags.create({ nombre: 'premium' });
await emalia.tags.remove({ contacto_id: 'uuid', tag_id: 'uuid' });Campaigns
const { data } = await emalia.campaigns.list({ estado: 'enviada' });Automations
const { data } = await emalia.automations.list();Webhooks
// List webhooks
const { data } = await emalia.webhooks.list();
// Create webhook
await emalia.webhooks.create({
url: 'https://yourapp.com/webhook',
eventos: ['email.sent', 'email.opened', 'email.clicked'],
});
// Update webhook
await emalia.webhooks.update('webhook-id', { activo: false });
// Delete webhook
await emalia.webhooks.remove('webhook-id');Webhook Events
email.sent— Email deliveredemail.opened— Email openedemail.clicked— Link clickedemail.bounced— Email bouncedemail.complained— Spam complaintcontacto.created— Contact createdcontacto.updated— Contact updatedcontacto.unsubscribed— Contact unsubscribedlista.subscribed— Added to listlista.unsubscribed— Removed from listcampana.sent— Campaign sentautomation.started— Automation triggeredautomation.completed— Automation finished
License
MIT — EME Automations
