Introduction to Apex REST

You can expose your Apex class and methods so that external applications can access your code and your application through the REST architecture. This is done by defining your Apex class with the @RestResource annotation to expose it as a REST resource. Similarly, add annotations to your methods to expose them through REST. For example, you can add the @HttpGet annotation to your method to expose it as a REST resource that can be called by an HTTP GET request. For more information, see Apex REST Annotations

These are the classes containing methods and properties you can use with Apex REST.

Class Description
RestContext Class Contains the RestRequest and RestResponse objects.
request Represents an object used to pass data from an HTTP request to an Apex RESTful Web service method.
response Represents an object used to pass data from an Apex RESTful Web service method to an HTTP response.

Governor Limits

Calls to Apex REST classes count against the organization's API governor limits. All standard Apex governor limits apply to Apex REST classes. For example, the maximum request or response size is 6 MB for synchronous Apex or 12 MB for asynchronous Apex. For more information, see Execution Governors and Limits.

Authentication

Apex REST supports these authentication mechanisms:

  • OAuth 2.0
  • Session ID

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

Previous
Next