> ## Documentation Index
> Fetch the complete documentation index at: https://docs.withampersand.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Salesforce

The Salesforce connector supports:

* **CRM**
* **Account Engagement** (formerly Pardot)

## What's supported

### Supported actions

This connector has two modules, with CRM as the default.

The **CRM** module supports:

* [Proxy Actions](/proxy-actions), using the base URL `https://{{.workspace}}.my.salesforce.com`.
* [Read Actions](/read-actions), including full historic backfill, incremental read, and filters.
* [Subscribe Actions](/subscribe-actions).
* [Write Actions](/write-actions), including Bulk Write and Delete.

The **Account Engagement** module supports:

* [Proxy Actions](/proxy-actions), using the base URL `https://{{.workspace}}.my.salesforce.com`.
* [Read Actions](/read-actions), including full historic backfill and incremental read.
* [Write Actions](/write-actions).

### Supported CRM objects

export const Check = () => <span>✅</span>;
export const Cross = () => <span>🚫</span>;
export const Maybe = () => <span>🟡</span>;

<div style={{ width: '100%', overflowX: 'auto', display: 'block' }}>
  <table style={{ width: '100%', minWidth: '100%', tableLayout: 'fixed', textAlign: 'center', borderCollapse: 'collapse', display: 'table' }}>
    <thead style={{ display: 'table-header-group', width: '100%' }}>
      <tr style={{ display: 'table-row', width: '100%' }}>
        <th style={{ textAlign: 'left', width: '40%' }}>Object</th>
        <th style={{ width: '20%' }}>Read</th>
        <th style={{ width: '20%' }}>Write</th>
        <th style={{ width: '20%' }}>Subscribe</th>
      </tr>
    </thead>

    <tbody style={{ display: 'table-row-group', width: '100%' }}>
      <tr style={{ display: 'table-row' }}><td style={{ textAlign: 'left' }}><a href="https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_account.htm">Account</a></td><td><Check /></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{ textAlign: 'left' }}><a href="https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_campaign.htm">Campaign</a></td><td><Check /></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{ textAlign: 'left' }}><a href="https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_case.htm">Case</a></td><td><Check /></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{ textAlign: 'left' }}><a href="https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contact.htm">Contact</a></td><td><Check /></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{ textAlign: 'left' }}><a href="https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_event.htm">Event</a></td><td><Check /></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{ textAlign: 'left' }}><a href="https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_lead.htm">Lead</a></td><td><Check /></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{ textAlign: 'left' }}><a href="https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_opportunity.htm">Opportunity</a></td><td><Check /></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{ textAlign: 'left' }}><a href="https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_product.htm">Product</a></td><td><Check /></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{ textAlign: 'left' }}><a href="https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_task.htm">Task</a></td><td><Check /></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{ textAlign: 'left' }}><a href="https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_user.htm">User</a></td><td><Check /></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{ textAlign: 'left' }}>All other <a href="https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_list.htm">standard objects</a></td><td><Check /></td><td><Check /></td><td><Maybe /><br /><a href="https://developer.salesforce.com/docs/atlas.en-us.change_data_capture.meta/change_data_capture/cdc_object_support.htm">(See the full list\*)</a></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{ textAlign: 'left' }}>All custom objects</td><td><Check /></td><td><Check /></td><td><Check /></td></tr>
    </tbody>
  </table>
</div>

