Create di.xml file your module and add the below code
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCustomerApiCustomerRepositoryInterface">
<plugin name="save_customer_group" type="VendorModulePluginMagentoCustomerApiCustomerRepositoryPlugin" />
</type>
</config>
Create plugin file under this directory Vendor/Module/Plugin/Magento/Customer/Api/CustomerRepositoryPlugin.php
<?php
namespace VendorModulePluginMagentoCustomerApi;
use MagentoCustomerApiDataCustomerInterface;
use MagentoCustomerApiCustomerRepositoryInterface;
use MagentoFrameworkControllerResultFactory;
use MagentoFrameworkUrlInterface;
use MagentoFrameworkExceptionLocalizedException;
class CustomerRepositoryPlugin
{
/**
* @var Data
*/
private $helper;
/**
* Constructor of class.
*
* @param Data $helper
*/
public function __construct(
MagentoFrameworkAppRequestInterface $request,
MagentoCustomerModelResourceModelGroupCollectionFactory $groupCollection,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
MagentoCustomerApiGroupRepositoryInterface $groupRepository,
MagentoFrameworkMessageManagerInterface $messageManager,
ResultFactory $resultFactory,
UrlInterface $url
) {
$this->request = $request;
$this->groupCollection = $groupCollection;
$this->scopeConfig = $scopeConfig;
$this->groupRepository = $groupRepository;
$this->messageManager = $messageManager;
$this->resultFactory = $resultFactory;
$this->url = $url;
}
/**
*
* @param CustomerRepositoryInterface $subject
* @param CustomerInterface $customer
* @return array
*/
public function beforeSave(CustomerRepositoryInterface $subject, CustomerInterface $customer, $passwordHash = null)
{
$groupid = 5; //change customer group id here
$customer->setGroupId($groupId);
return [$customer, $passwordHash];
}
}

