Skip to navigation

Create an automation workflow

View as Markdown

Creates a whole automation workflow (triggers and steps) as a draft, in one call. The workflow is never activated by this call: activate it with PUT /automation/workflows/{workflowId}/status.

Get the available types from GET /automation/catalog and the fields of each type from GET /automation/catalog/{type}/schema. IDs of lists, segments, attributes, templates and senders come from GET /contacts/lists, GET /contacts/segments, GET /contacts/attributes, GET /smtp/templates and GET /senders. To check a body without creating anything, send it to POST /automation/workflows/validate.

When the body is not valid, nothing is created and the 400 lists every problem with its JSON path. Each send_email template is copied for the workflow. The response has the new workflow’s ID, the same warnings as validation (for example list_name_replaced, reentry_recommended or event_data_unavailable), and its definition as GET /automation/workflows/{workflowId} returns it.

Authentication

api-keystring

The API key should be passed in the request headers as api-key for authentication.

OR
AuthorizationBearer

OAuth 2.0 client_credentials (machine-to-machine) grant. Exchange your app’s client_id/client_secret for a short-lived Bearer token.

Request

The whole automation. Unknown fields and values of the wrong JSON type are refused with a 400 that lists them.
namestringRequired<=255 characters
Name of the automation, as shown in Brevo. 1 to 255 characters.
triggerslist of objectsRequired

What starts the automation: 1 to 3 trigger objects, each type at most once. Each object has type plus the fields of that type, at the top level of the object; a field the type does not use is refused. Get the fields with GET /automation/catalog/{type}/schema. Types and their fields: added_to_lists and removed_from_lists (lists: [{"id", "name"}] from GET /contacts/lists; removed_from_lists starts when a contact is removed from one of the lists, not when it is moved from one list to another); order_created, cart_updated, page_visited (no field); manual_trigger (no field: it starts only for the contacts someone adds by hand in the Brevo app once the automation is active; this API cannot add them); custom_event (event_name, one of the event_names that GET /automation/catalog lists for custom_event); contact_match_one_segment (segment: {"id", "name"} from GET /contacts/segments, schedule: {"time": "9:00" (24-hour H:MM or HH:MM), "timezone": "Europe/Paris", "interval": "daily|weekly|monthly|yearly", "day_of_week": 1=Monday ... 7=Sunday (ISO), ...}; it runs on every scheduled date, but without reentry allowed a contact goes through it only once); anniversary (attribute: a date attribute from GET /contacts/attributes, when: same_day|before_the_date|after_the_date, offset: {"duration", "unit": day|week|month} for before or after, schedule: {"time", "timezone"}; it compares day and month only, so it matches every year, and a yearly send, such as a birthday email, needs reentry allowed).

stepslist of objectsRequired

