Every Apex class, trigger, and Visualforce page in Salesforce is compiled and executed against a specific API version. Components running on older API versions may behave differently from current platform expectations, miss new features, or encounter deprecated functionality. Salesforce recommends updating Apex code components to API version 45.0 or higher to maintain compatibility with current releases. This article explains how to update the API version using three methods: Salesforce Setup, the Developer Console, and VS Code with the Salesforce CLI.
This article explains how to update the API version for Apex classes, Apex triggers, and Visualforce pages to version 45.0 or higher. Use the method that matches your development environment.
Go to Setup by clicking the gear icon and selecting Setup.
To update an Apex Class: In the Quick Find box, type Apex Classes and select it. Click Edit next to the class you want to update. Change the API Version field to 45.0 or higher and click Save.
To update an Apex Trigger: In the Quick Find box, type Apex Triggers and select it. Click Edit next to the trigger. Change the API Version field to 45.0 or higher and click Save.
To update a Visualforce Page: In the Quick Find box, type Visualforce Pages and select it. Click Edit next to the page. Change the API Version field to 45.0 or higher and click Save.
Open the Developer Console from the gear icon menu.
Go to File > Open and select the Apex class, trigger, or Visualforce page you want to update.
In the file editor, click the Version Settings tab (at the bottom of the editor pane).
Update the API Version to 45.0 or higher and click Save (Ctrl+S or Cmd+S).
Open your Salesforce DX project in VS Code.
Locate the metadata file for the component you want to update. For an Apex class named `MyClass`, the file is `force-app/main/default/classes/MyClass.cls-meta.xml`.
Open the `-meta.xml` file and update the `<apiVersion>` value to `45.0` or higher. For example:
`<apiVersion>61.0</apiVersion>`
Save the file and deploy the updated component to your org using the Salesforce CLI: `sf project deploy start -m ApexClass:MyClass`
Updating the API version of a component may change its runtime behavior if your code relies on features or defaults that differ between API versions. Test updated components in a sandbox before deploying to production. To check the current API version of all Apex classes in your org at once, query the `ApexClass` object in the Developer Console or Tooling API: `SELECT Name, ApiVersion FROM ApexClass ORDER BY ApiVersion ASC`.
005389424

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.