---
schema_version: "1"
id: e885dcb8177fd0ddab387a6f45e9d57951e1dd9bf844253b539cf9140fbc1743
title: Manage Version Settings for Apex
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/code_version_settings_apex.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.code_version_settings_apex.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: b013caa75b6059592564b144b4ab59ea6224f91e5adfa3e4f7e86eea2d4d808e
description: To aid backwards-compatibility, Apex classes and triggers are stored with version settings for the Salesforce API and any referenced managed packages.
products:
  - Salesforce Platform
release: "264"
---
# Manage Version Settings for Apex

To aid backwards-compatibility, Apex classes and triggers are stored with version settings for the Salesforce API and any referenced managed packages.

### 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;">
              <p>Available in: <strong>Performance</strong>, <strong>Unlimited</strong>, <strong>Developer</strong>,
                <strong>Enterprise</strong>, and <strong>Database.com</strong> Editions
              </p>
              <p style="margin-bottom:0;">Managed Packages are not
                available in <strong>Database.com</strong>.</p>
            </td>

          </tr>
        </tbody>
      </table> <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:74%">
          <col style="width:26%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d15635e85">User Permissions
              Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d15635e85 ">
              <span id="code_version_settings_apex__class_perm_text"><a name="code_version_settings_apex__class_perm_text"><!-- --></a>To define, edit, delete, set security, and set version
                settings for Apex classes:</span>
            </td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d15635e85 ">
              <span id="code_version_settings_apex__apex_perm_value"><a name="code_version_settings_apex__apex_perm_value"><!-- --></a>Author Apex</span>
            </td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d15635e85 ">
              <span id="code_version_settings_apex__class__runtest_perm_text"><a name="code_version_settings_apex__class__runtest_perm_text"><!-- --></a>To run Apex tests:</span>
            </td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d15635e85 ">
              <span id="code_version_settings_apex__apex_runtest_perm_value"><a name="code_version_settings_apex__apex_runtest_perm_value"><!-- --></a>View Setup and Configuration</span>
            </td>

          </tr>
        </tbody>
      </table>

If the Apex class references components, such as a custom object, in installed managed packages, the version settings for each managed package referenced by the class is saved too. This ensures that as Apex, the API, and the components in managed packages evolve in subsequent released versions, a class or trigger is still bound to versions with specific, known behavior.

A package version is a number that identifies the set of components uploaded in a package. The version number has the format majorNumber.minorNumber.patchNumber (for example, 2.1.3). The major and minor numbers increase to a chosen value during every major release. The patchNumber is generated and updated only for a patch release. Publishers can use package versions to evolve the components in their managed packages gracefully by releasing subsequent package versions without breaking existing customer integrations using the package.

1. Edit either a class or trigger, and click **Version Settings**.
2. Select the Version of the Salesforce API. This is also the version of Apex associated with the class or trigger.
3. Click **Save**.

#### See Also

- [_Apex Developer Guide_ Apex in Managed Packages](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_manpkgs_behavior_intro.htm)

## Configure the Package Version Settings for a Class or Trigger

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_code-264-0-0-production-enus/789bc523-706b-4ae4-8fe9-be6322e38b6b/images/icon_note.png)

Note In Summer ’25 and later, package subscribers can use version settings to specify the version of a migrated second-generation managed package (2GP) that an Apex class or trigger depends on. This functionality is already available to first-generation managed packages (1GP), but isn’t yet supported in 2GP packages that weren’t converted from a 1GP package. See [Apex Version Settings in Migrated Second-Generation Managed Packages (2GP)](https://help.salesforce.com/s/articleView?id=005101483&type=1&language=en_US).

- If you save an Apex class or trigger that references a managed package without specifying a version of the managed package, the Apex class or trigger is associated with the latest installed version of the managed package by default.
- You cannot **Remove** a class or trigger's version setting for a managed package if the package is referenced in the class or trigger. Use **Show Dependencies** to find where a managed package is referenced by a class or a trigger.

1. Edit either a class or trigger, and click **Version Settings**
2. Select a Version for each managed package referenced by the class or trigger. This version of the managed package will continue to be used by the class or trigger if later versions of the managed package are installed, unless you manually update the version setting. To add an installed managed package to the settings list, select a package from the list of available packages. The list is only displayed if you have an installed managed package that is not already associated with the class or trigger.
3. Click **Save**.

![Tip](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_code-264-0-0-production-enus/789bc523-706b-4ae4-8fe9-be6322e38b6b/images/icon_tip.png)

Tip You can also set the package version for an Apex class or trigger through metadata deployments or with API requests. See [Set Package Versions for Apex Classes and Triggers](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_manpkgs_subscriber_version.htm) in the Apex Developer Guide.