In many cases they are interchangeable, but not always.
"At the time" is a phrase. Like many phrases the grammar isn't the most important thing. What it means is more important. Cambridge Dictionary says it means "at a particular point at which something was thought of or done". Personally I think I might suggest the definition should also include when something happened. Anyway, the thing to note is that all the verbs (thought/done/happened) are in the past tense. Therefore, it's appropriate to think that we only use this phrase when talking about the past.
"At that time" by contrast is more grammatical. What I mean is we can look at the "that" and identify a pronoun. "That" refers to a specific thing previously mentioned. Therefore we can use "at that time" to talk about the past, and in that case it often has exactly the same meaning as "at the time" , BUT we can also use "at that time" to talk about the future.
Also remember that "time" has more than one meaning. In general, we are perhaps more likely to use "that" when talking about a specific time, and "the" when we're talking about a non specific period.
Example:
Person A: What were you doing at 9 o'clock on the 17th?
Person B: At that time I was having dinner at a restaurant.
Person A: What job did you do after you finished university?
Person B: At the time I was living with my parents, but I really wanted to travel.
HOWEVER that's not an exact, fixed rule. So many people speak English in so many different places, and there's no authority that oversees the language, so there's lots of variation.