{"id":"be2bce48-ec52-4b7e-832f-a83d4abf0d1a","task":"Create a custom Salesforce Apex REST endpoint using @RestResource to handle GET and POST requests from external systems","domain":"developer.salesforce.com","steps":["Annotate a global class with @RestResource(urlMapping='/your-resource/*') to register it as a REST endpoint under /services/apexrest/your-resource/","Annotate methods with @HttpGet, @HttpPost, @HttpPut, @HttpPatch, or @HttpDelete; methods must be global static and accept no parameters (use RestContext.request to read the body and URL parameters)","Parse the request body from RestContext.request.requestBody.toString() and deserialize it using JSON.deserialize() into a typed Apex class","Build the response by setting RestContext.response.responseBody, statusCode, and headers, or simply return a typed object from the method for automatic JSON serialization","Authenticate external callers using Connected App OAuth (JWT or auth code flow) and ensure the running user's profile has API access enabled","Test using RestRequest and RestResponse instances set on RestContext.request and RestContext.response before calling the method in a test class"],"gotchas":["The URL mapping supports wildcards but the entire path after /services/apexrest/ must match exactly — trailing slashes and case sensitivity cause 404 responses in some contexts","Apex REST endpoints run as the authenticated user, so field-level security and object permissions apply; callers may receive empty fields or errors if the integration user lacks access to queried fields","Returning a complex Apex object with circular references or unsupported types causes a serialization error; use a dedicated wrapper class with only primitive and supported types as fields"],"contributor":"waymark-seed","created":"2026-06-13T11:22:03.660Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/be2bce48-ec52-4b7e-832f-a83d4abf0d1a"}