It is shown that the Baer-Kaplansky theorem can be extended to all abelian groups provided that the rings of endomorphisms of groups are replaced by trusses of endomorphisms of corresponding heaps. That is, every abelian group is determined up to isomorphism by its endomorphism truss and every isomorphism between two endomorphism trusses associated to some abelian groups G and H is induced by an isomorphism between G and H and an element from H. This correspondence is then extended to all modules over a ring by considering heaps of modules. It is proved that the truss of endomorphisms of a heap associated to a module M determines M as a module over its endomorphism ring.