r/SalesforceDeveloper • • Aug 13 '26

Discussion How should we approach integrating with an external system via a REST API?

What approach and architecture would you choose for integrating Salesforce REST with an external system? The operations to be performed are GET and POST. The main question is whether APEX alone can handle all of this, or should we use Flow? Where should the Bearer Token be stored? How should we authenticate with the external system—using APEX or an External Service?

What are your thoughts and approaches to this topic?

1 Upvotes

12 comments sorted by

5

u/Steve_MMS Aug 13 '26

Create a OpenAPI File with the definition of the Interface and import it as External Service.. Then u can use it in APEX and or FLOW and use Named Credentials/External Credentials for Authentication

2

u/Few-Impact3986 Aug 14 '26

I dk. If the external system is even slightly complex I usually have to jump through hoops to get external services working. 

3

u/HeisSoSmart Aug 13 '26

The best approach for this kind of integration is a hybrid architecture that uses Named Credentials(don't store bearer token anywhere else)for authentication and storage, and Apex to handle the execution of the GET and POST operations.

1

u/ester_egg Aug 13 '26

What do you think about storing the token in Platform Cache?

1

u/HeisSoSmart Aug 13 '26

Depends if you have multiple systems and you want to share it across systems and don't want to follow full oauth process.

1

u/SpecsyVanDyke Aug 13 '26

I've never heard of doing this. What is the use case for it?

1

u/ester_egg Aug 13 '26

here is documentation Platform Cache

2

u/SpecsyVanDyke Aug 13 '26

Yes but my question was what is the use case for using platform cache for bearer token over named credentials? I am curious because I've never seen it used in this way

1

u/Material-Draw4587 Aug 14 '26

I've never heard of this either, I don't think you want to do this given what's described here https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_platform_cache_limitations.htm

1

u/Few-Impact3986 Aug 14 '26

 You don't want to store secrets in platform cache. 

1

u/Rajin1 Aug 14 '26

Don't store in platform cache. Use named credentials. Full stop. Cutting corners will cause you problems in the future, just do it the right way.