//native
/**
* Get Migrated Workflow Mappings
* Map legacy v3 workflow IDs to v4 flow IDs and back. Pass either or both lists. Requires the automation scope.
*/
export async function main(
auth: RT.Hubspot,
flow_ids: string[] | undefined,
workflow_ids: string[] | undefined
) {
const inputs = [
...(flow_ids ?? []).map((id) => ({
flowMigrationStatuses: String(id),
type: "FLOW_ID",
})),
...(workflow_ids ?? []).map((id) => ({
flowMigrationStatusForClassicWorkflows: String(id),
type: "WORKFLOW_ID",
})),
]
const response = await fetch(
"https://api.hubapi.com/automation/v4/workflow-id-mappings/batch/read",
{
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({ inputs }),
}
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 5 hours ago