---
schema_version: "1"
id: ea3242ab89320fda577d4679d23ea2caa33923b79f49eede02affdee94129285
title: Apex Code Overview
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/code_about.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.code_about.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 6feb100ea6846c2d710434d347a923669143d7f7665e710579cd63fa2f4c26d2
description: Apex is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on the Salesforce Platform. Apex enables developers to add business logic to most system events, including button clicks, related record updates, and Visualforce pages. Apex code can be initiated by web service requests and from triggers on objects.
products:
  - Salesforce Platform
release: "264"
---
# Apex Code Overview

Apex is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on the Salesforce Platform. Apex enables developers to add business logic to most system events, including button clicks, related record updates, and Visualforce pages. Apex code can be initiated by web service requests and from triggers on objects.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Salesforce Classic (<a href="https://help.salesforce.com/s/articleView?id=xcloud.overview_edition_lex_only.htm&amp;type=5&amp;language=en_US" target="_blank">not available in all orgs</a>) and Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <span id="code_about__Apex_Code_editions_text"><a name="code_about__Apex_Code_editions_text"></a><strong>Enterprise</strong>, <strong>Performance</strong>, <strong>Unlimited</strong>, <strong>Developer</strong>, and <strong>Database.com</strong> Editions</span></td></tr></tbody></table>

Apex can be stored on the Salesforce Platform in two different forms:

- A class is a template or blueprint from which Apex objects are created. Classes consist of other classes, user-defined methods, variables, exception types, and static initialization code. From Setup, enter Apex Classes in the Quick Find box, then select **Apex Classes**.
- A trigger is Apex code that executes before or after specific data manipulation language (DML) events occur, such as before object records are inserted into the database, or after records have been deleted. Triggers are stored as metadata in Salesforce. A list of all triggers in your organization is located on the Apex Triggers page in Setup.

In API version 67.0 and later, Apex database operations run in user context by default, meaning that the current user’s permissions and field-level security (FLS) are enforced during code execution. In API version 66.0 and earlier, system mode is the default.

You must have at least 75% of your Apex covered by unit tests before you can deploy your code to production environments. In addition, all triggers must have some test coverage.

After creating your classes and triggers, as well as your tests, replay the execution using the Developer Console or in VS Code with the Salesforce Extensions for Visual Studio Code.

You can add, edit, or delete Apex using the Salesforce user interface only in a Developer Edition organization, a Salesforce Enterprise Edition trial organization, or sandbox organization. In a Salesforce production organization, you can change Apex only by using the Metadata API `deploy` call, the Salesforce Extensions for Visual Studio Code, or the Ant Migration Tool. The Salesforce Extensions for Visual Studio Code and Ant Migration Tool are free resources provided by Salesforce to support its users and partners, but are not considered part of our Services for purposes of the Salesforce Main Services Agreement.

For more information on the syntax and use of Apex, see the [Apex Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/).

