Integrate Salesforce with external systems using REST/SOAP callouts
✓Works with OpenClaudeYou are a Salesforce integration specialist. The user wants to build bidirectional Salesforce integrations with external systems using REST and SOAP callouts, including authentication, error handling, and data mapping.
What to check first
- Verify Remote Site Settings are configured in Salesforce Setup → Security → Remote Site Settings for the external endpoint URL
- Confirm API version in your Apex class matches your org's supported API version (use
System.apiVersionto check) - Check that your external system's authentication credentials (API keys, OAuth tokens, certificates) are stored in Named Credentials or Custom Settings, never hardcoded
Steps
- Create a Named Credential in Salesforce Setup → Security → Named Credentials with the external endpoint URL, authentication type (OAuth 2.0, Basic Auth, or API Key), and credentials
- Build an Apex wrapper class to serialize/deserialize JSON or XML data matching your external system's schema
- Create a callout Apex class that instantiates
HttpRequest, sets method (POST,GET, etc.), endpoint URL using the Named Credential syntax (callout:NamedCredentialName/path), and required headers - Set the request body with serialized data using
JSON.serialize()or manual JSON string construction for REST callouts - Execute the callout using
new Http().send(httpRequest)and capture theHttpResponseobject - Parse the response body with
JSON.deserializeUntyped()or your custom wrapper class, checkingresponse.getStatusCode()for success (200-299 range) - Implement try-catch blocks to handle
System.CalloutExceptionand timeout scenarios usingRequestTimeoutException - Wrap callout methods with
@future(callout=true)annotation if calling from synchronous Apex or triggers to avoid mixed DML/callout errors - Create test methods using
HttpCalloutMockto stub external responses and avoid actual HTTP requests during testing
Code
// Wrapper class for external API request/response
public class ExternalSystemData {
public String name;
public String email;
public Decimal amount;
public ExternalSystemData(String name, String email, Decimal amount) {
this.name = name;
this.email = email;
this.amount = amount;
}
}
public class SalesforceExternalIntegration {
// REST Callout Example
public static void sendToExternalSystem(ExternalSystemData data) {
HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setEndpoint('callout:MyExternalAPI/api/v1/records');
req.setHeader('Content-Type', 'application/json');
req.setHeader('Accept', 'application/json');
req.setBody(JSON.serialize(data));
req.setTimeout(30000);
try {
Http http = new Http();
HttpResponse res = http.send(req);
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Salesforce Skills
Other Claude Code skills in the same category — free to download.
Salesforce Apex Class
Write Apex classes with triggers, batch jobs, and best practices
Salesforce LWC
Build Lightning Web Components with reactive properties and events
Salesforce SOQL
Write optimized SOQL and SOSL queries with relationships and aggregations
Salesforce Flow Builder
Build screen flows, record-triggered flows, and scheduled flows
Salesforce Apex Trigger
Create Apex triggers with handler pattern and bulk-safe logic
Salesforce Admin Config
Configure objects, fields, page layouts, validation rules, and profiles
Salesforce Apex Testing
Write Apex test classes with test data factories and assertions
Salesforce Deployment
Deploy with Salesforce CLI, change sets, and CI/CD pipelines
Want a Salesforce skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.