---
title: "migrateAutomationsForTemplate"
method: POST
path: "/v1/email-template/templates/{id}:migrate-automations"
tags: ["Email templates"]
---

# migrateAutomationsForTemplate

`POST /v1/email-template/templates/{id}:migrate-automations`

Find all automation flows in the org that contain a `send-email` or `reply-email`
action referencing `old_template_id` and rewrite those actions to point at the
new template id (`{id}` path param). Intended to be called after a duplicated
template has been refined, so automations follow over to the new template.

## Path parameters

- `id` string, required

## Request body

- object
  - `old_template_id` string, required — Source template id that automations are being migrated away from

## Response `200`

Success

- MigrateAutomationsResponse
  - `migrated_flow_count` integer, required — Number of automation flows successfully rewritten to point at the new template
  - `migrated_flow_ids` string[], required — IDs of automation flows that were successfully migrated
  - `migrated_workflow_count` integer, required — Number of v2 workflows whose `AUTOMATION` tasks point at a migrated automation flow. Derived from `migrated_flow_ids` — a workflow is counted once even if multiple of its tasks reference the same migrated flow.
  - `migrated_workflow_ids` string[], required — IDs of workflows (`wf-*`) that owned at least one migrated automation flow
  - `migrated_portal_count` integer, required — Number of customer-portal email-template config rows whose references were rewritten from the old template id to the new one (via customer-portal-api's `migrateEmailTemplateReferences`).
  - `migrated_portal_ids` string[], required — Portal IDs whose email-template references were successfully rewritten
  - `failed_flow_ids` string[], required — IDs of automation flows whose `putFlow` update failed. Caller can retry or surface to the user.
  - `failed_portal_ids` string[], required — Portal IDs whose email-template reference rewrite failed in customer-portal-api.
  - `portal_migration_errored` boolean, required — True when the call to customer-portal-api threw before returning, so the portal counts could not be computed. Flow/workflow results are still valid; the caller should surface this and offer a retry of the portal migration.

## Other responses

- `403` — Forbidden

---

[API](https://skmtc.dev/epilot/apis/email-template-api.md) · [All operations](https://skmtc.dev/epilot/apis/email-template-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/epilot/email-template-api/revisions/0c6165eaceb0/schema)