- **[Apex Developer Guide and Developer Tools](https://help.salesforce.com/s/articleView?id=platform.code_apex_dev_guide_tools.htm&release=264.0.0&type=5)**  
    The Apex Developer Guide and Apex Reference Guide provide the complete reference for the Apex programming language. The Apex Developer Guide explains how to invoke Apex, how to work with limits, how to write tests, and more. The Apex Reference Guide provides reference information on Apex classes, interfaces, exceptions and so on. To write Apex code, you can choose from several Salesforce and third-party tools.
- **[Define Apex Classes](https://help.salesforce.com/s/articleView?id=platform.code_define_package.htm&release=264.0.0&type=5)**  
    Salesforce stores Apex classes as metadata.
- **[Define Apex Triggers](https://help.salesforce.com/s/articleView?id=platform.code_define_trigger.htm&release=264.0.0&type=5)**  
    Apex code can be invoked by using triggers. Apex triggers can be configured to perform custom actions before or after changes to Salesforce records, such as insertions, updates, or deletions.
- **[Executing Anonymous Apex Code](https://help.salesforce.com/s/articleView?id=platform.code_dev_console_execute_anonymous.htm&release=264.0.0&type=5)**  
    The Developer Console allows you to execute Apex code as another way to generate debug logs that cover specific application logic.
- **[What Happens When an Apex Exception Occurs?](https://help.salesforce.com/s/articleView?id=platform.code_apex_exceptions.htm&release=264.0.0&type=5)**  
    When an exception occurs, code execution halts. Any DML operations that were processed before the exception are rolled back and aren’t committed to the database. Exceptions get logged in debug logs. For unhandled exceptions, which are exceptions that the code doesn’t catch, Salesforce sends an email that includes the exception information. The end user sees an error message in the Salesforce user interface.
- **[Handling Apex Exceptions in Managed Packages](https://help.salesforce.com/s/articleView?id=platform.code_handling_managed_errors.htm&release=264.0.0&type=5)**  
    When you create a managed package for AppExchange, you can specify a user to receive an email notification when an exception occurs that Apex doesn’t catch.
- **[Manage Apex Classes](https://help.salesforce.com/s/articleView?id=platform.code_manage_packages.htm&release=264.0.0&type=5)**  
    An Apex class is a template or blueprint from which Apex objects are created. Classes consist of other classes, user-defined methods, variables, exception types, and static initialization code.
- **[Manage Apex Triggers](https://help.salesforce.com/s/articleView?id=platform.code_manage_triggers.htm&release=264.0.0&type=5)**  
    A trigger is Apex code that executes before or after specific data manipulation language (DML) events occur, such as before object records are inserted into the database, or after records have been deleted.
- **[Manage Version Settings for Apex](https://help.salesforce.com/s/articleView?id=platform.code_version_settings_apex.htm&release=264.0.0&type=5)**  
    To aid backwards-compatibility, Apex classes and triggers are stored with version settings for the Salesforce API and any referenced managed packages.
- **[View Apex Classes](https://help.salesforce.com/s/articleView?id=platform.code_view_class.htm&release=264.0.0&type=5)**  
    After you have created a class, you can view the code contained in the class, as well as the API against which the class was saved, and whether the class is valid or active.
- **[View Apex Trigger Details](https://help.salesforce.com/s/articleView?id=platform.code_view_trigger.htm&release=264.0.0&type=5)**  
    Apex triggers are stored as metadata in the application under the object with which they are associated.
- **[Create an Apex Class from a WSDL](https://help.salesforce.com/s/articleView?id=platform.code_wsdl_to_package.htm&release=264.0.0&type=5)**  
    An Apex class can be automatically generated from a WSDL document that is stored on a local hard drive or network.
- **[Monitor the Apex Job Queue](https://help.salesforce.com/s/articleView?id=platform.code_apex_job.htm&release=264.0.0&type=5)**  
    The Apex Jobs Setup page has information about Apex jobs, including the percentage of async Apex usage and the number of Apex operations that have been used out of the 24-hour org limit. Monitor the status of Apex jobs to mitigate potential limit problems before they happen.
- **[Monitoring the Apex Flex Queue](https://help.salesforce.com/s/articleView?id=platform.code_apex_flex_queue.htm&release=264.0.0&type=5)**  
    Use the Apex Flex Queue page to view and reorder all batch jobs that have a status of Holding. Or reorder your batch jobs programmatically using Apex code.
- **[Schedule Apex Jobs](https://help.salesforce.com/s/articleView?id=platform.code_schedule_batch_apex.htm&release=264.0.0&type=5)**  
    Use the Apex scheduler and the `Schedulable` interface if you have specific Apex classes that you want to run on a regular basis, or to run a batch Apex job using the Salesforce user interface.
- **[Apex Hammer Test Results](https://help.salesforce.com/s/articleView?id=platform.apex_hammer_execution_status.htm&release=264.0.0&type=5)**  
    With the Hammer process, Salesforce runs your org’s Apex tests in both the current and new release, and compares the results to identify issues for you.
- **[Apex FAQ](https://help.salesforce.com/s/articleView?id=platform.faq_apex.htm&release=264.0.0&type=5)**  
    Frequently asked questions about external Web services, supported WSDL Schema types, and differences between a Apex classes and triggers.