Skip to content

Tutorial: Send Email from API

In this tutorial, you’ll learn how to send an email using the Contacta API. We’ll walk through the steps required to authenticate, compose your message, and send it programmatically.

  • A Contacta account
  • Your API key (find it in your Contacta dashboard)
  • Basic knowledge of HTTP requests
  • A tool like curl, Postman, or any programming language that can make HTTP requests

Log in to your Contacta dashboard and navigate to the API section. Copy your API key; you’ll need it to authenticate your requests.

Prepare the JSON payload for your email. Here’s an example:

developer@developer:~#
{
"from": {
"name": "John Doe",
"email": "john@doe.com"
},
"to": [
{
"name": "Jane Smith",
"email": "jane@smith.com"
}
],
"subject": "Welcome to Our Service",
"text": "Hello, this is a test email.",
"html": "<p>Hello, this is a test email.</p>",
"variables": {
"variable_a_var": "Variable A Value"
},
"attachment": [
{
"name": "document.pdf",
"url": "https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf"
}
]
}

Now, send a POST request to the Contacta API endpoint with your API key and the payload. Here’s how you can do it with curl:

developer@developer:~#
curl -X POST https://api.example.com/v1/email/send
-H "Authorization: Bearer YOUR_API_KEY"
-H "Content-Type: application/json"
-d @payload.json