---
schema_version: "1"
id: 7dc84c6d9d42f3c9398f92f2b9010cb1002974900b28a8fd1e72d8bf5c4861c8
title: |-
  Retrieve Compilation Results for Invalid Apex with the apexCompileResults
      Resource
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_tooling/intro_rest_resources_recompile_invalid_apex.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/intro_rest_resources_recompile_invalid_apex.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 4249f2a6b1b52c5749f9ef970ed4d610ee88039abba5f0db27c54048c4d3d90f
description: Retrieve compilation results for Apex classes and triggers with validation errors. Routinely monitoring results allows you to detect and respond to compilation issues.Available in API version 68.0 and later. This resource requires the Author Apex org permission.
---
# Retrieve Compilation Results for Invalid Apex with the apexCompileResults Resource

Retrieve compilation results for Apex classes and triggers with validation errors. Routinely monitoring results allows you to detect and respond to compilation issues.Available in API version 68.0 and later. This resource requires the Author Apex org permission.

## Syntax

**URI**: /services/data/vXX.X/tooling/apexCompileResults/

**HTTPS Method**: POST

**Authentication**: Authorization: Bearer token

**Format**: JSON

## Request Parameters

None.

## Request Body

The request body must be an empty JSON object ({}). Specifying any fields returns an error.

## Response Body Properties

### status

- **Type**: String
- **Description**: The operation-level outcome of the compilation.
- **Possible values**:
    - OK—all invalid Apex classes and triggers compiled successfully, or no invalid classes or triggers required recompilation.
    - PARTIAL\_FAILURE—at least one invalid Apex class or trigger failed to compile.

### results

- **Type**: Object\[\]
- **Description**: An array of compilation outcomes for Apex classes and triggers that failed to compile.
    
    Each object includes the class or trigger name, namespace, success indicator, errors, and warnings. Classes and triggers that compile successfully aren’t included. Warnings are included only when the class or trigger also has compilation errors.
    
    If the entire compilation succeeds without any failures, this array is empty.

Each object in the results array can include these properties.

### name

- **Type**: String
- **Description**: The developer name of the Apex class or trigger.

### namespace

- **Type**: String
- **Description**: The namespace of the Apex class or trigger. For the default namespace, the value is an empty string.

### success

- **Type**: Boolean
- **Description**: Indicates whether the Apex class or trigger compiled successfully. The value is true when there are no compilation problems. The value is false when at least one problem is present. Warning-only outcomes are still considered successful, so these outcomes aren’t returned in the results array.

### problems

- **Type**: Object\[\]
- **Description**: An array of compilation errors for the Apex class or trigger. Empty when success is true.

### warnings

- **Type**: Object\[\]
- **Description**: An array of compilation warnings for the Apex class or trigger. Warnings are returned only for classes and triggers that also have compilation errors.

Each object in a problems or warnings array can include these properties.

### line

- **Type**: Integer
- **Description**: The source line of the error or warning. The value is 0 if a line isn’t applicable.

### column

- **Type**: Integer
- **Description**: The source column of the problem or warning. The value is 0 if a column isn’t applicable.

### message

- **Type**: String
- **Description**: A description of the compilation error or warning.

## Usage

- Use the apexCompileResults resource to retrieve compilation results for invalid Apex class and triggers. To recompile invalid classes or triggers, use the “Compile only invalid classes” and “Compile only invalid triggers” buttons on the Apex Classes or Apex Triggers pages in Setup. Successful compilation via the Setup buttons updates the IsValid field on the corresponding Apex class or trigger to true. Retrieving compilation results via apexCompileResults doesn’t update the field.
- The request is synchronous.

## Example

**Example Request Body**

{}

**Example Response Body on Successful Compilation**: Returned if all invalid Apex classes and triggers compiled successfully, or none required recompilation.

{
  "status": "OK",
  "results": \[\]
}

**Example Response Body on Partial Failure**: Returned if least one invalid Apex class or trigger failed to compile.

{
  "status": "PARTIAL\_FAILURE",
  "results": \[
    {
      "name": "MyInvalidClass",
      "namespace": "MyNamespace",
      "success": false,
      "problems": \[
        {
          "line": 14,
          "column": 9,
          "message": "Variable does not exist: var1"
        }
      \],
      "warnings": \[
        {
          "line": 0,
          "column": 0,
          "message": "Apex API version 18.0 is scheduled for retirement. Update to the latest API version to avoid compile failures."
        }
      \]
    }
  \]
}