Node.js library for the IndiePitcher API.
Note: The IndiePitcher REST API and this SDK is not means to be used from your frontend code - you would leak your secret access key that is being used to send emails and manupulate your contact lists.
npm install indiepitcher
- Create a free account on IndiePitcher
- Create a project under one of your organizations
- Generate an API key for your project
import { IndiePitcher } from 'indiepitcher';
const indiePitcher = new IndiePitcher('sk_xxxxxxxxxxxxxxxxxxxx');
await indiePitcher.sendEmail({
to: 'petr@indiepitcher.com',
subject: 'Hello World!',
body: 'This is a test body that supports **markdown**.',
bodyFormat: 'markdown',
});
- This examle turns a markdown string into a decent looking email, where you can customize the appearance in the dashboard.
- All endpoints to send an email also support sending raw HTML email body to send fully custom-looking emails.
- Please understand that sending cold outreach, and other spammy emails is against our Terms and Services, and may get you banned from the platform.
const contact = (
await indiePitcher.addContact({
email: 'petr@indiepitcher.com',
name: 'Petr Pavlik'
})
).data;
- Refer to our API documentation to learn more about topics such as contact lists and custom properties.
await indiePitcher.sendEmailToContact({
contactEmail: 'petr@indiepitcher.com',
subject: 'Hello {{firstName|default:"there"}}',
body: 'Hi {{firstName|default:"there"}}, This is a personalized email that supports **markdown**.',
bodyFormat: 'markdown',
list: 'important',
});
- Use the
important
mailing list only for important communication, emails such as a newsletter should have their own mailing list that contacts can unsubscribe from. - You can send an email to multiple contacts using a single API call by using
contactEmails
field instead, this takes an array of strings. - You can delay sending of the email by using
delaySeconds
ordelayUntilDate
properties. - Both markdown and html email bodies can be personalized using personalization tags, such as
{{firstName}}
or{{firstName|default:"there"}}
.
await indiePitcher.sendEmailToMailingList({
list: 'important',
subject: 'Hello {{firstName|default:"there"}}',
body: 'Hi {{firstName|default:"there"}}, This is a personalized email that supports **markdown**.',
bodyFormat: 'markdown',
});
const data = await indiePitcher.createMailingListsPortalSession(
'petr@indiepitcher.com',
'https://indiepitcher.com',
);
// redirect the user to data.returnUrl to manage their mailing list subscripitons