An AppExchange app calls a third-party API, including your own product's API, through a named credential and an external credential that ship inside your managed package, with the Apex callouts running asynchronously whenever a record save starts them. The package carries the endpoint and the auth setup. Each customer's org supplies the tokens after install, and your API itself becomes part of the security review because Salesforce data flows to it.
For a SaaS company, this callout path is the integration your enterprise customers see. It runs inside their org, under their limits, and every failure looks like your bug. Appnigma's marketplace apps team builds "a Salesforce managed package or HubSpot app built around your product and customer workflows," including "the native app and required integration code" and security review preparation. If your backend calls into customer orgs instead (the opposite direction), read our guide to connecting a SaaS product to customer Salesforce orgs with OAuth.
Updated October 2026. Checked against the Apex Developer Guide, the Named Credentials Developer Guide, the Secure Coding Guide and the ISVforce Guide. The earlier version said Salesforce runs the code and endpoint scans, and listed secret storage options in terms Salesforce doesn't use. This update adds what ships in the package and what customers set up, the February 2026 change to packaged named credentials, the separate limits a reviewed package gets, and worked callout arithmetic.
Pick the method by what the customer's org has to do
A managed package can reach a third-party API in four ways. They differ in who writes the request, what the customer's admin configures and how much of your API the package exposes.
| Method | Fits when | What it needs | Source |
|---|---|---|---|
| Apex callout to a named credential | You need custom request logic, retries or mapping | Apex classes plus packaged named and external credentials | Named Credentials as Callout Endpoints |
| External Services | Admins should call your API from Flow, or you want typed Apex classes | An OpenAPI 2.0.x or 3.0.x schema registered against a named credential | ExternalServiceRegistration |
| Salesforce Connect external objects | Customers need to read large external datasets without copying them | An external data source using an OData 2.0, 4.0 or 4.01 adapter | ExternalDataSource |
| Your backend calls the org's APIs | Your product does the sync work and the package only adds UI and metadata | OAuth from each customer org to your app | Our OAuth guide |
External Services is worth a closer look than most teams give it. Operations in your schema "become Apex classes and methods in the ExternalService namespace," so you can "make a type safe callout to an external service from Apex without needing to use the Http class," per the Apex Developer Guide. One catch is that each registration is pinned to a system version. Salesforce says "You can't upgrade an external service to a newer system version," so plan schema changes as new registrations.
Salesforce Connect has its own limits. External objects can't run Apex triggers or Apex-managed sharing, apart from triggers on external change data capture events from OData 4.0 connections, per Apex Considerations for Salesforce Connect External Objects. If your product needs to react when customer data changes, that rules it out for most of the work.
What ships in your package and what each customer sets up
A named credential holds "the URL of a callout endpoint and its required authentication parameters in one definition," per Get Started with Named Credentials. Since Winter '23 it pairs with an external credential that holds the auth protocol. Salesforce states that "Legacy named credentials are deprecated and will be discontinued in a future release," so a new package should not use them. Our named credentials and external credentials guide covers the setup screens.
The split between your package and the customer's org is where most install problems start. Salesforce lists the packaged pieces in Package Named Credentials and states plainly that "External credential certificates and access tokens aren't packageable."
| Piece | Who provides it | Notes |
|---|---|---|
| Named credential (endpoint URL) | Your package | Not added automatically, so add it to the package yourself |
| External credential (auth protocol) | Your package | Updated on upgrade, the customer can't delete it |
| External Auth Identity Provider | Your package | Only for the OAuth 2.0 browser flow |
| Permission set granting the principal | Your package | Its access settings are created at install |
| Access tokens, API keys, certificates | The customer's admin, after install | Entered in Setup or through the Connect REST API |
| Auth provider or signing certificate | The customer's admin, after install | Needed for the browser flow and JWT bearer flow |
Upgrades keep the customer's half intact. "Upgrading named credentials doesn't overwrite or delete the populated principals," per Upgrade a Named Credentials Managed Package. If you change the auth protocol, Salesforce recommends a new external credential instead of editing the old one.
Two packaging rules catch SaaS teams late. The first applies when your code calls a named credential that your package doesn't ship. In that case "the subscriber must add the package's namespace to a named credential's list of allowed namespaces to enable callouts." The second is newer. Per the same page, named credentials added to a managed package now "default to developer control," a change Salesforce made in February 2026 "to improve security." Under developer control, the customer can't edit the URL or auth settings. If each customer has its own subdomain of your product (acme.yourapp.com), Salesforce's packaging page shows how to switch a credential to subscriber mode so admins can set their own URL. Decide this before your first release, because it changes your install guide.
The callout code, written for a customer's org
A callout that runs because a record changed belongs in a Queueable job. Salesforce blocks callouts when DML is pending in the same transaction, and queueable jobs allow callouts "if they implement the Database.AllowsCallouts marker interface," per Queueable Apex. This is an illustrative sketch with an invented namespace and endpoint, not tested code.
public with sharing class AcmeContactSync implements Queueable, Database.AllowsCallouts {
private final List<Id> contactIds;
public AcmeContactSync(List<Id> contactIds) {
this.contactIds = contactIds;
}
public void execute(QueueableContext ctx) {
List<Contact> contacts = [
SELECT Id, Email, LastName FROM Contact
WHERE Id IN :contactIds WITH USER_MODE
];
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Acme_API/v2/contacts/batch');
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json');
req.setTimeout(20000);
req.setBody(JSON.serialize(contacts));
HttpResponse res = new Http().send(req);
if (res.getStatusCode() >= 300) {
// Log the status only. Never log the body or headers.
AcmeSyncLog.recordFailure(contactIds, res.getStatusCode());
}
}
}The callout: prefix is how Apex addresses a named credential. "Salesforce manages all authentication for Apex callouts that specify a named credential as the callout endpoint so that your code doesn't have to," per Named Credentials as Callout Endpoints. No API key appears in the code, which is the point. WITH USER_MODE makes the query respect the running user's object and field access. One request carries the whole batch of records, which matters for the limits below.
Tests can't reach your API. "By default, test methods don't support HTTP callouts, so tests that perform callouts fail," per Testing HTTP Callouts. Use Test.setMock with an HttpCalloutMock for success, error and timeout responses, since packaging still needs 75% Apex coverage.
Callout limits, and what they mean for one sync
These are per-transaction limits from Callout Limits and Limitations and Execution Governors and Limits.
| Limit | Value |
|---|---|
| Callouts per Apex transaction | 100 |
| Default timeout per callout | 10 seconds |
| Custom timeout range | 1 to 120,000 milliseconds |
| Cumulative callout time per transaction | 120 seconds |
| Request or response size | 6 MB synchronous, 12 MB asynchronous |
| Concurrent callouts in Developer Edition orgs only | 20 |
Here is what those numbers do to a real workload, worked from the documented limits. Say a customer has 10,000 contacts to push, and your API answers in about 1.5 seconds. One callout per record can't even use the 100-callout cap, because 80 calls at 1.5 seconds already spend the 120-second budget. That makes 125 separate transactions for one push. A batch endpoint changes the picture. At 200 records per request, the same push is 50 callouts. Those fit in one asynchronous transaction on count and on time (50 x 1.5 s = 75 s), as long as each 200-record payload stays under 12 MB. If you own the API, add a batch endpoint before you write the Apex.
Reviewed packages get room of their own. Per the governor limits page, managed packages that have passed the security review "get their own set of limits for most per-transaction limits." The cross-namespace total is 1,100 callouts per transaction. Before review, "Namespaces in non-certified packages don't have their own separate governor limits," so a pilot install shares the customer's 100 callouts with their own code. CPU time and heap remain shared. Our post on governor limits in managed packages covers which limits split and which don't.
Can you make a callout after DML in Apex?
No. "You can't make a callout when there are pending operations in the same transaction," per Callout Limits and Limitations. Pending operations include DML statements and asynchronous Apex such as future methods and batch jobs. Scheduled Apex and sending email count too. You can make the callout before those operations, or move it out of the transaction.
In a package, moving it out is usually the answer, because your trigger runs inside the customer's save and you can't control what DML ran before it. Your options are a method marked @future(callout=true), a Queueable that implements Database.AllowsCallouts, or Batch Apex with the same interface. Each batch execute "is considered a discrete transaction," per Use Batch Apex, so every execute gets its own 100 callouts. Continuations are a different tool, built for long callouts from a Visualforce page or Lightning component, and capped at three parallel callouts per continuation, per Asynchronous Callout Limits.
What security review tests when your package calls an API
Your API is in scope. Salesforce says external endpoints are "within the scope of the security review" when the endpoint authenticates the user or "Salesforce data is transferred to or from the endpoint," per Test Your Entire Solution. A package that sends customer records to your product meets that test on day one.
You run the scans and submit the reports, and then Salesforce tests the solution. For a managed package, "you're required to scan it using Salesforce Code Analyzer and submit comprehensive scan results." The Code Analyzer guide adds that this is "in addition to the scan that you must complete using the Source Code Scanner, also referred to as the Checkmarx scanner," per Scan Your Managed Package with Code Analyzer. "Salesforce Code Analyzer doesn't scan external endpoints," so your API needs a dynamic scan with ZAP, Burp Suite or a similar DAST tool. Salesforce's required materials page also asks for "URLs and login credentials for external components requiring authentication," so reviewers will need a working test account in your product. After that, Salesforce's own team can "perform pen tests that attack your Developer Edition test org."
Secrets follow Salesforce's storage rules. "Secrets, which are common across all users of the package (such as an API key) must be stored in Managed Protected Custom Metadata Types," per the Secure Coding Guide. Protected custom settings suit "secrets initialized by the admin user or generated at install time." Named credentials are "a safe and secure way of storing authentication data," but if your policy requires hiding secrets from customer admins, Salesforce points to a protected custom metadata type or setting. The same guide says "We don't recommend storing authentication data in encrypted custom fields."
Transport and logs come next. Salesforce asks that a solution be "reachable exclusively over secure connections such as SFTP and HTTPS," per Secure Communication. Code Analyzer's AppExchange rules flag remote site settings that use HTTP and hardcoded credentials in HTTP headers. Keep tokens, payloads and personal data out of debug logs. Our managed package security review guide walks through the rest of the submission.
Mistakes that break callouts after install
- Shipping an API key in Apex or a public custom setting. Code Analyzer flags it, and the key reaches every customer org.
- Calling a named credential your package doesn't ship. The callout fails until the customer adds your namespace to its allowed namespaces.
- Leaving per-customer URLs under developer control. Since February 2026 a packaged named credential defaults to it, so admins can't point it at their own subdomain.
- Relying on a remote site setting for a new host. Remote site settings aren't updated on upgrade and the customer can delete them, per the packageable components list.
- Calling from the trigger itself. It works in your test org and fails in a customer org where other automation has already done DML.
- One callout per record. It hits the 100-callout cap long before it hits anything else.
- No test account for reviewers. Your API is in scope, so the review stalls without credentials to reach it.
When to build the package yourself and when to bring in help
Build it in-house when Salesforce is a core channel, and an engineer can own Apex, packaging and the review cycle for years. The callout code is the easy part. The work that lasts is keeping the package in step with your API and with Salesforce releases, such as the February 2026 switch of packaged named credentials to developer control.
Bring in help when your engineers should stay on your product. Appnigma's marketplace apps service covers the native app, the required integration code and "Salesforce security review preparation and responses." As the page puts it, "Build and review are separate steps," and Salesforce controls review timing. For integrations you'd rather hand off entirely, Appnigma's done-for-you integrations team builds and maintains them, in their words "Build your product. We'll build the integrations."
Frequently Asked Questions
Should a managed package use Remote Site Settings or Named Credentials?
Named credentials. They carry the endpoint and auth, and Salesforce says "If the callout specifies a named credential as the endpoint, you don't need to configure remote site settings."
How must an AppExchange app store API keys to pass the security review?
A key shared by all customers belongs in protected custom metadata, never in code. Per-customer tokens go in the named credential's external credential after install, since tokens aren't packageable.
How many callouts can a managed package make per transaction?
100 per transaction. After the package passes security review, it gets its own 100 instead of sharing the org's, within a 1,100 total across namespaces.
Does security review test my own API?
Yes, when Salesforce data goes to it or it authenticates users. Submit a DAST scan of the endpoint and test credentials for reviewers.
Can Appnigma build the managed package that calls our API?
Yes. Appnigma's marketplace apps service builds the managed package and required integration code, and supports security review preparation.
About the author
Sunny Chauhan is the co-founder and CEO of Appnigma AI, which builds and maintains customer integrations and native Salesforce and HubSpot apps for B2B SaaS teams. Before Appnigma, he was on Salesforce's AppExchange team, where he worked with more than 300 SaaS partners. He has spent close to a decade on the Salesforce platform, including work at Zennify, and holds Salesforce certifications including Platform Developer II, Platform App Builder, Administrator, Data Cloud Consultant, and AI Associate.
Related Articles
- Named Credentials and External Credentials in Salesforce
- Governor Limits in Managed Packages
- Security Review for a Salesforce Managed Package
- Salesforce Code Analyzer Guide
- How a SaaS Product Connects to Customer Salesforce Orgs With OAuth
Sources
- Salesforce Developers, Apex Developer Guide, Callout Limits and Limitations
- Salesforce Developers, Apex Developer Guide, Execution Governors and Limits
- Salesforce Developers, Apex Developer Guide, Named Credentials as Callout Endpoints
- Salesforce Developers, Named Credentials Developer Guide, Get Started with Named Credentials
- Salesforce Developers, Named Credentials Developer Guide, Package Named Credentials
- Salesforce Developers, Named Credentials Developer Guide, Upgrade a Named Credentials Managed Package
- Salesforce Developers, Apex Developer Guide, Queueable Apex
- Salesforce Developers, Apex Developer Guide, Use Batch Apex
- Salesforce Developers, Apex Developer Guide, Asynchronous Callout Limits
- Salesforce Developers, Apex Developer Guide, Testing HTTP Callouts
- Salesforce Developers, Apex Developer Guide, External Services
- Salesforce Developers, Metadata API Developer Guide, ExternalServiceRegistration
- Salesforce Developers, Tooling API, ExternalDataSource
- Salesforce Developers, Apex Developer Guide, Apex Considerations for Salesforce Connect External Objects
- Salesforce Developers, Second-Generation Managed Packaging, Packageable Components
- Salesforce Developers, Secure Coding Guide, Storing Sensitive Data
- Salesforce Developers, ISVforce Guide, Test Your Entire Solution
- Salesforce Developers, ISVforce Guide, Scan Your Managed Package with Salesforce Code Analyzer
- Salesforce Developers, ISVforce Guide, Required Materials for Security Review Submission
- Salesforce Developers, ISVforce Guide, Secure Communication
- Salesforce Developers, Salesforce Code Analyzer, PMD AppExchange Rules Reference