Nomsa Guide
  • 👋About Nomsa
  • Campaign Guide - General
    • 🚀How to send a campaign?
  • Campaign Guide - Email
    • 📧Email Campaigns - Basics
      • Scheduled Sending
      • Bounced Emails and Halted Campaigns
      • Email Statistics
      • Formatting your Message Template
      • Variable Fields
      • Unique URL Link per Recipient
      • Pasting Content from Microsoft Word
      • Manage your Unsubscriptions
      • Understanding Unsubscriptions
    • 🔐Sending Password-Protected Emails
      • Tutorial
  • Campaign Guide - SMS
    • 📲SMS Campaigns - Basics
    • SMS Onboarding Overview
      • How do I send SMS
  • Campaign Guide - Telegram
    • 🤖Telegram Campaigns - Basics
      • Add Telegram Bot Token in Nomsa
      • Instructions for Recipient Onboarding
      • Use the Bot in the Campaign
      • Telegram Formatting
      • Telegram Bot Statistics
  • Api Guide
    • 📖Overview
      • API Response Formats
      • Bearer Authentication
      • Generate your API Key
      • Rotate your API Key
    • 📨Programmatic Email API
      • Custom From Address
      • Tracking Email Status
      • Send Email API
        • From Name and From Address
        • CC and BCC
        • Recipient Blacklist
        • Email Tagging and Classification
        • Email Body
          • Embedding Images
            • Linked Images
            • Content-ID Images
        • Attachments
        • Rate Limit
      • Get Email by ID API
      • List Emails API
    • 📬Programmatic SMS API
Powered by GitBook
On this page
  • Overview
  • Send Email by API CURL
  • Request Body
  • Status Code
  1. Api Guide
  2. Programmatic Email API

Send Email API

PreviousTracking Email StatusNextFrom Name and From Address

Last updated 1 year ago

This section of the guide contains information on how our API to send email works. For detailed information, please follow the links at the end of this page.

Overview

This POST endpoint accepts a request body that contains information about the email to be sent. Each successful request to this endpoint will send a single email.

The request body can either be JSON or . The latter is required for .

Send Email by API CURL

curl --location 'https://api.nomsa.gov.kh/v1/transactional/email/send' \
--header 'Authorization: Bearer {{apikey}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "subject": "One time OTP",
    "body": "Hello here is your OTP: 145863 ",
    "recipient": "recipient@gmail.com"
}'

Request Body

{
    "id": "16",
    "from": "Nomsa <donotreply@mail.nomsa.gov.kh>",
    "recipient": "recipient@gmail.com",
    "params": {
        "body": "Hello here is your OTP: 145863 ",
        "from": "Nomsa <donotreply@mail.nomsa.gov.kh>",
        "subject": "One time OTP"
    },
    "attachments_metadata": null,
    "status": "ACCEPTED",
    "error_code": null,
    "error_sub_type": null,
    "accepted_at": "2023-10-04T13:17:34.407Z",
    "sent_at": null,
    "delivered_at": null,
    "opened_at": null,
    "created_at": "2023-10-04T13:17:34.017Z",
    "updated_at": "2023-10-04T13:17:34.407Z",
    "classification": null,
    "tag": null,
    "cc": [],
    "bcc": []
}

The mandatory fields in the request body are as follows:

  1. subject - The subject of the email.

  2. body - The body of the email. For more information, see here.

  3. recipient - The email address of the recipient. Currently, we only support sending email to a single recipient (i.e. cc and bcc are not supported).

The optional fields accepted by the endpoint are as follows:

  1. reply_to - This sets the "Reply-To" email address, which allows sending an email from one email address and telling the recipients to reply to another address. If this field is omitted, it will default to the sender's email address.

See the screenshot below for an example of how some of these fields correspond to what an email recipient sees:

Status Code

In the event of a successful request, the response status code will be 201 Created.

For unsuccessful requests, we will provide an appropriate status code and error message to indicate the reason for the failure.

A (non-exhaustive) list of reasons why a request may fail is as follows:

  1. The request body is invalid because of missing mandatory fields or invalid field values. The error message will provide more details.

  2. Internal server error. Unlike the previous reasons (which have a 4xx error code), the error code for this will be 500. (This is rare and unlikely to happen.)

The user is strongly advised to save the id field (42 in the example), which is a unique identifier for the email. This can be used to check the status of the email via a separate endpoint that will return a similar JSON object. For more information, .

from - The email address of the sender. If this field is omitted, the email will be sent from Nomsa<donotreply@mail.nomsa.gov.kh>. For more information, .

classification - This field accepts one of the following values: URGENT, FOR_ACTION, and FOR_INFO. For more information, .

tag - This fields accept a user-defined string. For more information, .

attachments - This field accepts a list of attachments and is only available via multipart requests. For more information, .

The recipient has been blacklisted. For more information, .

The user has exceeded the rate limit. For more information, .

📨
multipart request
sending attachments
see here
see here
see here
see here
see here
see here
see here