I looked in the documentation but I can't seem to find a way to add a contact to a group using the API.
1 Answer
Open API Explorer - Support menu > Developer > API Explorer
and use GroupContact
API to add contacts to group. See an eg in the screenshot below -
API formed for PHP is -
$result = civicrm_api3('GroupContact', 'create', [
'group_id' => <group_id>,
'contact_id' => <contact id>,
]);