This is a relatively short post. You want to know the IP addresses that Salesforce uses when you make send a HTTP request from Salesforce Apex to external system which does not accept unindentified IP addresses.

I found the easiest way to find out which IP is used by Salesforce when making callout. You can include the following code in your Apex:

HttpRequest req = new HttpRequest();
req.setEndpoint('http://icanhazip.com/');
req.setMethod('GET');
Http httpReq = new Http();
HttpResponse res = httpReq.send(req);
System.debug(res.getBody());

Of course, make sure you have added the url to Setup > Remote Site Settings, otherwise you will not be able to send the request.

remote-site-settings

You can find out the IP address in the debug log:

ip-address-from-icanhazip

You can find out the returned IP address falls under 13.108.0.0/14 IP range.

However, it is always a good practice to whitelist all the Salesforce IP ranges for seamless access. You don't know when the IP will be changed.

Find out the IP ranges that Salesforce uses:

https://help.salesforce.com/articleView?id=000003652&type=1


Well, that's all! The post is short but I hope it is helpful to you!

Post was published on , last updated on .

Like the content? Support the author by paypal.me!