Emails

Emails efficiently handle one-off messages like welcome emails, password resets, and crucial transactions. Requests are prioritized and processed within 30 seconds.

Emails are the simple and efficient way to craft one-off messages such as welcome emails, password resets, or other crucial transactional communications. Requests are instant and queued into a priority queue, with most processed within 30 seconds.

Method Endpoint Description
POST /v1/batch/emails Create Emails

The email model

Shape payloads with sender/recipient metadata, transactional flags, and optional personalizations to inject Liquid variables.

to · string

Recipient email address. Bento will create a user automatically if one does not exist.

from · string

Sender email address. Must match an approved author inside Bento.

subject · string

Email subject line.

html_body · string

HTML body of the email (Liquid supported).

transactional · boolean

Set to `true` to bypass unsubscribe status. Defaults to `false`—use carefully.

personalizations · object

Key/value pairs injected into the HTML via Liquid placeholders.

POST /v1/batch/emails

Create Emails

Queue up to 60 transactional messages per request. Requests enter a high-priority queue and typically send within 30 seconds.

Required attributes

emails[].to · string
Recipient address.
emails[].from · string
Approved author address.
emails[].subject · string
Email subject line.
emails[].html_body · string
HTML content for the email.
emails[].transactional · boolean
Set `true` for transactional sends that ignore unsubscribe status.

Optional attributes

emails[].personalizations · object
Liquid variables injected into the template.

cURL

bash
curl -L -u publishableKey:secretKey \
  -X POST "https://app.bentonow.com/api/v1/batch/emails?site_uuid=ExampleID1234" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  --data-raw '{
    "emails": [
      {
        "to": "test@bentonow.com",
        "from": "jesse@bentonow.com",
        "subject": "Reset Password",
        "html_body": "<p>Here is a link to reset your password ... {{ link }}</p>",
        "transactional": true,
        "personalizations": {
          "link": "https://example.com/test"
        }
      }
    ]
  }'

JavaScript

javascript
const axios = require('axios');

let data = {
  emails: [
    {
      to: 'test@bentonow.com',
      from: 'jesse@bentonow.com',
      subject: 'Reset Password',
      html_body: '<p>Here is a link to reset your password ... {{ link }}</p>',
      transactional: true,
      personalizations: {
        link: 'https://example.com/test'
      }
    }
  ]
};

let config = {
  method: 'post',
  url: 'https://app.bentonow.com/api/v1/batch/emails',
  params: { site_uuid: 'ExampleID1234' },
  auth: {
    username: 'publishableKey',
    password: 'secretKey'
  },
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  data: JSON.stringify(data)
};

axios(config)
  .then((response) => {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch((error) => {
    console.error('Error:', error.response ? error.response.data : error.message);
  });

Node SDK

javascript
bento.V1.Batch.sendTransactionalEmails({
  emails: [
    {
      to: 'test@bentonow.com',
      from: 'jesse@bentonow.com',
      subject: 'Reset Password',
      html_body: '<p>Here is a link to reset your password ... {{ link }}</p>',
      transactional: true,
      personalizations: {
        link: 'https://example.com/test'
      }
    }
  ],
})
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

Python

python
from bento_api import BentoAPI
import os

api = BentoAPI(
  site_uuid=os.getenv('BENTO_SITE_UUID'),
  username=os.getenv('BENTO_PUBLISHABLE_KEY'),
  password=os.getenv('BENTO_SECRET_KEY')
)
emails = [
  {
    "to": "recipient@example.com",
    "from": "sender@example.com",
    "subject": "Reset Password",
    "html_body": "<p>Reset your password ... {{ link }}</p>",
    "transactional": True,
    "personalizations": {"link": "https://example.com/reset"}
  }
]
result = api.batch_create_emails(emails)

C#

csharp
public class EmailExample
{
  private readonly IBentoEmailService _emailService;

  public EmailExample(IBentoEmailService emailService)
  {
    _emailService = emailService;
  }

  public async Task EmailExamples()
  {
    var emailRequest = new EmailRequest(
      From: "sender@example.com",
      Subject: "Welcome to Our App",
      HtmlBody: "<p>Welcome aboard!</p>",
      To: "recipient@example.com"
    );

    var response = await _emailService.SendEmailAsync<dynamic>(emailRequest);
  }
}

Response

Returns how many emails were accepted into the queue.

Response body

json
{
  "result": 1
}

Need the original Markdown? Open raw file