You use the -n ending with the noun that receives the action of the verb. When you thank, you thank someone. The person being thanked is the object. It can also be done with a direct object.
Mi volas danki vin
Mi volas danki al vi
are both correct and both common.