Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save cemerson/803336c29e04cee47463c9b152dba541 to your computer and use it in GitHub Desktop.

Select an option

Save cemerson/803336c29e04cee47463c9b152dba541 to your computer and use it in GitHub Desktop.
SFDC: Delete Apex Logs (Salesforce)

Bulk Delete Apex Debug Logs (Workbench Method)

  1. Visit: https://workbench.developerforce.com

  2. Login:

    • Environment: Production or Sandbox
    • API Version: Latest
    • Check "I agree to the terms of service"
    • Click "Login with Salesforce"
  3. Get Apex Log IDs:

    • Go to: Utilities → REST Explorer
    • URI: /services/data/v61.0/tooling/query/?q=SELECT+Id+FROM+ApexLog
    • Click "Execute"
    • Copy the returned IDs
  4. Delete Logs in Bulk:

    • URI: /services/data/v61.0/tooling/composite
    • Method: POST
    • Request Body (replace with your IDs, up to 25/max):

    { "allOrNone": false, "compositeRequest": [ { "method": "DELETE", "url": "/services/data/v61.0/tooling/sobjects/ApexLog/NEXT_APEX_LOG_HERE1", "referenceId": "a1" }, { "method": "DELETE", "url": "/services/data/v61.0/tooling/sobjects/ApexLog/NEXT_APEX_LOG_HERE2", "referenceId": "a2" }, { "method": "DELETE", "url": "/services/data/v61.0/tooling/sobjects/ApexLog/NEXT_APEX_LOG_HERE3", "referenceId": "a3" }, { "method": "DELETE", "url": "/services/data/v61.0/tooling/sobjects/ApexLog/NEXT_APEX_LOG_HERE4", "referenceId": "a4" }, { "method": "DELETE", "url": "/services/data/v61.0/tooling/sobjects/ApexLog/NEXT_APEX_LOG_HERE5", "referenceId": "a5" } ] }

✅ Each successful deletion returns "httpStatusCode": 204

🔁 If you have more than 25 IDs, repeat in batches of 25.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment