messaging

Send transactional email

Send a transactional email to one or more recipients. Supports HTML and plain text. Use for verification emails, password resets, notifications, and marketing. Attachments and templates can be configured per project. Accepts BearerToken (JWT) or ApiKeyAuth (X-API-Key).

POST/api/messaging/projects/{projectId}/messaging/email

Authentication

Requires JWT
Note
Include your JWT in the Authorization: Bearer YOUR_TOKEN header (user-facing apps, RBAC). View authentication guide →

Path Parameters

NameTypeRequiredDescription
projectIdstringYesProject ID (MongoDB ObjectId) for the messaging project.

Request Body

Recipient(s), subject, HTML and/or plain text body; optional reply-to and attachments.

json
{
  "to": "port back up",
  "subject": "hard drive program",
  "html": "array calculate",
  "text": "hard drive reboot",
  "templateId": "AScVSoKoVzbR28Ps",
  "templateData": {}
}
{
  "to": "port back up",
  "subject": "hard drive program",
  "html": "array calculate",
  "text": "hard drive reboot",
  "templateId": "AScVSoKoVzbR28Ps",
  "templateData": {}
}

SDK setup

Create a client and set credentials (JWT and/or API key) before calling the API. Match the authentication type shown above.

import { MudbaseClient } from "mudbase";

const client = new MudbaseClient();
client.setJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c3JfbW9yZ2FuX2RlIiwiZW1haWwiOiJtb3JnYW4uY2hlbkBub3J0aHdpbmQuZGV2IiwiZXhwIjoxODI1MTI5NjAwfQ.doc_preview_sig");
import { MudbaseClient } from "mudbase";

const client = new MudbaseClient();
client.setJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c3JfbW9yZ2FuX2RlIiwiZW1haWwiOiJtb3JnYW4uY2hlbkBub3J0aHdpbmQuZGV2IiwiZXhwIjoxODI1MTI5NjAwfQ.doc_preview_sig");

Example request

Call this endpoint using the client from SDK setup. Use View HTTP for a raw cURL example.

const result = await client.messaging.sendEmail({
  projectId: "proj_uvbks3H6e3Ef",
  to: "port quantify",
  subject: "circuit compress",
  html: "pixel quantify",
  text: "panel quantify",
  templateId: "yZFj7N3Twvw5Ybm2",
  templateData: "monitor input"
});
const result = await client.messaging.sendEmail({
  projectId: "proj_uvbks3H6e3Ef",
  to: "port quantify",
  subject: "circuit compress",
  html: "pixel quantify",
  text: "panel quantify",
  templateId: "yZFj7N3Twvw5Ybm2",
  templateData: "monitor input"
});

Try It Live

Test this endpoint with your own credentials. Your requests will be sent to the live API.

Use the auth endpoints to obtain a JWT.

No Request Yet

Send a request to see the full inspector

Responses

201Email sent
json
{
  "success": true,
  "data": {
    "_id": "65a1b2c3d4e5f6789012345d",
    "type": "email",
    "status": "sent",
    "to": "user@example.com",
    "sentAt": "2024-01-15T10:00:00.000Z"
  }
}
{
  "success": true,
  "data": {
    "_id": "65a1b2c3d4e5f6789012345d",
    "type": "email",
    "status": "sent",
    "to": "user@example.com",
    "sentAt": "2024-01-15T10:00:00.000Z"
  }
}
400Bad request or validation error.
401Authentication required or invalid token.
403Access denied or insufficient permissions.

Errors

CodeMeaning
400Bad request or validation error.
401Authentication required or invalid token.
403Access denied or insufficient permissions.
Edit this page on GitHub