자동화
`automations.list`, `get`, `create`, `update`, `publish`, `pause`, `resume`, `archive`, `duplicate`, `delete`, `sendTest`, `stats`, `listVersions`, `restoreVersion`, `listStarters`, `listEnrollments`, `getEnrollment`, `enroll`, `exitEnrollment`, 그리고 `events.send`, `sendBatch`, `listNames`.
모든 메서드
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)자동화는 초안 definition과 실행되는 published 버전을 유지합니다. update는 초안과 설정을 바꾸고, publish는 초안을 다음 버전으로 확정하고 자동화를 켭니다. problems는 초안의 게시를 아직 막고 있는 것을 알려 주고, expectedUpdatedAt은 다른 사람의 저장을 덮어쓰게 될 저장을 409 version_conflict로 거부합니다.
읽기에는 automations:read, 변경에는 automations:write가 필요합니다. publish, resume, sendTest에는 emails:send도 필요합니다. events.send와 events.sendBatch에는 contacts:write가, contacts.listEvents에는 contacts:read가 필요합니다. delete는 OAuth 액세스 토큰에 인증 코드를 요구하며, API 키에는 절대 요구하지 않습니다.
events.sendBatch는 이벤트를 최대 100개까지 받으며, 잘못된 이벤트 하나 때문에 예외를 던지지 않습니다. 응답에는 accepted와 failed가 나열되고, 각각 보낸 배열에서의 이벤트 index가 붙습니다.