*\* Only some standard objects are available for subscribe action. Check here for the [full list](https://developer.salesforce.com/docs/atlas.en-us.change_data_capture.meta/change_data_capture/cdc_object_support.htm) of supported objects.*

For each of these CRM objects, the connector supports:

* Standard fields
* Custom fields

### Supported Account Engagement objects

The Salesforce connector supports the following **Account Engagement** module objects:

<div style={{width: '100%', overflowX: 'auto', display: 'block'}}>
  <table
    style={{
width: '100%',
minWidth: '100%',
tableLayout: 'fixed',
textAlign: 'center',
borderCollapse: 'collapse',
display: 'table'
}}
  >
    <thead style={{display: 'table-header-group', width: '100%'}}>
      <tr style={{display: 'table-row', width: '100%'}}>
        <th style={{textAlign: 'left', width: '40%'}}>Object</th>
        <th style={{width: '20%'}}>Read</th>
        <th style={{width: '20%'}}>Write</th>
      </tr>
    </thead>

    <tbody style={{display: 'table-row-group', width: '100%'}}>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/campaign-v5.html">campaigns</a></td><td><Check /></td><td><Cross /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/custom-redirect-v5.html">custom-redirects</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/dynamic-content-v5.html">dynamic-contents</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/dynamic-content-variation.html">dynamic-content-variations</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/email-template-v5.html">email-templates</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/email-v5.html">emails</a></td><td><Check /></td><td><Cross /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/engagement-studio-program-v5.html">engagement-studio-programs</a></td><td><Check /></td><td><Cross /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/file-v5.html">files</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/folder-contents-v5.html">folder-contents</a></td><td><Check /></td><td><Cross /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/folder-v5.html">folders</a></td><td><Check /></td><td><Cross /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/form-field-v5.html">form-fields</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/form-handler-field-v5.html">form-handler-fields</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/form-handler-v5.html">form-handlers</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/form-v5.html">forms</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/landing-page-v5.html">landing-pages</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/layout-template-v5.html">layout-templates</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/lifecycle-history-v5.html">lifecycle-histories</a></td><td><Check /></td><td><Cross /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/lifecycle-stage-v5.html">lifecycle-stages</a></td><td><Check /></td><td><Cross /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/list-email-v5.html">list-emails</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/list-membership-v5.html">list-memberships</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/list-v5.html">lists</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/opportunity-v5.html">opportunities</a></td><td><Check /></td><td><Cross /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/prospect-account-v5.html">prospect-accounts</a></td><td><Check /></td><td><Cross /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/prospect-v5.html">prospects</a><sup>{"*"}</sup></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/tag-v5.html">tags</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/tagged-object-v5.html">tagged-objects</a></td><td><Check /></td><td><Cross /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/tracker-domain-v5.html">tracker-domains</a></td><td><Check /></td><td><Cross /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/user-v5.html">users</a></td><td><Check /></td><td><Check /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/visit-v5.html">visits</a></td><td><Check /></td><td><Cross /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/visitor-activity-v5.html">visitor-activities</a></td><td><Check /></td><td><Cross /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/visitor-page-view-v5.html">visitor-page-views</a></td><td><Check /></td><td><Cross /></td></tr>
      <tr style={{ display: 'table-row' }}><td style={{textAlign: 'left'}}><a href="https://developer.salesforce.com/docs/marketing/pardot/guide/visitor-v5.html">visitors</a></td><td><Check /></td><td><Cross /></td></tr>
    </tbody>
  </table>
</div>

*\* Because Salesforce's [bulk Prospect Query endpoint](https://developer.salesforce.com/docs/marketing/pardot/guide/prospect-v5.html#requesting-custom-fields) does not support `Multi-Select` or `Checkbox` custom fields on `prospects`, these field types will not appear in the Ampersand field mapping UI and cannot be read or written through standard Read or Write Actions.*

### Example integration

Example manifest files can be found in our samples repository on GitHub:

* [Salesforce CRM example](https://github.com/amp-labs/samples/blob/main/salesforce/amp.yaml)
* [Salesforce Account Engagement example](https://github.com/amp-labs/samples/blob/main/salesforce-account-engagement-demo/amp.yaml)

## Before you get started

### Salesforce orgs needed

You will need two separate Salesforce orgs to complete this process:

1. **Dev Hub Org**: A Salesforce org with Dev Hub enabled. You will create the External Client App inside this org.

2. **Namespace Org**: A Developer Edition Salesforce org that is only used to register a namespace. You will link this namespace to the Dev Hub Org.

### 1. Enable Dev Hub

First you need to choose the Salesforce org to make into your "Dev Hub Org".

**If you intend to become a Salesforce partner and distribute via AppExchange later:**

* You can sign up for a [trial Salesforce Partner Business Org](https://partners.salesforce.com/pdx/s/trial-org-request), which is essentially a trial of a regular Salesforce org (typically 12 months long). Once you become an official partner, Salesforce will grant you two free Sales Cloud licenses. You can [request an extension of the trial or purchase more licenses](https://help.salesforce.com/s/articleView?id=000380510\&type=1).

* Alternatively, if you are already a Salesforce customer, then you can use your existing Salesforce org, and Salesforce will add these free licenses to your existing org when you are accepted as a partner. Please see [Salesforce documentation](https://partners.salesforce.com/s/education/general/Partner_Business_Org) for more information.

**If you don't intend to become a Salesforce partner:**

* You can sign up for a [free Developer Edition Salesforce org](https://developer.salesforce.com/signup) and use it as your Dev Hub Org. Please note that even though Developer Edition orgs are subject to deletion when there is inactivity, this [does not apply if you have an External Client App](https://help.salesforce.com/s/articleView?id=xcloud.admin_de_org_expiration.htm\&type=5) in the org, so it is safe to use a free Developer Edition org as your Dev Hub Org.

Once you have chosen the Salesforce org you will use as your Dev Hub org, you can enable Dev Hub by following these steps:

1. Log in to your Salesforce org.
2. From **Setup**, enter **Dev Hub** in the Quick Find box and select **Dev Hub**.
3. Select **Enable Dev Hub**.
4. Select **Enable Unlocked Packages and Second-Generation Managed Packages**.

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce/enable-dev-hub.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=c6d8a15eb3d2b77b021903da5cf0e855" alt="Enable Dev Hub" width="1257" height="1329" data-path="images/provider-guides/salesforce/enable-dev-hub.png" />

### 2. Register a namespace

Please note that namespaces cannot be created in the Dev Hub Org you just enabled in the step above. You must use a separate Salesforce Developer Edition org (we will call this org the "Namespace Org").

1. Sign up for a free [Developer Edition org](https://developer.salesforce.com/signup).

2. Navigate to the gear icon in the top right corner and select **Setup**.

   <img src="https://mintcdn.com/ampersand-24eb5c1a/CkzFg-K1u4gYx3ZD/images/provider-guides/e8dc5f2-setup.gif?s=a44b052a1c08d34a9533681c29ea575f" alt="Alt text" width="390" height="145" data-path="images/provider-guides/e8dc5f2-setup.gif" />

3. In the quick search box at the top, type in **Package Manager** in the Quick Find box and select **Package Manager**. In **Namespace Settings**, click **Edit**.

4. Enter a namespace and select **Check Availability**. We recommend picking a namespace that is your product name or a shortened version of your product name.

5. When prompted to select a package to associate with this namespace, select **None**, then click **Review**.

6. Review your selections and click **Save**.

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce/create-namespace.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=916fde79ca915df5ec42e2e061d71ab3" alt="Create Namespace" width="1262" height="403" data-path="images/provider-guides/salesforce/create-namespace.png" />

### 3. Link namespace to Dev Hub Org

* Log in to the Dev Hub Org from Step 1.
* Open **App Launcher** (9 dots at the top left), and search for **Namespace Registries**.
* Click **Link Namespace** on the top right.
* When prompted to authenticate, log into the Namespace Org from Step 2. If you are having trouble with this step, try again in an incognito window.
* After linking, select **All Namespace Registries** filter to view the namespace.

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce/link-namespace.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=18cb7b1290293238a226fddd6a35a615" alt="Link namespace" width="1215" height="1291" data-path="images/provider-guides/salesforce/link-namespace.png" />

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce/view-all-namespaces.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=432004c69e7f84b7ab7520b8c73e86c0" alt="View namespaces" width="1181" height="309" data-path="images/provider-guides/salesforce/view-all-namespaces.png" />

### 4. Create External Client App

In order to connect with your customer's Salesforce instances, you'll need to create a Salesforce External Client App by following the steps below:

1. Log in to your Dev Hub Org that you created above.

2. Navigate to the gear icon in the top right corner and select **Setup**.

   <img src="https://mintcdn.com/ampersand-24eb5c1a/CkzFg-K1u4gYx3ZD/images/provider-guides/e8dc5f2-setup.gif?s=a44b052a1c08d34a9533681c29ea575f" alt="Alt text" width="390" height="145" data-path="images/provider-guides/e8dc5f2-setup.gif" />

3. Search for **External Client App Manager**.

4. Click **New External Client App**.

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce/new-app.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=7a6e369eca1428d1651e3504ba205d52" alt="New ECA" width="1326" height="916" data-path="images/provider-guides/salesforce/new-app.png" />

* Enter a **name** for the External Client App. This should match your product name.
* Specify a **contact email**; this should be your support email address.
* Set **Distribution State** to **"Packaged"**.
* Enable **OAuth settings**.
* In **callback URL** put `https://api.withampersand.com/callbacks/v1/oauth`.
* Add the following **OAuth scopes** at the minimum:
  * Perform requests at any time (`refresh_token`, `offline_access`)
  * Manage user data via APIs (`api`)

> ✅ For more details on which OAuth scopes to include, refer to the [OAuth Tokens and Scopes](https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_tokens_scopes.htm\&language=en_US\&type=5) guide.

* Uncheck the box for `Require Proof Key for Code Exchange (PKCE) extension for Supported Authorization Flows`
* Check the box for `Enable Authorization Code and Credentials Flow`

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce_eca_creation.gif?s=d82d260e7a0374201bb1cc2a9991b5f8" alt="Create ECA" width="1496" height="686" data-path="images/provider-guides/salesforce_eca_creation.gif" />

5. Go to the Policies tab, expand “OAuth Policies”, and click the edit button. In the “App Authorization” box, make the following modifications:

* In “Refresh Token Policy”, select “Refresh token is valid until revoked”
* In “IP Relaxation”, select “Relax IP restrictions”

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce_eca_authorization.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=d8429b96d72c93170f13ae4ddf69f69c" width="2420" height="542" data-path="images/provider-guides/salesforce_eca_authorization.png" />

6. Go to the Settings tab, expand “OAuth Settings”. Click on “Consumer Key and Secret”.

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce_eca_oauth.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=8f85ab3805c16376e81e4c15cf25e572" width="200" data-path="images/provider-guides/salesforce_eca_oauth.png" />

### 5. Package the External Client App

In order for your External Client App to be able to make API calls to your customers' Salesforce instances, Salesforce requires that you create a package version, and have your customers install your package in their Salesforce org.

1. **Install the Salesforce CLI** using npm or [another supported method](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm):

```bash theme={null}
npm install -g @salesforce/cli
```

2. **Create a Salesforce DX project.** From a new directory, generate a project:

```bash theme={null}
sf project generate --name MySalesforcePackage
```

Replace `MySalesforcePackage` with a name that fits your integration, such as your product name.

3. **Authenticate with your Dev Hub Org.** From the project directory you just created, log in to your Dev Hub Org (the org where you created the External Client App):

```bash theme={null}
sf org login web --set-default-dev-hub --alias DevHubOrg
```

A browser window will open for you to sign in.

4. **Set the namespace in the project.** Edit `sfdx-project.json` in the project root. Set the `namespace` value to the namespace you registered and linked to your Dev Hub earlier:

```json theme={null}
{
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true
    }
  ],
  "namespace": "MY_NAMESPACE",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "59.0"
}
```

Replace `MY_NAMESPACE` with your actual namespace prefix.

5. **Create the managed package.** Use the command below and replace these flags with actual values that are applicable to you:

* `name`: replace with your product name
* `error-notification-username`: this must match the email address of one of the users in the Dev Hub Org. For example, you can use your own email here. This is the email address that will receive notifications from Salesforce about errors in the package.

```bash theme={null}
sf package create \
  --name "My Package" \
  --package-type Managed \
  --path force-app \
  --target-dev-hub DevHubOrg \
  --error-notification-username your-notification-email@company.com
```

6. **Pull External Client App metadata into the project.** Run this command to programmatically fetch the settings that you had just configured for your External Client App:

```bash theme={null}
sf project retrieve start --metadata ExternalClientApplication ExtlClntAppOauthSettings --target-org DevHubOrg
```

This creates (or updates) metadata under:

* `force-app/main/default/extlClntAppOauthSettings/`
* `force-app/main/default/externalClientApps/`

If you have several External Client Apps and only want to package one, remove the XML files for the apps you do not want in the package.

7. **Build and promote a package version.** Create a new package version (this can take several minutes). Replace `My Package` with the name you supplied in the `name` flag of the `sf package create` command above.

```bash theme={null}
sf package version create \
  --package "My Package" \
  --installation-key-bypass \
  --wait 20 \
  --code-coverage
```

When it finishes, note the **Subscriber Package Version ID** that is printed. Please note that two IDs will be printed, you want the “Subscriber Package Version ID”, not the “Package Version”.

8. Promote that version so it can be installed by customers:

```bash theme={null}
sf package version promote --package SUBSCRIBER_PACKAGE_VERSION_ID --no-prompt
```

Replace `SUBSCRIBER_PACKAGE_VERSION_ID` with the ID from the previous step.

### 6. Build the Package Install URL

1. **Build the package install URL.** Use the Subscriber Package Version ID from Step 7 above to build the install URL for your package.

For production orgs:

```text theme={null}
https://login.salesforce.com/packaging/installPackage.apexp?p0=SUBSCRIBER_PACKAGE_VERSION_ID
```

For sandbox orgs:

```text theme={null}
https://test.salesforce.com/packaging/installPackage.apexp?p0=SUBSCRIBER_PACKAGE_VERSION_ID
```

2. **Ensure customers install the package**

*If you are using `@amp-labs/react` **v2.14.1** or above*:

Once you create the Provider App with the package install URL (in the next step), the UI library will automatically prompt your user to install the package on their Salesforce instance.

<img src="https://mintcdn.com/ampersand-24eb5c1a/sKbKV_vtvAz_CfP2/images/provider-guides/salesforce/UI%20library%20install%20URL.png?fit=max&auto=format&n=sKbKV_vtvAz_CfP2&q=85&s=1ad4e4f4530f680a26cc7dfb7ebecf47" width="500" data-path="images/provider-guides/salesforce/UI library install URL.png" />

Clicking on **Install Salesforce Package** will open up a new tab that has the Salesforce UI for them to install the package. Instruct your customers to go to the package install URL and click "Install for All Users".

<img src="https://mintcdn.com/ampersand-24eb5c1a/J9f8iHXvkp9yvkO8/images/provider-guides/salesforce/InstallURL1.png?fit=max&auto=format&n=J9f8iHXvkp9yvkO8&q=85&s=febf1b9e421e819bfbc7d10f7f48bfc1" width="500" data-path="images/provider-guides/salesforce/InstallURL1.png" />

They should see a screen like this after they are successful.

<img src="https://mintcdn.com/ampersand-24eb5c1a/J9f8iHXvkp9yvkO8/images/provider-guides/salesforce/InstallURL2.png?fit=max&auto=format&n=J9f8iHXvkp9yvkO8&q=85&s=c5a4267b740f709b33ac8200d1a9f9c4" width="500" data-path="images/provider-guides/salesforce/InstallURL2.png" />

*If you are using `@amp-labs/react` versions below **2.14.1**:*

The UI library will not prompt your users to install the package, you must independently share the Package Install URL with them, and they must complete the installation process **before** they connect their Salesforce using the Ampersand UI components.

### 7. Create Provider App in Ampersand

1. Log in to your [Ampersand Dashboard](https://dashboard.withampersand.com).

2. Select the project where you want to create a Salesforce integration.

   <img src="https://mintcdn.com/ampersand-24eb5c1a/CkzFg-K1u4gYx3ZD/images/provider-guides/dd47b7a-Ampersand.png?fit=max&auto=format&n=CkzFg-K1u4gYx3ZD&q=85&s=d580aa00cc421fe14cfbab79c2e0812f" alt="Alt text" width="2244" height="442" data-path="images/provider-guides/dd47b7a-Ampersand.png" />

3. Select **Provider apps**.

4. Select *Salesforce* from the **Provider** list.

5. Enter the following information:
   * *Client ID*: enter the Consumer Key for the External Client App, obtained from [Step 4. Create External Client App](#4-create-external-client-app).
   * *Client Secret*: enter the Consumer Secret for the External Client App, obtained from [Step 4. Create External Client App](#4-create-external-client-app)
   * *Package Install URL*: enter the Package Install URL, obtained from [Step 6. Build the Package Install URL](#6-build-the-package-install-url)

## Migrating Connected App to External Client App

Salesforce no longer supports the creation of new Connected Apps. If you had previously created a Connected App to be used for Ampersand integrations, it will continue to work for your existing and new customers as long as their user profile has the `Approve Uninstalled Connected Apps` or `Use Any API Client` permissions. See [Salesforce customer guide](/customer-guides/salesforce#1-view-and-edit-permissions-for-profile) for details.

Whenever you would like to, you can follow these steps to migrate a Connected App to an External Client App:

1. Open Salesforce **Setup** and search for **Manage Connected Apps** and select the Connected App that you want to convert. Click **Migrate To External Client Application**.

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce/migrate-1.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=44051a3cfbf1e9e246f0e923fe6b9671" alt="Migrate connected app 1" width="1060" height="636" data-path="images/provider-guides/salesforce/migrate-1.png" />

2. Check both required checkboxes to confirm migration.

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce/migrate-2.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=d37888812abef9161063dadbbc4464c9" alt="Migrate connected app 2" width="500" height="243" data-path="images/provider-guides/salesforce/migrate-2.png" />

3. Click **Migrate**.

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce/migrate-3.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=63c465b1ab5366c1c7154687f1261d99" alt="Migrate connected app 3" width="504" height="242" data-path="images/provider-guides/salesforce/migrate-3.png" />

4. Click **OK**.

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce/migrate-4.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=e6dfa55c1e9dd83553ff031be1988162" alt="Migrate connected app 4" width="395" height="146" data-path="images/provider-guides/salesforce/migrate-4.png" />

5. A **confirmation message** will appear.

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce/migrate-5.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=b7321b3983247cf86039b801a0853ade" alt="Migrate connected app 5" width="1062" height="675" data-path="images/provider-guides/salesforce/migrate-5.png" />

6. Open **External Client App Manager**.

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce/migrate-6.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=bbbd61a805037d5b4423f182bece7c34" alt="Migrate connected app 6" width="1023" height="268" data-path="images/provider-guides/salesforce/migrate-6.png" />

7. Select your app, go to the **Settings** tab and set "Distribution State" to **Packaged**.

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce/migrate-7.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=f20389bf0480b314b536f958680d3f09" alt="Migrate connected app 7" width="1033" height="746" data-path="images/provider-guides/salesforce/migrate-7.png" />

8. Go to the Policies tab, expand “OAuth Policies”, and click the edit button. In the “App Authorization” box, make the following modifications:

* In “Refresh Token Policy”, select “Refresh token is valid until revoked”
* In “IP Relaxation”, select “Relax IP restrictions”

<img src="https://mintcdn.com/ampersand-24eb5c1a/09IvuYzHLm_cimbY/images/provider-guides/salesforce_eca_authorization.png?fit=max&auto=format&n=09IvuYzHLm_cimbY&q=85&s=d8429b96d72c93170f13ae4ddf69f69c" width="2420" height="542" data-path="images/provider-guides/salesforce_eca_authorization.png" />

9. [Enable Dev Hub](#1-enable-dev-hub) on your Salesforce org that is hosting the Connected App (which is now an External Client App).

10. Create a new Developer Edition Salesforce org and [register a namespace](#2-register-a-namespace), then [link the namespace](#3-link-namespace-to-dev-hub-org) to the Dev Hub Org.

11. Package the External Client App by [following these instructions](#5-package-the-external-client-app).

## Using the connector

To start integrating with Salesforce:

* Create a manifest file like the [example](https://github.com/amp-labs/samples/blob/main/salesforce/amp.yaml).
* Deploy it using the [amp CLI](/cli/overview).
* If you are using Read Actions or Subscribe Actions, create a [destination](/destinations).
* Embed the [InstallIntegration](/embeddable-ui-components#install-integration) UI component.
* Start using the connector!
  * If your integration has [Read Actions](/read-actions) or [Subscribe Actions](/subscribe-actions), you'll start getting webhook messages.
  * If your integration has [Write Actions](/write-actions), you can start making API calls to our Write API.
  * If your integration has [Proxy Actions](/proxy-actions), you can start making Proxy API calls.

## Customer guide

The [Salesforce customer guide](/customer-guides/salesforce) is a guide that can be shared with your customers to help them be successful in using your integration.

## Troubleshooting

For common errors and how to resolve them, see the [Salesforce troubleshooting guide](/troubleshooting-guides/salesforce).
