Brevo drag and drop editor (block editor) - how to create templates via API

Workaround: Brevo Templates Created via API Don’t Have Drag & Drop Editor Available

Brevo allows to create templates using their API. This is useful when creating templates in bulk. Unfortunately Brevo API development has been kind of abandoned (since they migrated their code from SendInBlue) and it misses some features.

One of the features it misses is to create templates that later allow use of their block editor (drag and drop editor) in Brevo. Instead, any templates created using API only allow rich text editor and HTML editor that not only feel outdated, but are inferior.

The issue – Brevo templates created using API

Only simple and HTML editor are allowed, e.g. Brevo admin app URLs such as:

  • https://app.brevo.com/editor/classic/html/XX
  • https://app.brevo.com/editor/classic/rich-text/XX

When trying to edit template created in bulk via API using their block editor:

https://app.brevo.com/editor/newsletters/XX

the drag & drop editor crashes and the response given is this error:

GET https://editor-api.brevo.com/editor-api/newsletters/32?editorType=6:
{"message":"Campaign is not supporting editor type 6"}

How does one create template that is able to use drag&drop editor? Well, it is impossible using their API.

Drag & drop templates (using blocks) created via Brevo web admin have this param:
"doiTemplate": true

Templates created via API have this param:
"doiTemplate": false

However, it is impossible to force this param using PUT or POST set to true and it does not change anything as it is ignored.

Workaround – create drag&drop templates in bulk using CURL

For anyone bumping into this: this is not resolvable using API that Brevo offers.

Only way to create templates in bulk with support for the drag&drop (block) editor is to clone and hijack requests the Brevo web admin app uses and run it via CURL.

You can use the following CURL request as an example that I have heavily anonymized. I recommend you to copy yours from Network monitor in your browser (developer tools) in full to obtain real-time up-to-date request including valid authentication tokens:

curl 'https://my.brevo.com/camp/save-campaign' --compressed -X POST -H 'User-Agent: XXXXXXXXX' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br, zstd' -H 'Referer: https://my.brevo.com/camp/template/setup' -H 'Content-Type: application/x-www-form-urlencoded' -H 'X-Requested-With: XMLHttpRequest' -H 'Origin: https://my.brevo.com' -H 'DNT: 1' -H 'Sec-GPC: 1' -H 'Connection: keep-alive' -H 'Cookie: tmpl_lang=en; country=US; first_referrer=https://account-app.brevo.com/; did=XXXXXXX; keen_anonymous_id=XXXXXX; anonymous_id=XXXXXXX; _plantrack=XXXXXXX; fs_uid=XXXXXXX; keen={%22uuid%22:XXXXXXXXinitialReferrer%22:%22https://app.brevo.com/%22}; cf_clearance=XXXXXXX; _zitok=XXXXXX; _reb2buid=XXXXXXXX; pscd=get.brevo.com; _gcl_au=XXXXXXXX; auth=XXXXXXXXX; loggedin=true; selected_app=campaigns; trk_usr_vld_trk=1; userTimeZone=XXXXXXX; contact_listpage_users=[3%2C1]; ACCOUNTSESSID=XXXXXX; exp=%7B%22SSC%22%3A%7B%22variant%22%3A%22V1%22%2C%22traffic%22%3A%22100%7C0%22%7D%7D; __ssid=XXXXXXXX; fs_lua=XXXXXXXX' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-origin' -H 'Priority: u=0' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' --data-raw 'camp_name=admin_voucher_sk&fromemail=XXXXXXXX&fromfield=XXXXXXXX&sender=1&warmup_enable=0&increase_rate=&initial_quota=&tofield=&attachmentfile=&form_name=Default+unsubscribe+page+-+XXXXXXXXXX&is_new_page=true&replyto=&header=&footer=&utm_campaign=&mirror_active=0&ga_active=1&utm_id_active=1&inline_images=0&category=&type=template&step=setup&id=&ab_testing=false&update_form=&preheader=&subject=XXXXX&token=XXXXXXX'

Copy this request as cURL using context menu and paste it to your favorite editor.

Change any template API params you need such as the name of the template:

camp_name=[template_name]

Paste the changed CURL request into command line and submit. You will receive the template ID back after success.

This successfully creates Brevo SMTP templates that support drag&drop / block editor. You can automate this, so you can create Brevo templates in bulk (not using their inferior API).


Have a comment? Join discussion on Mastodon as a reply to: @dusoft@fosstodon.org