Automations
`automations.list`, `get`, `create`, `update`, `publish`, `pause`, `resume`, `archive`, `duplicate`, `delete`, `send_test`, `stats`, `list_versions`, `restore_version`, `list_starters`, `list_enrollments`, `get_enrollment`, `enroll` and `exit_enrollment`, with `events.send`, `send_batch` and `list_names`.
Every method
from openemail import openemail automation = openemail.automations.create({ 'name': 'Welcome series', 'starter': 'welcome-series', 'settings': {'timezone': 'Europe/London'},}) saved = openemail.automations.update(automation['id'], { 'definition': { **automation['definition'], 'trigger': {'kind': 'event', 'eventName': 'trial.started', 'filters': []}, }, 'expectedUpdatedAt': automation['updatedAt'],}) blocking = [problem for problem in saved['problems'] if problem['blocking']]if blocking: raise RuntimeError(blocking[0]['message']) openemail.automations.send_test(saved['id'], {'stepKey': saved['definition']['entry'] or ''})live = openemail.automations.publish(saved['id']) sent = openemail.events.send( { 'name': 'trial.started', 'email': '[email protected]', 'properties': {'plan': 'starter'}, 'createContact': True, }, idempotency_key='trial:[email protected]',) for enrollment in openemail.automations.iterate_enrollments(live['id'], status='active'): if enrollment['heldFor']: print(enrollment['contact']['email'], enrollment['heldFor']) stats = openemail.automations.stats(live['id'])history = openemail.contacts.list_events('[email protected]', name='trial.started') openemail.automations.pause(live['id'])openemail.automations.resume(live['id']) print(sent['enrolled'], stats['totals']['entered'], len(history['items']))An automation keeps a draft definition and the published version that runs. update changes the draft and the settings, and publish freezes the draft as the next version and turns the automation on. problems says what still stops a draft from being published, and expectedUpdatedAt refuses a save that would overwrite someone else’s with 409 version_conflict.
Reading needs automations:read and changing needs automations:write. publish, resume and send_test also need emails:send. events.send and events.send_batch need contacts:write, and contacts.list_events needs contacts:read. delete asks an OAuth access token for a verification code, and an API key never.
events.send_batch takes up to 100 events and never raises for one bad event: the answer lists accepted and failed, each with the index of the event in the list you sent.
attributes on a contact holds its custom fields, and an automation reads one as attributes.<key>.
Reference
automations.list()Full referenceautomations.list_all()Full referenceautomations.iterate()Full referenceautomations.get()Full referenceautomations.create()Full referenceautomations.update()Full referenceautomations.delete()Full referenceautomations.publish()Full referenceautomations.pause()Full referenceautomations.resume()Full referenceautomations.archive()Full referenceautomations.duplicate()Full referenceautomations.send_test()Full referenceautomations.stats()Full referenceautomations.list_versions()Full referenceautomations.restore_version()Full referenceautomations.list_starters()Full referenceautomations.list_enrollments()Full referenceautomations.list_all_enrollments()Full referenceautomations.iterate_enrollments()Full referenceautomations.get_enrollment()Full referenceautomations.enroll()Full referenceautomations.exit_enrollment()Full referenceevents.send()Full referenceevents.send_batch()Full referenceevents.list_names()Full referencecontacts.list_events()Full referencecontacts.list_all_events()Full referencecontacts.iterate_events()Full reference