How to send an email using API?

In order to send an email using Pepipost API, you should be ready with all the prerequisites mentioned this documentation.

Step 1: Build you API call

Your API call must have the following components:

  • An Endpoint: Use https://api.pepipost.com/v2/ or select the one from the list which best meets your requirement.
  • An API Key within the authorization header.
  • A valid Request method. When submitting data to a resource use a valid allowed request method like POST, PUT, GET, PATCH and DELETE.
  • A valid payload. You must submit your payload in JSON format only.
Once you're ready with the above components, follow the next steps.

Step 2: Send your email using the API

Using the cURL Method

Warning: Some samples are using curl utility for API examples. UNIX shells require that some characters must be escaped, for example $ becomes $. If your API key contains unescaped characters you may receive HTTP error 401 (Unauthorized).

  1. Copy the below cURL example:
curl --request POST \
--url https://api.pepipost.com/v2/sendEmail \
--header 'api_key: <YOUR_API_KEY>' \
--header 'content-type: application/json' \
--data '{"personalizations":[{"recipient":"steve@example.com","attributes":{"NAME":"Steve"}}],"tags":"OrderConfirmationEmail","from":{"fromEmail":"sales@yourdomain.com","fromName":"ABC Sales"},"subject":"Your Order is confirmed","content":"Hi,[%NAME%] this is my first test email"}'
  1. Paste the curl call into your favorite text editor.

  2. Copy your API key and paste it in the api_key header.

  3. In the data section, specify the recipient and from email addresses.

From/Sender address consists of the Sender domain, which need to be pre-configured on Pepipost prior to initiate a test.

  1. Copy the code and paste it in your terminal.

  2. Hit Enter.

  3. Check the recipient’s inbox. You must have received the email.