Skip to content

Send API

This API endpoint is in beta

Our REST API offers a simplified way to integrate email capabilities into your application. With a few lines of code, you can leverage our deliverability expertise and infrastructure without needing to use SMTP connections.

Examples

curl -XPOST -H "x-api-key: {mail-credential-user}-{mail-credential-pass}" \ 
https://send.api.sendamatic.net/send \
--data-binary @- <<EOF
{
    "to": [
        "Recipient 1 <[email protected]>",
        "Recipient 2 <[email protected]>"
    ],
    "cc": [
        "CC Recipient 1 <[email protected]>"
    ],
    "bcc": [
        "BCC Recipient 1 <[email protected]>"
    ],
    "sender": "Sender <[email protected]>",
    "subject": "Hello world",
    "text_body": "This is a test email",
    "html_body": "<b>This is a test email</b>",
    "headers": [
        {
            "header": "Reply-To",
            "value": "Reply-To User <[email protected]>"
        }
    ],
    "attachments": [
        {
            "filename": "test.txt",
            "data": "VGhpcyBpcyBhIHRlc3QgZmlsZQ==",
            "mimetype": "text/plain"
        }]
}
EOF
<?php
$data = [
    "to" => ["Recipient 1 <[email protected]>"],
    "sender" => "Sender <[email protected]>",
    "subject" => "Hello world",
    "text_body": "This is a test email"
];

$headers = [
    'Content-Type: application/json',
    'x-api-key: {mail-credential-user}-{mail-credential-pass}'
];

$ch = curl_init("https://send.api.sendamatic.net/send");

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
curl_close($ch);
import requests

payload = {"to": [
        "Recipient <[email protected]>"
    ],
    "sender": "Sender <[email protected]>",
    "subject": "Hello world",
    "text_body": "This is a test"
    }

headers = {"x-api-key": "{mail-credential-user}-{mail-credential-pass}"}

r = requests.post("https://send.api.sendamatic.net/send", json=payload, headers=headers)    

Output

HTTP status: 200

An dictionary will be returned with an item for each recipient, along with status code and message ID.

{
    "Recipient <[email protected]>": [
        250,
        "Message Queued (111111-2222-3333-4444-0123456789AB.1)"
    ]
}

A json-schema representation of acceptable JSON data

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "default": {},
    "title": "Sendamatic email send api",
    "required": [
        "to",
        "sender",
        "subject"
    ],
    "anyOf": [
        {
            "required": ["text_body"]
        },
        {
            "required": ["html_body"]
        }
    ],
    "properties": {
        "to": {
            "type": "array",
            "title": "An array of recipients",
            "maxItems": 255,
            "items": {
                "type": "string",
                "format": "email",
                "title": "Recipient mailbox"
            },
            "examples": [
                [
                    "Recipient <[email protected]>"
                ]
            ]
        },
        "cc": {
            "type": "array",
            "title": "An array of CC recipients",
            "maxItems": 255,
            "items": {
                "type": "string",
                "format": "email",
                "title": "Recipient mailbox"
            },
            "examples": [
                [
                    "Recipient <[email protected]>"
                ]
            ]
        },
        "bcc": {
            "type": "array",
            "title": "An array of BCC recipients",
            "maxItems": 255,
            "items": {
                "type": "string",
                "format": "email",
                "title": "Recipient mailbox"
            },
            "examples": [
                [
                    "Recipient <[email protected]>"
                ]
            ]
        },
        "sender": {
            "type": "string",
            "format": "email",
            "title": "The sender address",
            "examples": [
                "Sender <[email protected]>"
            ]
        },
        "subject": {
            "type": "string",
            "minLength": 1,
            "title": "The email subject",
            "examples": [
                "Hello world"
            ]
        },
        "text_body": {
            "type": "string",
            "minLength": 1,
            "title": "The text part of the email",
            "examples": [
                "This is a test email"
            ]
        },
        "html_body": {
            "type": "string",
            "minLength": 1,
            "title": "The html part of the email",
            "examples": [
                "<b>This is a test email</b>"
            ]
        },
        "headers": {
            "type": "array",
            "default": [],
            "title": "Optional additional headers to send with the email",
            "items": {
                "type": "object",
                "required": [
                    "header",
                    "value"
                ],
                "properties": {
                    "header": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 512,
                        "title": "Header name"
                    },
                    "value": {
                        "type": "string",
                        "minLength": 1,
                        "title": "Header value"
                    }
                }
            },
            "examples": [
                [{
                    "header": "Reply-To",
                    "value": "Reply-To User <[email protected]>"
                }]
            ]
        },
        "attachments": {
            "type": "array",
            "default": [],
            "title": "Attachments",
            "items": {
                "type": "object",
                "required": [
                    "filename",
                    "data",
                    "mimetype"
                ],
                "properties": {
                    "filename": {
                        "type": "string",
                        "minLength": 1,
                        "title": "The file name"
                    },
                    "data": {
                        "type": "string",
                        "minLength": 1,
                        "title": "Base64 encoded file data"
                    },
                    "mimetype": {
                        "type": "string",
                        "minLength": 1,
                        "title": "The file mimetype",
                        "examples": [
                            "application/pdf",
                            "text/plain"
                        ]
                    }
                }
            },
            "examples": [
                [
                    {
                        "filename": "test.pdf",
                        "data": "--base64-data--",
                        "mimetype": "application/pdf"
                    },
                    {
                        "filename": "test.txt",
                        "data": "--base64-data--",
                        "mimetype": "text/plain"
                    }
                ]
            ]
        }
    },
    "examples": [{
        "to": [
            "Recipient <[email protected]>"
        ],
        "cc": [
            "CC recipient <[email protected]>"
        ],
        "bcc": [
            "BCC recipient <[email protected]>"
        ],
        "sender": "Sender <[email protected]>",
        "subject": "Hello world",
        "text_body": "This is a test email",
        "html_body": "<b>This is a test email</b>",
        "headers": [{
            "header": "Reply-To",
            "value": "Reply-To User <[email protected]>"
        }],
        "attachments": [
            {
                "filename": "test.txt",
                "data": "VGhpcyBpcyBhIHRlc3QgZmlsZQ==",
                "mimetype": "text/plain"
            }]
    }]
}

Notes

Specifying cc values will overwrite any supplied CC header