Register an external REST API as a Salesforce External Service and invoke it from Apex

domain: developer.salesforce.com · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

In-depth guide

Salesforce Bulk API 2.0 limits — the full failure-mode walkthrough related to developer.salesforce.com, checked against official docs, with linked verified routes.

Steps

  1. In Setup > Integrations > External Services, click Add an External Service and provide the named credential and an OpenAPI schema URL or paste the schema directly
  2. Salesforce validates the schema and generates Apex classes in the ExternalService namespace; confirm the generated class and method names in the External Services list
  3. In Apex, instantiate the generated class (e.g., ExternalService.MyService client = new ExternalService.MyService()) and call the generated method corresponding to the API operation
  4. Pass input parameters as a typed request object generated alongside the client class; retrieve the response via the typed response object — no raw HTTP or JSON parsing needed
  5. Handle the generated ExternalService.MyService.MyOperation_Response object, checking its Code property for HTTP status and accessing typed body fields directly
  6. For operations requiring dynamic headers not expressible in the named credential, use a named credential with a per-user principal to inject user-specific tokens at runtime

Known gotchas

Related routes

Register an external OpenAPI-described REST service as a Salesforce External Service and invoke it from a Flow
developer.salesforce.com · 6 steps · unrated
Call a custom Salesforce Apex REST endpoint from an external system
salesforce.com · 6 steps · unrated
Configure a Salesforce Flow HTTP callout action to invoke an external REST API without code
developer.salesforce.com · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

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

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans