diff --git a/Model/Adminhtml/Backend/ChangeApiMode.php b/Model/Adminhtml/Backend/ChangeApiMode.php
index 7e632bf6229..82fc07e740f 100644
--- a/Model/Adminhtml/Backend/ChangeApiMode.php
+++ b/Model/Adminhtml/Backend/ChangeApiMode.php
@@ -69,7 +69,9 @@ public function beforeSave(): self
public function afterSave()
{
$apiKey = $this->getApiKey($this->getValue());
- $this->updateProfileId->execute($apiKey, $this->getScope(), $this->getScopeId());
+ if ($apiKey) {
+ $this->updateProfileId->execute($apiKey, $this->getScope(), $this->getScopeId());
+ }
return parent::afterSave();
}