What the automation does, 1 to 50 step objects, one after the other, divided into paths by a percentage_split: {"id": "<your label>", "type": "<step type>", "<step type>": {<fields>}, "next": "<label of the next step>" or null}. id is your own label (letters, digits, _ or -, unique), next is required: another step’s id, or null for the last step of a path. A step follows at most one other step, so paths never join again; every path ends with a step whose next is null; the only paths are the variants of a percentage_split and the only loop is a go_to_step. At least one step must not be a time_delay, and the last step cannot be a time_delay. A delete_contact step must be the last step (next null). The fields of each type go in the object named after the type; get them with GET /automation/catalog/{type}/schema. Types and their object: send_email {"template_id", optional "tags", "frequency_cap", "send_window", "cc", "bcc", "event_data"} (an email template from GET /smtp/templates, or one made with POST /smtp/templates with the senderId of an active sender from GET /senders, which the automation sends from; it is copied for the automation; “tags”: a non-empty array of unique, non-empty strings; “frequency_cap”: true applies the account’s email frequency cap to this email; “cc” and “bcc”: {"contact_attribute"}, the exact name of a text attribute from GET /contacts/attributes that holds an email address, matched as for update_contact_attribute, fixed addresses are not supported; “send_window”: see below); time_delay {"duration": ISO 8601 such as P2D, PT2H30M, P1M, P2W}; add_to_list and remove_from_list {"lists": [{"id", "name"}]} from GET /contacts/lists; update_contact_attribute {"attribute", "action": set|clear, "type": text|boolean|category|date|number|multiple_choice, "value", "index", "date_mode": custom|dynamic, "operation": replace|add|subtract} from GET /contacts/attributes (send the exact name: an exact match wins, a unique case-insensitive match is rewritten to the account’s name, and names that differ only in case are refused with invalid_value listing them; an attribute that Brevo maintains itself, such as LAST_EMAIL_OPEN_DATE, is refused with not_available, while Brevo default attributes such as OPT_IN, DOUBLE_OPT-IN or JOB_TITLE, and user attributes whose name starts with "", are accepted, as in the editor; a category needs both “index”, the option’s value in the attribute’s enumeration, which is what is written to the contact, and “value”, that option’s label, shown in the editor; they must name the same option, otherwise the step is refused with invalid_value; a custom date is YYYY-MM-DD, other formats are refused; a number attribute (the float type of GET /contacts/attributes) needs “operation” with set, and “operation” is refused on any other type: replace writes “value”, a JSON number, and add or subtract change the contact’s current value by it (not negative); a multiple_choice “value” is a non-empty array of option labels from the attribute’s multiCategoryOptions; clear works for both and takes no value); call_webhook {"url", "include_contact_attributes", "include_event_data", "auth", "headers"} (include_event_data when not every trigger is an event is accepted with an event_data_unavailable warning; send auth or headers only when call_webhook in GET /automation/catalog has no unavailable_fields listing them: they are refused with not_available when webhook authentication is not enabled for the account); send_sms {"sender", "content" or "template_id", "sms_type": transactional|marketing, optional "unicode", "send_window", "event_data", "link_tracking" (true shortens and tracks the links of the SMS, as the editor's link shortener does), and for a text SMS "manage_us_compliance", "organisation_prefix", "unsubscribe_instructions"} (“template_id”: an SMS template from GET /transactionalSMS/templates, copied for the automation, instead of “content”; it is not allowed with content or the US compliance fields, and it is refused with not_available when send_sms in GET /automation/catalog lists it in unavailable_fields; warnings: unicode_needed, us_compliance_off and event_data_unavailable, see the send_sms object); delete_contact {} (deletes the contact and its data, which cannot be undone; it must be the last step); blocklist_contact {"scope": transactional|marketing|both, "senders": [sender email addresses]} (“senders” is required with transactional, optional with both and refused with marketing; take them from GET /senders, as they are not checked against the account). start_another_workflow {"workflow_id", optional "step_id"} (moves the contact into another automation of the account, from GET /automation/workflows, at its first step or at “step_id”, a step id of that automation as GET /automation/workflows/{workflowId} returns it; never this automation itself, use go_to_step for that; the target must be active when contacts reach the step, otherwise they skip it: an inactive target gives the warning destination_inactive, and an unknown one is refused with workflow_not_found or workflow_step_not_found); go_to_step {"step"} (jumps back to another step of this automation, by its id or label, not to itself or to another go_to_step; it ends its path, so its own next is null; the engine sends a contact through the same go_to_step at most 5 times; a loop with no time_delay in it gives the warning loop_without_delay); percentage_split {"variants": [{"percentage", "next"}]} (divides contacts at random between 2 or more paths: each variant has a percentage, above 0 with at most one decimal, all of them summing to 100, and “next”, the id of the first step of its path or null to end that path at the split; the split’s own next is null; 2 variants on any plan and up to 10 on Enterprise and Pro plans, more is refused with restricted_by_plan). “send_window” (send_email and send_sms) is {"timezone": IANA such as Europe/Paris, required, and exactly one of "days": [{"day": monday ... sunday, "from": "HH:MM", "to": "HH:MM"}] (each day at most once, two-digit 24-hour times from 00:00 to 23:59, from before to; outside them the message waits for the next allowed time) or "exact_date_time": RFC 3339 such as 2026-12-24T09:00:00+01:00, in the future and at most 2 years ahead}; without it the message is sent as soon as the contact reaches the step. “event_data” (send_email and send_sms, optional) is {"mode": "event_triggered_automation"} (the event that started the run) or {"mode": "latest_event_instance", "source", "event_name"} (the contact’s latest event of that kind, whatever started the run; source and event_name are required and must be an event the account has, as in GET /automation/catalog); it is what the {{ params.* }} variables of the message read. Without it, a step of a workflow whose triggers are all events uses the triggering event (reading the workflow back shows it as event_triggered_automation), and other workflows get no event data. event_triggered_automation with no event trigger is accepted with the warning event_data_unavailable (the variables stay empty).

descriptionstringOptional
Optional internal description of the automation
reentryobjectOptional

Optional. Whether a contact can enter the automation again: {"allowed": true, "delay": "P1D"}. Omitted = each contact runs this workflow at most once, ever. Set allowed:true (optionally delay) for recurring intents like every order/visit/week/year. delay is one ISO 8601 unit (P1M, P2W, P3D, PT5H, PT30M, at most 12 months), the minimum time before the same contact can enter again. Send delay only with allowed: true; it is refused otherwise. Without allowed: true, validate and create return a reentry_recommended warning for each order_created, cart_updated, page_visited, contact_match_one_segment or anniversary trigger.

Response

Draft created
idlongOptional
ID of the new automation. The draft is listed in Brevo under Automations.
statusstringOptional

Status of the new automation. Always a draft (inactive) until it is activated.

warningslist of objectsOptional

Problems that do not block the draft but should be resolved before activating it, the same as validate returns, for example an email template that is inactive or has no sender, a recurring trigger without re-entry, or a list name replaced by the account’s.

definitionobjectOptional

The new workflow, as GET /automation/workflows/{workflowId} returns it, with editor_url

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
424
Failed Dependency Error
503
Service Unavailable Error