POST
/
webhook
/
mail
/
send
cURL
curl --request POST \
  --url https://webhook.cocoonmail.com/webhook/mail/send \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "email_content": "<h1>Hello John,</h1><p>Welcome to our service!</p>",
  "sender": "sender@example.com",
  "subject": "Hello from us",
  "to": [
    {
      "email": "recipient@example.com",
      "first_name": "John"
    }
  ],
  "tags": [
    "tag1"
  ]
}
'
{
    "success": true,
    "failed_recipients": [],
    "report": [
        {
            "to": "email_address",
            "message_id": "unique_id"
        },
        {
            "to": "email_address",
            "message_id": "unique_id"
        },
    ],
    "quotas": {
        "MAX_SEND_MAIL_PER_DAY": {
            "limit": "usage",
            "usage": "usage"
        },
        "MAX_SEND_MAIL_PER_MONTH_TRANSACTIONAL": {
            "limit": "usage",
            "usage": "usage"
        }
    },
    "sender": "email_address",
    "message": "Transactional mails sent successfully"
}

Send transactional mail

Use this endpoint to send transactional email.

Request Requirements

You must use one of the following options to send email. Each option has its own required fields:
  • Option 1: Send raw email content.
    • Required fields:
      • email_content: The rich HTML or text content of the email.
      • sender: Email address of the sender.
      • subject: Subject line of the email.
      • to: The recipient’s email address.
  • Option 2: Use a custom template.
    • Required fields:
      • template_uuid: The UUID of the custom template.
      • sender: Email address of the sender.
      • subject: Subject line of the email.
      • to: The recipient’s email address.
  • Option 3: Use a predefined transactional template.
    • Required fields:
      • transactional_id: The ID of the transactional template to use.
      • to: The recipient’s email address.

Example Payloads

Send an email with custom HTML or text content.
{
    "email_content": "<h1>Hello John,</h1><p>Welcome to our service!</p>",
    "sender": "sender@example.com",
    "subject": "Hello from us",
    "to": [
        {
            "email": "recipient@example.com"
        }
    ],
    "tags": ["tag1"]
}

Response fields

PropertyDescription
201Transactional mails sent successfully
400Bad request
401Request authentication
403Too many bad requests. Temparory block
406Missing accept header. For example : Accept: application/json
429Too many requests/ Rate limit exceeded
500Internal server error
{
    "success": true,
    "failed_recipients": [],
    "report": [
        {
            "to": "email_address",
            "message_id": "unique_id"
        },
        {
            "to": "email_address",
            "message_id": "unique_id"
        },
    ],
    "quotas": {
        "MAX_SEND_MAIL_PER_DAY": {
            "limit": "usage",
            "usage": "usage"
        },
        "MAX_SEND_MAIL_PER_MONTH_TRANSACTIONAL": {
            "limit": "usage",
            "usage": "usage"
        }
    },
    "sender": "email_address",
    "message": "Transactional mails sent successfully"
}

Authorizations

Authorization
string
header
required

Use your API key with the 'Bearer ' prefix

Body

application/json

API payload when email content is provided.

email_content
string
required

Email content

Example:

"<h1>Hello John,</h1><p>Welcome to our service!</p>"

sender
string
required

From email address

Example:

"sender@example.com"

subject
string
required

Email subject

Example:

"Hello from us"

to
object[]
required

Email address of the recipient.

reply_to
string

Valid email address.

parameterized_variables
object

Object containing key-value pairs to replace merge tags in the email template

attachments
object[]

Attachment

attachments_remote
object[]

Remote attachments

add_recipient_to_contact
boolean
default:false

Add recipient to contact

scheduled_at
string<date-time>

Date and time when the email should be sent (ISO 8601 format)

Example:

"2023-12-31T23:59:59Z"

allow_click_tracking
boolean
default:true

Enable tracking of link clicks within the email.

allow_open_tracking
boolean
default:true

Enable tracking of email opens using tracking pixels.

ignore_contact_bounce
boolean
default:true

Send emails even to addresses that previously bounced.

ignore_contact_unsubscribe
boolean
default:true

Send emails to recipients even if they have unsubscribed.

enable_view_in_browser
boolean
default:true

Enable view in browser

include_unsubscribe
boolean
default:false

Include unsubscribe link in the email footer

cc
array

Email address of the CC recipient.

tags
string[]

Array of strings to tag the message with.

Example:
["tag1", "tag2"]

Response

Email sent successfully.

success
boolean
Example:

true

failed_recipients
string[]
Example:
[]
report
object[]
quotas
object
sender
string
Example:

"sender@example.com"

message
string
Example:

"Transactional mails sent successfully"