Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Salesforce API Version entry
How-to guide

Set the API version on an Apex class

You set the Salesforce API version on an Apex class or trigger from its Version Settings in Setup. This pins the platform behavior the code runs under and the versions of any managed packages it depends on. Use this to keep code on a deliberate, reviewed version rather than letting it drift.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated Jun 16, 2026

You set the Salesforce API version on an Apex class or trigger from its Version Settings in Setup. This pins the platform behavior the code runs under and the versions of any managed packages it depends on. Use this to keep code on a deliberate, reviewed version rather than letting it drift.

  1. Open the class or trigger in Setup

    Go to Setup and open the Apex Classes or Apex Triggers list. Click the name of the class or trigger you want to change, then click Edit to open it for changes. You need the relevant author or modify permission to edit Apex in that environment.

  2. Open the Version Settings tab

    With the class open for editing, select the Version Settings tab. The Salesforce API Version field shows the version the code is currently saved against. This is the number that decides which platform behavior applies when the code runs.

  3. Choose the API version

    Pick the API version you want from the list of supported versions. Move forward to a newer version to reach new fields and methods, or hold an older one if you need its behavior. Avoid any version near a published retirement so the code does not age out.

  4. Pin package versions and save

    In the same tab, set the version for each managed package the code depends on so a package upgrade cannot silently change behavior. Save the class. In a team setting, make the change in source control so everyone deploys the same version.

Key options
Salesforce API Versionremember

The platform release version the class or trigger runs under, written as a decimal such as 64.0. It selects the feature and behavior set the code sees.

Managed package versionsremember

The pinned version of each installed managed package the code calls, so upgrading the package does not change how your code interacts with it.

Component scoperemember

Version Settings apply per class or trigger, so different pieces of code in the same org can run at different API versions on purpose.

Gotchas
  • A field or method added in a newer release cannot be used by code saved at an older API version, even when the org is fully upgraded.
  • Mismatched API versions across developers sharing a repository cause deploy failures, so set the version as a project decision, not a personal one.
  • In Salesforce DX, sourceApiVersion and the CLI apiVersion are separate settings; keep them aligned to avoid confusing deploy and retrieve differences.

See the full Salesforce API Version entry

Salesforce API Version includes the definition, worked example, deep dive, related terms, and a quiz.