I’m not exactly certain about this, haven’t tried any of it at all, but from what I can piece together you’ll need to use the /api/enrollment/v1/enrollment endpoint with a POST request with the key parameter used being is_active set to false.
/api/enrollment/v1/enrollment
POST
is_active
There’s also a bulk enrollment api that can be enabled and used for unenrollment (according to this topic here: Programatically enroll or unenroll students)