With Emailkick, you no longer need to write email HTML within your application code. Emailkick provides a mordern template builder to help you design good looking emails. To send the email to an email address, use the Emailkick Send API. Every email will have it's own unique ID to keep track of the emails.
In this guide we are explaining,
- Prerequisites
- Sending using API
- Working with variables
- Handling API responses
- Understanding Error Codes
Prerequisites for sending your first email with the Emailkick API
Before you can start using the API, you need to do the following:
- Create a Emailkick account.
- Create an API Key and Access ID.
Sending using API
Your API call must have the following components:
- A host. The host for emailkick is https ://api.emailkick.com/mail/send
- Request method set to POST
- A request payload. the email payload is a structured JSON which has data like to, from, templateId and the authorization keys.
A Sample curl request looks like this
curl --location --request POST 'http://api.emailkick.com/mail/send?' \
--header 'Content-Type: application/json' \
--data-raw '{
"APIKEY": "<<YOUR-APIKEY>>",
"ACCESSID": "<<YOUR ACCESSID>>",
"to": "someone@example.com",
"from": "hi@yourdomain.com",
"templateId": "<<TEMPLATE_ID>>",
"variables": {
"full_name": "Elon Musk" ,
"company": "spacex"
}
}'
Understanding the request payload
Request Payload required following elements
- APIKEY Required - Your Emailkick API Key. You get the key from your Emailkick dashboard > Settings > Emailkick API key.
- ACCESSID Required - Your Emailkick Access ID. You get the key from your Emailkick dashboard > Settings > Emailkick API key.
- to Required - The to recipient email address you want to send the email to.
- from Required - Sender email address you are sending from. This email address should be same as the email you registered
with Emailkick and Amazon SES.
- templateId Required - The id of the email design template. You will get the design template ID from your Emailkick dashboard.
- variables - This data is used to replace the variables you have set on the templates. if a variable is defined on the design but not on the API payload, it will be replaced with blank space.
Handling API responses
Once you trigger the Send API, your email will will be added to a queue which will be then processed by SES mail server.
If the payload and secret keys are correct, you will get a success as true result with 200 OK response code.
In case of an error the following table will help you identify the issue
Reponse Code | Error Code | Reason |
---|---|---|
200 | - | Your email is now processing and sending to the recipient ✅ |
401 | EK_0401 | You are unauthorized to process this request. This is because your API Key is wrong |
403 | EK_0403-2 | You are sending to an unsubscribed user. |
404 | EK_0404 | Requested template ID is not found |
404 | EK_0404-1 | Incorrect Access ID / A user of this access ID might not exist |
405 | EK_0405-1 | To email address is missing on your request payload |
405 | EK_0405-2 | From email address is missing on your request payload |
405 | EK_0405-3 | Design Template ID is missing on your request payload |
405 | EK_0405-4 | Access ID (ACCESSID) is missing on your request payload |
405 | EK_0405-5 | API Key (APIKEY) is missing on your request payload |
405 | EK_0405-6 | To email address format is incorrect. Check the validity of the email address |
500 | EK_500 | An issue with Emailkick server. ⚠️ |