Ir a la documentación
TypeScript

Automatizaciones

`automations.list`, `get`, `create`, `update`, `publish`, `pause`, `resume`, `archive`, `duplicate`, `delete`, `sendTest`, `stats`, `listVersions`, `restoreVersion`, `listStarters`, `listEnrollments`, `getEnrollment`, `enroll` y `exitEnrollment`, con `events.send`, `sendBatch` y `listNames`.

Todos los métodos

automations.ts
const automation = await openemail.automations.create({  name: 'Welcome series',  starter: 'welcome-series',  settings: { timezone: 'Europe/London' },}) const saved = await openemail.automations.update(automation.id, {  definition: { ...automation.definition, trigger: { kind: 'event', eventName: 'trial.started', filters: [] } },  expectedUpdatedAt: automation.updatedAt,}) if (saved.problems.some((problem) => problem.blocking)) throw new Error(saved.problems[0]?.message) await openemail.automations.sendTest(saved.id, { stepKey: saved.definition.entry ?? '' })const live = await openemail.automations.publish(saved.id) const sent = await openemail.events.send(  { name: 'trial.started', email: '[email protected]', properties: { plan: 'starter' }, createContact: true },  { idempotencyKey: 'trial:[email protected]' },) for await (const enrollment of openemail.automations.iterateEnrollments(live.id, { status: 'active' })) {  if (enrollment.heldFor) console.log(enrollment.contact.email, enrollment.heldFor)} const stats = await openemail.automations.stats(live.id)const history = await openemail.contacts.listEvents('[email protected]', { name: 'trial.started' }) await openemail.automations.pause(live.id)await openemail.automations.resume(live.id) console.log(sent.enrolled, stats.totals.entered, history.items.length)

Una automatización guarda un borrador definition y la versión published que se ejecuta. update cambia el borrador y los ajustes, y publish congela el borrador como la siguiente versión y activa la automatización. problems dice qué impide todavía publicar un borrador, y expectedUpdatedAt rechaza con 409 version_conflict un guardado que sobrescribiría el de otra persona.

Leer requiere automations:read y cambiar requiere automations:write. publish, resume y sendTest también requieren emails:send. events.send y events.sendBatch requieren contacts:write, y contacts.listEvents requiere contacts:read. delete pide un código de verificación a un token de acceso OAuth, y a una clave de API nunca.

events.sendBatch acepta hasta 100 eventos y nunca lanza un error por un solo evento incorrecto: la respuesta lista accepted y failed, cada uno con el index del evento en el array que enviaste.