Ir a la documentación
Go

client.Automations

Cada método de este espacio de nombres: su firma, sus parámetros, lo que devuelve y un ejemplo.

Métodos

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

Alcancesautomations:readRecorre los resultados por páginas
Firma
List(ctx context.Context, opts ...openemail.RequestOption) (*openemail.Page, error)

Returns one page of the automations the caller can reach, the most recently saved first, without their definitions or settings. Paging is keyset: openemail.WithLimit takes 1 to 100 and defaults to 50, and NextCursor goes back as openemail.WithCursor while HasMore is true. ListAll 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.

Parámetros

openemail.WithStatus...string

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

openemail.WithLimitint

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

openemail.WithCursorstring

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

openemail.WithAPIKeystring

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

Devuelve

A *openemail.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.

Ejemplo

page, err := client.Automations.List(ctx, openemail.WithStatus("live"))if err != nil {	return err} for _, automation := range page.Items {	fmt.Printf("%s starts on %s, %d in it now\n", automation.String("name"), automation.String("triggerKind"), automation.Object("counts").Int("active"))} fmt.Println(page.HasMore, page.NextCursor)

Notas

  • 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.

También disponible en

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

Automations.ListAll

Collect every automation you can reach into one slice

Alcancesautomations:readRecorre los resultados por páginas
Firma
ListAll(ctx context.Context, opts ...openemail.RequestOption) ([]openemail.Object, error)

Follows NextCursor from page to page and returns with every automation the caller can reach, the most recently saved first, in the shape List returns. openemail.WithLimit sets the page size of each request, not the total.

Parámetros

openemail.WithStatus...string

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

openemail.WithLimitint

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

openemail.WithCursorstring

A NextCursor from an earlier page to start after.

openemail.WithAPIKeystring

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

Devuelve

A []openemail.Object holding every automation across all pages.

Ejemplo

automations, err := client.Automations.ListAll(ctx)if err != nil {	return err} for _, automation := range automations {	if automation.String("status") == "paused" {		fmt.Println(automation.String("name"), automation.String("pausedReason"))	}}

Notas

  • A failure on any page fails the whole call.

También disponible en

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

Automations.Iterate

Stream the automations you can reach one at a time

Alcancesautomations:readRecorre los resultados por páginas
Firma
Iterate(ctx context.Context, opts ...openemail.RequestOption) *openemail.Iterator

Returns an iterator 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.

Parámetros

openemail.WithStatus...string

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

openemail.WithLimitint

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

openemail.WithCursorstring

A NextCursor from an earlier page to start after.

openemail.WithAPIKeystring

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

Devuelve

An *openemail.Iterator yielding one automation per step.

Ejemplo

for automation, err := range client.Automations.Iterate(ctx).All() {	if err != nil {		return err	} 	if automation.Bool("hasUnpublishedChanges") {		fmt.Println("unpublished edits:", automation.String("name"))	}}

Notas

  • The iterator is lazy, so an abandoned loop costs only the pages you consumed.

También disponible en

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

Automations.Create

Create an automation as a draft

Alcancesautomations:write
Firma
Create(ctx context.Context, body openemail.Body, opts ...openemail.RequestOption) (openemail.Object, error)

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.

Parámetros

namestringObligatorio

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

descriptionstring | nil

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

starterstring

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

definitionopenemail.Body

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. Null 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.sendWindowopenemail.Body | 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. Null, the default, sends at any time.

settings.reentryDaysint | nil

How 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.exitOnLeavebool

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

settings.listAudienceIdstring | nil

The 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.

openemail.WithAPIKeystring

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

Devuelve

An openemail.Object: the automation object fields with status draft, plus definition, published, which is null, settings and problems.

Ejemplo

automation, err := client.Automations.Create(ctx, openemail.Body{	"name":     "Welcome series",	"starter":  "welcome-series",	"settings": openemail.Body{"timezone": "Europe/London"},})if err != nil {	return err} fmt.Println(automation.String("id"), automation.String("status")) for _, problem := range automation.Objects("problems") {	fmt.Println(problem.String("path"), problem.String("message"))}

Notas

  • 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 the Body of the error lists each one in problems, under error.

  • 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.

También disponible en

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

Automations.ListStarters

List the ready-made automations to start from

Alcancesautomations:read
Firma
ListStarters(ctx context.Context, opts ...openemail.RequestOption) ([]openemail.Object, error)

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.

Parámetros

openemail.WithAPIKeystring

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

Devuelve

A []openemail.Object, each with slug, name, description and definition.

Ejemplo

starters, err := client.Automations.ListStarters(ctx)if err != nil {	return err} for _, starter := range starters {	fmt.Println(starter.String("slug"), starter.String("description"))}

Notas

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

