Перейти к документации
Ruby

client.automations

Каждый метод этого пространства имён: его сигнатура, параметры, что он возвращает, и пример.

Методы

Emails and other steps that run by themselves for each contact, such as a welcome series or a birthday note: build a draft from a starter or your own trigger and steps, publish, pause, resume and archive it, send a test, read its versions and statistics, and enroll contacts or take them out.

automations.list

List one page of the automations in the workspace

Разрешенияautomations:readПостранично перебирает результаты
Сигнатура
list(status: nil, limit: nil, cursor: nil, api_key: nil) -> OpenEmail::Page

Returns one page of the automations the caller can reach, the most recently saved first, without their definitions or settings. Paging is keyset: limit: takes 1 to 100 and defaults to 50, and next_cursor goes back as cursor: while has_more? is true. list_all and iterate do that walk for you.

Each automation carries its status, triggerKind, how many steps and emails the draft holds, hasUnpublishedChanges, publishedVersion and counts: the contacts in it now, and the ones that completed or left in all its time, counted at the moment of the read. A paused automation says why in pausedReason.

Read one with get for the draft definition, the published one, the settings and the problems that would stop a publish.

Параметры

statusString

Only automations in this state: draft, live, paused or archived.

limitInteger

Rows per page, a whole number from 1 to 100. The server defaults to 50.

cursorString

The next_cursor from the previous page, passed back exactly as it came. One that names no automation is a 400 invalid_cursor.

api_keyString

Overrides the client's API key for this call only.

Возвращает

An OpenEmail::Page with items, has_more? and next_cursor. Each item is a Hash with id, name, description, status, triggerKind, stepCount, emailCount, hasUnpublishedChanges, publishedVersion, pausedReason, lastError, counts, createdBy, publishedAt, pausedAt, archivedAt, createdAt and updatedAt.

Пример

page = client.automations.list(status: "live") page.items.each do |automation|  puts "#{automation[:name]} #{automation[:triggerKind]} #{automation[:counts][:active]} in it now"end

Примечания

  • An app a member connected lists only the automations that member made. An API key and an app the owner connected list every automation in the workspace.

  • Read only, so the SDK retries it after a network failure like any other read.

Также доступно в

API
GET /automations
TypeScript
automations.list()
Python
automations.list()
PHP
automations->list
Go
Automations.List
Java
automations().list
C#
Automations.ListAsync
CLI
openemail automations list

automations.list_all

Collect every automation you can reach into one array

Разрешенияautomations:readПостранично перебирает результаты
Сигнатура
list_all(status: nil, limit: nil, cursor: nil, api_key: nil) -> Array<Hash>

Follows next_cursor from page to page and returns every automation the caller can reach, the most recently saved first, in the shape list returns. limit sets the page size of each request, not the total.

Параметры

statusString

Only automations in this state: draft, live, paused or archived.

limitInteger

Page size per request, from 1 to 100, defaulting to 50 on the server.

cursorString

A next_cursor from an earlier page to start after.

api_keyString

Overrides the client's API key for every page of this walk.

Возвращает

An Array of Hashes holding every automation across all pages, each shaped like an item of list.

Пример

automations = client.automations.list_all paused = automations.select { |automation| automation[:status] == "paused" } paused.each { |automation| puts "#{automation[:name]} #{automation[:pausedReason]}" }

Примечания

  • A failure on any page raises, and the automations already fetched are discarded.

Также доступно в

API
GET /automations
TypeScript
automations.listAll()
Python
automations.list_all()
PHP
automations->listAll
Go
Automations.ListAll
Java
automations().listAll
C#
Automations.ListAllAsync

automations.iterate

Stream the automations you can reach one at a time

