Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.ub.bitbros.in/llms.txt

Use this file to discover all available pages before exploring further.

Access mail methods via client.mail. This module allows you to send emails using your project’s configured mail provider (e.g. Resend).
Mail operations require a Secret Key (sk_live_...). This module should only be used in server-side environments (Node.js, Edge Functions, etc.). Never call these methods from a browser.

send

Send an email.
send(payload: SendMailPayload): Promise<SendMailResponse>
Parameters (SendMailPayload)
FieldTypeRequiredDescription
tostring | string[]YesRecipient email address(es).
subjectstringTemplate mode: No, Direct mode: YesEmail subject line.
textstringDirect mode: one of text or html is requiredPlain text body.
htmlstringDirect mode: one of text or html is requiredHTML body.
templateIdstringTemplate mode: one of templateId or templateName is requiredMail template ObjectId.
templateNamestringTemplate mode: one of templateId or templateName is requiredTemplate key/name lookup.
variablesRecord<string, unknown>NoVariables used in template rendering.

Payload modes

Use one of these modes:
  • Template mode: templateId or templateName (+ optional variables)
  • Direct mode: subject + at least one of text or html
Do not send both templateId and templateName in the same request.

Template resolution order

When you use templateName, urBackend resolves templates in this order:
  1. Project template (override)
  2. Global/system template
  3. Legacy embedded project template fallback (older projects only)

Placeholder syntax

  • Escaped placeholder: {{name}}
  • Raw placeholder: {{{htmlSnippet}}} (use carefully)
  • Nested variables: {{user.name}}
For URL fields, prefer escaped placeholders like {{appUrl}}. URL-like variables are sanitized to safe http/https URLs before rendering. Returns (SendMailResponse)
FieldTypeDescription
idstring | nullThe message ID from the provider (null if unavailable).
provider"byok" | "default"The provider used for sending.
monthlyUsagenumberTotal emails sent this month.
monthlyLimitnumberYour project’s monthly quota.
Example
// Template mode
const response = await client.mail.send({
  to: 'customer@example.com',
  templateName: 'welcome',
  variables: {
    name: 'Ava',
    projectName: 'Acme',
    appUrl: 'https://acme.com'
  }
});

console.log(response.id);
// Direct mode
const response = await client.mail.send({
  to: 'customer@example.com',
  subject: 'Welcome to urBackend',
  html: '<h1>Hi there!</h1><p>Thanks for joining.</p>'
});

console.log(response.id);