My understanding is that carriers will only give the unlock code to the account holder, so if you buy a phone from someone else who tells you it is unlocked when it isn't you are out of luck. That was probably your situation when you called asking for a code - though of course they could have explained that without hostility (though I can imagine many ways in which that can be a crappy job).
But yeah, normally you need a code. I suggest you test it with a non-ATT SIM (to be sure don't use one from a virtual operator who use ATT's network either), and if it doesn't work get back to them and tell them you never received the text/email. Whatever you do, make sure it is unlocked while you are still a customer with them, because if you end a contract there is no guarantee they'll give you the code after that.