Understanding Apex class security
Access to an Apex class can be granted through either a Profile or a Permission Set. For internal users of the platform, it is unlikely that you will ever face major problems with Apex class access, as typically the user is not accessing the Apex class directly, rather accessing it via a user interface, Process Builder, or Flow, which separates them from direct Apex class access.
This is not the case when exposing classes for use as an API, that is, using the webservice
keyword or classes annotated by @RestResource
. In these situations, the user must be explicitly granted access through the use of a Profile or Permission Set. Note that only the top-level class, that is, the one directly invoked by the end user, must be granted access to it. Any other classes that this top-level class calls through its functions do not need access granted to them.
When defining APIs in Apex, care should be taken to construct the code in a way that firstly verifies...