How to set an order as shipped programmatically from an external ERP system?

Ok, great!

But what about main case – setting as “Sent” + sending email?

To mark an order as shipped you can create a shipment document for it.
How is «Submit Shipment» implemented?