I suspect it depends on both the network and the device. But I wanted 3 phones unlocked for a recent trip overseas (so i could buy cheap local SIM cards) and AT&T provided all the info needed free of charge. I was told that it was outside of their standard protocol, but if you were still under contract and your account was in good standing, it’s a service they commonly provide. All three unlocked, free of charge.
Just guessing that they might not be so helpful if the device wasn’t purchased from them in the first place. But it seems the info is out there for most devices either free or for a minimal charge for the codes.