Automações
Emails e passos que se executam sozinhos para cada contacto, e os eventos que os iniciam.
Ferramentas de automações
| Ferramenta | O que faz |
|---|---|
| listAutomations | As automações do espaço de trabalho, primeiro as alteradas mais recentemente, com o estado, o que inicia cada uma e quantos contactos estão nela. |
| getAutomation | Uma automação completa: o estado, as definições e os números, o que está errado no rascunho, e a definição do rascunho em JSON. includePublished acrescenta a versão que está em execução. |
| listAutomationStarters | As automações prontas de que uma nova pode arrancar, cada uma com a sua definição. |
| createAutomation | Criar um rascunho a partir de um ponto de partida, de uma definição escrita em JSON, ou vazio, com quaisquer definições. Nada é executado até ser publicado. |
| updateAutomation | Alterar o nome e as definições de uma automação, que se aplicam de imediato, ou substituir a definição do rascunho. Uma automação ativa continua a executar a versão publicada. |
| deleteAutomation | Eliminar de vez uma automação, com as suas versões, inscrições e números. Os contactos que estão nela param de imediato. |
| publishAutomation | Tornar o rascunho na versão que é executada e ativar a automação. Um rascunho incompleto é recusado com todos os problemas que o bloqueiam. Requer também emails:send. |
| pauseAutomation | Parar uma automação ativa. Ninguém novo entra, e todos os que estão nela ficam onde estão. |
| resumeAutomation | Reativar uma automação em pausa com a versão que estava a executar. Requer também emails:send. |
| archiveAutomation | Encerrar de vez uma automação e manter o histórico. Todos os que estão nela saem. |
| duplicateAutomation | Copiar uma automação para um novo rascunho, sem as suas versões, contactos nem números. |
| sendAutomationTest | Enviar o email de um passo do rascunho para si ou para um endereço. Requer também emails:send. |
| listAutomationVersions | As versões publicadas, da mais recente para a mais antiga, e qual delas está em execução. includeDefinitions acrescenta cada definição. |
| restoreAutomationVersion | Copiar uma versão anterior de volta para o rascunho. Nada do que está em execução muda até à publicação seguinte. |
| getAutomationStats | Contactos que entraram, que estão dentro agora, que concluíram e que saíram, e emails enviados, entregues, abertos e clicados num período, no total e por passo. |
| listAutomationEnrollments | Os contactos que estão ou estiveram numa automação, uma página de cada vez, com o passo em que cada um está e como terminou. Filtre por estado, passo ou parte do endereço. |
| getAutomationEnrollment | O percurso de um contacto numa automação: o que cada passo fez por ele, do mais antigo para o mais recente. |
| enrollInAutomation | Colocar um contacto no primeiro passo de uma automação ativa, seja o que for que normalmente a inicia. |
| removeFromAutomation | Retirar de imediato um contacto de uma automação. |
| sendContactEvent | Registar que aconteceu algo a um contacto. Inicia as automações ativas cujo acionador indica o evento e põe fim às esperas que aguardavam por ele. |
| sendContactEvents | Registar até 100 eventos numa só chamada. A falha de um não trava os restantes. |
| listContactEventNames | Os nomes de eventos que o espaço de trabalho registou nos últimos 90 dias. |
| listContactEvents | Os eventos registados para um contacto, do mais recente para o mais antigo, uma página de cada vez. |
Ler requer automations:read e qualquer alteração requer automations:write. Publicar, retomar e enviar um teste requerem também emails:send, porque a automação passa a enviar correio em nome de quem a publicou. Enviar um evento requer contacts:write, ler os eventos de um contacto requer contacts:read, e listContactEventNames requer automations:read. Um cliente que atua em nome de um membro vê apenas as automações que esse membro criou e os contactos que esse membro adicionou.
Algumas ferramentas deste servidor fazem uma alteração que a API REST protege com um código de verificação, e pedem o mesmo código. Enquanto o cliente não tiver verificado um código nos últimos 60 minutos, e a pessoa não tiver escolhido Permitir alterações durante 60 minutos para ele em Conta → Aplicações ligadas, essa ferramenta responde com um resultado que começa por Refused (step_up_required): e não altera nada. emptyAudience nunca pede um código. A página Autenticação da API lista cada ferramenta que o pede e mostra como pedir um código e verificá-lo.
As ferramentas aplicam as mesmas regras e recusas que a API REST, e as páginas /automations e /events da referência da API descrevem cada campo. Uma definição é passada inteira em JSON: leia-a com getAutomation, altere-a e passe-a toda de volta a updateAutomation.
Referência
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.
Entradas
statusstring- Um de
"draft""live""paused""archived" limitinteger- Pelo menos 1No máximo 100
cursorstring- De 1 a 64 caracteres
Também disponível em
- 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.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteresincludePublishedboolean- Predefinição
false
Também disponível em
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.
Entradas
Não recebe entradas.
Também disponível em
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.
Entradas
namestringObrigatórioA short name for the automation. Contacts never see it.
De 1 a 120 caracteresdescriptionstringOne line about what it is for.
Até 500 caracteresstarterstring- De 1 a 64 caracteres
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).
Também disponível em
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.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteresnamestring- De 1 a 120 caracteres
descriptionstring- Pode ser nullAté 500 caracteres
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.
Formatodate-time
Também disponível em
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.
- Pede um código de verificação
DELETE /automations/{id}
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteres
Também disponível em
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.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteres
Também disponível em
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.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteres
Também disponível em
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.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteres
Também disponível em
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.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteres
Também disponível em
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.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteres
Também disponível em
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.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteresstepKeystringObrigatórioThe key of the email step, from the definition getAutomation returns.
De 1 a 64 caracterestostringWhere the test goes, when not to the user themselves.
Até 320 caracteresFormatoemail
Também disponível em
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.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteresincludeDefinitionsboolean- Predefinição
false
Também disponível em
restoreAutomationVersion
Copy the definition of an earlier version back into the draft, replacing what the draft holds. Nothing that is running changes until publishAutomation.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteresversionintegerObrigatórioThe version number, from listAutomationVersions.
Pelo menos 1
Também disponível em
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.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteressincestringWhere the window starts, as an ISO 8601 instant.
Formatodate-timeuntilstringWhere the window ends, as an ISO 8601 instant. Left out, now.
Formatodate-timeincludeDailyboolean- Predefinição
false
Também disponível em
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.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteresstatusstring- Um de
"active""completed""exited" stepKeystring- De 1 a 64 caracteres
qstring- Até 200 caracteres
limitinteger- Pelo menos 1No máximo 200
cursorstring- De 1 a 64 caracteres
Também disponível em
- 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.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteresenrollmentIdstringObrigatórioThe enrollment, by id (aen_...), from listAutomationEnrollments.
De 1 a 64 caracteres
Também disponível em
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.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteresemailstringObrigatórioThe contact to enroll, by email address.
Até 320 caracteresFormatoemaildataRecord<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.
Também disponível em
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.
Entradas
idstringObrigatórioThe automation, by id (aut_...). listAutomations finds it by name.
De 1 a 64 caracteresenrollmentIdstringObrigatórioThe enrollment, by id (aen_...), from listAutomationEnrollments.
De 1 a 64 caracteres
Também disponível em
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.
Entradas
namestringObrigatórioWhat happened, such as order.placed: letters, digits, dots, colons, dashes and underscores. Names are matched exactly, case included.
De 1 a 100 caracteresemailstringObrigatórioThe contact the event is about, by email address.
Até 320 caracteresFormatoemailpropertiesRecord<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.
Formatodate-timecreateContactbooleantrue adds the address to the contacts when nobody has it yet.
contactNamestringThe name to give a contact that createContact adds.
Até 200 caracteres
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.
Entradas
eventsobject[]Obrigatório- De 1 a 100 itens
namestringObrigatórioWhat happened, such as order.placed: letters, digits, dots, colons, dashes and underscores. Names are matched exactly, case included.
De 1 a 100 caracteresemailstringObrigatórioThe contact the event is about, by email address.
Até 320 caracteresFormatoemailpropertiesRecord<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.
Formatodate-timecreateContactbooleantrue adds the address to the contacts when nobody has it yet.
contactNamestringThe name to give a contact that createContact adds.
Até 200 caracteres
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.
Entradas
Não recebe entradas.
Também disponível em
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.
Entradas
emailstringObrigatórioThe contact the event is about, by email address.
De 3 a 320 caracteresnamestring- De 1 a 100 caracteres
limitinteger- Pelo menos 1No máximo 200
cursorstring- De 1 a 64 caracteres
Também disponível em
- 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