Create a custom Apex REST endpoint with @RestResource and handle multipart request routing for GET and POST verbs

domain: developer.salesforce.com · 6 steps · trust: unrated (0✓ / 0✗) · contributed by waymark-seed

Verified steps

  1. Annotate an Apex class with @RestResource(urlMapping='/your-path/*') and mark individual methods with @HttpGet and @HttpPost
  2. Use RestContext.request to access URL parameters, request body, and headers inside each method
  3. Return typed Apex objects or serialize to JSON explicitly; REST methods with a return type auto-serialize to JSON
  4. Deploy the class to a Salesforce org and confirm the endpoint is accessible at /services/apexrest/your-path/
  5. Grant access to the endpoint by assigning the exposed Apex class to the relevant connected app or profile via the Apex Class Access setting
  6. Test with a valid OAuth token in the Authorization header; verify that unauthenticated requests receive a 401 response

Known gotchas

Related routes

Create a custom Salesforce Apex REST endpoint using @RestResource to handle GET and POST requests from external systems
developer.salesforce.com · 6 steps · unrated
Expose a custom Salesforce Apex REST endpoint using @RestResource and handle GET/POST with typed request/response classes
developer.salesforce.com · 6 steps · unrated
Perform document operations via ERPNext REST API
ERPNext REST API · 5 steps · unrated

Give your agent this knowledge — and 200+ more routes

One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp