---
schema_version: "1"
id: 0595e3541a26dd2d3c97eca02275fa59c7eefa18762bccb5776a568121e64e7b
title: Apex Reference Guide
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_ref_guide.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ref_guide.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: a76190f41f22739b697ac11a861aaf8ca297265be17969a3d168073047007be1
description: Apex is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on the Salesforce Platform server, in conjunction with calls to the API. This reference guide includes built-in Apex classes, interfaces, enums, and exceptions, grouped by namespace. It also includes Apex DML statements to insert, update, merge, delete, and restore data in Salesforce.
---
# Apex Reference Guide

Apex is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on the Salesforce Platform server, in conjunction with calls to the API. This reference guide includes built-in Apex classes, interfaces, enums, and exceptions, grouped by namespace. It also includes Apex DML statements to insert, update, merge, delete, and restore data in Salesforce.

For information on the Apex development process, see [Apex Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/apex_dev_guide.htm "HTML (New Window)").

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

#### Note

In API version 51.0 and earlier, Apex Reference information was included in the Apex Developer Guide in the "Apex Language Reference" section.

Keep these guidelines in mind regarding API version usage:

- Salesforce strongly recommends that you use the latest available API version.
- If you can't upgrade to the latest version yet, use API versions released in the past three years, for improved performance, security, and compatibility.
- To reduce complexity, consolidate your Apex codebase to use the minimal number of API versions, ideally, just one API version.

For a non-exhaustive list of major Apex behavior changes across API versions, organized by version number, see [Apex Versioned Behavior Changes](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/versioned_behavior_changes.htm "This document includes major Apex behavior changes across API versions, organized by version number for easy lookup. It isn’t an exhaustive list of all versioned Apex behavior. For example, this compilation excludes versioned changes to Connect in Apex and classes in the ConnectApi namespace.").

- **[Apex Release Notes](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_releasenotes.htm)**  
    Use the Salesforce Release Notes to learn about the most recent updates and changes to Apex.
