An Overview of Apex REST

You can make your Apex class and its methods accessible to external applications via the REST architecture. To achieve this, you need to annotate your Apex class with @RestResource, making it available as a REST resource. Additionally, you can annotate your methods to expose them through REST. For instance, you can use the @HttpGet annotation to make a method accessible as a REST resource that can be invoked through an HTTP GET request. More details can be found in the Apex REST Annotations documentation.

These classes include the methods and properties that you can utilize with Apex REST.

ClassDescription
RestContext ClassContains the RestRequest and RestResponse objects.
requestUse the System.RestRequest class to access and pass request data in a RESTful Apex method.
responseRepresents an object used to pass data from an Apex RESTful Web service method to an HTTP response.

Apex Governor Limits

Invocations of Apex REST classes are included in the organization’s API governor limits. Apex REST classes are subject to the same standard Apex governor limits. This includes constraints such as a maximum request or response size of 6 MB for synchronous Apex or 12 MB for asynchronous Apex. You can find further details in the Execution Governors and Limits documentation.

User Verification

Apex REST supports these authentication mechanisms:

  • OAuth 2.0
  • Session ID

See Step Two: Set Up Authorization in the REST API Developer Guide.