Emails API

Overview of emails API methods

post
Send Email

https://api.codemash.io/:version/notifications/email
Send an email message.
Request
Response
Request
Path Parameters
version
required
string
A version of the API endpoint.
Headers
Authorization
required
string
Secret API key which belongs to your project or user. Not required if using cookies with a session ID.
x-cm-projectid
required
string
Your project's ID. Can be passed as a query parameter.
Body Parameters
templateId
required
string
The ID of the email template to use.
cultureCode
optional
string
Language code. If you have more than one language set in your project you can use this parameter to specify which language template to use.
forceRequestLanguage
optional
string
If the recipient user has a language set, user language is used to select a template language. This forces us to use cultureCode parameter instead of user's language.
roles
optional
array
Roles of users to be set as recipients.
emails
optional
array
An array of emails to be set as recipients.
users
optional
array
An array of user IDs to be set as recipients.
ccEmails
optional
array
An array of emails to be set as CC recipients.
ccUsers
optional
array
An array of user IDs to be set as CC recipients.
bccEmails
optional
array
An array of emails to be set as BCC recipients.
bccUsers
optional
array
An array of user IDs to be set as BCC recipients.
tokens
optional
object
Key-value pair (string: string) object of custom tokens.
postpone
optional
integer
Amount of milliseconds to postpone sending the email.
respectTimeZone
optional
boolean
If creating a postponed email and the recipient of an email has a timezone set, then postpones according to the recipient's timezone.
Response
200: OK
Returns true if request was successfully processed.
{
"result": true
}
.NET
Node
PHP
.NET
var client = new CodeMashClient(apiKey, projectId);
var emailService = new CodeMashEmailService(client);
var response = await emailService.SendEmailAsync(new SendEmailRequest
{
TemplateId = Guid.Parse("{TEMPLATE_ID}"),
Emails = new [] { "test@email.com" }
});
Node
PHP
use Codemash\CodemashClient;
use Codemash\CodemashEmail;
class CodemashService
{
protected CodemashEmail $codemashEmail;
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
$client = new CodemashClient($secretKey, $projectId);
$this->codemashEmail = new CodemashEmail($client);
}
public function sendEmail()
{
$responseData = $this->codemashEmail->send([
'templateId' => '{TEMPLATE_ID}',
'emails' => [
'test1@example.com',
'test2@example.com',
'test3@example.com',
],
]);
}
}

More about templates and template languages here.