- **[Apex DML Operations](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_dml_section.htm#apex_dml_section)**  
    You can perform DML operations using the Apex DML statements or the methods of the Database class. For lead conversion, use the convertLead method of the Database class. There is no DML counterpart for it.
- **[ApexPages Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_ApexPages.htm)**  
    The ApexPages namespace provides classes used in Visualforce controllers.
- **[AppLauncher Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_applauncher.htm)**  
    The AppLauncher namespace provides methods for managing the appearance of apps in the App Launcher, including their visibility and sort order.
- **[Approval Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Approval.htm)**  
    The Approval namespace provides classes and methods for approval processes.
- **[Auth Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Auth.htm)**  
    The Auth namespace provides an interface and classes for single sign-on into Salesforce and session security management.
- **[Cache Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_cache.htm)**  
    The Cache namespace contains methods for managing the platform cache.
- **[Canvas Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Canvas.htm)**  
    The Canvas namespace provides an interface and classes for canvas apps in Salesforce.
- **[ChatterAnswers Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_ChatterAnswers.htm)**  
    The ChatterAnswers namespace provides an interface for creating Account records.
- **[CommerceBuyGrp Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_CommerceBuyGrp.htm)**  
    The CommerceBuyGrp namespace provides classes and methods for retrieving information about the buyer groups associated with a user.
- **[CommerceExtension Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_CommerceExtension.htm)**  
    Use the CommerceExtension namespace to define resolution strategies for registered Commerce extensions.
- **[CommerceOrders Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_commerceorders.htm)**  
    The CommerceOrders namespace provides classes and methods to place orders with integrated pricing, configuration, and validation.
- **[CommercePayments Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_commercepayments.htm)**  
    Use the CommercePayments namespace to provide a safe and customizable platform for managing customer payments and refunds.
- **[CommerceTax Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_commercetax.htm)**  
    Manage the communication between Salesforce and an external tax engine.
- **[commonserviceexcellence Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_commonserviceexcellence.htm)**  
    The commonserviceexcellence namespace provides classes used in financial account FlexCards. These classes are documented in the Agentforce Financial Services Developer Guide.
- **[ComplianceMgmt Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_compliancemgmt.htm)**  
    The ComplianceMgmt namespace provides classes and methods to implement rule processors for compliance control.
- **[Compression Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_compression.htm)**  
    The Compression namespace provides classes and methods to create and extract zip files.
- **[ConnectApi Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_connect_api.htm)**  
    The ConnectApi namespace (also called Connect in Apex) provides classes for accessing the same data available in Connect REST API. Use Connect in Apex to create custom experiences in Salesforce.
- **[Context Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_context.htm)**  
    The Context namespace provides classes and methods to manage the sharing and consumption of business application data by using Context Service.
- **[Database Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Database.htm)**  
    The Database namespace provides classes used with DML operations.
- **[Datacloud Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_datacloud.htm)**  
    The Datacloud namespace provides classes and methods for retrieving information about duplicate rules. Duplicate rules let you control whether and when users can save duplicate records within Salesforce.
- **[DataRetrieval Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_DataRetrieval.htm)**  
    The DataRetrieval namespace provides classes and methods to record details of customer-agent engagements, as well as transcripts of their conversations.
- **[DataSource Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_DataSource.htm)**  
    The DataSource namespace provides the classes for the Apex Connector Framework. Use the Apex Connector Framework to develop a custom adapter for Salesforce Connect. Then connect your Salesforce organization to any data anywhere via the Salesforce Connect custom adapter.
- **[DataWeave Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_dataweave.htm)**  
    The DataWeave namespace provides classes and methods to support the invocation of DataWeave scripts from Apex.
- **[Dom Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Dom.htm)**  
    The Dom namespace provides classes and methods for parsing and creating XML content.
- **[embeddedai Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_embeddedai.htm)**  
    The embeddedai namespace provides classes and methods to manage and represent records and data in Apex to support embedded AI features.
- **[EventBus Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_eventbus.htm)**  
    The EventBus namespace provides classes and methods for platform events and Change Data Capture events.
- **[ExternalService Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_ExternalService.htm)**  
    The ExternalService namespace provides dynamically generated Apex service interfaces and Apex classes for complex object data types.
- **[Flow Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Flow.htm)**  
    The Flow namespace provides a class for advanced access to flows from Apex such as from Visualforce controllers and asynchronous Apex.
- **[Flowtesting Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_flowtesting.htm)**  
    The flowtesting namespace provides dynamically generated Apex classes for flow tests that are created in Flow Builder.
- **[flowuiruntime Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_flowuiruntime.htm)**  
    The classes and methods in this namespace are reserved for internal use only or future use.
- **[FormulaEval Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_formulaeval.htm)**  
    The FormulaEval namespace provides classes and methods to evaluate dynamic formulas for SObjects and Apex objects. Use the methods to avoid unnecessary DML statements to recalculate formula field values or evaluate dynamic formula expressions.
- **[disputemanagement Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_disputemanagement.htm)**  
    The disputemanagement namespace classes provide services for Integration Procedures used by the Transaction Dispute Management OmniScript. These classes are documented in the Agentforce Financial Services Developer Guide.
- **[fsccashflow Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_fsccashflow.htm)**  
    The fsccashflow namespace provides classes used in the FSCCashFlow FlexCards and their child FlexCards. These classes are documented in the Agentforce Financial Services developer guide.
- **[fsccomplaintmanagement Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_fsccomplaintmanagement.htm)**  
    The fsccomplaintmanagement namespace classes provide data helper functions for use in complaint management. These classes are documented in the Agentforce Financial Services Developer Guide.
- **[fschousehold Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_fschousehold.htm)**  
    The fschousehold namespace provides classes used for households, financial accounts, goals, and plans. These classes are documented in the Agentforce Financial Services Developer Guide.
- **[fscserviceprocesses Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_fscserviceprocesses.htm)**  
    The fscserviceprocesses namespace provides classes used in service process OmniScripts, such as change address and fee reversal. These classes are documented in the Agentforce Financial Services Developer Guide.
- **[fscwmgen Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_fscwmgen.htm)**  
    The fscwmgen namespace provides an interface and classes used for record alerts. These are documented in the Agentforce Financial Services Developer Guide.
- **[industriespersonalizedfinance Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_industriespersonalizedfinance.htm)**  
    The industriespersonalizedfinance namespace classes provide data helper functions for use in personalized finance. These classes are documented in the Agentforce Financial Services Developer Guide.
- **[Functions Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_functions.htm)**  
    The Functions namespace provides classes and methods used to invoke and manage Salesforce Functions.
- **[ise\_bots\_apex Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_ise_bots_apex.htm)**  
    The ise\_bots\_apex namespace provides classes and properties to facilitate dynamic content generation and data handling for menu-driven bot interactions. Create and manage dynamic menu items that adapt to user inputs, context, and underlying object data.
- **[IssueCreditMemo Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_issuecreditmemo.htm)**  
    The IssueCreditMemo namespace provides classes to create and apply credit memos against invoices or invoice lines based on dispute adjustments.
- **[ind\_mfg\_sample\_mgmt\_apex Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_ind_mfg_sample_mgmt_apex.htm)**  
    The ind\_mfg\_sample\_mgmt\_apex namespace provides classes and properties to manage the lifecycle and documentation of product requirements in manufacturing. Create, update, or version Product Requirement Specification records to ensure sample data remains consistent and compliant with production standards.
- **[industriesNlpSvc](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_industriesNlpSvc.htm)**  
    Stores the objects used in Industries Einstein Natural Language Processing (NLP) services.
- **[IndustriesDigitalLending Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_industriesDigitalLending.htm)**  
    The industriesDigitalLending namespace provides classes used in the Digital Lending OmniScripts and Integration Procedures.
- **[Invocable Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Invocable.htm)**  
    The Invocable namespace provides classes for calling invocable actions from Apex.
- **[InvoiceWriteOff Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_invoicewriteoff.htm)**  
    The InvoiceWriteOff namespace provides classes to create credit memos with the total charge amount on the invoice as the write-off amount.
- **[IsvPartners Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_IsvPartners.htm)**  
    The IsvPartners namespace provides a class associated with Salesforce ISV partner use cases, such as optimizing code, providing great customer trial experiences, and driving feature adoption.
- **[KbManagement Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_KbManagement.htm)**  
    The KbManagement namespace provides a class for managing knowledge articles.
- **[LxScheduler Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_lxscheduler.htm)**  
    The LxScheduler namespace provides an interface and classes for integrating Salesforce Scheduler with external calendars.
- **[Messaging Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Messaging.htm)**  
    The Messaging namespace provides classes and methods for Salesforce notifications and email functionality.
- **[Metadata Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Metadata.htm)**  
    The Metadata namespace provides classes and methods for working with custom metadata in Salesforce
- **[PlaceQuote Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_placequote.htm)**  
    The PlaceQuote namespace provides classes and methods to create or update quotes with pricing preferences and configuration options.
- **[Pref\_center Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_pref_center.htm)**  
    The Pref\_center namespace provides an interface, classes, and methods to create and retrieve data in forms in Preference Manager. Preference Manager, previously called Preference Center, is a feature within the Privacy Center app.
- **[Process Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_process.htm)**  
    The Process namespace provides an interface and classes for passing data between your organization and a flow.
- **[QuickAction Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_QuickAction.htm)**  
    The QuickAction namespace provides classes and methods for quick actions.
- **[renew\_assets\_summary Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_renew_assets_summary.htm)**  
    The renew\_assets\_summary namespace provides classes that retrieve details about renewable assets to create renewal opportunities.
- **[Reports Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Reports.htm)**  
    The Reports namespace provides classes for accessing the same data as is available in the Salesforce Reports and Dashboards REST API.
- **[RevSignaling Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_RevSignaling.htm)**  
    The RevSignaling namespace provides classes to extend the standard procedure plan implementation through custom logic. A procedure plan helps you set up your procedures, configure the procedure execution settings, and relate them to a context definition in one centralized location based on your requirements.
- **[RevSalesTrxn Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_revsalestrxn.htm)**  
    The RevSalesTrxn namespace provides classes and methods to create a sales transaction, such as a quote or an order, with integrated pricing and configuration.
- **[RichMessaging Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_RichMessaging.htm)**  
    Provides objects and methods for handling content in enhanced Messaging channels.
- **[RulesAppln Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_rulesappln.htm)**  
    The RulesAppln namespace contains output classes that store details about a rules-based application of payments and credits.
- **[runtime\_industries\_cpq Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_runtime_industries_cpq.htm)**  
    The runtime\_industries\_cpq namespace provides classes and methods to search products or to manage products, catalogs, and categories.
- **[runtime\_industries\_insurance Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_runtime_industries_insurance.htm)**  
    The runtime\_industries\_insurance namespace provides options classes for insurance operations, such as creating and updating insurance quotes, generating insurance clauses, and running insurance rating.
- **[Schema Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Schema.htm)**  
    The Schema namespace provides classes and methods for schema metadata information.
- **[Search Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Search.htm)**  
    The Search namespace provides classes for getting search results and suggestion results.
- **[setup\_flow\_performance Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_setup_flow_performance.htm)**  
    The class and methods in this namespace are for internal use only.
- **[SF\_Archive Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_SF_Archive.htm)**  
    The SF\_Archive namespace provides classes for testing Apex code that calls Archive Apex.
- **[Sfc Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Sfc.htm)**  
    The Sfc namespace contains classes used in Salesforce Files.
- **[Sfdc\_Checkout Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_sfdc_checkout.htm)**  
    The Sfdc\_Checkout namespace provides an interface and classes for B2B Commerce apps in Salesforce.
- **[Sfdc\_Enablement Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_sfdc_enablement.htm)**  
    The sfdc\_enablement namespace provides classes for creating custom learning items to implement custom exercise types in Enablement programs. Lightning web components are used to render the custom exercises on Program Builder.
- **[sfdc\_surveys Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_sfdc_surveys.htm)**  
    The sfdc\_surveys namespace provides an interface for shortening survey invitations.
- **[sfdw Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_sfdw.htm)**  
    Contains classes that describe Digital Wallet consumption card status and the alerts triggered when consumption crosses a threshold.
- **[sfsqlquery Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_sfsqlquery.htm)**  
    Contains classes for executing SQL queries against Data 360 data spaces from Apex.
- **[Site Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Site.htm)**  
    The Site namespace provides an interface for rewriting Sites URLs.
- **[Slack Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Slack.htm)**  
    The Slack Namespace provides tools designed to accelerate and ease the process of developing Slack apps on the Salesforce platform.
- **[Support Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Support.htm)**  
    The Support namespace provides an interface used for Case Feed.
- **[System Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_System.htm)**  
    The System namespace provides classes and methods for core Apex functionality.
- **[TerritoryMgmt Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_TerritoryMgmt.htm)**  
    The TerritoryMgmt namespace provides an interface used for territory management.
- **[TxnSecurity Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_TxnSecurity.htm)**  
    The TxnSecurity namespace provides an interface used for transaction security.
- **[UserProvisioning Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_UserProvisioning.htm)**  
    The UserProvisioning namespace provides methods for monitoring outbound user provisioning requests.
- **[VisualEditor Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_VisualEditor.htm)**  
    The VisualEditor namespace provides classes and methods for interacting with the Lightning App Builder. The classes and methods in this namespace operate on Lightning components, which include Lightning web components and Aura components.
- **[Wave Namespace](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_wave.htm)**  
    The classes in the Wave namespace are part of the CRM Analytics Analytics SDK, designed to facilitate querying CRM Analytics data from Apex code.
- **[Appendices](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_appendices.htm)**