The chemical reactions and pathways involving diaminopimelate, the anion of the dicarboxylic acid 2,6-diaminoheptanedioic acid. It is an intermediate in lysine biosynthesis and as a component (as meso-diaminopimelate) of the peptidoglycan of Gram-negative bacterial cell walls.