The Yankees announced the move Monday.
The 21-year-old Sanmartin went 7-2 with a 2.45 ERA in 14 games last season, splitting time between Single-A Spokane and Hickory. The Colombian lefthander was signed by the Rangers in 2015 and is 14-4 with a 2.62 ERA in three minor league seasons.
The 22-year-old Herrera made his major league debut with the Yankees last season, going 0-1 with a 6.00 ERA in two relief appearances. The righthander was sidelined by midseason shoulder inflammation and split time between Double-A Trenton and Triple-A Scranton/Wilkes-Barre.
Herrera is 41-33 with a 3.60 ERA in six minor league seasons.