---
schema_version: "1"
id: 3104e1203cff2e78bc741055fb0f3df535c5eb4659cf08ade49df01d3950f6ff
title: Remote Call-In
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/integration_patterns_and_practices/integ_pat_remote_call_in.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.integration_patterns_and_practices.meta/integration_patterns_and_practices/integ_pat_remote_call_in.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 7df511018fed5de685aec8cf741e1b5a13ecc388425d81436da49579d2dc5dc2
---
# Remote Call-In

## Context

You use Salesforce to track leads, manage your pipeline, create opportunities, and capture order details that convert leads to customers. But, Salesforce isn’t the system that contains or processes orders. Orders are managed by an external (remote) system. That remote system needs to update the order status in Salesforce as the order passes through its processing stages.

## Problem

How does a remote system connect and authenticate with Salesforce to notify Salesforce about external events, create records, and update existing records?

## Forces

There are various forces to consider when applying solutions based on this pattern:

- Is the purpose of the remote call to Salesforce to notify Salesforce of an event that occurred externally using an event-driven architecture? Or is the purpose to perform CRUD operations on specific records? If you use an event-driven architecture, the event producer (the remote process) is decoupled from the Salesforce event consumer.
- Does the call to Salesforce require the remote process to wait for a response before continuing processing? Remote calls to Salesforce are always synchronous request-reply, although the remote process can discard the response if it isn’t needed to simulate an asynchronous call.
- Does each transaction operate against a single Salesforce object or multiple, related objects?
- What is the format of the message (for example, SOAP or REST, or both over HTTP)?
- Is the message size relatively small or large?
- If the remote system is SOAP-capable, is the remote system able to participate in a contract-first approach, where Salesforce dictates the contract? This is required where our SOAP API is used, for which a predefined WSDL is supplied.
- Is transaction processing required?
- What is the extent to which you’re tolerant of customization in Salesforce?

## Solution

This table contains various solutions to this integration problem.

