Ninja Forms – change redirect URL based on API response?

So, the way I’ve ended up doing this is as follows. It’s probably not the optimal way but I can’t find a way to change the submission data during the submission workflow (the redirect action always seems to read the original entered data). Basically, the key hook is ninja_forms_run_action_settings where you can filter $action_settings which contains the redirect url.

In my Action class:

class CustomProcessing extends NF_Abstracts_Action {

private string $_redirect_url;

   public function __construct()
    {

        parent::__construct();
        $this->_nicename="Custom Process";


        add_filter( 'ninja_forms_run_action_settings', [ $this, 'changeRedirectURL' ], 10, 4 );
    }


    public function process( $action_id, $form_id, $data ) {

    // code to call API endpoint

    // set redirect url on response from API
    if ( 201 === $response[ 'response' ][ 'code' ] ) {
        $this->_redirect_url = $body_url;
    }

    return $data

}


    public function changeRedirectURL( $action_settings, $form_id, $action_id, $form_settings )
    {

        if ( '<redirect action name>' === $action_settings[ "label" ] ) {
            $action_settings[ 'redirect_url' ] = $this->_redirect_url;
        }

        return $action_settings;
    }


}