
Are your API calls failing after an org migration or instance refresh? You're not alone! Many Salesforce customers experience disruptions due to hard-coded instance URLs. This blog will guide you through updating your API calls and using your My Domain login URL to ensure uninterrupted service.
Hard-coded instance URLs, such as https://ap2.salesforce.com, become outdated after a migration or refresh, causing API failures. Switching to your My Domain login URL ensures API calls are always routed to the correct instance. This change is relevant to all API versions.
The update regarding the API calls was introduced in the Summer’24 release, and an additional update was later received in Spring’25.
Important Dates:
Sandbox Decommission: April 1, 2025
Production Decommission: June 14, 2025. Ensure your API calls are updated before these dates to avoid disruptions.
Solution: Follow these steps to update your API calls:
Step-by-Step Guide
Step 1: Find Your My Domain Login URL
Navigate to Setup → Quick Find → Search for My Domain.

Locate the Current My Domain URL field.
Step 2: Identify Hard-Coded Instance URLs
Retrieve your org's metadata using Salesforce CLI or Visual Studio Code.
Use Ctrl + Shift + F (Windows) / Command + Shift + F (Mac) to search for URLs like *.salesforce.com for instance.
Step 3: Update API Calls
Replace instance URLs with your My Domain login URL.
Example:
Using Salesforce Extensions in Visual Studio Code to search for Hard-Coded References
Salesforce Extensions for Visual Studio Code is a developer tool that helps find hard-coded references. Follow these steps to update hard-coded references in your org and metadata (setup or custom code):
Creating a Salesforce Project in Visual Studio Code:
Launch Visual Studio Code, then select “SFDX: Create Project with Manifest” from the Command Palette.
Run SFDX: Authorize an Org and select a login URL, like Production.
Give an organization's alias. A window of the browser opens. Give permission, sign in to your organization, and then go back to Visual Studio Code. The alias you supplied is now displayed in the Org Picker.
When you run the SFDX: Create Project with Manifest command, a package.xml file is created. Add the metadata types you want to retrieve to this file. For details on working with different subsets of metadata in package.xml, see Sample package.xml Manifest Files in the Metadata API Developer Guide.
In the VS Code Explorer or editor, right-click a manifest file and select SFDX: Retrieve Source in Manifest from Org. This retrieves the components from the authorized org based on what's defined in the package.xml.
Searching for Keywords in the Project:
Once the components are retrieved, do a Command + Shift + F on Mac or Control + Shift + F on Windows to search for a hard-coded reference in the code base.
Considerations
Ensure you have installed Visual Studio Code and Salesforce Extension Pack.
You can use Org Browser without a manifest file.
These steps work for non-scratch orgs. For scratch orgs, use force:source:pull instead.
Example Scenario
Now let’s see how we can update the domain name -
Step 1: Identify the domain name you need to replace.
Step 2: Locate the current org domain name you want to update by going to setup → Search 'My Domain' → find the domain name in the 'Current My Domain URL' field.

Step 3: Open Visual Studio Code, press Ctrl + Shift + P, and select Create Project with Manifest.

Step 4: Choose the project type and provide a project name

Step 5: Authorize the org.
Step 6: In the manifest folder, open the package.xml file and add the metadata types you want to retrieve from the org.

Step 7: Right-click on package.xml and select "SFDX: Retrieve Source in Manifest from Org".

Step 8: Press Ctrl + Shift + F and search for the old domain name you want to replace with the new one.

Step-9: Update all instances where the old domain name is hardcoded to the new domain name.
Step-10: Deploy the updated code back to the org.
Conclusion
Review and update all hard-coded instance URLs.By updating your API calls to use your My Domain login URL, you can prevent service interruptions and make sure your API traffic always routes correctly. This proactive approach boosts the reliability of your Salesforce integrations and keeps everything running smoothly.
Remember to make these changes before the deadline of April 1, 2025, for sandbox environments and June 14, 2025, for production environments to avoid disruptions. Take time to review and update your API calls and enjoy uninterrupted service!
Reference
https://www.avenoir.ai/post/making-rest-api-callouts-using-the-lwc-component
https://www.avenoir.ai/post/salesforce-connect-rest-api-for-batch-account-sync-scheduling
https://help.salesforce.com/s/articleView?id=000387070&type=1
https://developer.salesforce.com/docs/platform/sfvscode-extensions/guide
https://help.salesforce.com/s/articleView?id=000381316&type=1
Blog Credit:
A. Rawani
D. Khare
Salesforce Developer
Avenoir Technologies Pvt. Ltd.
Reach us: team@avenoir.ai
Comentarios