Автоматизации
Письма и шаги, которые выполняются сами для каждого контакта, и события, которые их запускают.
Инструменты автоматизаций
| Инструмент | Что делает |
|---|---|
| listAutomations | Автоматизации рабочего пространства, сначала недавно изменённые, с их статусом, тем, что запускает каждую, и числом контактов в ней. |
| getAutomation | Одна автоматизация целиком: её статус, настройки и цифры, что не так с её черновиком и определение черновика в виде JSON. includePublished добавляет работающую версию. |
| listAutomationStarters | Готовые автоматизации, с которых может начинаться новая, каждая со своим определением. |
| createAutomation | Создать черновик из заготовки, из определения, записанного в JSON, или пустой, с любыми настройками. Ничего не выполняется, пока он не опубликован. |
| updateAutomation | Изменить имя и настройки автоматизации, которые применяются сразу, или заменить определение её черновика. Активная автоматизация продолжает выполнять опубликованную версию. |
| deleteAutomation | Навсегда удалить автоматизацию вместе с её версиями, участиями и цифрами. Контакты в ней останавливаются сразу. |
| publishAutomation | Сделать черновик работающей версией и включить автоматизацию. Незавершённый черновик отклоняется со всеми проблемами, которые ему мешают. Нужен ещё и emails:send. |
| pauseAutomation | Остановить активную автоматизацию. Никто новый не входит, а все, кто в ней, остаются на своих местах. |
| resumeAutomation | Снова включить приостановленную автоматизацию с той версией, которая работала. Нужен ещё и emails:send. |
| archiveAutomation | Навсегда вывести автоматизацию из работы и сохранить её историю. Все, кто в ней, выходят. |
| duplicateAutomation | Скопировать автоматизацию в новый черновик без её версий, контактов и цифр. |
| sendAutomationTest | Отправить письмо одного шага черновика себе или на один адрес. Нужен ещё и emails:send. |
| listAutomationVersions | Опубликованные версии, сначала новые, и какая из них работает. includeDefinitions добавляет определение каждой. |
| restoreAutomationVersion | Скопировать более раннюю версию обратно в черновик. До следующей публикации ничего из работающего не меняется. |
| getAutomationStats | Контакты, которые вошли, находятся внутри сейчас, завершили и вышли, а также письма, которые отправлены, доставлены, открыты и по которым кликнули за окно, всего и по каждому шагу. |
| listAutomationEnrollments | Контакты, которые находятся в автоматизации или были в ней, по странице за раз, с шагом, на котором находится каждый, и тем, как всё закончилось. Фильтруйте по статусу, шагу или части адреса. |
| getAutomationEnrollment | Путь одного контакта через автоматизацию: что каждый шаг сделал для него, сначала старые. |
| enrollInAutomation | Поместить один контакт на первый шаг активной автоматизации, что бы её обычно ни запускало. |
| removeFromAutomation | Сразу убрать один контакт из автоматизации. |
| sendContactEvent | Записать, что с контактом что-то произошло. Это запускает активные автоматизации, триггер которых называет это событие, и завершает ожидания, которые его дожидались. |
| sendContactEvents | Записать до 100 событий за один вызов. Сбой одного не останавливает остальные. |
| listContactEventNames | Имена событий, которые рабочее пространство записало за последние 90 дней. |
| listContactEvents | События, записанные для одного контакта, сначала новые, по странице за раз. |
Для чтения нужен automations:read, а для любого изменения automations:write. Публикация, возобновление и отправка теста требуют ещё и emails:send, потому что после этого автоматизация отправляет почту от имени того, кто её опубликовал. Для отправки события нужен contacts:write, для чтения событий контакта contacts:read, а для listContactEventNames нужен automations:read. Клиент, действующий от имени участника, видит только автоматизации, созданные этим участником, и контакты, которые этот участник добавил.
Некоторые инструменты этого сервера вносят изменение, которое REST API защищает кодом подтверждения, и спрашивают тот же код. Пока клиент не подтвердил код за последние 60 минут и человек не выбрал для него «Разрешить изменения на 60 минут» в разделе «Аккаунт → Подключённые приложения», такой инструмент отвечает результатом, который начинается с Refused (step_up_required):, и ничего не меняет. emptyAudience никогда не спрашивает код. Страница «Аутентификация» в API перечисляет все инструменты, которые спрашивают код, и показывает, как запросить код и подтвердить его.
Инструменты применяют те же правила и отказы, что и REST API, а страницы /automations и /events справочника API описывают каждое поле. Определение передаётся целиком в виде JSON: прочитайте его через getAutomation, измените и передайте всё обратно в updateAutomation.
Справочник
listAutomationsgetAutomationlistAutomationStarterscreateAutomationupdateAutomationdeleteAutomationpublishAutomationpauseAutomationresumeAutomationarchiveAutomationduplicateAutomationsendAutomationTestlistAutomationVersionsrestoreAutomationVersiongetAutomationStatslistAutomationEnrollmentsgetAutomationEnrollmentenrollInAutomationremoveFromAutomationsendContactEventsendContactEventslistContactEventNameslistContactEvents
listAutomations
List the automations in this workspace, the most recently changed first: name, id, status (draft, live, paused or archived), what starts each one, its steps and how many contacts are in it now, completed it or left early. Use it to find an automation by name before reading or changing it. One page at a time: when more follow, the last line gives a cursor to pass back.
Входные данные
statusstring- Одно из
"draft""live""paused""archived" limitinteger- Не меньше 1Не больше 100
cursorstring- От 1 до 64 символов
Также доступно в
- API
GET /automations- TypeScript
automations.list()automations.listAll()automations.iterate()- Python
automations.list()automations.list_all()automations.iterate()- Ruby
automations.listautomations.list_allautomations.iterate- PHP
automations->listautomations->listAllautomations->iterate- Go
Automations.ListAutomations.ListAllAutomations.Iterate- Java
automations().listautomations().listAllautomations().iterate- C#
Automations.ListAsyncAutomations.ListAllAsyncAutomations.IterateAsync
getAutomation
Read one automation: its status, settings, numbers, what is wrong with its draft, and the draft definition (trigger and steps) as JSON, to change and pass back to updateAutomation. includePublished adds the definition of the version that is running, which differs from the draft while there are unpublished changes.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символовincludePublishedboolean- По умолчанию
false
Также доступно в
listAutomationStarters
The ready-made automations a new one can begin from, such as a welcome series or a birthday note: slug, name, what each is for and its definition as JSON. Pass a slug to createAutomation as starter. A starter leaves the audience, the templates and the from address empty to fill in.
Входные данные
Не принимает входных данных.
Также доступно в
createAutomation
Create an automation as a draft: from a starter (listAutomationStarters names them), from a definition written out as JSON, or empty. Nothing runs until publishAutomation. The answer lists what the draft still needs before it can be published, such as a template or a from address for each email. Find audiences with listAudiences, templates with listTemplates and forms with listForms.
Входные данные
namestringОбязательноA short name for the automation. Contacts never see it.
От 1 до 120 символовdescriptionstringOne line about what it is for.
До 500 символовstarterstring- От 1 до 64 символов
definitionRecord<string, any> | stringThe trigger and steps as JSON: {"trigger": {...}, "entry": "<key of the first step>", "steps": [...]}. Triggers: {"kind": "audience_joined", "audienceId", "includeImported": false}, {"kind": "form_submitted", "formId"}, {"kind": "event", "eventName", "filters": []}, {"kind": "date", "field": "birthday" or "joined", "audienceId", "offsetDays": 0} and {"kind": "manual"}. Every step has a unique key of 3 to 24 lowercase letters and digits starting with a letter, and points at the next step by key in next, or null to end the path. Steps: {"kind": "send_email", "key", "next", "templateId", "templateVersion": null, "from": {"email", "name"}, "replyTo": null, "subject": null, "props": {}}, {"kind": "wait", "key", "next", "wait": {"mode": "duration", "amount": 3, "unit": "days"}}, {"kind": "branch", "key", "condition": {"kind": "email_clicked", "stepKey"}, "yes", "no"}, {"kind": "add_to_audience" or "remove_from_audience", "key", "next", "audienceId"}, {"kind": "update_field", "key", "next", "field", "value": {"source": "static", "value"}}, {"kind": "webhook", "key", "next", "endpointId"} and {"kind": "exit", "key"}. A wait can also be {"mode": "until", "weekdays": [1], "hour": 9, "minute": 0} or {"mode": "event", "eventName", "timeout": {"amount": 7, "unit": "days"}}. Conditions: email_opened and email_clicked with stepKey, in_audience with audienceId, field with field, operator and value, and event with eventName and withinDays. A props value is {"source": "static", "value"}, {"source": "contact", "field"} or {"source": "event", "path"}. Paths never join or loop. getAutomation shows a saved definition in this shape, and listAutomationStarters has ready-made ones.
settingsRecord<string, any> | stringHow it runs, as JSON with any of: timezone (an IANA zone such as Europe/London), sendWindow ({"days": [1, 2, 3, 4, 5], "startMinute": 540, "endMinute": 1020} or null for any time), reentryDays (days after finishing before a contact may enter again, or null for once only), exitOnLeave (true takes a contact out when they leave the audience that started it) and listAudienceId (the audience unsubscribes are recorded in).
Также доступно в
updateAutomation
Change an automation. Its name, description and settings apply at once. definition replaces the whole draft, so start from getAutomation, change the JSON and pass all of it back. A live automation keeps running its published version until publishAutomation, and contacts already in it stay on the version they entered on. Pass only what changes.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символовnamestring- От 1 до 120 символов
descriptionstring- Может быть nullДо 500 символов
definitionRecord<string, any> | stringThe trigger and steps as JSON: {"trigger": {...}, "entry": "<key of the first step>", "steps": [...]}. Triggers: {"kind": "audience_joined", "audienceId", "includeImported": false}, {"kind": "form_submitted", "formId"}, {"kind": "event", "eventName", "filters": []}, {"kind": "date", "field": "birthday" or "joined", "audienceId", "offsetDays": 0} and {"kind": "manual"}. Every step has a unique key of 3 to 24 lowercase letters and digits starting with a letter, and points at the next step by key in next, or null to end the path. Steps: {"kind": "send_email", "key", "next", "templateId", "templateVersion": null, "from": {"email", "name"}, "replyTo": null, "subject": null, "props": {}}, {"kind": "wait", "key", "next", "wait": {"mode": "duration", "amount": 3, "unit": "days"}}, {"kind": "branch", "key", "condition": {"kind": "email_clicked", "stepKey"}, "yes", "no"}, {"kind": "add_to_audience" or "remove_from_audience", "key", "next", "audienceId"}, {"kind": "update_field", "key", "next", "field", "value": {"source": "static", "value"}}, {"kind": "webhook", "key", "next", "endpointId"} and {"kind": "exit", "key"}. A wait can also be {"mode": "until", "weekdays": [1], "hour": 9, "minute": 0} or {"mode": "event", "eventName", "timeout": {"amount": 7, "unit": "days"}}. Conditions: email_opened and email_clicked with stepKey, in_audience with audienceId, field with field, operator and value, and event with eventName and withinDays. A props value is {"source": "static", "value"}, {"source": "contact", "field"} or {"source": "event", "path"}. Paths never join or loop. getAutomation shows a saved definition in this shape, and listAutomationStarters has ready-made ones.
settingsRecord<string, any> | stringHow it runs, as JSON with any of: timezone (an IANA zone such as Europe/London), sendWindow ({"days": [1, 2, 3, 4, 5], "startMinute": 540, "endMinute": 1020} or null for any time), reentryDays (days after finishing before a contact may enter again, or null for once only), exitOnLeave (true takes a contact out when they leave the audience that started it) and listAudienceId (the audience unsubscribes are recorded in).
expectedUpdatedAtstringThe Updated time getAutomation gave. When somebody saved the automation since, the change is refused instead of written over theirs.
Форматdate-time
Также доступно в
deleteAutomation
Delete an automation for good, with its versions, its enrollments and its numbers. Contacts in it stop at once. The emails it already sent stay. It cannot be undone: to retire one and keep its history, use archiveAutomation.
- Запрашивает код подтверждения
DELETE /automations/{id}
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символов
Также доступно в
publishAutomation
Publish an automation: its draft becomes the version that runs and it goes live, so its trigger starts putting contacts in and its emails start going out. Use it for a first publish and to put later changes to work. The draft has to be complete, and a refusal lists every problem that blocks it. Contacts already in it stay on the version they entered on.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символов
Также доступно в
pauseAutomation
Pause a live automation. Nobody new enters, and everyone in it stays where they are and moves on when it is resumed with resumeAutomation.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символов
Также доступно в
resumeAutomation
Turn a paused automation back on with the version it was running, without publishing the draft. Contacts that were held move on and its emails go out again. One that was paused because something it needs went away stays paused until that is fixed, and the refusal says what.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символов
Также доступно в
archiveAutomation
Retire an automation for good and keep its history. Everyone in it leaves, nobody enters again and it can no longer be changed, published or resumed. Its versions, enrollments and numbers stay readable. To stop one for a while, use pauseAutomation.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символов
Также доступно в
duplicateAutomation
Copy an automation into a new draft with "(copy)" after its name: the same draft definition and settings, and none of its versions, contacts or numbers.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символов
Также доступно в
sendAutomationTest
Send the email of one step of the draft to one address, to read it before publishing. It goes to the user's own account address unless to names another. Contact values come from a sample contact, the subject starts with [Test], and nobody is enrolled. It counts toward the monthly sends.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символовstepKeystringОбязательноThe key of the email step, from the definition getAutomation returns.
От 1 до 64 символовtostringWhere the test goes, when not to the user themselves.
До 320 символовФорматemail
Также доступно в
listAutomationVersions
The published versions of an automation, the newest first: number, when it was published and whether it is the one running. includeDefinitions adds each definition as JSON. restoreAutomationVersion copies one back into the draft.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символовincludeDefinitionsboolean- По умолчанию
false
Также доступно в
restoreAutomationVersion
Copy the definition of an earlier version back into the draft, replacing what the draft holds. Nothing that is running changes until publishAutomation.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символовversionintegerОбязательноThe version number, from listAutomationVersions.
Не меньше 1
Также доступно в
getAutomationStats
How one automation did over a window, 30 days by default: contacts that entered, are in it now, completed it or left early, emails sent, delivered, opened, clicked, bounced and marked as spam, and unsubscribes, in total and for each step. Opens are a floor, because many mail apps hide them. includeDaily adds a line for each day.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символовsincestringWhere the window starts, as an ISO 8601 instant.
Форматdate-timeuntilstringWhere the window ends, as an ISO 8601 instant. Left out, now.
Форматdate-timeincludeDailyboolean- По умолчанию
false
Также доступно в
listAutomationEnrollments
The contacts that are in an automation or have been, the most recent entry first: which step each is at, what they are waiting for, what holds a step that is due, when they move next and how it ended. Narrow it by status, by step or by a piece of the address or name. One page at a time: when more follow, the last line gives a cursor.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символовstatusstring- Одно из
"active""completed""exited" stepKeystring- От 1 до 64 символов
qstring- До 200 символов
limitinteger- Не меньше 1Не больше 200
cursorstring- От 1 до 64 символов
Также доступно в
- API
GET /automations/{id}/enrollments- TypeScript
automations.listEnrollments()automations.listAllEnrollments()automations.iterateEnrollments()- Python
automations.list_enrollments()automations.list_all_enrollments()automations.iterate_enrollments()- Ruby
automations.list_enrollmentsautomations.list_all_enrollmentsautomations.iterate_enrollments- PHP
automations->listEnrollmentsautomations->listAllEnrollmentsautomations->iterateEnrollments- Go
Automations.ListEnrollmentsAutomations.ListAllEnrollmentsAutomations.IterateEnrollments- Java
automations().listEnrollmentsautomations().listAllEnrollmentsautomations().iterateEnrollments- C#
Automations.ListEnrollmentsAsyncAutomations.ListAllEnrollmentsAsyncAutomations.IterateEnrollmentsAsync
getAutomationEnrollment
One contact's way through an automation: where they are, and what each step did for them, oldest first, such as an email sent, a wait, a yes or no at a branch, or why a step was skipped or failed.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символовenrollmentIdstringОбязательноThe enrollment, by id (aen_...), from listAutomationEnrollments.
От 1 до 64 символов
Также доступно в
enrollInAutomation
Put one contact into a live automation at its first step, whatever starts it normally, so its emails start going to them. The contact has to exist already. A contact is in an automation once at a time, and an address that is suppressed or unsubscribed is refused.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символовemailstringОбязательноThe contact to enroll, by email address.
До 320 символовФорматemaildataRecord<string, any>Values the steps read wherever a value comes from the event, such as an order number. At most 50 keys and 4 KB of JSON.
Также доступно в
removeFromAutomation
Take one contact out of an automation at once, by the id of their enrollment from listAutomationEnrollments. They get nothing more from it, and stay in the contacts and in their audiences.
Входные данные
idstringОбязательноThe automation, by id (aut_...). listAutomations finds it by name.
От 1 до 64 символовenrollmentIdstringОбязательноThe enrollment, by id (aen_...), from listAutomationEnrollments.
От 1 до 64 символов
Также доступно в
sendContactEvent
Record that something happened to one contact, such as order.placed or trial.started. Every live automation that starts on that event name takes the contact in, so its emails start going to them, and a wait step holding out for the name moves on. The answer says which automations it started. Events are kept for 90 days.
Входные данные
namestringОбязательноWhat happened, such as order.placed: letters, digits, dots, colons, dashes and underscores. Names are matched exactly, case included.
От 1 до 100 символовemailstringОбязательноThe contact the event is about, by email address.
До 320 символовФорматemailpropertiesRecord<string, any>Details of the event as a JSON object, at most 50 keys and 4 KB. An event trigger can filter on them and steps can use them.
occurredAtstringWhen it happened, as an ISO 8601 instant. Left out, it is now. Not in the future, and at most 90 days ago.
Форматdate-timecreateContactbooleantrue adds the address to the contacts when nobody has it yet.
contactNamestringThe name to give a contact that createContact adds.
До 200 символов
sendContactEvents
Record up to 100 events in one call, each handled as sendContactEvent handles one, in order. One event failing does not stop the rest: the answer says which were recorded, what each started, and why any was not.
Входные данные
eventsobject[]Обязательно- От 1 до 100 элементов
namestringОбязательноWhat happened, such as order.placed: letters, digits, dots, colons, dashes and underscores. Names are matched exactly, case included.
От 1 до 100 символовemailstringОбязательноThe contact the event is about, by email address.
До 320 символовФорматemailpropertiesRecord<string, any>Details of the event as a JSON object, at most 50 keys and 4 KB. An event trigger can filter on them and steps can use them.
occurredAtstringWhen it happened, as an ISO 8601 instant. Left out, it is now. Not in the future, and at most 90 days ago.
Форматdate-timecreateContactbooleantrue adds the address to the contacts when nobody has it yet.
contactNamestringThe name to give a contact that createContact adds.
До 200 символов
listContactEventNames
The names of the events this workspace has recorded in the last 90 days, to choose the event that starts an automation or that a wait step holds out for.
Входные данные
Не принимает входных данных.
Также доступно в
listContactEvents
The events recorded for one contact in the last 90 days, the most recent first: name, when it happened and its properties. Narrow it to one event name. One page at a time: when more follow, the last line gives a cursor.
Входные данные
emailstringОбязательноThe contact the event is about, by email address.
От 3 до 320 символовnamestring- От 1 до 100 символов
limitinteger- Не меньше 1Не больше 200
cursorstring- От 1 до 64 символов
Также доступно в
- API
GET /contacts/{email}/events- TypeScript
contacts.listEvents()contacts.listAllEvents()contacts.iterateEvents()- Python
contacts.list_events()contacts.list_all_events()contacts.iterate_events()- Ruby
contacts.list_eventscontacts.list_all_eventscontacts.iterate_events- PHP
contacts->listEventscontacts->listAllEventscontacts->iterateEvents- Go
Contacts.ListEventsContacts.ListAllEventsContacts.IterateEvents- Java
contacts().listEventscontacts().listAllEventscontacts().iterateEvents- C#
Contacts.ListEventsAsyncContacts.ListAllEventsAsyncContacts.IterateEventsAsync