we are now available on product Hunt . Support usHere
How does it work?

How to build a mailing list or waitlist in less than 2 minutes

Use our API endpoints for custom integration

Save an Email to Your Mailing List

To add an email to your mailing list, make a POST request to the following endpoint:

POST: https://api.smadmail.com/api/v1/email/save

The request body should be a JSON object with the following structure:

{
        email: string;
        project_id: string;
        private_key: string;
        name: string; // Optional, only if "add user name field" is enabled when you create the project
      }

Field Descriptions:

  • email : The email address you want to add to your mailing list.
  • project_id : The unique identifier of your project. Replace 123-456-789-000 with your own project ID. You can retrieve it by clicking the Copy Project ID button on the dashboard.
  • private_key : Your private key to authenticate the request. Replace your_private_key_here with your private key. You can retrieve it on the /account page accessible by clicking on the chevron near your profile picture and selecting the Account & Pricing menu. Then, on the new page, copy the private_key.
  • name : The name of the user. This field is optional and will only be considered if the add user name field checkbox was enabled during project creation.

Body Example:

{
        "email": "example@gmail.com",
        "project_id": "123-456-789-000",
        "private_key": "your_private_key_here",
        "name": "John Doe" //  Optional, only if "add user name field" is enabled when you create the project, else set null
      }

Instructions:

  1. Replace the example values with your actual data.
  2. The private key is essential for authentication. Keep it secret, and it should be stored as an environment variable.
  3. Ensure the email address is valid before sending the request to avoid errors.
  4. If the add user name field checkbox was enabled during project creation, include the name field in the payload.

Example with JavaScript:

async function saveEmailToMailingList(email, name) {
        const response = await fetch('https://api.smadmail.com/api/v1/email/save', {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
          },
          body: JSON.stringify({
            email: email,
            project_id: process.env.PROJECT_ID,
            private_key: process.env.PRIVATE_KEY,
            name: name //  Optional, only if "add user name field" is enabled when you create the project, else set null
          })
        });

        if (!response.ok) {
          throw new Error('Failed to save email');
        }

        return await response.json();
      }

Example with Node.js:

const fetch = require('node-fetch');

      async function saveEmailToMailingList(email, name) {
        try {
          const response = await fetch('https://api.smadmail.com/api/v1/email/save', {
            method: 'POST',
            headers: {
              'Content-Type': 'application/json',
            },
            body: JSON.stringify({
              email: email,
              project_id: process.env.PROJECT_ID,
              private_key: process.env.PRIVATE_KEY,
              name: name // Include name  Optional, only if "add user name field" is enabled when you create the project, else set null
            }),
          });

          if (!response.ok) {
            throw new Error(`Failed to save email: ${response.statusText}`);
          }

          return await response.json();
        } catch (error) {
          console.error(`Error saving email: ${error.message}`);
          throw error;
        }
      }

      module.exports = saveEmailToMailingList;

Example with PHP:

<?php
      $url = 'https://api.smadmail.com/api/v1/email/save';
      $data = array(
        'email' => 'example@gmail.com',
        'project_id' => getenv('PROJECT_ID'),
        'private_key' => getenv('PRIVATE_KEY'),
        'name' => 'John Doe' //  Optional, only if "add user name field" is enabled when you create the project, else set null
      );

      $options = array(
        'http' => array(
          'header'  => "Content-Type: application/json
",
          'method'  => 'POST',
          'content' => json_encode($data),
        ),
      );

      $context  = stream_context_create($options);
      $result = file_get_contents($url, false, $context);

      if ($result === FALSE) {
        throw new Exception('Failed to save email');
      }

      var_dump($result);
      ?>