function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dhruv Khattar 8Dhruv Khattar 8 

Authorized URL for Apex Class?

I want to create a schedulable APEX class that fetches data from an external system using their REST API. For the other system, the developer needs to create an app, and enter an authorized URL for my "app".

How does one get a URL to my Apex class that his app can redirect to?

Thanks for your help!

BP SinghBP Singh
If I understand your question correctly, you want a third party system to be able to interact with your Apex.

This can be achieved via Apex REST API or Apex SOAP API:

For authorization, please refer here:

You may choose either mechanism i.e. OAuth 2.0 or Session ID.
Laxman Vattam 26Laxman Vattam 26
For calling external REST service from Salesforce, you can refer the sample code here:

Call back URL is important only when another website is interacting wtih Salesforce. In your case, you can just redirect to http://localhost:8080
Dhruv Khattar 8Dhruv Khattar 8


I DO have an external system/website that I need to fetch data from. I need to request an authentication token to make data requests from that system. The external website needs a redirect URI to my application (APEX class) to be able to send that authentication token to it. Wondering what that redirect URI is for my apex class (or how I obtain it).

Tle link that BP Singh shared is the flip-side of my situation (i.e. the app that's being configured on the external service) and I need to provide the callback URI for that application.

BP SinghBP Singh

As I mentioned in my previous comment, you need to make use of either Apex REST API or Apex SOAP API to expose a URL for your apex class so that external system can invoke it.

Let me explain with a quick high level template for Apex REST API,

global class ApexRESTMyExample {
global static void myPostTestMethod(String s1, String s2) {
//ToDo: Business Logic 
global static String myGetTestMethod() {
//ToDo: Business Logic 

URI for this will be:
POST request will invoke method myPostTestMethod
GET request will invoke method myGetTestMethod

Hope this helps.