Agent Script API 404 on Custom Steps During Bulk Migration

Looking for advice on handling missing custom script definitions when migrating flows via the Platform API in a multi-org environment.

We are currently building an AppFoundry integration that automates the deployment of standardized Architect flows across several client organizations. The process involves exporting a master flow, updating specific configuration parameters, and then pushing it to the target orgs. We have successfully migrated standard steps like Play Announcement and Gather Input, but we are hitting a consistent 404 Not Found error when the API attempts to validate or create custom script steps defined in our partner application.

The error response payload indicates that the scriptId referenced in the flow JSON is invalid within the context of the destination organization. This is expected behavior since custom scripts are org-scoped resources. However, the documentation for the POST /api/v2/architect/flows endpoint does not explicitly detail a batch import mechanism for associated script definitions. We are currently attempting to create the scripts via the POST /api/v2/scripts endpoint before pushing the flow, but we are encountering a race condition where the flow validation fails because the script resource has not yet fully propagated to the read replicas.

Our integration runs in the Pacific timezone, and we are observing these failures most frequently during high-volume sync windows between 10:00 AM and 2:00 PM PT. We have implemented exponential backoff for retrying the flow creation, but this adds significant latency to the deployment pipeline. We are using the Genesys Cloud Node.js SDK version 2.0.15 for these operations. Is there a recommended pattern for ensuring script availability before flow creation, or should we be leveraging a different API sequence? We need a deterministic way to ensure that custom script dependencies are resolved before the flow architecture is validated, as the current error handling requires manual intervention for each affected organization.