<table class="featureTable sort_table" summary="">



            <thead class="thead sorted" align="left">
              <tr>
                <th class="featureTableHeader  " id="d7164e104">Solution</th>

                <th class="featureTableHeader  " id="d7164e107">Fit</th>

                <th class="featureTableHeader  " id="d7164e110">Comments</th>

              </tr>

            </thead>

            <tbody class="tbody">
              <tr>
                <td class="entry" headers="d7164e104" data-title="Solution">SOAP API</td>

                <td class="entry" headers="d7164e107" data-title="Fit">Best</td>

                <td class="entry" headers="d7164e110" data-title="Comments">
                  <ul class="ul bulletList">
                    <li class="li">
                      <em class="ph i">Accessibility</em>—Salesforce provides a SOAP API that remote systems can use to:<ul class="ul bulletList">
                        <li class="li">Publish events to notify your Salesforce org</li>

                        <li class="li">Query data in your org</li>

                        <li class="li">Create, update, and delete data</li>

                        <li class="li">Obtain metadata about your org</li>

                        <li class="li">Run utilities to perform administrative tasks</li>

                      </ul>
                    </li>

                    <li class="li">
                      <em class="ph i">Synchronous API</em>—After the API call is made, the remote client
                      application waits until it receives a response from the service. Asynchronous calls to
                      Salesforce aren’t supported.
                    </li>

                    <li class="li">
                      <em class="ph i">Generated WSDL</em>—Salesforce provides two WSDLs for remote systems:<ul class="ul bulletList">
                        <li class="li">Enterprise WSDL—Provides a strongly-typed WSDL that’s specific to a
                          Salesforce org.</li>

                        <li class="li">Partner WSDL—Contains a loosely typed WSDL that’s not specific to a
                          Salesforce org.</li>

                      </ul>
                    </li>

                    <li class="li">
                      <em class="ph i">Security</em>—The client executing SOAP API must have a valid login and
                      obtain a session to perform any API calls. The API respects object-level and field-level
                      security configured in Salesforce based on the logged in user’s profile.
                    </li>

                    <li class="li">
                      <em class="ph i">Transaction/Commit Behavior</em>—By default, each API call allows for partial
                      success if some records are marked with errors. This can be changed to an “all or
                      nothing” behavior where all the results are rolled back if any error occurs. It’s
                      not possible to span a transaction across multiple API calls. To overcome this
                      limitation, it’s possible for a single API call to affect multiple objects.
                    </li>

                    <li class="li">
                      <em class="ph i">Bulk Data</em>—Any data operation that includes more than 2,000 records is a
                      good candidate for Bulk API 2.0 to successfully prepare, execute, and manage an
                      <em class="ph i">asynchronous</em> workflow that uses the Bulk framework. Jobs with fewer than
                      2,000 records should involve “bulkified” <em class="ph i">synchronous</em> calls in REST (for
                      example, Composite) or SOAP.
                    </li>

                    <li class="li">
                      <em class="ph i">Event-Driven Architecture</em>—Platform events are defined the same way you
                      define Salesforce objects. Publishing an event via SOAP API is the same as creating a
                      Salesforce record.
                    </li>

                  </ul>

                </td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e104" data-title="Solution">REST API</td>

                <td class="entry" headers="d7164e107" data-title="Fit">Best</td>

                <td class="entry" headers="d7164e110" data-title="Comments">
                  <ul class="ul bulletList">
                    <li class="li">
                      <em class="ph i">Accessibility</em>—Salesforce provides a REST API that remote systems can use to:<ul class="ul bulletList">
                        <li class="li">Publish events to notify your Salesforce org</li>

                        <li class="li">Query data in your org</li>

                        <li class="li">Create, update, and delete data</li>

                        <li class="li">Obtain metadata about your org</li>

                        <li class="li">Run utilities to perform administrative tasks</li>

                      </ul>
                    </li>

                    <li class="li">
                      <em class="ph i">Synchronous API</em>—After the API call is made, the remote client
                      application waits until it receives a response from the service. Asynchronous calls to
                      Salesforce aren’t supported.
                    </li>

                    <li class="li">
                      <em class="ph i">REST API vs. SOAP API</em>—REST exposes resources (entities/objects) as URIs
                      and uses HTTP verbs to define CRUD operations on these resources. Unlike SOAP, REST API
                      requires no predefined contract, utilizes XML and JSON for responses, and has loose
                      typing. REST API is lightweight and provides a simple method for interacting with
                      Salesforce. Its advantages include ease of integration and development, and it’s an
                      excellent choice for use with mobile apps and web apps.
                    </li>

                    <li class="li">
                      <em class="ph i">Security</em>—The client executing REST API must have a valid login and
                      obtain a session to perform any API calls. The API respects object-level and field-level
                      security configured in Salesforce based on the logged in user’s profile.
                    </li>

                    <li class="li">
                      <em class="ph i">Transaction/Commit Behavior</em>—By default, each record is treated as a
                      separate transaction and committed separately. Failure of one record change doesn’t cause
                      rollback of other record changes. This behavior can be altered to an “all or
                      nothing” behavior. Use the REST API composite resources to make a series of
                      updates in one API call.
                    </li>

                    <li class="li">
                      <em class="ph i">REST Composite Resources</em>—Use these REST API resources to perform
                      multiple operations in a single API call. It’s also possible to use the output of one
                      call as the input to the next call. All of the response bodies and HTTP statuses for the
                      requests are returned in a single response body. The entire request counts as a single
                      call toward your API limits.
                    </li>

                    <li class="li">
                      <em class="ph i">Bulk Data</em>—Any data operation that includes more than 2,000 records is a
                      good candidate for Bulk API 2.0 to successfully prepare, execute, and manage an
                      <em class="ph i">asynchronous</em> workflow that uses the Bulk framework. Jobs with fewer than
                      2,000 records should involve “bulkified” <em class="ph i">synchronous</em> calls in REST (for
                      example, Composite) or SOAP.
                    </li>

                    <li class="li">
                      <em class="ph i">Event-Driven Architecture</em>—Platform events are defined the same way you
                      define Salesforce objects. Publishing an event via REST API is the same as creating a
                      Salesforce record.
                    </li>

                  </ul>

                </td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e104" data-title="Solution">Apex web services</td>

                <td class="entry" headers="d7164e107" data-title="Fit">Suboptimal</td>

                <td class="entry" headers="d7164e110" data-title="Comments">Apex class methods can be exposed as web service methods to external applications.
                  This method is an alternative to SOAP API, and is typically used only where the following
                  additional requirements must be met.<ul class="ul bulletList">
                    <li class="li">Full transactional support is required (for example, create an account, contact, and
                      opportunity all in one transaction).</li>

                    <li class="li">Custom logic must be applied on the Salesforce side before committing.</li>

                  </ul>
                  <p class="p">The benefit of using an Apex web service must be weighed against the additional
                    code that needs to be maintained in Salesforce.</p>
                  <p class="p">Not applicable for platform events
                    because transaction pre-insert logic at the consumer doesn’t apply in an event-driven
                    architecture. To notify a Salesforce org that an event has occurred, use SOAP API, REST
                    API, or Bulk API 2.0.</p>
                </td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e104" data-title="Solution">Apex REST services</td>

                <td class="entry" headers="d7164e107" data-title="Fit">Suboptimal</td>

                <td class="entry" headers="d7164e110" data-title="Comments">An Apex class can be exposed as REST resources mapped to specific URIs with an HTTP
                  verb defined against it (for example, POST or GET). <p class="p">You can use REST API composite
                    resources to perform multiple updates in a single transaction.</p>
                  <p class="p">Unlike SOAP, there’s
                    no need for the client to consume a service definition/contract (WSDL) and generate client
                    stubs. The remote system requires only the ability to form an HTTP request and process the
                    returned results (XML or JSON).</p>
                  <p class="p">Not applicable for platform events because
                    transaction pre-insert logic at the consumer doesn’t apply in an event-driven
                    architecture. To notify a Salesforce org that an event has occurred, use SOAP API, REST
                    API, or Bulk API 2.0.</p>
                </td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e104" data-title="Solution">Bulk API 2.0</td>

                <td class="entry" headers="d7164e107" data-title="Fit">Optimal for bulk operations</td>

                <td class="entry" headers="d7164e110" data-title="Comments">Bulk API 2.0 is based on REST principles, and is optimized for loading or deleting
                  large sets of data. It has the same accessibility and security behavior as REST API.<p class="p">Any data operation that includes more than 2,000 records is a
                    good candidate for Bulk API 2.0 to successfully prepare, execute, and manage an
                    <em class="ph i">asynchronous</em> workflow that uses the Bulk framework. Jobs with fewer than
                    2,000 records should involve “bulkified” <em class="ph i">synchronous</em> calls in REST (for
                    example, Composite) or SOAP.
                  </p>
                  <p class="p">Bulk API 2.0 allows the client application to query, insert, update, upsert, or
                    delete a large number of records asynchronously by submitting a number of batches, which
                    are processed in the background by Salesforce. In contrast, SOAP API is optimized for
                    real-time client applications that update small numbers of records at a time.
                  </p>
                  <p class="p">Although SOAP API can also be used for processing large numbers of records, when
                    the data sets contain hundreds of thousands to millions of records, it becomes less
                    practical. This is due to its relatively high overhead and lower performance
                    characteristics.</p>
                  <ul class="ul bulletList">
                    <li class="li">
                      <em class="ph i">Event-Driven Architecture</em>—Platform events are defined the same way you
                      define Salesforce objects. Publishing an event via Bulk API 2.0 is the same as creating a
                      Salesforce record. Only the create and insert operations are supported. Events within a
                      batch are published to the Salesforce event bus asynchronously as the batch job is
                      processed.
                    </li>

                  </ul>
                </td>

              </tr>

            </tbody>

          </table>

