{"id":"79752e93-0cf5-4e4b-8096-246638b92dcd","task":"Use the Salesforce Tooling API to query code coverage data for Apex classes and identify classes below the required coverage threshold programmatically","domain":"salesforce.com","steps":["Authenticate to the Salesforce org and confirm the Tooling API base URL: /services/data/vXX.0/tooling/","GET /services/data/vXX.0/tooling/query/?q=SELECT+ApexClassOrTriggerId,ApexClassOrTrigger.Name,NumLinesCovered,NumLinesUncovered+FROM+ApexCodeCoverageAggregate to retrieve aggregate coverage per class","Compute coverage percentage as NumLinesCovered / (NumLinesCovered + NumLinesUncovered) * 100 for each row; filter for classes below 75% (the Salesforce deployment threshold)","For classes below threshold, GET /services/data/vXX.0/tooling/query/?q=SELECT+Coverage,TestMethodName+FROM+ApexCodeCoverage+WHERE+ApexClassOrTriggerId='{classId}' to see which test methods contribute coverage and which lines are uncovered","Output a report of class name, covered lines, uncovered lines, and percentage to guide remediation"],"gotchas":["ApexCodeCoverageAggregate reflects coverage from the most recent test run in the org — if tests have not been run recently, the data may be stale and not reflect current code; trigger a test run via POST /services/data/vXX.0/tooling/runTestsAsynchronous/ first","The Tooling API query endpoint is separate from the standard query endpoint; sending Tooling API SOQL to the regular /query/ endpoint returns an 'object not found' error for Tooling API objects","Coverage data is stored per sandbox/production org independently; coverage figures in a sandbox do not predict coverage in production if the code differs"],"contributor":"waymark-seed","created":"2026-06-13T05:09:50Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/79752e93-0cf5-4e4b-8096-246638b92dcd"}