Разрешенияautomations:readПостранично перебирает результаты
Сигнатура
iterate(status: nil, limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>

Returns an Enumerator that yields automations one by one, the most recently saved first, or passes each one to the block you give it. It requests the next page only once the current one is drained, and breaking out of the loop stops the requests.

Параметры

statusString

Only automations in this state: draft, live, paused or archived.

limitInteger

Page size per request, from 1 to 100, defaulting to 50 on the server.

cursorString

A next_cursor from an earlier page to start after.

api_keyString

Overrides the client's API key for every page of this walk.

Возвращает

An Enumerator of Hashes, one automation per step, each shaped like an item of list, or yields each one to a block.

Пример

client.automations.iterate do |automation|  puts "unpublished edits: #{automation[:name]}" if automation[:hasUnpublishedChanges]end

Примечания

  • Pages are fetched only as the loop reaches them, so an abandoned loop costs only the pages you consumed.

Также доступно в

API
GET /automations
TypeScript
automations.iterate()
Python
automations.iterate()
PHP
automations->iterate
Go
Automations.Iterate
Java
automations().iterate
C#
Automations.IterateAsync

automations.create

Create an automation as a draft

Разрешенияautomations:write
Сигнатура
create(body = nil, api_key: nil, **fields) -> Hash

Makes a draft automation and returns it whole, in the shape get returns. Its trigger and steps come from definition when you send one, from the starter named in starter when you do not, and otherwise the draft starts empty. settings changes any of the defaults.

A draft may be incomplete: problems in the answer lists what is still missing, such as a template or a from address a starter leaves for you. Nothing runs until publish, which needs a complete draft and emails:send.

Параметры

nameStringОбязательно

What the workspace calls the automation, trimmed, 1 to 120 characters. Contacts never see it, and it need not be unique.

descriptionString or nil

A note for the workspace, at most 500 characters. Contacts never see it.

starterString

Begin from a starter, by the slug list_starters returns: welcome-series, trial-follow-up, birthday or win-back. Ignored when definition is sent. An unknown slug is 422 invalid_automation.

definitionHash

The trigger and the steps, in the shape get returns as definition. trigger says what starts the automation: audience_joined with audienceId and includeImported, form_submitted with formId, event with eventName and filters, date with field, audienceId and offsetDays, or manual. entry is the key of the first step, and steps holds every step: send_email, wait, branch, add_to_audience, remove_from_audience, update_field, webhook or exit. Each step has a unique key of 3 to 24 lowercase letters and digits starting with a letter, and names the next step by key in next, or in yes and no for a branch. nil ends the path. Paths never join or loop, and a definition holds at most 50 steps. Leave it out to use starter or an empty draft.

settings.timezoneString

The IANA time zone the sending window and waits until a day and time are read in, such as Europe/London. Defaults to UTC.

settings.sendWindowHash or nil

When emails may go out: days of the week, where 0 is Sunday, and startMinute to endMinute of the day, counted from midnight. An email due outside it waits for the window to open. nil, the default, sends at any time.

settings.reentryDaysInteger or nil

How many days after a contact finishes before they may enter again, from 1 to 3650. nil, the default, lets each contact through once only.

settings.exitOnLeaveBoolean

Take a contact out when they leave the audience that started the automation. Defaults to true.

settings.listAudienceIdString or nil

The audience an unsubscribe from one of these emails is recorded in. nil, the default, uses the audience that starts the automation, or the built-in audience of every contact when no audience starts it. An id that is not an audience of the workspace is 422 invalid_automation.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash, the automation as get returns it: the fields of a list item with status draft, plus definition, published, which is nil, settings and problems.

Пример

automation = client.automations.create(  name: "Welcome series",  starter: "welcome-series",  settings: {timezone: "Europe/London"}) automation[:problems].each { |problem| puts "#{problem[:path]} #{problem[:message]}" }

Примечания

  • A value of the wrong type or length is 422 invalid_parameter with param naming it, and a key the body does not take is 422 unknown_parameter. A definition that breaks a rule of its structure, such as two steps with one key or two paths into one step, is 422 invalid_automation, and problems on the error lists each one.

  • A workspace holds a limited number of automations, drafts included, and support can raise that for a workspace that needs more. The next one past the limit is 422 workspace_limit_reached.

  • Not retried automatically, and nothing deduplicates by name, so a retry after a lost response can leave two drafts. List them and delete the spare.

Также доступно в

API
POST /automations
TypeScript
automations.create()
Python
automations.create()
PHP
automations->create
Go
Automations.Create
Java
automations().create
C#
Automations.CreateAsync
CLI
openemail automations create

automations.list_starters

List the ready-made automations to start from

Разрешенияautomations:read
Сигнатура
list_starters(api_key: nil) -> Array<Hash>

Returns the starting points the app offers when somebody makes an automation: a welcome series, a trial follow-up, a birthday note and a win-back. Each comes with its whole definition, so you can read it, change it and send it to create, or pass its slug to create as starter.

A starter leaves the audience, the templates and the from address as empty strings for you to fill in. The list is the same for every workspace and is not paginated.

Параметры

api_keyString

Overrides the client's API key for this call only.

Возвращает

An Array of Hashes, each with slug, name, description and definition.

Пример

starters = client.automations.list_starters starters.each { |starter| puts "#{starter[:slug]} #{starter[:description]}" }

Примечания

  • Read only, so the SDK retries it after a network failure like any other read.

Также доступно в

API
GET /automations/starters
TypeScript
automations.listStarters()
Python
automations.list_starters()
PHP
automations->listStarters
Go
Automations.ListStarters
Java
automations().listStarters
C#
Automations.ListStartersAsync
CLI
openemail automations list-starters

automations.get

Retrieve an automation with its definition and settings

Разрешенияautomations:read
Сигнатура
get(id, api_key: nil) -> Hash

Returns the whole automation: the draft definition you edit, published, the definition of the version that is running, settings, fresh counts and problems.

problems is what is wrong with the draft at the moment of the read, each with a code, the path of the field, the stepKey, a message and blocking, which is false for a warning. An empty list means the draft is ready, though publish checks more: that every template can be sent and that the caller may send from every from address.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash with id, name, description, status, triggerKind, stepCount, emailCount, hasUnpublishedChanges, publishedVersion, pausedReason, lastError, counts, createdBy, publishedAt, pausedAt, archivedAt, createdAt and updatedAt, plus definition, published, settings and problems.

Пример

automation = client.automations.get("aut_5c1e9a7b3d2f48e6a0b4c7d1") puts automation[:status], automation.dig(:definition, :trigger, :kind), automation[:definition][:steps].size automation[:problems].select { |problem| problem[:blocking] }.each { |problem| puts problem[:message] }

Примечания

  • An id that names no automation the caller can reach is 404 automation_not_found, whether it does not exist or belongs to another workspace.

  • Read only, so the SDK retries it after a network failure like any other read.

Также доступно в

API
GET /automations/{id}
TypeScript
automations.get()
Python
automations.get()
PHP
automations->get
Go
Automations.Get
Java
automations().get
C#
Automations.GetAsync
CLI
openemail automations get

automations.update

Change the draft, the settings or the name of an automation

Разрешенияautomations:write
Сигнатура
update(id, patch = nil, api_key: nil, **fields) -> Hash

A partial update that returns the automation whole. definition replaces the draft, and a live automation keeps running its published version until you publish again, so an edit never changes the path of a contact who is halfway through. settings is merged field by field and takes effect at once.

Read the automation, change it and send expectedUpdatedAt with the updatedAt you read. If someone saved it in between, the call is refused with 409 version_conflict instead of writing over their change.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

nameString

New name, trimmed, 1 to 120 characters.

descriptionString or nil

New note, at most 500 characters. nil clears it.

definitionHash

The new draft, whole. The trigger and the steps, in the shape get returns as definition. trigger says what starts the automation: audience_joined with audienceId and includeImported, form_submitted with formId, event with eventName and filters, date with field, audienceId and offsetDays, or manual. entry is the key of the first step, and steps holds every step: send_email, wait, branch, add_to_audience, remove_from_audience, update_field, webhook or exit. Each step has a unique key of 3 to 24 lowercase letters and digits starting with a letter, and names the next step by key in next, or in yes and no for a branch. nil ends the path. Paths never join or loop, and a definition holds at most 50 steps.

settings.timezoneString

The IANA time zone the sending window and waits until a day and time are read in, such as Europe/London. Defaults to UTC.

settings.sendWindowHash or nil

When emails may go out: days of the week, where 0 is Sunday, and startMinute to endMinute of the day, counted from midnight. An email due outside it waits for the window to open. nil, the default, sends at any time.

settings.reentryDaysInteger or nil

How many days after a contact finishes before they may enter again, from 1 to 3650. nil, the default, lets each contact through once only.

settings.exitOnLeaveBoolean

Take a contact out when they leave the audience that started the automation. Defaults to true.

settings.listAudienceIdString or nil

The audience an unsubscribe from one of these emails is recorded in. nil, the default, uses the audience that starts the automation, or the built-in audience of every contact when no audience starts it. An id that is not an audience of the workspace is 422 invalid_automation.

expectedUpdatedAtString

The updatedAt you read, as an ISO 8601 instant. When the automation was saved since, the call is refused with 409 version_conflict and nothing is written.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash, the automation as get returns it after the save, with a new updatedAt and, when the draft changed, hasUnpublishedChanges true on a published automation.

Пример

current = client.automations.get("aut_5c1e9a7b3d2f48e6a0b4c7d1") saved = client.automations.update(  current[:id],  settings: {sendWindow: {days: [1, 2, 3, 4, 5], startMinute: 540, endMinute: 1020}},  expectedUpdatedAt: current[:updatedAt]) p saved[:settings][:sendWindow], saved[:updatedAt]

Примечания

  • An archived automation cannot be changed and answers 409 automation_archived.

  • A value of the wrong type or length is 422 invalid_parameter, a key the patch does not take is 422 unknown_parameter, and a definition that breaks a rule of its structure is 422 invalid_automation with problems on the error.

  • Retried automatically on network failure and retryable statuses, since saving the same patch twice leaves the same automation. With expectedUpdatedAt, a retry after a lost response answers 409 version_conflict: read the automation to see that your change is there.

Также доступно в

API
PATCH /automations/{id}
TypeScript
automations.update()
Python
automations.update()
PHP
automations->update
Go
Automations.Update
Java
automations().update
C#
Automations.UpdateAsync
CLI
openemail automations update

automations.delete

Delete an automation with its versions and history

Разрешенияautomations:write
Сигнатура
delete(id, api_key: nil) -> Hash

Deletes the automation with its versions, its enrollments and its statistics. Contacts in it stop at once and get nothing more. The emails it already sent stay in emails.list.

There is no undo. To retire an automation and keep its history, use archive.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash with object set to automation, id and deleted set to true.

Пример

removed = client.automations.delete("aut_5c1e9a7b3d2f48e6a0b4c7d1") puts removed[:id], removed[:deleted]

Примечания

  • An OAuth access token needs a verification code for this call, and is refused with 403 step_up_required until the app has verified one in the last 60 minutes. step_up_required? on the error says so. An API key is never asked for a code.

  • The SDK does not retry a delete. A 404 on your own second attempt after a lost response means the first one worked.

Также доступно в

API
DELETE /automations/{id}
TypeScript
automations.delete()
Python
automations.delete()
PHP
automations->delete
Go
Automations.Delete
Java
automations().delete
C#
Automations.DeleteAsync
CLI
openemail automations delete

automations.publish

Publish the draft and turn the automation on

Разрешенияautomations:writeemails:send
Сигнатура
publish(id, api_key: nil) -> Hash

Saves the draft as the next version and sets the automation live, so its trigger starts taking contacts in. Contacts already in it stay on the version they entered on. Publishing a paused automation turns it back on. It takes no body.

The draft has to be complete: a trigger, at least one step, every email with a published template that declares unsubscribeUrl and a from address the caller may send as, and every audience, form and webhook it names still there. Anything else is 422 invalid_automation, and problems on the error lists every problem that blocks it.

The automation sends as whoever published it. When that API key is revoked, expires or is turned off, the automation pauses itself with pausedReason key_revoked.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash, the automation as get returns it, with status live, a new publishedAt, the publishedVersion that is now running and hasUnpublishedChanges false.

Пример

automation = client.automations.publish("aut_5c1e9a7b3d2f48e6a0b4c7d1") puts automation[:status], automation[:publishedVersion], automation[:publishedAt]

Примечания

  • A plan covers a number of live automations: 1 on Free, 10 on Starter and 50 on Business, with no limit on Enterprise. One more is 403 automation_limit_reached. Pause one, or upgrade.

  • An archived automation answers 409 automation_archived.

  • Publishing a draft that has not changed since the last publish keeps the same version number.

  • Retried automatically on network failure and retryable statuses, since publishing the same draft twice leaves the same live version.

Также доступно в

API
POST /automations/{id}/publish
TypeScript
automations.publish()
Python
automations.publish()
PHP
automations->publish
Go
Automations.Publish
Java
automations().publish
C#
Automations.PublishAsync
CLI
openemail automations publish

automations.pause

Stop a live automation without losing anybody

Разрешенияautomations:write
Сигнатура
pause(id, api_key: nil) -> Hash

Stops a live automation. Nobody new enters, and everyone in it stays where they are and moves on when it is resumed. The automation.paused webhook event fires. Pausing a paused automation changes nothing. It takes no body.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash, the automation as get returns it, with status paused, pausedReason manual and pausedAt set.

Пример

automation = client.automations.pause("aut_5c1e9a7b3d2f48e6a0b4c7d1") puts automation[:status], automation[:pausedReason], automation[:counts][:active]

Примечания

  • A draft that was never published answers 409 automation_not_published, and an archived automation 409 automation_archived.

  • Retried automatically on network failure and retryable statuses, since pausing twice leaves the same paused automation.

Также доступно в

API
POST /automations/{id}/pause
TypeScript
automations.pause()
Python
automations.pause()
PHP
automations->pause
Go
Automations.Pause
Java
automations().pause
C#
Automations.PauseAsync
CLI
openemail automations pause

automations.resume

Turn a paused automation back on

Разрешенияautomations:writeemails:send
Сигнатура
resume(id, api_key: nil) -> Hash

Turns a paused automation back on with the version it was running, without publishing the draft. Contacts that were held move on, and from now on it sends as the caller. Resuming a live automation changes nothing. It takes no body.

The published version is checked again first, exactly as publish checks a draft. An automation OpenEmail paused, because its from address, its templates or an audience went away, stays paused with 422 invalid_automation until what stopped it is fixed.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash, the automation as get returns it, with status live and pausedReason, pausedAt and lastError cleared.

Пример

automation = client.automations.resume("aut_5c1e9a7b3d2f48e6a0b4c7d1") puts automation[:status], automation[:publishedVersion]

Примечания

Также доступно в

API
POST /automations/{id}/resume
TypeScript
automations.resume()
Python
automations.resume()
PHP
automations->resume
Go
Automations.Resume
Java
automations().resume
C#
Automations.ResumeAsync
CLI
openemail automations resume

automations.archive

Retire an automation for good and keep its history

Разрешенияautomations:write
Сигнатура
archive(id, api_key: nil) -> Hash

Retires an automation. Everyone in it leaves with the exit reason archived, nobody enters again, and it can no longer be changed, published or resumed. Its versions, enrollments and statistics stay readable. Archiving an archived automation changes nothing. It takes no body.

An automation with many contacts in it empties in the background over the next minutes. To start again from its steps, use duplicate.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash, the automation as get returns it, with status archived and archivedAt set.

Пример

automation = client.automations.archive("aut_5c1e9a7b3d2f48e6a0b4c7d1") puts automation[:status], automation[:archivedAt]

Примечания

  • There is no way back from archived. To stop an automation for a while, use pause.

  • Retried automatically on network failure and retryable statuses, since archiving twice leaves the same archived automation.

Также доступно в

API
POST /automations/{id}/archive
TypeScript
automations.archive()
Python
automations.archive()
PHP
automations->archive
Go
Automations.Archive
Java
automations().archive
C#
Automations.ArchiveAsync
CLI
openemail automations archive

automations.duplicate

Copy an automation into a new draft

Разрешенияautomations:write
Сигнатура
duplicate(id, api_key: nil) -> Hash

Makes a new draft with the same draft definition and settings, named after the original with (copy) on the end. The copy has no versions, no contacts and no statistics, and it works on an archived automation too. It takes no body.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash, the copy as get returns it, with its own id and status draft.

Пример

copy = client.automations.duplicate("aut_5c1e9a7b3d2f48e6a0b4c7d1") puts copy[:id], copy[:name], copy[:status]

Примечания

  • A workspace that already holds the most automations it may answers 422 workspace_limit_reached.

  • Not retried automatically, so a retry after a lost response can leave two copies. List them and delete the spare.

Также доступно в

API
POST /automations/{id}/duplicate
TypeScript
automations.duplicate()
Python
automations.duplicate()
PHP
automations->duplicate
Go
Automations.Duplicate
Java
automations().duplicate
C#
Automations.DuplicateAsync
CLI
openemail automations duplicate

automations.send_test

Send yourself the email of one step

Разрешенияautomations:writeemails:send
Сигнатура
send_test(id, body = nil, api_key: nil, **fields) -> Hash

Sends the email of one step of the draft to one address, so you can read it before publishing. Contact values are filled from a sample contact, values that come from an event are left empty, and the subject starts with [Test]. It counts toward the monthly sends, is not tracked and enrolls nobody.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

stepKeyStringОбязательно

The key of the email step to send, from the draft definition.

toString

Where the test goes. Left out, it goes to the account email of the person the key or app acts for: the workspace owner for an API key.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash with automationId, emailId, the email as emails.get returns it, to and stepKey.

Пример

test = client.automations.send_test("aut_5c1e9a7b3d2f48e6a0b4c7d1", stepKey: "welcome", to: "[email protected]") puts test[:emailId], test[:to]

Примечания

  • A stepKey that names no step, a step that is not an email, or a template that cannot be sent is 422 invalid_automation with param stepKey.

  • The from address of the step has to be one the caller may send as, or the call is refused with 403 from_address_forbidden. A domain that cannot send yet is 409 domain_not_sendable, and a plan with no sends left is 429 send_quota_exceeded.

  • Not retried automatically, because a retry after a lost response would send the test twice.

Также доступно в

API
POST /automations/{id}/test
TypeScript
automations.sendTest()
Python
automations.send_test()
PHP
automations->sendTest
Go
Automations.SendTest
Java
automations().sendTest
C#
Automations.SendTestAsync
CLI
openemail automations send-test

automations.list_versions

List the published versions of an automation

Разрешенияautomations:read
Сигнатура
list_versions(id, api_key: nil) -> Array<Hash>

Returns every published version, the newest first, each with its whole definition. current marks the one that is running. A publish that changed the definition adds a version, and each contact stays on the version they entered on. A draft that was never published has none. The list is not paginated.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

api_keyString

Overrides the client's API key for this call only.

Возвращает

An Array of Hashes, each with id, automationId, version, definition, current, createdBy and createdAt.

Пример

versions = client.automations.list_versions("aut_5c1e9a7b3d2f48e6a0b4c7d1") versions.each { |version| puts "#{version[:version]} #{version[:current]} #{version[:createdAt]}" }

Примечания

  • Read only, so the SDK retries it after a network failure like any other read.

Также доступно в

API
GET /automations/{id}/versions
TypeScript
automations.listVersions()
Python
automations.list_versions()
PHP
automations->listVersions
Go
Automations.ListVersions
Java
automations().listVersions
C#
Automations.ListVersionsAsync
CLI
openemail automations list-versions

automations.restore_version

Copy an earlier version back into the draft

Разрешенияautomations:write
Сигнатура
restore_version(id, version, api_key: nil) -> Hash

Copies the definition of an earlier version into the draft, replacing what the draft holds. Nothing that is running changes until you publish. It takes no body.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

versionIntegerОбязательно

The number of the version, from list_versions. A whole number from 1 up.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash, the automation as get returns it, with the version in definition, and hasUnpublishedChanges true when it differs from the one that is running.

Пример

automation = client.automations.restore_version("aut_5c1e9a7b3d2f48e6a0b4c7d1", 2) puts automation[:hasUnpublishedChanges], automation[:definition][:steps].size

Примечания

  • A version the automation does not have is 404 automation_not_found with param version, and an archived automation is 409 automation_archived.

  • Retried automatically on network failure and retryable statuses, since restoring the same version twice leaves the same draft.

Также доступно в

API
POST /automations/{id}/versions/{version}/restore
TypeScript
automations.restoreVersion()
Python
automations.restore_version()
PHP
automations->restoreVersion
Go
Automations.RestoreVersion
Java
automations().restoreVersion
C#
Automations.RestoreVersionAsync
CLI
openemail automations restore-version

automations.stats

Read how an automation has performed

Разрешенияautomations:read
Сигнатура
stats(id, since: nil, until: nil, api_key: nil) -> Hash

Returns the numbers of an automation over a window: totals for the whole automation, steps with the same numbers step by step, and series with a point for each UTC day on which something happened. The window defaults to the last 30 days and reaches back at most 366 days before until:.

The steps are those of the published version, or of the draft when nothing is published. active in totals and the waiting of each step are counted at the moment of the read, whatever the window. Opens are a floor, because many mail apps hide them.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

sinceTime, Date or String

Where the window starts, as a Time or an ISO 8601 string. Left out, 30 days before until:.

untilTime, Date or String

Where the window ends, as a Time or an ISO 8601 string. Left out, now. It has to be later than since:.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash with automationId, since, until, totals (entered, active, completed, exited, sent, delivered, opened, clicked, bounced, complained and unsubscribed), steps and series.

Пример

stats = client.automations.stats("aut_5c1e9a7b3d2f48e6a0b4c7d1", since: "2026-09-01T00:00:00Z") p stats[:totals].values_at(:entered, :sent, :clicked) stats[:steps].each { |step| puts "#{step[:stepKey]} #{step[:kind]} #{step[:entered]} #{step[:waiting]}" }

Примечания

  • A time that is not an ISO 8601 instant, or an until: that is not after since:, is 422 invalid_parameter.

  • Read only, so the SDK retries it after a network failure like any other read.

Также доступно в

API
GET /automations/{id}/stats
TypeScript
automations.stats()
Python
automations.stats()
PHP
automations->stats
Go
Automations.Stats
Java
automations().stats
C#
Automations.StatsAsync
CLI
openemail automations stats

automations.list_enrollments

List one page of the contacts in an automation

Разрешенияautomations:readПостранично перебирает результаты
Сигнатура
list_enrollments(id, status: nil, step_key: nil, q: nil, limit: nil, cursor: nil, api_key: nil) -> OpenEmail::Page

Returns one page of everyone who is in the automation or has been, the most recent entry first. Each enrollment says who the contact is, the stepKey they are at, whether they are waiting and for which event, what holds a step that is due in heldFor, when they move next in nextRunAt, and how it ended in exitReason.

limit: takes 1 to 200 and defaults to 50. Pass next_cursor back as cursor:, with the same filters, while has_more? is true. list_all_enrollments and iterate_enrollments do that walk for you.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

statusString

Only enrollments in this state: active, completed or exited.

step_keyString

Only contacts at the step with this key.

qString

Only contacts whose address or name contains this text, compared without case, up to 200 characters.

limitInteger

Rows per page, a whole number from 1 to 200. The server defaults to 50.

cursorString

The next_cursor from the previous page, passed back exactly as it came. One that names no enrollment of this automation is a 400 invalid_cursor.

api_keyString

Overrides the client's API key for this call only.

Возвращает

An OpenEmail::Page with items, has_more? and next_cursor. Each item is a Hash with id, automationId, version, contact, status, source, stepKey, waiting, waitingForEvent, heldFor, nextRunAt, exitReason, lastError, startedAt, finishedAt and updatedAt.

Пример

page = client.automations.list_enrollments("aut_5c1e9a7b3d2f48e6a0b4c7d1", status: "active") page.items.each do |enrollment|  puts "#{enrollment[:contact][:email]} #{enrollment[:stepKey]} #{enrollment[:nextRunAt]}"end

Примечания

  • Read only, so the SDK retries it after a network failure like any other read.

Также доступно в

API
GET /automations/{id}/enrollments
TypeScript
automations.listEnrollments()
Python
automations.list_enrollments()
PHP
automations->listEnrollments
Go
Automations.ListEnrollments
Java
automations().listEnrollments
C#
Automations.ListEnrollmentsAsync
CLI
openemail automations list-enrollments

automations.list_all_enrollments

Collect every enrollment of an automation into one array

Разрешенияautomations:readПостранично перебирает результаты
Сигнатура
list_all_enrollments(id, status: nil, step_key: nil, q: nil, limit: nil, cursor: nil, api_key: nil) -> Array<Hash>

Follows next_cursor from page to page and returns every enrollment that matches, the most recent entry first, in the shape list_enrollments returns. limit sets the page size of each request, not the total. An automation can hold a great many enrollments, so prefer iterate_enrollments when you do not need them all in memory.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

statusString

Only enrollments in this state: active, completed or exited.

step_keyString

Only contacts at the step with this key.

qString

Only contacts whose address or name contains this text, compared without case, up to 200 characters.

limitInteger

Page size per request, from 1 to 200, defaulting to 50 on the server.

cursorString

A next_cursor from an earlier page to start after.

api_keyString

Overrides the client's API key for every page of this walk.

Возвращает

An Array of Hashes holding every matching enrollment across all pages, each shaped like an item of list_enrollments.

Пример

exited = client.automations.list_all_enrollments("aut_5c1e9a7b3d2f48e6a0b4c7d1", status: "exited", limit: 200) unsubscribed = exited.count { |enrollment| enrollment[:exitReason] == "unsubscribed" } puts "#{unsubscribed} of #{exited.size} left by unsubscribing"

Примечания

  • A failure on any page raises, and the enrollments already fetched are discarded.

Также доступно в

API
GET /automations/{id}/enrollments
TypeScript
automations.listAllEnrollments()
Python
automations.list_all_enrollments()
PHP
automations->listAllEnrollments
Go
Automations.ListAllEnrollments
Java
automations().listAllEnrollments
C#
Automations.ListAllEnrollmentsAsync

automations.iterate_enrollments

Stream the enrollments of an automation one at a time

Разрешенияautomations:readПостранично перебирает результаты
Сигнатура
iterate_enrollments(id, status: nil, step_key: nil, q: nil, limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>

Returns an Enumerator that yields enrollments one by one, the most recent entry first, or passes each one to the block you give it. It requests the next page only once the current one is drained, and breaking out of the loop stops the requests.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

statusString

Only enrollments in this state: active, completed or exited.

step_keyString

Only contacts at the step with this key.

qString

Only contacts whose address or name contains this text, compared without case, up to 200 characters.

limitInteger

Page size per request, from 1 to 200, defaulting to 50 on the server.

cursorString

A next_cursor from an earlier page to start after.

api_keyString

Overrides the client's API key for every page of this walk.

Возвращает

An Enumerator of Hashes, one enrollment per step, each shaped like an item of list_enrollments, or yields each one to a block.

Пример

client.automations.iterate_enrollments("aut_5c1e9a7b3d2f48e6a0b4c7d1", status: "active") do |enrollment|  puts "#{enrollment[:contact][:email]} held for #{enrollment[:heldFor]}" if enrollment[:heldFor]end

Примечания

  • Pages are fetched only as the loop reaches them, so an abandoned loop costs only the pages you consumed.

Также доступно в

API
GET /automations/{id}/enrollments
TypeScript
automations.iterateEnrollments()
Python
automations.iterate_enrollments()
PHP
automations->iterateEnrollments
Go
Automations.IterateEnrollments
Java
automations().iterateEnrollments
C#
Automations.IterateEnrollmentsAsync

automations.get_enrollment

Retrieve one contact's way through an automation

Разрешенияautomations:read
Сигнатура
get_enrollment(id, enrollment_id, api_key: nil) -> Hash

Returns one enrollment with runs: what each step did for the contact, oldest first, up to 200. A run has the stepKey, the kind of step, an outcome such as sent, waited, yes, no, skipped or failed, the emailId a send step produced and a detail that says why a step was skipped or failed.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

enrollment_idStringОбязательно

Enrollment id such as aen_2b8d4f6a1c3e5079b6d8f0a2, from list_enrollments.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash with id, automationId, version, contact, status, source, stepKey, waiting, waitingForEvent, heldFor, nextRunAt, exitReason, lastError, startedAt, finishedAt and updatedAt, plus runs.

Пример

enrollment = client.automations.get_enrollment("aut_5c1e9a7b3d2f48e6a0b4c7d1", "aen_2b8d4f6a1c3e5079b6d8f0a2") enrollment[:runs].each { |run| puts "#{run[:createdAt]} #{run[:stepKey]} #{run[:outcome]} #{run[:detail]}" }

Примечания

  • An enrollment id that is not in this automation is 404 automation_enrollment_not_found.

  • Read only, so the SDK retries it after a network failure like any other read.

Также доступно в

API
GET /automations/{id}/enrollments/{enrollmentId}
TypeScript
automations.getEnrollment()
Python
automations.get_enrollment()
PHP
automations->getEnrollment
Go
Automations.GetEnrollment
Java
automations().getEnrollment
C#
Automations.GetEnrollmentAsync
CLI
openemail automations get-enrollment

automations.enroll

Put a contact into a live automation

Разрешенияautomations:write
Сигнатура
enroll(id, body = nil, api_key: nil, **fields) -> Hash

Puts one contact into a live automation at its first step, whatever its trigger is. Name the contact with email or contactId, never both. The contact has to exist already: save one with contacts.create first. data gives the steps the values they would otherwise read from an event.

A contact is in an automation once at a time, and comes back in only after settings.reentry_days. An address on the suppression list, or one that unsubscribed from the audience the automation sends through, is refused.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

emailString

The contact, by email address. Send this or contactId.

contactIdString

The contact, by id, as an event or another enrollment carries it. Send this or email.

dataHash

Values the steps can read wherever a value comes from the event, such as an order number for an email. At most 50 keys and 4 KB of JSON.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash, the enrollment shaped like an item of list_enrollments, with status active, source api and nextRunAt now. The first step runs within about a minute.

Пример

enrollment = client.automations.enroll(  "aut_5c1e9a7b3d2f48e6a0b4c7d1",  email: "[email protected]",  data: {plan: "team"}) puts enrollment[:id], enrollment[:status], enrollment[:nextRunAt]

Примечания

Также доступно в

API
POST /automations/{id}/enrollments
TypeScript
automations.enroll()
Python
automations.enroll()
PHP
automations->enroll
Go
Automations.Enroll
Java
automations().enroll
C#
Automations.EnrollAsync
CLI
openemail automations enroll

automations.exit_enrollment

Take a contact out of an automation

Разрешенияautomations:write
Сигнатура
exit_enrollment(id, enrollment_id, api_key: nil) -> Hash

Ends an active enrollment at once with the exit reason removed. The contact gets nothing more from this automation, and stays in the contacts and in their audiences. It takes no body.

Параметры

idStringОбязательно

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

enrollment_idStringОбязательно

Enrollment id such as aen_2b8d4f6a1c3e5079b6d8f0a2, from list_enrollments.

api_keyString

Overrides the client's API key for this call only.

Возвращает

A Hash, the enrollment shaped like an item of list_enrollments, with status exited, exitReason removed and finishedAt set.

Пример

enrollment = client.automations.exit_enrollment("aut_5c1e9a7b3d2f48e6a0b4c7d1", "aen_2b8d4f6a1c3e5079b6d8f0a2") puts enrollment[:status], enrollment[:exitReason], enrollment[:finishedAt]

Примечания

Также доступно в

API
POST /automations/{id}/enrollments/{enrollmentId}/exit
TypeScript
automations.exitEnrollment()
Python
automations.exit_enrollment()
PHP
automations->exitEnrollment
Go
Automations.ExitEnrollment
Java
automations().exitEnrollment
C#
Automations.ExitEnrollmentAsync
CLI
openemail automations exit-enrollment