También disponible en

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

Automations.Get

Retrieve an automation with its definition and settings

Alcancesautomations:read
Firma
Get(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

openemail.WithAPIKeystring

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

Devuelve

An openemail.Object: 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.

Ejemplo

automation, err := client.Automations.Get(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1")if err != nil {	return err} definition := automation.Object("definition") fmt.Println(automation.String("status"), definition.Object("trigger").String("kind"), len(definition.Objects("steps"))) for _, problem := range automation.Objects("problems") {	if problem.Bool("blocking") {		fmt.Println(problem.String("message"))	}}

Notas

  • 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.

También disponible en

API
GET /automations/{id}
TypeScript
automations.get()
Python
automations.get()
Ruby
automations.get
PHP
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

Alcancesautomations:write
Firma
Update(ctx context.Context, id string, patch openemail.Body, opts ...openemail.RequestOption) (openemail.Object, error)

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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

namestring

New name, trimmed, 1 to 120 characters.

descriptionstring | nil

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

definitionopenemail.Body

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. Null 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.sendWindowopenemail.Body | 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. Null, the default, sends at any time.

settings.reentryDaysint | nil

How 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.exitOnLeavebool

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

settings.listAudienceIdstring | nil

The 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.

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.

openemail.WithAPIKeystring

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

Devuelve

An openemail.Object as it is after the save, with a new updatedAt and, when the draft changed, hasUnpublishedChanges true on a published automation.

Ejemplo

current, err := client.Automations.Get(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1")if err != nil {	return err} saved, err := client.Automations.Update(ctx, current.String("id"), openemail.Body{	"settings": openemail.Body{		"sendWindow": openemail.Body{"days": []int{1, 2, 3, 4, 5}, "startMinute": 540, "endMinute": 1020},	},	"expectedUpdatedAt": current.String("updatedAt"),})if err != nil {	return err} fmt.Println(saved.Object("settings").Object("sendWindow"), saved.String("updatedAt"))

Notas

  • 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 under error in the Body of 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.

También disponible en

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

Automations.Delete

Delete an automation with its versions and history

Alcancesautomations:write
Firma
Delete(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

openemail.WithAPIKeystring

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

Devuelve

An openemail.Object with object set to automation, id and deleted set to true.

Ejemplo

removed, err := client.Automations.Delete(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1")if err != nil {	return err} fmt.Println(removed.String("id"), removed.Bool("deleted"))

Notas

  • 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. The error matches openemail.ErrStepUpRequired. 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.

También disponible en

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

Automations.Publish

Publish the draft and turn the automation on

Alcancesautomations:writeemails:send
Firma
Publish(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

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 error 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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

openemail.WithAPIKeystring

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

Devuelve

An openemail.Object with status live, a new publishedAt, the publishedVersion that is now running and hasUnpublishedChanges false.

Ejemplo

automation, err := client.Automations.Publish(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1")if err != nil {	return err} fmt.Println(automation.String("status"), automation.Int("publishedVersion"), automation.String("publishedAt"))

Notas

  • 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.

También disponible en

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

Automations.Pause

Stop a live automation without losing anybody

Alcancesautomations:write
Firma
Pause(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

openemail.WithAPIKeystring

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

Devuelve

An openemail.Object with status paused, pausedReason manual and pausedAt set.

Ejemplo

automation, err := client.Automations.Pause(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1")if err != nil {	return err} fmt.Println(automation.String("status"), automation.String("pausedReason"), automation.Object("counts").Int("active"))

Notas

  • 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.

También disponible en

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

Automations.Resume

Turn a paused automation back on

Alcancesautomations:writeemails:send
Firma
Resume(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

openemail.WithAPIKeystring

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

Devuelve

An openemail.Object with status live and pausedReason, pausedAt and lastError cleared.

Ejemplo

automation, err := client.Automations.Resume(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1")if err != nil {	return err} fmt.Println(automation.String("status"), automation.Int("publishedVersion"))

Notas

También disponible en

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

Automations.Archive

Retire an automation for good and keep its history

Alcancesautomations:write
Firma
Archive(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

openemail.WithAPIKeystring

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

Devuelve

An openemail.Object with status archived and archivedAt set.

Ejemplo

automation, err := client.Automations.Archive(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1")if err != nil {	return err} fmt.Println(automation.String("status"), automation.String("archivedAt"))

Notas

  • 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.

También disponible en

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

Automations.Duplicate

Copy an automation into a new draft

Alcancesautomations:write
Firma
Duplicate(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

openemail.WithAPIKeystring

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

Devuelve

An openemail.Object for the copy, with its own id and status draft.

Ejemplo

copied, err := client.Automations.Duplicate(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1")if err != nil {	return err} fmt.Println(copied.String("id"), copied.String("name"), copied.String("status"))

Notas

  • 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.

También disponible en

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

Automations.SendTest

Send yourself the email of one step

Alcancesautomations:writeemails:send
Firma
SendTest(ctx context.Context, id string, body openemail.Body, opts ...openemail.RequestOption) (openemail.Object, error)

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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

stepKeystringObligatorio

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.

openemail.WithAPIKeystring

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

Devuelve

An openemail.Object with automationId, emailId, the email as Emails.Get returns it, to and stepKey.

Ejemplo

test, err := client.Automations.SendTest(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1", openemail.Body{"stepKey": "welcome", "to": "[email protected]"})if err != nil {	return err} fmt.Println(test.String("emailId"), test.String("to"))

Notas

  • 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.

También disponible en

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

Automations.ListVersions

List the published versions of an automation

Alcancesautomations:read
Firma
ListVersions(ctx context.Context, id string, opts ...openemail.RequestOption) ([]openemail.Object, error)

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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

openemail.WithAPIKeystring

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

Devuelve

A []openemail.Object, each with id, automationId, version, definition, current, createdBy and createdAt.

Ejemplo

versions, err := client.Automations.ListVersions(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1")if err != nil {	return err} for _, version := range versions {	fmt.Println(version.Int("version"), version.Bool("current"), version.String("createdAt"))}

Notas

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

También disponible en

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

Automations.RestoreVersion

Copy an earlier version back into the draft

Alcancesautomations:write
Firma
RestoreVersion(ctx context.Context, id string, version int, opts ...openemail.RequestOption) (openemail.Object, error)

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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

versionintObligatorio

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

openemail.WithAPIKeystring

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

Devuelve

An openemail.Object with the version in definition, and hasUnpublishedChanges true when it differs from the one that is running.

Ejemplo

automation, err := client.Automations.RestoreVersion(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1", 2)if err != nil {	return err} fmt.Println(automation.Bool("hasUnpublishedChanges"), len(automation.Object("definition").Objects("steps")))

Notas

  • 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.

También disponible en

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

Automations.Stats

Read how an automation has performed

Alcancesautomations:read
Firma
Stats(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

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 openemail.WithUntil.

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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

openemail.WithSincetime.Time

Where the window starts. Left out, 30 days before openemail.WithUntil.

openemail.WithUntiltime.Time

Where the window ends. Left out, now. It has to be later than openemail.WithSince.

openemail.WithAPIKeystring

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

Devuelve

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

Ejemplo

stats, err := client.Automations.Stats(	ctx,	"aut_5c1e9a7b3d2f48e6a0b4c7d1",	openemail.WithSince(time.Date(2026, time.September, 1, 0, 0, 0, 0, time.UTC)),)if err != nil {	return err} totals := stats.Object("totals") fmt.Println(totals.Int("entered"), totals.Int("sent"), totals.Int("clicked")) for _, step := range stats.Objects("steps") {	fmt.Println(step.String("stepKey"), step.String("kind"), step.Int("entered"), step.Int("waiting"))}

Notas

  • An openemail.WithUntil that is not after openemail.WithSince is 422 invalid_parameter.

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

También disponible en

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

Automations.ListEnrollments

List one page of the contacts in an automation

Alcancesautomations:readRecorre los resultados por páginas
Firma
ListEnrollments(ctx context.Context, id string, opts ...openemail.RequestOption) (*openemail.Page, error)

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.

openemail.WithLimit takes 1 to 200 and defaults to 50. Pass NextCursor back as openemail.WithCursor, with the same filters, while HasMore is true. ListAllEnrollments and IterateEnrollments do that walk for you.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

openemail.WithStatus...string

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

openemail.WithStepKeystring

Only contacts at the step with this key.

openemail.WithQstring

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

openemail.WithLimitint

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

openemail.WithCursorstring

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

openemail.WithAPIKeystring

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

Devuelve

A *openemail.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.

Ejemplo

page, err := client.Automations.ListEnrollments(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1", openemail.WithStatus("active"))if err != nil {	return err} for _, enrollment := range page.Items {	fmt.Println(enrollment.Object("contact").String("email"), enrollment.String("stepKey"), enrollment.String("nextRunAt"))} fmt.Println(page.HasMore, page.NextCursor)

Notas

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

También disponible en

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

Automations.ListAllEnrollments

Collect every enrollment of an automation into one slice

Alcancesautomations:readRecorre los resultados por páginas
Firma
ListAllEnrollments(ctx context.Context, id string, opts ...openemail.RequestOption) ([]openemail.Object, error)

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

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

openemail.WithStatus...string

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

openemail.WithStepKeystring

Only contacts at the step with this key.

openemail.WithQstring

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

openemail.WithLimitint

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

openemail.WithCursorstring

A NextCursor from an earlier page to start after.

openemail.WithAPIKeystring

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

Devuelve

A []openemail.Object holding every matching enrollment across all pages.

Ejemplo

exited, err := client.Automations.ListAllEnrollments(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1", openemail.WithStatus("exited"), openemail.WithLimit(200))if err != nil {	return err} unsubscribed := 0 for _, enrollment := range exited {	if enrollment.String("exitReason") == "unsubscribed" {		unsubscribed++	}} fmt.Printf("%d of %d left by unsubscribing\n", unsubscribed, len(exited))

Notas

  • A failure on any page fails the whole call.

También disponible en

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

Automations.IterateEnrollments

Stream the enrollments of an automation one at a time

Alcancesautomations:readRecorre los resultados por páginas
Firma
IterateEnrollments(ctx context.Context, id string, opts ...openemail.RequestOption) *openemail.Iterator

Returns an iterator 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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

openemail.WithStatus...string

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

openemail.WithStepKeystring

Only contacts at the step with this key.

openemail.WithQstring

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

openemail.WithLimitint

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

openemail.WithCursorstring

A NextCursor from an earlier page to start after.

openemail.WithAPIKeystring

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

Devuelve

An *openemail.Iterator yielding one enrollment per step.

Ejemplo

for enrollment, err := range client.Automations.IterateEnrollments(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1", openemail.WithStatus("active")).All() {	if err != nil {		return err	} 	if enrollment.String("heldFor") != "" {		fmt.Println(enrollment.Object("contact").String("email"), "held for", enrollment.String("heldFor"))	}}

Notas

  • The iterator is lazy, so an abandoned loop costs only the pages you consumed.

También disponible en

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

Automations.GetEnrollment

Retrieve one contact's way through an automation

Alcancesautomations:read
Firma
GetEnrollment(ctx context.Context, id string, enrollmentID string, opts ...openemail.RequestOption) (openemail.Object, error)

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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

enrollmentIDstringObligatorio

Enrollment id such as aen_2b8d4f6a1c3e5079b6d8f0a2, from ListEnrollments.

openemail.WithAPIKeystring

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

Devuelve

An openemail.Object: id, automationId, version, contact, status, source, stepKey, waiting, waitingForEvent, heldFor, nextRunAt, exitReason, lastError, startedAt, finishedAt and updatedAt, plus runs.

Ejemplo

enrollment, err := client.Automations.GetEnrollment(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1", "aen_2b8d4f6a1c3e5079b6d8f0a2")if err != nil {	return err} for _, run := range enrollment.Objects("runs") {	fmt.Println(run.String("createdAt"), run.String("stepKey"), run.String("outcome"), run.String("detail"))}

Notas

  • 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.

También disponible en

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

Automations.Enroll

Put a contact into a live automation

Alcancesautomations:write
Firma
Enroll(ctx context.Context, id string, body openemail.Body, opts ...openemail.RequestOption) (openemail.Object, error)

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.reentryDays. An address on the suppression list, or one that unsubscribed from the audience the automation sends through, is refused.

Parámetros

idstringObligatorio

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.

dataopenemail.Body

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.

openemail.WithAPIKeystring

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

Devuelve

An openemail.Object with status active, source api and nextRunAt now. The first step runs within about a minute.

Ejemplo

enrollment, err := client.Automations.Enroll(	ctx,	"aut_5c1e9a7b3d2f48e6a0b4c7d1",	openemail.Body{"email": "[email protected]", "data": openemail.Body{"plan": "team"}},)if err != nil {	return err} fmt.Println(enrollment.String("id"), enrollment.String("status"), enrollment.String("nextRunAt"))

Notas

También disponible en

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

Automations.ExitEnrollment

Take a contact out of an automation

Alcancesautomations:write
Firma
ExitEnrollment(ctx context.Context, id string, enrollmentID string, opts ...openemail.RequestOption) (openemail.Object, error)

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.

Parámetros

idstringObligatorio

Automation id such as aut_5c1e9a7b3d2f48e6a0b4c7d1.

enrollmentIDstringObligatorio

Enrollment id such as aen_2b8d4f6a1c3e5079b6d8f0a2, from ListEnrollments.

openemail.WithAPIKeystring

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

Devuelve

An openemail.Object with status exited, exitReason removed and finishedAt set.

Ejemplo

enrollment, err := client.Automations.ExitEnrollment(ctx, "aut_5c1e9a7b3d2f48e6a0b4c7d1", "aen_2b8d4f6a1c3e5079b6d8f0a2")if err != nil {	return err} fmt.Println(enrollment.String("status"), enrollment.String("exitReason"), enrollment.String("finishedAt"))

Notas

También disponible en

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