As Salesforce regularly releases updates that include API deprecations, the involved tasks can become cumbersome and time-consuming, particularly for those managing multiple production Orgs.
So, I created this tool to automate the process.
- Detect REST and SOAP API based on Salesforce recommendations
- Configurable N days inspection
- Configurable threshold API version
- Login to Sandbox/Org using a created token or connected App
.. and also:
- Detect Apex Classes using deprecated API versions
- Detect Apex Triggers using deprecated API versions
- Detect LWCs using deprecated API versions
Based on Pablo’s idea here, I created a tool for detecting deprecated API versions that might help you, based on Pablo’s idea here (I strongly recommend you follow his blog).
As explained here, https://help.salesforce.com/s/articleView?id=000389618&type=1 those tasks are:
- Use a tool such as the Salesforce CLI to run a SOQL query against the EventLogFile* object, which will provide you with a log of all actions taken within your org during the last 24 hours.
sfdx force:data:soql:query -q "SELECT LogFile, EventType, CreatedDate FROM EventLogFile WHERE EventType IN ('API', 'RestApi', 'ApiTotalUsage')" -u <your-username>
- For each result, perform a REST request using the endpoint to obtain the data and copy into a .CSV file.
- e.g.
/services/data/v52.0/sobjects/EventLogFile/0AT3i000005vXpWGAU/LogFile
- Paste the response body into an application such as Excel to efficiently view the event log data as a .CSV file.
- e.g.
- Review each .CSV file and determine if requests are being made to endpoints with API versions 30 and below.
- SOAP / API EventType — review values in column API_VERSION for records of API_TYPE of “E” or “P”
- REST / RestApi EventType — review values in column URI and note endpoints featuring “/v30.0” or lower in the path
- API Total Usage / ApiTotalUsage EventType — review all events with API_VERSION of 30 and below
- Any integrations that consume versions 30.0 and below will be impacted by this API retirement.
*Access to “API” and “RestAPI” EventLogFile types requires a license to Event Monitoring.
So, I have created a Python tool that executes the 4 steps above plus:
- Detect Apex Classes using deprecated API versions
- Detect Apex Triggers using deprecated API versions
- Detect LWCs using deprecated API versions
- Configurable N days inspection
- Configurable lowest Api version Applicable
- Login to Sandbox/Org via by token or connected App
Results
Results provided by the tool lool like this (also included an example in the repo)

How to run the tool
Configuring inspection
Adjust config.json for the general configuration
"config": {
"min_api_version_to_check_for": 30, <-> Api versions <=30 are considered deprecated
"api_version_to_run_calls_with": 57.0, <-> Connect to Org/Sandboxes which this API version, usually the latest
"n_days_to_analyze": 5 <-> How many days you want to inspect
}
Configuring credentials
Adjust config.json by adding credentials:
- either providing an access_token that you already have or has been given
- or full details for a connected app created in the Org
"salesforce_environments": [
{
"creds_via_access_token": {
"access_token": "00D29000000ELAp!aaldkfjañdkfajñdfkjakadjdfñakjadñdkajdñkfajdfklajfañlkjfañ.cTHuvJmtr7dVZu",
"instance_url" : "https://your-my-domain.com"
}
},
{
"creds_via_app" : {
"sf_url": "https://test.salesforce.com/services/oauth2/token?",
"username": "your_username_name",
"security_token": "your_security_token",
"password": "your_password",
"client_id": "your_client_id_for_your_connected_app",
"client_secret": "your_client_secret_for_your_connected_app"
}
}
]
}
Repo available
- Repo available here: https://bitbucket.org/estevegraells/detect-deprecated-api-versions/src/master/
- Install libraries with:
pip install -r requirements.txt
Please send me your comments or suggestions, I hope this helps.
Deja una respuesta