How to execute the "Merge Segments" command through the API

I have a scenario where a cell in an excel file has multiple segments.  When the user activates my plug in, I want to iterate over all segment pairs and merge all segment pairs that belong to the same cell for them.  This would be the equivalent of the Home > Segment Actions > Merge Segments functionality.  Does anyone know how to duplicate that functionality?