I want to delete a previously deployed class. Is there a way to do it strictly through the web interface (sandbox and/or production)?

I'm kind of surprised that something like this isn't at least slightly easier to do.

When looking for an answer every place explains how to do it through the IDE but I don't have access to a security token that can do that, I only have access to their sandbox and production accounts through the "grant login" feature (custom work on a client's system).

  • 1
    I don't know how the grant login feature works, but could you temporarily add you IP address as trusted so that you don't require the security token? Alternatively, all you really need for API access is a Session ID and Server URL. You could hijack those and then bootstrap them into the correct API calls. Sep 3 '12 at 4:47

I am 99.999% sure that you cannot delete the class through the Salesforce Web interface. You cannot do it through Changesets.

I believe that you have to use something backed by the metadata API such as the Force.com IDE or the Ant Migration tool with a destructiveChanges file. That is no help for you, however, since you'd need the token in your situation.

  • 1
    Or create the destructiveChanges file and provide it to the client with instructions.
    – Mike Chale
    Sep 2 '12 at 23:24
  • @MikeChale - That's a good idea. Along those same lines, the client could whitelist your IP...would that negate the need for the token? Sep 3 '12 at 13:05
  • 1
    Yes, it would negate the token. We have an API user account on a whitelisted server and it does not require the token.
    – Mike Chale
    Sep 3 '12 at 15:36

I guess you can do that with the Developer Workbench.


  1. Navigate to Rest Explorer
  2. Select Delete
  3. call /services/data/v34.0/tooling/sobjects/ApexClass/{Class Id}

Also you can query for desire class by Id: /services/data/v34.0/tooling/query/?q=Select+Id+from+ApexClass+Where+Id='{Class Id}'

or query by name: /services/data/v34.0/tooling/query/?q=Select+Id,Name+from+ApexClass+Where+Name='{name of the class}'

  • 1
    No, I don't believe this can be achieved. I return this error: ' [ { "message" : "Cannot complete this operation. Cannot delete classes/triggers in production. Use compileAndTest verb to delete. : null ", "errorCode" : "DEPENDENCY_EXISTS", "fields" : [ ] } ]' Mar 8 '16 at 11:35
  • Hey @AndyHitchings were you able to delete the class using metadata API such as the Force.com IDE or the Ant Migration tool , one of these methods?
    – Alexander
    Mar 9 '16 at 22:55
  • 1
    Hey @AlexBar I was able to delete the class via Workbench in the end using the methodology outlined by sfdcfox here: salesforce.stackexchange.com/questions/46612/… Mar 10 '16 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.