hardis:org:diagnose:apex-api-version
Description
Detects Apex classes and triggers deployed with API versions at or below a configurable threshold.
Apex metadata API version is the version the code was compiled against. This is separate from hardis:org:diagnose:legacyapi, which checks deprecated API call versions (SOAP, REST, Bulk) from EventLogFile.
Key functionalities:
- Threshold-based detection: API versions at or below the threshold are flagged as deprecated. Configure via
DEPRECATED_APEX_API_VERSIONenv var (default:50). - Apex classes: Queries custom Apex classes (excludes managed packages). Optionally excludes
@isTestclasses via--includetestclasses. - Apex triggers: Queries custom Apex triggers (excludes managed packages).
- CSV report: Generates a report listing all deprecated classes and triggers with their ApiVersion.
- Notifications: Sends alerts to Grafana, Slack, MS Teams when deprecated Apex is found.
This command is part of sfdx-hardis Monitoring and can output Grafana, Slack and MsTeams Notifications.
Agent Mode
Supports non-interactive execution with --agent:
sf hardis:org:diagnose:apex-api-version --agent --target-org myorg@example.com
In agent mode, the command runs fully automatically. The API version threshold defaults to 50 (or DEPRECATED_APEX_API_VERSION env var) when --threshold is not provided.
Screenshots
Helios Apex classes and triggers at API version 64 or below, listed with their version to plan the upgrade
- (1) One row per class or trigger to upgrade, with its API version
Reports
The command writes these reports in the hardis-report folder of the project: a CSV file, and its Excel copy (XLSX) in the xls sub-folder.
Deprecated API versions
One row per Apex class or trigger whose API version is at or below the threshold, with its name and API version, to know what to upgrade.
Files: apex-api-version-*.csv, xls/apex-api-version-*.xlsx
Parameters
| Name | Type | Description | Default | Required | Options |
|---|---|---|---|---|---|
| agent | boolean | Run in non-interactive mode for agents and automation. Uses default values and skips prompts. | |||
| debug -d |
boolean | Activate debug mode (more logs) | |||
| flags-dir | option | Import flag values from a directory. | |||
| includetestclasses -i |
boolean | Include @isTest classes in the report (excluded by default) | |||
| json | boolean | Format output as json. | |||
| outputfile -f |
option | Force the path and name of output report file. Must end with .csv | |||
| skipauth | boolean | Skip authentication check when a default username is required | |||
| target-org -o |
option | Username or alias of the target org. Not required if the target-org configuration variable is already set. |
true | ||
| threshold -t |
option | API version threshold. Classes/triggers with ApiVersion <= this value are flagged. Overrides DEPRECATED_APEX_API_VERSION env var. | |||
| websocket | option | Websocket host:port for VsCode SFDX Hardis UI integration |
Examples
$ sf hardis:org:diagnose:apex-api-version
$ sf hardis:org:diagnose:apex-api-version --threshold 55
$ sf hardis:org:diagnose:apex-api-version --outputfile ./reports/apex-api-version.csv
$ sf hardis:org:diagnose:apex-api-version --agent

