This is the link that has the requirements and procedure (if you meet the requirements) to request the unlock code; Unlock your mobile wireless device
I will point out that if you are not or haven't been a T-Mobile US customer they will not unlock the device. Your only options then are either get the original owner/T-Mobile customer to request it or use a third party company (just google it) and pay to have it unlocked.
Need our help? Contact us.