## Sketch

The following diagrams illustrate the sequence of events when you implement this pattern using either REST API for notifications from external events or SOAP API to query a Salesforce object. The sequence of events is the same when using REST API.

Remote System Querying Salesforce Via SOAP API ![Remote Call In - Remote System Calling In Using SOAP API](https://developer.salesforce.com/docs/atlas.en-us.integration_patterns_and_practices.meta/integration_patterns_and_practices/integration_patterns/images/remote_call_in.png)

Remote System Notifying Salesforce with Events Via REST API ![Remote Call In - Remote System Calling In Using REST API](https://developer.salesforce.com/docs/atlas.en-us.integration_patterns_and_practices.meta/integration_patterns_and_practices/integration_patterns/images/remote_call_in_rest.png)

## Results

In an event-driven architecture, the remote system calls into Salesforce using SOAP API, REST API, or Bulk API 2.0 to publish an event to the Salesforce event bus. Publishing an event notifies all subscribers. Event subscribers can be on the Salesforce Platform such as Process Builder Processes, Flows, or Lightning Components, Apex triggers. Event subscribers can also be external to the Salesforce Platform such as CometD subscribers.

When working directly with Salesforce objects, the solutions related to this pattern allow for:

- The remote system to call the Salesforce APIs to query the database and execute single-object operations (create, update, delete, and so on).
- The remote system to call the Salesforce REST API composite resources to perform a series of object operations.
- Remote system to call custom-built Salesforce APIs (services) that can support multi-object transactional operations and custom pre/post processing logic.

**Calling Mechanisms**

The calling mechanism depends on the solution chosen to implement this pattern.

<table class="featureTable sort_table" summary="">


            <thead class="thead sorted" align="left">
              <tr>
                <th class="featureTableHeader  " id="d7164e432">Calling mechanism</th>

                <th class="featureTableHeader  " id="d7164e435">Description</th>

              </tr>

            </thead>

            <tbody class="tbody">
              <tr>
                <td class="entry" headers="d7164e432" data-title="Calling mechanism">SOAP API</td>

                <td class="entry" headers="d7164e435" data-title="Description">The remote system uses the Salesforce Enterprise or Partner WSDL to generate client
                  stubs that are in turn used to invoke the standard SOAP API.</td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e432" data-title="Calling mechanism">REST API</td>

                <td class="entry" headers="d7164e435" data-title="Description">The remote system has to authenticate before accessing any Apex REST service. The
                  remote system can use OAuth 2.0 or username and password authentication. In either case,
                  the client must set the authorization HTTP header with the appropriate value (an OAuth
                  access token or a session ID can be acquired via a login call to SOAP API).<p class="p">The remote
                    system then generates REST invocations (HTTP requests) with the appropriate verbs and
                    processes the results returned (JSON and XML data formats are supported).</p>
                </td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e432" data-title="Calling mechanism">Apex web service</td>

                <td class="entry" headers="d7164e435" data-title="Description">The remote system consumes the custom Apex web service WSDL to generate client stubs
                  that are in turn used to invoke the custom Apex web service.</td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e432" data-title="Calling mechanism">Apex REST service</td>

                <td class="entry" headers="d7164e435" data-title="Description">As per REST API, the resource URI and applicable verbs are defined using the <samp class="codeph nolang">@RestResource</samp>, <samp class="codeph nolang">@HttpGet</samp>,
                  and <samp class="codeph nolang">@HttpPost</samp> annotations.</td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e432" data-title="Calling mechanism">Bulk API 2.0</td>

                <td class="entry" headers="d7164e435" data-title="Description">Bulk API 2.0 is a REST-based API, so the same calling mechanisms as REST API
                  apply.</td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e432" data-title="Calling mechanism">REST API to invoke Flow</td>

                <td class="entry" headers="d7164e435" data-title="Description">Use REST API to call a custom invocable actions endpoint to invoke an auto-launched
                  flow.</td>

              </tr>

            </tbody>

          </table>

**Error Handling and Recovery**

An error handling and recovery strategy must be considered as part of the overall solution.

- _Error handling_—All the remote call-in methods, standard or custom APIs, require the remote system to handle any subsequent errors, such as timeouts and the management of retries. Middleware can be used to provide the logic for error handling and recovery.
- _Recovery_—A custom retry mechanism needs to be created if quality-of-service requirements dictate it. In this case, it’s important to ensure idempotent design characteristics. Platform event enables subscribers to use the replay ID to fetch messages within a certain time period after those messages were published.

**Idempotent Design Considerations**

Idempotent capabilities guarantee that repeated invocations are safe and won’t have a negative effect. If idempotency isn’t implemented, then repeated invocations of the same message can have different results, potentially resulting in data integrity issues, for example, creation of duplicate records, duplicate processing of transactions, and so on.

The remote system must manage multiple (duplicate) calls, in the case of errors or timeouts, to avoid duplicate inserts and redundant updates (especially if downstream triggers and workflow rules fire). While it’s possible to manage some of these situations within Salesforce (particularly in the case of custom SOAP and REST services), we recommend that the remote system (or middleware) manages error handling and idempotent design.

**Security Considerations**

Different security considerations apply, depending on the pattern solution chosen. In all cases, the platform uses the logged-in user’s access rights (for example, profile settings, sharing rules, permission sets, and so on). Additionally, profile IP restrictions can be used to restrict access to the API for a specific IP address range.

<table class="featureTable sort_table" summary="">


            <thead class="thead sorted" align="left">
              <tr>
                <th class="featureTableHeader  " id="d7164e561">Solution</th>

                <th class="featureTableHeader  " id="d7164e564">Security considerations</th>

              </tr>

            </thead>

            <tbody class="tbody">
              <tr>
                <td class="entry" headers="d7164e561" data-title="Solution">SOAP API</td>

                <td class="entry" headers="d7164e564" data-title="Security considerations">Salesforce supports Secure Sockets Layer v3 (SSL) and the Transport Layer Security
                  (TLS) protocols. Ciphers must have a key length of at least 128 bits. <p class="p">The remote system
                    must log in using valid credentials to obtain a session ID. If the remote system already
                    has a valid session ID, then it can call the API without an explicit login. This is used
                    in call-back patterns covered earlier in this document, where a preceding Salesforce
                    outbound message contained a session ID and record ID for subsequent use.</p>
                  <p class="p">We
                    recommend that clients that call SOAP API cache and reuse the session ID to maximize
                    performance, rather than obtaining a new session ID for each call.</p>
                </td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e561" data-title="Solution">REST API</td>

                <td class="entry" headers="d7164e564" data-title="Security considerations">We recommend that the remote system establish an OAuth trust for authorization. REST
                  calls can then be made on specific resources using HTTP verbs. It’s also possible to make
                  REST calls with a valid session ID that might have been obtained by other means (for
                  example, retrieved by calling SOAP API or provided via an outbound message).<p class="p">We recommend
                    that clients that call the REST API cache and reuse the session ID to maximize
                    performance, rather than obtaining a new session ID for each call.</p>
                </td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e561" data-title="Solution">Apex web service</td>

                <td class="entry" headers="d7164e564" data-title="Security considerations">We recommend that the remote system establish an OAuth trust for
                  authorization.</td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e561" data-title="Solution">Apex REST service</td>

                <td class="entry" headers="d7164e564" data-title="Security considerations">We recommend that the remote system establish an OAuth trust for
                  authorization.</td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e561" data-title="Solution">Bulk API 2.0</td>

                <td class="entry" headers="d7164e564" data-title="Security considerations">We recommend that the remote system establish an OAuth trust for
                  authorization.</td>

              </tr>

            </tbody>

          </table>

See [Security Considerations](https://developer.salesforce.com/docs/atlas.en-us.integration_patterns_and_practices.meta/integration_patterns_and_practices/integ_pat_security_considerations.htm "To be effective members of the enterprise portfolio, all applications must be created and integrated with relevant security mechanisms. Modern IT strategies employ a combination of on-premises and cloud-based services.").

## Sidebars

**Timeliness**

SOAP API and Apex web service API are synchronous. The following timeouts apply:

- Session timeout — The session times out if there’s no activity based on the Salesforce org’s session timeout setting.
- Query timeout — Each SOQL query has an individual timeout limit of 120 seconds.

**Data Volumes**

Data volume considerations depend on which solution and communication type you choose.

<table class="featureTable sort_table" summary="">



            <thead class="thead sorted" align="left">
              <tr>
                <th class="featureTableHeader  " id="d7164e674">Solution</th>

                <th class="featureTableHeader  " id="d7164e677">Communication type</th>

                <th class="featureTableHeader  " id="d7164e680">Limits</th>

              </tr>

            </thead>

            <tbody class="tbody">
              <tr>
                <td class="entry" headers="d7164e674" data-title="Solution">SOAP API or REST API</td>

                <td class="entry" headers="d7164e677" data-title="Communication type">Synchronous</td>

                <td class="entry" headers="d7164e680" data-title="Limits">
                  <ul class="ul bulletList">
                    <li class="li">
                      <em class="ph i">SOAP Login</em>—The SOAP login request size is limited to 10 KB or less. You
                      can make a maximum of 3,600 calls to the <samp class="codeph nolang">login()</samp>
                      function per user per hour. If you exceed this limit, the API returns an error.
                    </li>

                    <li class="li">
                      <em class="ph i">Create, Update, Delete</em>—The remote system can create, update, or delete
                      up to 200 records at a time. Multiple calls can be made to process more than a total of
                      200 records, but each request is limited to 200 records in size.
                    </li>

                    <li class="li">
                      <em class="ph i">BLOB Data</em>—You can use SObject Basic Information, SObject Rows, or
                      SObject Collections REST resources to insert or update BLOB data in Salesforce standard
                      objects. For the SObject Basic Information or SObject Rows resources, the maximum file
                      size for uploads is 2 GB for ContentVersion objects and 500 MB for all other eligible
                      standard objects. Using the SObject Collections resources, the maximum total size of all
                      files in a single request is 500 MB.
                    </li>

                    <li class="li">
                      <em class="ph i">Query Results Size </em>— By default, the number of rows returned in the
                      query result object (batch size), returned in a <samp class="codeph nolang">query()</samp> or <samp class="codeph nolang">queryMore()</samp> call is set to
                      500. The maximum number of rows returned is 2,000. You can explicitly set the batch size,
                      but there's no guarantee that the requested batch size will be the actual batch size.
                      This is done to maximize performance. Where the number of rows to be returned exceeds the
                      batch size, use the <samp class="codeph nolang">queryMore()</samp> API call to iterate
                      through multiple batches. Additional rules might apply, so for more information, see
                      <cite class="cite"><a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.salesforce_app_limits_cheatsheet.meta/salesforce_app_limits_cheatsheet/salesforce_app_limits_overview.htm" target="_blank" title="HTML (New Window)">Salesforce Developer Limits and Allocations
                          Quick Reference</a></cite>.
                    </li>

                    <li class="li">
                      <em class="ph i">Event Message</em>—The maximum event message size is 1 MB. Publishing an
                      event using the Salesforce APIs counts against your standard API limits.
                    </li>

                  </ul>

                </td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e674" data-title="Solution">Bulk API 2.0</td>

                <td class="entry" headers="d7164e677" data-title="Communication type">Synchronous</td>

                <td class="entry" headers="d7164e680" data-title="Limits">
                  <p class="p">Bulk API 2.0 is optimized for importing and exporting large sets of data
                    asynchronously.</p>

                  <p class="p">Any data operation that includes more than 2,000 records is a
                    good candidate for Bulk API 2.0 to successfully prepare, execute, and manage an
                    <em class="ph i">asynchronous</em> workflow that uses the Bulk framework. Jobs with fewer than
                    2,000 records should involve “bulkified” <em class="ph i">synchronous</em> calls in REST (for
                    example, Composite) or SOAP.
                  </p>

                  <p class="p">Bulk API 2.0 is synchronous when submitting the batch request and associated data. The
                    actual processing of the data occurs asynchronously. For more information about API and
                    batch processing limits, see <cite class="cite"><a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/bulk_common_limits.htm" target="_blank" title="HTML (New Window)">Limits</a></cite>.</p>

                </td>

              </tr>

            </tbody>

          </table>

**Endpoint Capability and Standards Support**

The capability and standards support for the endpoint depends on the solution that you choose.

<table class="featureTable sort_table" summary="">


          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d7164e800">Solution</th>

              <th class="featureTableHeader  " id="d7164e803">Endpoint considerations</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d7164e800" data-title="Solution">SOAP API</td>

              <td class="entry" headers="d7164e803" data-title="Endpoint considerations">The remote system must be capable of implementing a client that can call the
                Salesforce SOAP API, based on a message format predefined by Salesforce.<p class="p">The remote system
                  (client) must participate in a contract-first implementation where the contract is supplied
                  by Salesforce (for example, Enterprise or Partner WSDL).</p>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d7164e800" data-title="Solution">REST API</td>

              <td class="entry" headers="d7164e803" data-title="Endpoint considerations">The remote system must be capable of implementing a REST client that invokes
                Salesforce—defined REST services, and processes the XML or JSON results.</td>

            </tr>

            <tr>
              <td class="entry" headers="d7164e800" data-title="Solution">Apex web service</td>

              <td class="entry" headers="d7164e803" data-title="Endpoint considerations">The remote system must be capable of implementing a client that can invoke SOAP
                messages of a predefined format, as defined by Salesforce.<p class="p">The remote system must
                  participate in a code-first implementation, where the contract is supplied by Salesforce
                  after the Apex web service is implemented. Each Apex web service has its own
                  WSDL.</p>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d7164e800" data-title="Solution">Apex REST service</td>

              <td class="entry" headers="d7164e803" data-title="Endpoint considerations">The same endpoint considerations as REST API apply.</td>

            </tr>

          </tbody>

        </table>

**State Management**

When integrating systems, keys are important for on-going state tracking, for example, if a record gets created in the remote system, to support ongoing updates to that record. There are two options:

- Salesforce stores the remote system’s primary or unique surrogate key for the remote record.
- The remote system stores the Salesforce unique record ID or some other unique surrogate key.

There are specific considerations for handling integration keys in this synchronous pattern.

| Master system | Description |
| --- | --- |
| Salesforce | In this scenario, the remote system stores either the Salesforce RecordId or some other unique surrogate key from the record. |
| Remote system | In this scenario, Salesforce stores a reference to the unique identifier in the remote system. Because the process is synchronous, the key can be provided as part of the same transaction using external ID fields. |

**Complex Integration Scenarios**

Each solution in this pattern has different considerations when handling complex integration scenarios such as transformation and process orchestration.

| Solution | Considerations |
| --- | --- |
| SOAP API or REST API | SOAP API and REST API provide for simple transactions on objects. Complex integration scenarios, such as aggregation, orchestration, and transformation, can’t be performed in Salesforce. These scenarios must be handled by the remote system or middleware, with middleware as the preferred method. |
| Apex web service or Apex REST service | Custom web services can provide for cross-object functionality, custom logic, and more complex transaction support. This solution should be used with care, and you should always consider the suitability of middleware for any transformation, orchestration, and error handling logic. |

**Governor Limits**

Due to the multitenant nature of the Salesforce platform, there are limits when using the APIs.

<table class="featureTable sort_table" summary="">


            <thead class="thead sorted" align="left">
              <tr>
                <th class="featureTableHeader  " id="d7164e982">Solution</th>

                <th class="featureTableHeader  " id="d7164e985">Limits</th>

              </tr>

            </thead>

            <tbody class="tbody">
              <tr>
                <td class="entry" headers="d7164e982" data-title="Solution">SOAP API, REST API, and custom Apex APIs</td>

                <td class="entry" headers="d7164e985" data-title="Limits">
                  <ul class="ul bulletList">
                    <li class="li">
                      <em class="ph i">API request limits</em>—Salesforce applies a limit on the number of API calls
                      per 24–hour period. The limit is based on the Salesforce edition type and number
                      of licenses. For example, Unlimited Edition provides 5,000 API requests per Salesforce or
                      Lightning Platform license per 24 hours. For more information, see <cite class="cite"><a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.salesforce_app_limits_cheatsheet.meta/salesforce_app_limits_cheatsheet/salesforce_app_limits_overview.htm" target="_blank" title="HTML (New Window)">Salesforce Developer Limits
                          and Allocations Quick Reference</a></cite>.
                    </li>

                    <li class="li">
                      <em class="ph i">API query cursor limits</em>—A user can have up to 10 query cursors open at a
                      time. Otherwise, the oldest of the 10 cursors is released. If the remote application
                      attempts to open the released query cursor, an error results. For example, if sharing
                      integration user credentials, the maximum query cursors need to be considered. Whenever
                      possible, the middleware should complete the full query before executing another query
                      (in a serial fashion) or each application should use a designated integration user.
                      Alternatively, the middleware may need to execute requests across multiple users in a
                      “round robin” fashion.
                    </li>

                    <li class="li">
                      <em class="ph i">Call limits</em>—See <a class="xref" href="#data_volumes_header">Data Volumes</a> sidebar for create, update, and query limits.
                    </li>

                  </ul>

                </td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e982" data-title="Solution">Bulk API 2.0</td>

                <td class="entry" headers="d7164e985" data-title="Limits">See <a class="xref" href="#data_volumes_header">Data Volumes</a> sidebar for more
                  information.</td>

              </tr>

              <tr>
                <td class="entry" headers="d7164e982" data-title="Solution">Platform Events</td>

                <td class="entry" headers="d7164e985" data-title="Limits">
                  <ul class="ul bulletList">
                    <li class="li">
                      <em class="ph i">Event notification limits</em>—A maximum of 100,000 events can be published
                      per hour for standard volume platform events. A maximum of 250,000 events can be
                      published per hour for high-volume usage-based platform events. To monitor high-volume
                      event usage, use REST API limits resource.
                    </li>

                    <li class="li">
                      <em class="ph i">Event message size limits</em>—The maximum event message size is 1 MB.
                      Publishing an event using the Salesforce APIs counts against your standard API
                      limits.
                    </li>

                  </ul>

                </td>

              </tr>

            </tbody>

          </table>

**Reliable Messaging**

Reliable messaging attempts to resolve the issue of guaranteeing the delivery of a message to a remote system where the individual components themselves might be unreliable. The Salesforce SOAP API and REST API are synchronous and don’t provide explicit support for any reliable messaging protocols, per se (for example, WS-ReliableMessaging).

We recommend that the remote system implement a reliable messaging system to ensure that error and timeout scenarios are successfully managed. Publishing of platform events from external systems relies on Salesforce APIs, so the same considerations for SOAP API and REST API apply.

**Middleware Capabilities**

This table highlights the desirable properties of a middleware system that participates in this pattern:

| Property | Mandatory | Desirable | Not required |
| --- | --- | --- | --- |
| Event handling |  | X |  |
| Protocol conversion |  | X |  |
| Translation and transformation |  | X |  |
| Queuing and buffering | X |  |  |
| Synchronous transport protocols | X |  |  |
| Asynchronous transport protocols |  |  | X |
| Mediation routing |  | X |  |
| Process choreography and service orchestration |  | X |  |
| Transactionality (encryption, signing, reliable delivery, and transaction management) | X |  |  |
| Routing |  |  | X |
| Extract, transform, and load |  | X (for bulk/batches) |  |

## Example

A printing supplies and services company uses Salesforce as a front end to create and manage printer supplies and orders. Salesforce asset records representing printers are periodically updated with printing usage statistics (ink status, paper level) from the on-premises Printer Management System (PMS), which regularly monitors printers on client sites. Upon reaching a set threshold value (for example, low ink status or low/empty paper level of less than 30%), multiple apps/processes (variable) interested in the event are notified, email or Chatter alerts are sent, and an Order record is created. The PMS stores the Salesforce ID (Salesforce is the asset record master).

The following constraints apply:

- The PMS can participate in a contract-first integration, where Salesforce provides the contract and the PMS acts as a client (consumer) of the Salesforce service (defined via the Enterprise or Partner WSDL).
- There should be no custom development in Salesforce.

This example is best implemented using the Salesforce SOAP API or REST API to publish events, and declarative automation (Process Builder) in Salesforce. The primary reason to use platform events is the variable and non-finite number of subscribers; however, for simple updates to a finite list of records such as orders, then use SOAP or REST API to update the records.

In Salesforce:

- Define a platform event in Salesforce to contain the notification data coming from the PMS.
- Create a Process Builder process that’s triggered by the printer event notification. The process updates the printer asset and creates an order (using an auto-launched Flow).
- Download the Enterprise or Partner WSDL and provide it to the remote system.

In the remote system:

- Create a client stub from the Enterprise or Partner WSDL.
- Authenticate to Salesforce (via OAuth web server or bearer token flow) using the integration user’s credentials.
- Upon printer status event, the PMS calls the API to create the printer status platform event (with printer usage statistics). The Salesforce event bus notifies Process Builder subscriber and all other subscribers.

When you use platform events, the event bus lets you replay events for 72 hours for high-volume platform events. Publishing those events using a middleware solution can help incorporate error handling on the publishing side. However, you can implement error handling on the subscribing side if you need higher reliability.

This example demonstrates the following:

- Implementation of a Salesforce synchronous API client (consumer).
- A callback to Salesforce to publish a platform event (aligned with previously covered request/reply platform event patterns).