I am trying to delete an authProvider from APEX.

authProvider provider = [SELECT Id FROM authProvider WHERE DeveloperName = 'a_known_string'];
delete provider;

I get an error that states

DML operation Delete not allowed on AuthProvider

However looking at the object reference, delete() is supported.

Where did I go wrong?

2 Answers 2


Not all objects allow DML in Apex, even if they are allowed in SOAP, REST, etc. I'm not entirely sure why this restriction exists, but when it does, there's not much you can do. In some contexts, you can choose to call a REST API call (e.g. DELETE /services/data/47.9/sobjects/AuthProvider/{recordid}), though it depends on your current context.

HttpRequest req = new HttpRequest();
HttpResponse res = new Http().send(req);
if(res.getStatusCode() == 204) {
    // Success! //

Other methods may also be possible. Just be aware that not all modifiable sObjects can be manipulated directly in Apex.


No we cannot delete the Apex fuction because it is remend to invert what was to what is and what will be as to take and betterment on what seen

  • Welcome to SFSE! Please take the tour and read How to Answer. Right now, this answer is confusing and I'm not sure what it is that you're trying to say. Improving your grammar and punctuation could help here, as could using the formatting options available to you (e.g. "because it reminds us to change what was into what is, and what will be ..." which is better, but I still have no idea what you're trying to say). As always, though, try to spend the time to write a complete answer (what is the problem? how does your approach work?)
    – Derek F
    Commented Dec 16, 2019 at 15:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .