---
schema_version: "1"
id: e367a8332fb3cd63bbdc733ee1fb0e245476459c41836ddb4236ab8f839f4a52
title: Reduce Overhead by Recompiling Only Invalid Apex Classes and Triggers
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/release-notes/264-0-0/rn_apex_recompile_invalid_apex.md
canonical_url: https://help.salesforce.com/s/articleView?id=release-notes.rn_apex_recompile_invalid_apex.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 45e670bf7a1dadd5c692bcf3a5480ea21e24c2554e0114ef242e1f84328003f5
description: Return compilation results for Apex classes and triggers with validation errors, instead of recompiling the entire org. Access the compilation results through Setup or the Tooling API endpoint. Salesforce automatically identifies only classes and triggers that require recompilation, reducing compilation overhead and minimizing potential runtime errors. Routinely perform this targeted recompilation to prevent runtime delays during peak traffic.
products:
  - Cross Cloud
release: "264"
---
# Reduce Overhead by Recompiling Only Invalid Apex Classes and Triggers

Return compilation results for Apex classes and triggers with validation errors, instead of recompiling the entire org. Access the compilation results through Setup or the Tooling API endpoint. Salesforce automatically identifies only classes and triggers that require recompilation, reducing compilation overhead and minimizing potential runtime errors. Routinely perform this targeted recompilation to prevent runtime delays during peak traffic.

**Where:** This feature is available in API version 68.0 and later. This feature is available in Lightning Experience and Salesforce Classic in Enterprise, Performance, Unlimited, and Developer editions.

**How:** To retrieve results for invalid Apex classes or triggers, make a POST request to the new Tooling API endpoint /services/data/vXX.X/tooling/apexCompileResults. The request body must be the empty JSON object `{}`.

```
POST /services/data/v68.0/tooling/apexCompileResults HTTP/1.1
Authorization: Bearer <session-id>
Content-Type: application/json

{}
```

Here’s an example JSON response body.

```json
{
  "status": "PARTIAL_FAILURE",
  "results": [
    {
      "name": "MyInvalidClass",
      "namespace": "MyNamespace",
      "success": false,
      "problems": [
        { "line": 14,
          "column": 9,
          "message": "Variable does not exist: var1"
        }
      ],
      "warnings": []
    },
    {
      "name": "MyClassWithWarnings",
      "namespace": "OtherNamespace",
      "success": true,
      "problems": [],
      "warnings": [
        { "line": 0,
          "column": 0,
          "message": "Apex API version 16.0 is scheduled for retirement. Update to the latest API version to avoid compile failures"
        }
      ]
    }
  ]
}
```

You can recompile invalid Apex classes and triggers in Setup. In the Quick Find box, enter and select **Apex Classes** or **Apex Triggers**. Then click **Compile only invalid classes** or **Compile only invalid triggers**. If the compilation is successful, you see a confirmation message. If the compilation is unsuccessful, you see a list of errors or warnings for each affected class or trigger.

![The “Compile only invalid classes” button on the Apex Classes page in Setup](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-release-notes-salesforce_release_notes-264-0-0-production-enus/550ba85b-db1a-4608-9cd4-9a65ec96e1fa/salesforce_release_notes/images/rn_264_apex_compile_invalid_apex.png)

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-release-notes-salesforce_release_notes-264-0-0-production-enus/550ba85b-db1a-4608-9cd4-9a65ec96e1fa/images/icon_note.png)

Note

Successful compilation via the “Compile only invalid classes/triggers” buttons or the `/apexCompileResults` endpoint doesn’t update the corresponding `isValid` field of the affected Apex classes or triggers. The value remains `false`.

#### See Also

- [_Tooling API_: Retrieve Compilation Results for Invalid Apex with the apexCompileResults Resource](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_tooling.meta/api_tooling/intro_rest_resources_recompile_invalid_apex.htm)
- [_Salesforce Help_: Manage Apex Classes](https://help.salesforce.com/s/articleView?id=platform.code_manage_packages.htm&type=5&language=en_US)
- [_Salesforce Help_: Define Apex Classes](https://help.salesforce.com/s/articleView?id=platform.code_define_package.htm&type=5&language=en_US)
- [_Salesforce Help_: Define Apex Triggers](https://help.salesforce.com/s/articleView?id=platform.code_define_trigger.htm&type=5&language=en_US)