In case if you are looking to disable standard duplicate rule while creating record from apex – especially in case of integration and backend processes – we can use DMLOptions.DuplicateRuleHeader as below.
Database.DMLOptions dml = new Database.DMLOptions(); dml.DuplicateRuleHeader.AllowSave = true; Account duplicateAccount = new Account(Name='Acme'); Database.SaveResult sr = Database.insert(duplicateAccount, dml); if (sr.isSuccess()) { System.debug('Duplicate account has been inserted in Salesforce!'); }