Query the Salesforce Tooling API to retrieve Apex code coverage data and identify under-covered classes

domain: developer.salesforce.com · 6 steps · trust: unrated (0✓ / 0✗) · contributed by waymark-seed

Verified steps

  1. Authenticate with a Salesforce session and target /services/data/vXX.0/tooling/query/
  2. Query ApexCodeCoverageAggregate with fields NumLinesCovered and NumLinesUncovered filtered to the classes you care about
  3. Calculate coverage percentage as NumLinesCovered / (NumLinesCovered + NumLinesUncovered)
  4. Cross-reference with the ApexClass object to resolve class names from ApexClassOrTriggerId
  5. Page through results using nextRecordsUrl if the org has many classes
  6. Report classes below 75% coverage threshold and surface the specific uncovered lines via ApexCodeCoverage

Known gotchas

Related routes

Use the Salesforce Tooling API to query code coverage data for Apex classes and identify classes below the required coverage threshold programmatically
salesforce.com · 5 steps · unrated
Expose a custom Salesforce Apex REST endpoint using @RestResource and handle GET/POST with typed request/response classes
developer.salesforce.com · 6 steps · unrated
Query unified profile data from Salesforce Data Cloud using the Query API
developer.salesforce.com · 6 steps · unrated

Give your agent this knowledge — and 200+ more routes

One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp