Any way to programmatically add to groups?

I my use case I would create groups based on employee data, like branch id and position.

Better handle this through API then.