---
schema_version: "1"
id: ae9115938d1e9987e9f67d61f119f83b4f5d364ca9ab5cb1f330f4d565a4e011
title: ApexClass
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_tooling/tooling_api_objects_apexclass.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_apexclass.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 36b7095a49defda3e4496223e8b9a54988e68ee4ac0e6f95ce0b8e38a3fce914
description: Represents the saved copy of an Apex class. ApexClass uses the cached version of the class unless one is unavailable. Available from API version 28.0 or later.
---
# ApexClass

Represents the saved copy of an Apex class. ApexClass uses the cached version of the class unless one is unavailable. Available from API version 28.0 or later.

To edit, save, or compile Apex classes, use [ApexClassMember](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_apexclassmember.htm "Represents the working copy of an Apex class for editing, saving, or compiling in a MetadataContainer.").

## Supported SOAP API Calls

create(), delete(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), search(),  update(), upsert()

## Supported REST API HTTP Methods

GET, POST, PATCH, DELETE

## Fields

<table class="featureTable sort_table" summary="">


          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d21816e102">Field Name</th>

              <th class="featureTableHeader  " id="d21816e105">Details</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d21816e102" data-title="Field Name"><span class="keyword parmname">ApiVersion</span></td>

              <td class="entry" headers="d21816e105" data-title="Details">
                <dl class="dl detailList">

                  <dt class="dt dlterm">Type</dt>

                  <dd class="dd">double</dd>



                  <dt class="dt dlterm">Properties</dt>

                  <dd class="dd">Create, Filter, Sort, Update</dd>



                  <dt class="dt dlterm">Description</dt>

                  <dd class="dd">The API version for this class. Every class has an API version specified at
                    creation.</dd>


                </dl>

              </td>

            </tr>

            <tr>
              <td class="entry" headers="d21816e102" data-title="Field Name"><span class="keyword parmname">Body</span></td>

              <td class="entry" headers="d21816e105" data-title="Details">
                <dl class="dl detailList">

                  <dt class="dt dlterm">Type</dt>

                  <dd class="dd">textarea</dd>



                  <dt class="dt dlterm">Properties</dt>

                  <dd class="dd">Create, Nillable, Update</dd>



                  <dt class="dt dlterm">Description</dt>

                  <dd class="dd">The data for the Apex class. </dd>


                </dl>

              </td>

            </tr>

            <tr>
              <td class="entry" headers="d21816e102" data-title="Field Name"><span class="keyword parmname">BodyCrc</span></td>

              <td class="entry" headers="d21816e105" data-title="Details">
                <dl class="dl detailList">

                  <dt class="dt dlterm">Type</dt>

                  <dd class="dd">double</dd>



                  <dt class="dt dlterm">Properties</dt>

                  <dd class="dd">Create, Defaulted on create, Filter, Nillable, Sort, Update</dd>



                  <dt class="dt dlterm">Description</dt>

                  <dd class="dd">The CRC (cyclic redundancy check) of the class or trigger file</dd>


                </dl>

              </td>

            </tr>

            <tr>
              <td class="entry" headers="d21816e102" data-title="Field Name"><span class="keyword parmname">FullName</span></td>

              <td class="entry" headers="d21816e105" data-title="Details">
                <dl class="dl detailList">

                  <dt class="dt dlterm">Type</dt>

                  <dd class="dd">string</dd>



                  <dt class="dt dlterm">Properties</dt>

                  <dd class="dd">Group, Nillable</dd>



                  <dt class="dt dlterm">Description</dt>

                  <dd class="dd">The full name of the associated object in the Metadata API. Use to avoid race
                    conditions on create, before you have IDs.</dd>

                  <dd class="dd">Query this field only if the query result contains no
                    more than one record. Otherwise, an error is returned. If more than one record
                    exists, use multiple queries to retrieve the records. This limit protects
                    performance.</dd>


                </dl>

              </td>

            </tr>

            <tr>
              <td class="entry" headers="d21816e102" data-title="Field Name"><span class="keyword parmname">IsValid</span></td>

              <td class="entry" headers="d21816e105" data-title="Details">
                <dl class="dl detailList">

                  <dt class="dt dlterm">Type</dt>

                  <dd class="dd">boolean</dd>



                  <dt class="dt dlterm">Properties</dt>

                  <dd class="dd">Create, Defaulted on create, Filter, Group, Sort, Update</dd>



                  <dt class="dt dlterm">Description</dt>

                  <dd class="dd"><span class="ph" id="isvalid_desc"><a name="isvalid_desc"><!-- --></a>Indicates whether any dependent metadata has changed since the
                      class was last compiled (<samp class="codeph nolang">true</samp>) or not (<samp class="codeph nolang">false</samp>). The default value is <samp class="codeph nolang">false</samp>.</span></dd>


                </dl>

              </td>

            </tr>

            <tr>
              <td class="entry" headers="d21816e102" data-title="Field Name"><span class="keyword parmname">LengthWithoutComments</span></td>

              <td class="entry" headers="d21816e105" data-title="Details">
                <dl class="dl detailList">

                  <dt class="dt dlterm">Type</dt>

                  <dd class="dd">int</dd>



                  <dt class="dt dlterm">Properties</dt>

                  <dd class="dd">Create, Filter, Group, Sort, Update</dd>



                  <dt class="dt dlterm">Description</dt>

                  <dd class="dd">
                    <p class="p">Length of the class without comments.</p>

                  </dd>


                </dl>

              </td>

            </tr>

            <tr>
              <td class="entry" headers="d21816e102" data-title="Field Name"><span class="keyword parmname">ManageableState</span></td>

              <td class="entry" headers="d21816e105" data-title="Details">
                <dl class="dl detailList">

                  <dt class="dt dlterm">Type</dt>

                  <dd class="dd">ManageableState enumerated list</dd>



                  <dt class="dt dlterm">Properties</dt>

                  <dd class="dd">Filter, Group, Nillable, Restricted picklist, Sort</dd>



                  <dt class="dt dlterm">Description</dt>

                  <dd class="dd">Indicates the manageable state of the specified component that is contained
                    in a package: <ul class="ul bulletList">
                      <li class="li"><samp class="codeph nolang">beta</samp></li>

                      <li class="li"><samp class="codeph nolang">deleted</samp></li>

                      <li class="li"><samp class="codeph nolang" id="d1246e368-d1270e373"><a name="d1246e368-d1270e373"><!-- --></a>deprecated</samp></li>

                      <li class="li"><samp class="codeph nolang">deprecatedEditable</samp></li>

                      <li class="li"><samp class="codeph nolang">installed</samp></li>

                      <li class="li"><samp class="codeph nolang">installedEditable</samp></li>

                      <li class="li"><samp class="codeph nolang">released</samp></li>

                      <li class="li"><samp class="codeph nolang">unmanaged</samp></li>

                    </ul>
                  </dd>


                </dl>

                <p class="p">This field is available in API version 38.0 and later.</p>

              </td>

            </tr>

            <tr>
              <td class="entry" headers="d21816e102" data-title="Field Name"><span class="keyword parmname">Metadata</span></td>

              <td class="entry" headers="d21816e105" data-title="Details">
                <dl class="dl detailList">

                  <dt class="dt dlterm">Type</dt>

                  <dd class="dd">ApexClassMetadata</dd>



                  <dt class="dt dlterm">Properties</dt>

                  <dd class="dd">Create, Nillable, Update</dd>



                  <dt class="dt dlterm">Description</dt>

                  <dd class="dd">An object that describes the version, status, and packaged versions of the
                    corresponding Apex class.</dd>

                  <dd class="dd">Query this field only if the query result contains no
                    more than one record. Otherwise, an error is returned. If more than one record
                    exists, use multiple queries to retrieve the records. This limit protects
                    performance.</dd>


                </dl>

              </td>

            </tr>

            <tr>
              <td class="entry" headers="d21816e102" data-title="Field Name"><span class="keyword parmname">Name</span></td>

              <td class="entry" headers="d21816e105" data-title="Details">
                <dl class="dl detailList">

                  <dt class="dt dlterm">Type</dt>

                  <dd class="dd">string</dd>



                  <dt class="dt dlterm">Properties</dt>

                  <dd class="dd">Create, Filter, Group, Sort, Update</dd>



                  <dt class="dt dlterm">Description</dt>

                  <dd class="dd">
                    <p class="p">Name of the class.</p>

                    <p class="p">Limit: 255 characters</p>

                  </dd>


                </dl>

              </td>

            </tr>

            <tr>
              <td class="entry" headers="d21816e102" data-title="Field Name"><span class="keyword parmname">NamespacePrefix</span></td>

              <td class="entry" headers="d21816e105" data-title="Details">
                <dl class="dl detailList">

                  <dt class="dt dlterm">Type</dt>

                  <dd class="dd">string</dd>



                  <dt class="dt dlterm">Properties</dt>

                  <dd class="dd">Filter, Group, Nillable, Sort</dd>



                  <dt class="dt dlterm">Description</dt>

                  <dd class="dd">The namespace prefix associated with this object. Each Developer Edition organization
                    that creates a managed package has a unique namespace prefix. Limit: 15 characters. You
                    can refer to a component in a managed package by using the <samp class="codeph nolang"><var class="keyword varname">namespacePrefix</var>__<var class="keyword varname">componentName</var></samp>
                    notation.<div class="p">The namespace prefix can have one of the following values: <ul class="ul bulletList">
                        <li class="li">In Developer Edition organizations, the namespace prefix is set to the namespace
                          prefix of the organization for all objects that support it. There’s an exception if an
                          object is in an installed managed package. In that case, the object has the namespace
                          prefix of the installed managed package. This field’s value is the namespace prefix of
                          the Developer Edition organization of the package developer.</li>

                        <li class="li">In organizations that aren’t Developer Edition organizations,
                          <span class="keyword parmname">NamespacePrefix</span> is only set for objects that are part of an
                          installed managed package. There’s no namespace prefix for all other objects.
                        </li>

                      </ul>
                    </div>
                  </dd>


                </dl>

              </td>

            </tr>

            <tr>
              <td class="entry" headers="d21816e102" data-title="Field Name"><span class="keyword parmname">Status</span></td>

              <td class="entry" headers="d21816e105" data-title="Details">
                <dl class="dl detailList">

                  <dt class="dt dlterm">Type</dt>

                  <dd class="dd">picklist</dd>



                  <dt class="dt dlterm">Properties</dt>

                  <dd class="dd">Create, Filter, Group, Restricted picklist, Sort, Update</dd>



                  <dt class="dt dlterm">Description</dt>

                  <dd class="dd">The current status of the Apex class. Valid values are:<ul class="ul bulletList">
                      <li class="li">
                        <samp class="codeph nolang">Active</samp>—The class is active.
                      </li>

                      <li class="li">
                        <samp class="codeph nolang">Deleted</samp>—The class is marked for
                        deletion. This status is useful for managed packages, because it allows a class to be
                        deleted when a managed package is updated.
                      </li>

                      <li class="li">
                        <samp class="codeph nolang">Inactive</samp>—This option is unused and is
                        only supported for ApexTrigger. For more information, see the <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/" target="_blank" title="HTML (New Window)">Metadata API Developer
                          Guide</a>.
                      </li>

                    </ul>
                  </dd>


                </dl>

              </td>

            </tr>

            <tr>
              <td class="entry" headers="d21816e102" data-title="Field Name"><span class="keyword parmname">SymbolTable</span></td>

              <td class="entry" headers="d21816e105" data-title="Details">
                <dl class="dl detailList">

                  <dt class="dt dlterm">Type</dt>

                  <dd class="dd"><a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_symboltable.htm" title="A complex type that represents all user-defined tokens in the Body of an ApexClass, ApexClassMember, or ApexTriggerMember and their associated line and column locations within the Body.">SymbolTable</a></dd>



                  <dt class="dt dlterm">Properties</dt>

                  <dd class="dd">Nillable</dd>



                  <dt class="dt dlterm">Description</dt>

                  <dd class="dd">A complex type that represents all user-defined tokens in the Body of an ApexClass,
                    ApexClassMember, or ApexTriggerMember and their associated line and column locations
                    within the Body. <div class="p">This field is null if the symbol table can’t be created due to
                      reasons such as: <ul class="ul bulletList">
                        <li class="li">Another Apex compilation is in progress and holding a compile lock </li>

                        <li class="li">The Apex class is in an invalid state and can’t compile successfully </li>

                      </ul>
                    </div>
                  </dd>


                </dl>

              </td>

            </tr>

          </tbody>

        </table>

## Usage

To retrieve information about an Apex class, create an ApexClass object that references it. For example code, see [SOAP Calls](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/intro_soap_overview.htm).

To edit, save, or compile Apex classes, use [ApexClassMember](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_apexclassmember.htm "Represents the working copy of an Apex class for editing, saving, or compiling in a MetadataContainer.").

![Note](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/images/icon_note.png)

#### Note

If there Isn't a cached version of [SymbolTable](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_symboltable.htm "A complex type that represents all user-defined tokens in the Body of an ApexClass, ApexClassMember, or ApexTriggerMember and their associated line and column locations within the Body."), it’s compiled in the background and the query can take longer than expected. The SymbolTable returned from ApexClass doesn't contain references. To retrieve a SymbolTable with references, use [ApexClassMember](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_apexclassmember.htm "Represents the working copy of an Apex class for editing, saving, or compiling in a MetadataContainer.").

Although Apex classes and triggers have the Create and Update field properties, a runtime exception occurs if you try to create, update, or delete them using the API. Instead, use the Salesforce Extensions for Visual Studio Code or the Ant Migration Tool to create or update Apex classes or triggers. Apex classes and triggers can’t be created, edited, or deleted in a production org. See [Deploying Apex](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/apex_deploying.htm).