Bento API
Search
⌃K

Broadcasts

This endpoint allows you to programmatically create and draft/send broadcasts via the API.
post
https://app.bentonow.com
/api/v1/batch/broadcasts
Batch Import
The broadcasts parameter is an array meaning you can bulk upload up-to 100 broadcasts in a single API call. We strongly recommend testing this in a test site BEFORE doing your production site to ensure no mistake broadcasts are sent.
{
name: "Campaign #1 — Plain Text Example",
subject: "Hello Plain World",
content: "<p>Hi {{ visitor.first_name }}</p>",
type: "plain", // or "fancy" for full HTML control.
// [OPTIONAL] the following is optional and not required to create a broadcast but handy to have up your sleeve if you need it.
from: { email: "[email protected]" }, // requires both email and name — defaults to first author in your account.
inclusive_tags: "lead,mql", // comma seperated.
exclusive_tags: "customers", // comma seperated.
segment_id: "segment_123456789" },
batch_size_per_hour: 1500 // integer
}
A common pattern many teams like to do is use layouts in Bento. You can copy content from those layouts, to this broadcast, by adding a layout_id key and changing the type to layout.
{
name: "Campaign #4 — Layout",
subject: "Hello World",
layout_id: "layout_123456789",
type: "layout",
inclusive_tags: "customer",
}
By default, broadcasts will not send. You will have to go into the platform and approve them yourself. If, on the other hand, you do want to programatically send these do the following:
{
name: "Campaign #5 — Approved and Scheduled!",
subject: "Hello World",
content: "<p>Sending now</p>",
type: "plain",
send_at: "2022-12-13 12:50", // [REQUIRED] Need this to be able to send ASAP.
approved: true
}
There is no option currently to change the batch size or rate.
Below is a short example in Ruby on how you may want to utilize this import to add broadcast into the system. Whether you want to add 1 or many this endpoint should do the trick.
batch_importer.rb
# Find these under your account settings.
publishable_key = "XXXX-XXXX-XXXX-XXXX"
secret_key = "XXXX-XXXX-XXXX-XXXX"
# Find this under you site settings.
site_uuid = "XXXX-XXXX-XXXX-XXXX"
# You can send an array of subscribers.
# MAX 100 per request.
broadcasts = [
{ name: "Campaign #1: Plain Text", subject: "Hello World", content: "<p>Hi</p>", type: "plain",from: { email: "[email protected]" }, inclusive_tags: "lead,mql", exclusive_tags: "customers" },
{ name: "Campaign #2: Full HTML", subject: "Hello World", content: "<p><strong>Hi</strong></p>", type: "fancy" }
]
uri = URI.parse("https://app.bentonow.com/api/v1/batch/broadcasts")
request = Net::HTTP::Post.new(uri)
request.basic_auth(publishable_key, secret_key)
request.body = JSON.dump({site_uuid: site_uuid, broadcasts: broadcasts })
request.content_type = "application/json"
req_options = { use_ssl: uri.scheme == "https", }
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(request)
end
puts JSON.parse(response.body)