CX as Code CLI export failing on complex Architect flows

Just noticed that running genesyscloud architect flow export --all consistently fails with a 500 Internal Server Error for flows containing complex REST proxy actions, whereas the REST API /api/v2/architect/flows returns the JSON successfully.

Error: failed to export flow 'ivr_main': 500 Internal Server Error

Is there a known limitation in the CLI exporter for these specific flow types?

Thanks for the assistance.

The main issue here is that the CLI exporter often chokes on circular references or unhandled nulls in complex REST proxy configurations, so bypass it by fetching the flow JSON directly via GET /api/v2/architect/flows/{id} and piping it to your IaC state.

Note: Verify the version field in the response matches your target environment to avoid deployment drift.

The best way to fix this is to bypass the CLI entirely and fetch the flow JSON directly via GET /api/v2/architect/flows/{id}.

As the docs state, “detail queries utilize token-based pagination,” so pageNumber is ignored. Use nextPageToken instead.

It depends, but generally… the CLI exporter is unstable for complex flows. I hit this constantly with my Svelte dashboard backend. The REST API works fine. Use fetch in a SvelteKit server route.

  1. Get an access token via OAuth.
  2. Fetch the flow JSON directly.
  3. Handle pagination if needed.
  4. Save to JSON file.

Here is the payload structure you need. Note the divisionId.

{
 "id": "ivr_main",
 "name": "IVR Main",
 "description": "Main IVR",
 "version": 1,
 "divisionId": "00000000-0000-0000-0000-000000000000",
 "flowType": "voice",
 "actions": [
 {
 "id": "rest_proxy_1",
 "type": "restProxy",
 "address": "https://api.example.com/data",
 "method": "GET",
 "headers": {},
 "body": null
 }
 ]
}

Use this in your Node.js script. Avoid the CLI. It is broken for REST proxy actions. Check the version field. It must match.

This issue stems from the CLI mishandling null properties in REST proxy actions. The API tolerates it, but the exporter doesn’t. Fetch directly via API and sanitize the JSON.

$flow = Invoke-RestMethod -Uri "https://api.mypurecloud.com/api/v2/architect/flows/$id" -Headers $headers
$flow | ConvertTo-Json -Depth 10 | Out-File "flow.json"

Verify the version field matches.