---
schema_version: "1"
id: 965d7704665bbe4868885d5e330c6c8af00581479443a5db672f0cb70201b184
title: ApexClass
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/object_reference/sforce_api_objects_apexclass.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_apexclass.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 8d1d2da56971fb4e1acc364f49bc90233fdd95fbd570bf432e0503cc66c2d91c
description: Represents an Apex class.
---
# ApexClass

Represents an Apex class.

## Supported Calls

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

## Fields

| Field | Details |
| --- | --- |
| ApiVersion | 
Type

double

Properties

Create, Filter, Sort, Update

Description

The API version for this class. Every class has an API version specified at creation.



 |
| Body | 

Type

textarea

Properties

Create, Nillable, Update

Description

The Apex class definition.

Limit: 1 million characters.





 |
| BodyCrc | 

Type

double

Properties

Create, Defaulted on create, Filter, Nillable, Sort, Update

Description

The CRC (cyclic redundancy check) of the class or trigger file.



 |
| IsValid | 

Type

boolean

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

Indicates whether any dependent metadata has changed since the class was last compiled (true) or not (false). The default value is false.



 |
| LengthWithoutComments | 

Type

int

Properties

Create, Filter, Group, Sort, Update

Description

Length of the class without comments.





 |
| Name | 

Type

string

Properties

Create, Filter, Group, idLookup, Sort, Update

Description

Name of the class.

Limit: 255 characters





 |
| NamespacePrefix | 

Type

string

Properties

Filter, Group, Nillable, Sort

Description

The namespace prefix that is associated with this object. Each Developer Edition org 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 namespacePrefix\_\_componentName notation.

The namespace prefix can have one of the following values.

- In Developer Edition orgs, NamespacePrefix is set to the namespace prefix of the org for all objects that support it, unless 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 org of the package developer.
- In orgs that are not Developer Edition orgs, NamespacePrefix is set only for objects that are part of an installed managed package. All other objects have no namespace prefix.





 |
| Status | 

Type

picklist

Properties

Create, Filter, Group, Restricted picklist, Sort, Update

Description

The current status of the Apex class. The following string values are valid:

- Active—The class is active.
- Deleted—The class is marked for deletion. This is useful for managed packages, because it allows a class to be deleted when a managed package is updated.
- Inactive—This option is unused and is only supported for ApexTrigger. For more information, see the [Metadata API Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/ "HTML (New Window)").





 |

## Usage

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).

#### See Also

- [ApexTrigger](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_apextrigger.htm "Represents an Apex trigger.")
- [_Developer Guide_: Apex Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/ "
    Developer Guide: Apex Developer Guide - html (New Window)")