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.ListAsyncAutomations.ListAllAsyncAutomations.IterateAsyncAutomations.CreateAsyncAutomations.ListStartersAsyncAutomations.GetAsyncAutomations.UpdateAsyncAutomations.DeleteAsyncAutomations.PublishAsyncAutomations.PauseAsyncAutomations.ResumeAsyncAutomations.ArchiveAsyncAutomations.DuplicateAsyncAutomations.SendTestAsyncAutomations.ListVersionsAsyncAutomations.RestoreVersionAsyncAutomations.StatsAsyncAutomations.ListEnrollmentsAsyncAutomations.ListAllEnrollmentsAsyncAutomations.IterateEnrollmentsAsyncAutomations.GetEnrollmentAsyncAutomations.EnrollAsyncAutomations.ExitEnrollmentAsync
Automations.ListAsync
List one page of the automations in the workspace
Task<Page> ListAsync( string? status = null, int? limit = null, string? cursor = null, string? apiKey = null, CancellationToken cancellationToken = default)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 nextCursor goes back as cursor: while hasMore is true. ListAllAsync and IterateAsync 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 GetAsync 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,pausedorarchived.limitint?Rows per page, a whole number from 1 to 100. The server defaults to 50.
cursorstring?The
nextCursorfrom the previous page, passed back exactly as it came. One that names no automation is a 400invalid_cursor.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A Page with items, hasMore and nextCursor. Each item has id, name, description, status, triggerKind, stepCount, emailCount, hasUnpublishedChanges, publishedVersion, pausedReason, lastError, counts, createdBy, publishedAt, pausedAt, archivedAt, createdAt and updatedAt.
例
using OpenEmail.Constants; var page = await client.Automations.ListAsync(status: AutomationStatuses.Live); foreach (var automation in page){ Console.WriteLine($"{automation["name"]} starts on {automation["triggerKind"]}, {automation["counts"]?["active"]} in it now");}注意事項
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.
ほかの提供先
Automations.ListAllAsync
Collect every automation you can reach into one list
Task<IReadOnlyList<JsonObject>> ListAllAsync( string? status = null, int? limit = null, string? cursor = null, string? apiKey = null, CancellationToken cancellationToken = default)Follows nextCursor from page to page and returns every automation the caller can reach, the most recently saved first, in the shape ListAsync returns. limit sets the page size of each request, not the total.
パラメーター
statusstring?Only automations in this state:
draft,live,pausedorarchived.limitint?Page size per request, from 1 to 100, defaulting to 50 on the server.
cursorstring?A
nextCursorfrom an earlier page to start after.apiKeystring?Overrides the client's API key for every page of this walk.
cancellationTokenCancellationTokenCancels the request in flight and ends the whole walk.
戻り値
A list of JsonObject items holding every automation across all pages, each shaped like an item of ListAsync.
例
using OpenEmail.Constants; var automations = await client.Automations.ListAllAsync(); foreach (var automation in automations.Where(automation => (string?)automation["status"] == AutomationStatuses.Paused)){ Console.WriteLine($"{automation["name"]} paused: {automation["pausedReason"]}");}注意事項
A failure on any page throws out of the whole call.
ほかの提供先
Automations.IterateAsync
Stream the automations you can reach one at a time
IAsyncEnumerable<JsonObject> IterateAsync( string? status = null, int? limit = null, string? cursor = null, string? apiKey = null, CancellationToken cancellationToken = default)Returns an IAsyncEnumerable<JsonObject> that yields automations one by one, the most recently saved first, and requests the next page only once the current one is drained. Breaking out of the loop stops the requests.
パラメーター
statusstring?Only automations in this state:
draft,live,pausedorarchived.limitint?Page size per request, from 1 to 100, defaulting to 50 on the server.
cursorstring?A
nextCursorfrom an earlier page to start after.apiKeystring?Overrides the client's API key for every page of this walk.
cancellationTokenCancellationTokenCancels the request in flight and ends the whole walk.
戻り値
An IAsyncEnumerable<JsonObject> that yields one automation per step.
例
await foreach (var automation in client.Automations.IterateAsync()){ if ((bool?)automation["hasUnpublishedChanges"] == true) { Console.WriteLine($"Unpublished edits: {automation["name"]}"); }}注意事項
The enumerable is lazy, so an abandoned loop costs only the pages you consumed.
ほかの提供先
Automations.CreateAsync
Create an automation as a draft
Task<JsonObject> CreateAsync( IReadOnlyDictionary<string, object?> body, string? apiKey = null, CancellationToken cancellationToken = default)Makes a draft automation and returns it whole, in the shape GetAsync 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 PublishAsync, 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.
descriptionstringA note for the workspace, at most 500 characters. Contacts never see it.
starterstringBegin from a starter, by the
slugListStartersAsyncreturns:welcome-series,trial-follow-up,birthdayorwin-back. Ignored whendefinitionis sent. An unknown slug is 422invalid_automation.definitiondictionaryThe trigger and the steps, in the shape
GetAsyncreturns asdefinition.triggersays what starts the automation:audience_joinedwithaudienceIdandincludeImported,form_submittedwithformId,eventwitheventNameandfilters,datewithfield,audienceIdandoffsetDays, ormanual.entryis the key of the first step, andstepsholds every step:send_email,wait,branch,add_to_audience,remove_from_audience,update_field,webhookorexit. Each step has a uniquekeyof 3 to 24 lowercase letters and digits starting with a letter, and names the next step by key innext, or inyesandnofor a branch. Null ends the path. Paths never join or loop, and a definition holds at most 50 steps. Leave it out to usestarteror an empty draft.settings.timezonestringThe IANA time zone the sending window and waits until a day and time are read in, such as
Europe/London. Defaults toUTC.settings.sendWindowdictionaryWhen emails may go out:
daysof the week, where 0 is Sunday, andstartMinutetoendMinuteof the day, counted from midnight. An email due outside it waits for the window to open. Null, the default, sends at any time.settings.reentryDaysintHow many days after a contact finishes before they may enter again, from 1 to 3650. Null, the default, lets each contact through once only.
settings.exitOnLeaveboolTake a contact out when they leave the audience that started the automation. Defaults to true.
settings.listAudienceIdstringThe audience an unsubscribe from one of these emails is recorded in. Null, 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.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject, the automation as GetAsync returns it: the fields of a ListAsync item, with status draft, plus definition, published, which is null, settings and problems.
例
var automation = await client.Automations.CreateAsync(new Body{ ["name"] = "Welcome series", ["starter"] = "welcome-series", ["settings"] = new Body { ["timezone"] = "Europe/London" },}); Console.WriteLine($"{automation["id"]} is a {automation["status"]}"); foreach (var problem in automation["problems"]?.AsArray() ?? []){ Console.WriteLine($"{problem?["path"]}: {problem?["message"]}");}注意事項
A value of the wrong type or length is 422
invalid_parameterwithparamnaming it, and a key the body does not take is 422unknown_parameter. A definition that breaks a rule of its structure, such as two steps with one key or two paths into one step, is 422invalid_automation, and theBodyof the exception lists each one inproblems, undererror.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.
ほかの提供先
Automations.ListStartersAsync
List the ready-made automations to start from
Task<IReadOnlyList<JsonObject>> ListStartersAsync( string? apiKey = null, CancellationToken cancellationToken = default)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 CreateAsync, or pass its slug to CreateAsync 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.
パラメーター
apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A list of JsonObject items, each with slug, name, description and definition.
例
var starters = await client.Automations.ListStartersAsync(); foreach (var starter in starters){ Console.WriteLine($"{starter["slug"]}: {starter["description"]}");}注意事項
Read only, so the SDK retries it after a network failure like any other read.
ほかの提供先
Automations.GetAsync
Retrieve an automation with its definition and settings
Task<JsonObject> GetAsync( string id, string? apiKey = null, CancellationToken cancellationToken = default)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 PublishAsync 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.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject 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.
例
var automation = await client.Automations.GetAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1");var definition = automation["definition"]; Console.WriteLine($"{automation["status"]}, starts on {definition?["trigger"]?["kind"]}, {definition?["steps"]?.AsArray().Count} steps"); foreach (var problem in automation["problems"]?.AsArray() ?? []){ if ((bool?)problem?["blocking"] == true) { Console.WriteLine($"{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.
ほかの提供先
Automations.UpdateAsync
Change the draft, the settings or the name of an automation
Task<JsonObject> UpdateAsync( string id, IReadOnlyDictionary<string, object?> patch, string? apiKey = null, CancellationToken cancellationToken = default)A partial update that returns the automation whole. definition replaces the draft, and a live automation keeps running its published version until you PublishAsync 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.namestringNew name, trimmed, 1 to 120 characters.
descriptionstringNew note, at most 500 characters. Null clears it.
definitiondictionaryThe new draft, whole. The trigger and the steps, in the shape
GetAsyncreturns asdefinition.triggersays what starts the automation:audience_joinedwithaudienceIdandincludeImported,form_submittedwithformId,eventwitheventNameandfilters,datewithfield,audienceIdandoffsetDays, ormanual.entryis the key of the first step, andstepsholds every step:send_email,wait,branch,add_to_audience,remove_from_audience,update_field,webhookorexit. Each step has a uniquekeyof 3 to 24 lowercase letters and digits starting with a letter, and names the next step by key innext, or inyesandnofor a branch. Null ends the path. Paths never join or loop, and a definition holds at most 50 steps.settings.timezonestringThe IANA time zone the sending window and waits until a day and time are read in, such as
Europe/London. Defaults toUTC.settings.sendWindowdictionaryWhen emails may go out:
daysof the week, where 0 is Sunday, andstartMinutetoendMinuteof the day, counted from midnight. An email due outside it waits for the window to open. Null, the default, sends at any time.settings.reentryDaysintHow many days after a contact finishes before they may enter again, from 1 to 3650. Null, the default, lets each contact through once only.
settings.exitOnLeaveboolTake a contact out when they leave the audience that started the automation. Defaults to true.
settings.listAudienceIdstringThe audience an unsubscribe from one of these emails is recorded in. Null, 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.expectedUpdatedAtstringThe
updatedAtyou read, as an ISO 8601 instant. When the automation was saved since, the call is refused with 409version_conflictand nothing is written.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject, the automation as it is after the save, with a new updatedAt and, when the draft changed, hasUnpublishedChanges true on a published automation.
例
var current = await client.Automations.GetAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1"); var saved = await client.Automations.UpdateAsync(current["id"]!.GetValue<string>(), new Body{ ["settings"] = new Body { ["sendWindow"] = new Body { ["days"] = new[] { 1, 2, 3, 4, 5 }, ["startMinute"] = 540, ["endMinute"] = 1020 }, }, ["expectedUpdatedAt"] = current["updatedAt"],}); Console.WriteLine($"{saved["settings"]?["sendWindow"]} saved at {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 422unknown_parameter, and a definition that breaks a rule of its structure is 422invalid_automation, withproblemsundererrorin theBodyof the exception.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 409version_conflict: read the automation to see that your change is there.
ほかの提供先
Automations.DeleteAsync
Delete an automation with its versions and history
Task<JsonObject> DeleteAsync( string id, string? apiKey = null, CancellationToken cancellationToken = default)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.ListAsync.
There is no undo. To retire an automation and keep its history, use ArchiveAsync.
パラメーター
idstring必須Automation id such as
aut_5c1e9a7b3d2f48e6a0b4c7d1.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject with object set to automation, id and deleted set to true.
例
var removed = await client.Automations.DeleteAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1"); Console.WriteLine($"{removed["id"]} deleted: {removed["deleted"]}");注意事項
An OAuth access token needs a verification code for this call, and is refused with 403
step_up_requireduntil the app has verified one in the last 60 minutes.IsStepUpRequiredon the exception 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.
ほかの提供先
Automations.PublishAsync
Publish the draft and turn the automation on
Task<JsonObject> PublishAsync( string id, string? apiKey = null, CancellationToken cancellationToken = default)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 the Body of the exception lists every problem that blocks it in problems, under error.
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.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject, the automation as GetAsync returns it, with status live, a new publishedAt, the publishedVersion that is now running and hasUnpublishedChanges false.
例
var automation = await client.Automations.PublishAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1"); Console.WriteLine($"{automation["status"]}, version {automation["publishedVersion"]} since {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.
ほかの提供先
Automations.PauseAsync
Stop a live automation without losing anybody
Task<JsonObject> PauseAsync( string id, string? apiKey = null, CancellationToken cancellationToken = default)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.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject, the automation as GetAsync returns it, with status paused, pausedReason manual and pausedAt set.
例
var automation = await client.Automations.PauseAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1"); Console.WriteLine($"{automation["status"]} ({automation["pausedReason"]}), {automation["counts"]?["active"]} held");注意事項
A draft that was never published answers 409
automation_not_published, and an archived automation 409automation_archived.Retried automatically on network failure and retryable statuses, since pausing twice leaves the same paused automation.
ほかの提供先
Automations.ResumeAsync
Turn a paused automation back on
Task<JsonObject> ResumeAsync( string id, string? apiKey = null, CancellationToken cancellationToken = default)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 PublishAsync 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.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject, the automation as GetAsync returns it, with status live and pausedReason, pausedAt and lastError cleared.
例
var automation = await client.Automations.ResumeAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1"); Console.WriteLine($"{automation["status"]}, version {automation["publishedVersion"]}");注意事項
An automation with no published version answers 409
automation_not_published, an archived one 409automation_archived, and a plan that covers no more live automations 403automation_limit_reached.Retried automatically on network failure and retryable statuses, since resuming twice leaves the same live automation.
ほかの提供先
Automations.ArchiveAsync
Retire an automation for good and keep its history
Task<JsonObject> ArchiveAsync( string id, string? apiKey = null, CancellationToken cancellationToken = default)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 DuplicateAsync.
パラメーター
idstring必須Automation id such as
aut_5c1e9a7b3d2f48e6a0b4c7d1.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject, the automation as GetAsync returns it, with status archived and archivedAt set.
例
var automation = await client.Automations.ArchiveAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1"); Console.WriteLine($"{automation["status"]} at {automation["archivedAt"]}");注意事項
There is no way back from archived. To stop an automation for a while, use
PauseAsync.Retried automatically on network failure and retryable statuses, since archiving twice leaves the same archived automation.
ほかの提供先
Automations.DuplicateAsync
Copy an automation into a new draft
Task<JsonObject> DuplicateAsync( string id, string? apiKey = null, CancellationToken cancellationToken = default)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.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject, the copy as GetAsync returns an automation, with its own id and status draft.
例
var copy = await client.Automations.DuplicateAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1"); Console.WriteLine($"{copy["id"]} {copy["name"]} is a {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.
ほかの提供先
Automations.SendTestAsync
Send yourself the email of one step
Task<JsonObject> SendTestAsync( string id, IReadOnlyDictionary<string, object?> body, string? apiKey = null, CancellationToken cancellationToken = default)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
keyof the email step to send, from the draftdefinition.tostringWhere 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.
apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject with automationId, emailId, the email as Emails.GetAsync returns it, to and stepKey.
例
var test = await client.Automations.SendTestAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1", new Body{ ["stepKey"] = "welcome", ["to"] = "[email protected]",}); Console.WriteLine($"{test["emailId"]} went to {test["to"]}");注意事項
A
stepKeythat names no step, a step that is not an email, or a template that cannot be sent is 422invalid_automationwithparamstepKey.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 409domain_not_sendable, and a plan with no sends left is 429send_quota_exceeded.Not retried automatically, because a retry after a lost response would send the test twice.
ほかの提供先
Automations.ListVersionsAsync
List the published versions of an automation
Task<IReadOnlyList<JsonObject>> ListVersionsAsync( string id, string? apiKey = null, CancellationToken cancellationToken = default)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.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A list of JsonObject items, each with id, automationId, version, definition, current, createdBy and createdAt.
例
var versions = await client.Automations.ListVersionsAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1"); foreach (var version in versions){ Console.WriteLine($"{version["version"]}{((bool?)version["current"] == true ? " (running)" : "")} from {version["createdAt"]}");}注意事項
Read only, so the SDK retries it after a network failure like any other read.
ほかの提供先
Automations.RestoreVersionAsync
Copy an earlier version back into the draft
Task<JsonObject> RestoreVersionAsync( string id, int version, string? apiKey = null, CancellationToken cancellationToken = default)Copies the definition of an earlier version into the draft, replacing what the draft holds. Nothing that is running changes until you PublishAsync. It takes no body.
パラメーター
idstring必須Automation id such as
aut_5c1e9a7b3d2f48e6a0b4c7d1.versionint必須The number of the version, from
ListVersionsAsync. A whole number from 1 up.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject, the automation as GetAsync returns it, with the version in definition, and hasUnpublishedChanges true when it differs from the one that is running.
例
var automation = await client.Automations.RestoreVersionAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1", 2); Console.WriteLine($"{automation["definition"]?["steps"]?.AsArray().Count} steps in the draft, unpublished changes: {automation["hasUnpublishedChanges"]}");注意事項
A version the automation does not have is 404
automation_not_foundwithparamversion, and an archived automation is 409automation_archived.Retried automatically on network failure and retryable statuses, since restoring the same version twice leaves the same draft.
ほかの提供先
Automations.StatsAsync
Read how an automation has performed
Task<JsonObject> StatsAsync( string id, DateTimeOffset? since = null, DateTimeOffset? until = null, string? apiKey = null, CancellationToken cancellationToken = default)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. totals.active 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.sinceDateTimeOffset?Where the window starts. Left out, 30 days before
until:.untilDateTimeOffset?Where the window ends. Left out, now. It has to be later than
since:.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject with automationId, since, until, totals (entered, active, completed, exited, sent, delivered, opened, clicked, bounced, complained and unsubscribed), steps and series.
例
var stats = await client.Automations.StatsAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1", since: DateTimeOffset.Parse("2026-09-01T00:00:00Z"));var totals = stats["totals"]; Console.WriteLine($"{totals?["entered"]} entered, {totals?["sent"]} sent, {totals?["clicked"]} clicked"); foreach (var step in stats["steps"]?.AsArray() ?? []){ Console.WriteLine($"{step?["stepKey"]} ({step?["kind"]}): {step?["entered"]} entered, {step?["waiting"]} waiting");}注意事項
An
until:that is not aftersince:is 422invalid_parameter.Read only, so the SDK retries it after a network failure like any other read.
ほかの提供先
Automations.ListEnrollmentsAsync
List one page of the contacts in an automation
Task<Page> ListEnrollmentsAsync( string id, string? status = null, string? stepKey = null, string? q = null, int? limit = null, string? cursor = null, string? apiKey = null, CancellationToken cancellationToken = default)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 nextCursor back as cursor:, with the same filters, while hasMore is true. ListAllEnrollmentsAsync and IterateEnrollmentsAsync do that walk for you.
パラメーター
idstring必須Automation id such as
aut_5c1e9a7b3d2f48e6a0b4c7d1.statusstring?Only enrollments in this state:
active,completedorexited.stepKeystring?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.
limitint?Rows per page, a whole number from 1 to 200. The server defaults to 50.
cursorstring?The
nextCursorfrom the previous page, passed back exactly as it came. One that names no enrollment of this automation is a 400invalid_cursor.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A Page with items, hasMore and nextCursor. Each item has id, automationId, version, contact, status, source, stepKey, waiting, waitingForEvent, heldFor, nextRunAt, exitReason, lastError, startedAt, finishedAt and updatedAt.
例
using OpenEmail.Constants; var page = await client.Automations.ListEnrollmentsAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1", status: AutomationEnrollmentStatuses.Active); foreach (var enrollment in page){ Console.WriteLine($"{enrollment["contact"]?["email"]} is at {enrollment["stepKey"]}, next at {enrollment["nextRunAt"]}");}注意事項
Read only, so the SDK retries it after a network failure like any other read.
ほかの提供先
Automations.ListAllEnrollmentsAsync
Collect every enrollment of an automation into one list
Task<IReadOnlyList<JsonObject>> ListAllEnrollmentsAsync( string id, string? status = null, string? stepKey = null, string? q = null, int? limit = null, string? cursor = null, string? apiKey = null, CancellationToken cancellationToken = default)Follows nextCursor from page to page and returns every enrollment that matches, the most recent entry first, in the shape ListEnrollmentsAsync returns. limit sets the page size of each request, not the total. An automation can hold a great many enrollments, so prefer IterateEnrollmentsAsync when you do not need them all in memory.
パラメーター
idstring必須Automation id such as
aut_5c1e9a7b3d2f48e6a0b4c7d1.statusstring?Only enrollments in this state:
active,completedorexited.stepKeystring?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.
limitint?Page size per request, from 1 to 200, defaulting to 50 on the server.
cursorstring?A
nextCursorfrom an earlier page to start after.apiKeystring?Overrides the client's API key for every page of this walk.
cancellationTokenCancellationTokenCancels the request in flight and ends the whole walk.
戻り値
A list of JsonObject items holding every matching enrollment across all pages, each shaped like an item of ListEnrollmentsAsync.
例
using OpenEmail.Constants; var exited = await client.Automations.ListAllEnrollmentsAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1", status: AutomationEnrollmentStatuses.Exited, limit: 200);var unsubscribed = exited.Count(enrollment => (string?)enrollment["exitReason"] == AutomationExitReasons.Unsubscribed); Console.WriteLine($"{unsubscribed} of {exited.Count} left by unsubscribing");注意事項
A failure on any page throws out of the whole call.
ほかの提供先
Automations.IterateEnrollmentsAsync
Stream the enrollments of an automation one at a time
IAsyncEnumerable<JsonObject> IterateEnrollmentsAsync( string id, string? status = null, string? stepKey = null, string? q = null, int? limit = null, string? cursor = null, string? apiKey = null, CancellationToken cancellationToken = default)Returns an IAsyncEnumerable<JsonObject> that yields enrollments one by one, the most recent entry first, and requests the next page only once the current one is drained. Breaking out of the loop stops the requests.
パラメーター
idstring必須Automation id such as
aut_5c1e9a7b3d2f48e6a0b4c7d1.statusstring?Only enrollments in this state:
active,completedorexited.stepKeystring?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.
limitint?Page size per request, from 1 to 200, defaulting to 50 on the server.
cursorstring?A
nextCursorfrom an earlier page to start after.apiKeystring?Overrides the client's API key for every page of this walk.
cancellationTokenCancellationTokenCancels the request in flight and ends the whole walk.
戻り値
An IAsyncEnumerable<JsonObject> that yields one enrollment per step.
例
using OpenEmail.Constants; await foreach (var enrollment in client.Automations.IterateEnrollmentsAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1", status: AutomationEnrollmentStatuses.Active)){ if (enrollment["heldFor"] is not null) { Console.WriteLine($"{enrollment["contact"]?["email"]} is held for {enrollment["heldFor"]}"); }}注意事項
The enumerable is lazy, so an abandoned loop costs only the pages you consumed.
ほかの提供先
Automations.GetEnrollmentAsync
Retrieve one contact's way through an automation
Task<JsonObject> GetEnrollmentAsync( string id, string enrollmentId, string? apiKey = null, CancellationToken cancellationToken = default)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.enrollmentIdstring必須Enrollment id such as
aen_2b8d4f6a1c3e5079b6d8f0a2, fromListEnrollmentsAsync.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject with id, automationId, version, contact, status, source, stepKey, waiting, waitingForEvent, heldFor, nextRunAt, exitReason, lastError, startedAt, finishedAt and updatedAt, plus runs.
例
var enrollment = await client.Automations.GetEnrollmentAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1", "aen_2b8d4f6a1c3e5079b6d8f0a2"); foreach (var run in enrollment["runs"]?.AsArray() ?? []){ Console.WriteLine($"{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.
ほかの提供先
Automations.EnrollAsync
Put a contact into a live automation
Task<JsonObject> EnrollAsync( string id, IReadOnlyDictionary<string, object?> body, string? apiKey = null, CancellationToken cancellationToken = default)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.CreateAsync 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.reentryDays. 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.emailstringThe contact, by email address. Send this or
contactId.contactIdstringThe contact, by id, as an event or another enrollment carries it. Send this or
email.datadictionaryValues 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.
apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject, the enrollment shaped like an item of ListEnrollmentsAsync, with status active, source api and nextRunAt now. The first step runs within about a minute.
例
var enrollment = await client.Automations.EnrollAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1", new Body{ ["email"] = "[email protected]", ["data"] = new Body { ["plan"] = "team" },}); Console.WriteLine($"{enrollment["id"]} is {enrollment["status"]}, first step at {enrollment["nextRunAt"]}");注意事項
An automation that is a draft, paused or archived answers 409
automation_not_live. A contact who is in it, or finished it too recently, answers 409already_enrolled, and a suppressed or unsubscribed address 409contact_unreachable. An address or id nobody has is 404contact_not_found.Sending neither or both of
emailandcontactIdis 422invalid_parameter.Not retried automatically. After a lost response, a second attempt that answers 409
already_enrolledmeans the first one worked.
ほかの提供先
Automations.ExitEnrollmentAsync
Take a contact out of an automation
Task<JsonObject> ExitEnrollmentAsync( string id, string enrollmentId, string? apiKey = null, CancellationToken cancellationToken = default)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.enrollmentIdstring必須Enrollment id such as
aen_2b8d4f6a1c3e5079b6d8f0a2, fromListEnrollmentsAsync.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
戻り値
A JsonObject, the enrollment shaped like an item of ListEnrollmentsAsync, with status exited, exitReason removed and finishedAt set.
例
var enrollment = await client.Automations.ExitEnrollmentAsync("aut_5c1e9a7b3d2f48e6a0b4c7d1", "aen_2b8d4f6a1c3e5079b6d8f0a2"); Console.WriteLine($"{enrollment["status"]} ({enrollment["exitReason"]}) at {enrollment["finishedAt"]}");注意事項
An enrollment that already completed or left answers 409
automation_enrollment_finished.Not retried automatically. After a lost response, a second attempt that answers 409
automation_enrollment_finishedmeans the first one worked.