DEV Community

Aliyu Abubakar
Aliyu Abubakar

Posted on

How to Send Emails with JavaScript using Sendchamp Email API

Sendchamp Email API allows you to programmatically send emails to your customers.

Let’s walk through how to Send Emails with JavaScript using Sendchamp Email API step by step so you can get on to the important steps like sending Emails to your customers.


Before getting started, ensure you have:

  • JavaScript knowledge and familiarity with Nodejs.
  • Nodejs installed on your machine
  • Sendchamp account sign up on Sendchamp.
  • A subscription plan.

Sending emails using Sendchamp Email API is a simple process that requires a subscription plan. To subscribe to a plan, follow these steps:

  • Go to your Sendchamp Dashboard and navigate to the email section.
  • Click on the subscription option and select a plan that suits your needs.
  • The subscription fee will be charged from your wallet balance on Sendchamp.

Once you have an active subscription plan, you can start sending emails to your customers using the Sendchamp Email API.

Setting up your Nodejs Application

Create a .js file, let’s call it email.js, and in the file, initialize an instance with your credentials:

const options = {
  method: 'POST',
  headers: {
    accept: 'application/json',
    'content-type': 'application/json',
    Authorization: 'Bearer ACCESS_KEY’

Enter fullscreen mode Exit fullscreen mode

Make sure to replace ACCESS_KEY with your correct public access key on your Sendchamp dashboard.

Sending an Email Message

The Email API takes the following parameters:

Subject: The heading of the email.
To: The email and name of the recipient.
From: The email and name of the sender.
Message body: Message format and value of the message.

The type can be either "html" or "text" and the value should be the content of the message.

Let’s try to hard-code the following parameters to test out the Email API.

For example, if you want to send an email to a recipient with the subject "Test Email" and the message 'This is the content of the message', the body of the request would look like this.

  body: JSON.stringify({
    to: [{email: '', name: 'Sender'}],
    from: {email: '', name: 'Receiver'},
    message_body: {type: 'text/html', value: 'This is the content of the message'},
    subject: 'Hello world'

fetch('', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
Enter fullscreen mode Exit fullscreen mode

The email has been sent successfully. Thanks for following.

Join our Slack developer community for questions you might have and valuable resources.

For quicker testing, you can import our Postman collection and test APIs on Postman

Top comments (0)