How do I add a contact to a group using the API?
Open API Explorer - Support menu &gt; Developer &gt; 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' =&gt; &lt;group_id&gt;,
  'contact_id' =&gt; &lt;contact id&gt;,
]);