> For the complete documentation index, see [llms.txt](https://docs.getmesa.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.getmesa.com/connect/salesforce.md).

# Salesforce

## Connection

When you're setting up your first workflow with Salesforce, you will need to create a [Connection](https://docs.getmesa.com/going-further/credentials) in order to connect MESA with Salesforce.

<figure><img src="/files/UKQtQJatFSniFd1yT0LO" alt="Screenshot of the MESA Salesforce step Connection menu where you create a new Connection to link MESA with Salesforce. Spotlight the Connection setup area."><figcaption></figcaption></figure>

{% stepper %}
{% step %}
Log in to Salesforce, then click the Setup button (gear icon in the top right). If a menu is displayed, then click Setu&#x70;**.**

<figure><img src="/files/yxd48t5CbQX6T0HHaHZG" alt="Screenshot of Salesforce after logging in, click the Setup button in the top right. Spotlight the Setup gear icon in the top right."><figcaption></figcaption></figure>
{% endstep %}

{% step %}
In the left-hand menu, navigate to Apps and App Manager.

<figure><img src="/files/H2OGiM84aQycnxDKB9EW" alt="Screenshot of the Salesforce Setup left-hand menu, navigate to Apps then App Manager. Spotlight the App Manager menu item."><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Then click on New External Client App.

<figure><img src="/files/1wRSoOw0k87vI2Y4D7xM" alt="Screenshot of the Salesforce App Manager page. Spotlight the New External Client App button."><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Enter MESA for the External Client App Name. The API Name field will then auto-populate.
{% endstep %}

{% step %}
Enter a valid email for Contact Emai&#x6C;**.**

<figure><img src="/files/4cWD98p6k3bNcChEOMXT" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Ensure Enable OAuth Settings is checked in the API (Enable OAuth Settings) menu.

<figure><img src="/files/0MEGQ77PaqqHAvvI2L5Z" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Then for Callback URL, enter: <https://app.getmesa.com/apps/mesa/oauth/redirect-token>

<figure><img src="/files/4vLeujJ5EqxIcqbrToMk" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Then select all items under Available OAuth Scopes and hit the right arrow under Add to move all of them to Selected OAuth Scopes.

<figure><img src="/files/JOwsUsd11A4il3Y9oyAk" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/WV35ZCKUT0s6OvfiusEF" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
At the very least, Manage user data via APIs (api) and Perform requests at any time (refresh\_token, offline\_access) must be added as Selected OAuth Scopes.
{% endhint %}
{% endstep %}

{% step %}
By default, 3 settings will be selected automatically. Ensure that only the Require Secret for Web Server Flow and Introspect All Tokens checkboxes are selected from the list.

<figure><img src="/files/bv01KKcTLvX84RwqmHTu" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Then hit the Create button at the bottom.

<figure><img src="/files/ZKzmywqzAPNMaERTBt5o" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Once you are redirected back to view the app's details, click on Policies under your app's name.

<figure><img src="/files/G0Hf84hdE5VJ8AfiVKtS" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Under OAuth Policies, ensure that your Refresh Token Validity Period is set to 30 days.

<figure><img src="/files/FBGbZNMdiHicmnTP2ELt" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/Qpn6XeacpStGzM25HEoR" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Once you have checked your app policy settings, click Settings under your app name.

<figure><img src="/files/OVwCg89chCClfMe1LcHl" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
In the OAuth Settings menu, click on the App Settings Consumer Key and Secret button. You may get prompted to sign in again so please do so.

<figure><img src="/files/wiNWYlw5xgGl7GHhPEra" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
For this next step, you are going to copy and paste these values from the Salesforce screen into your MESA workflow. In a new tab on your browser, open your [Salesforce Trigger or Action](https://docs.getmesa.com/workflow-builder) to proceed.
{% endstep %}

{% step %}
In Salesforce, click on the Consumer Key button and paste the copied value into the Client ID field of your MESA Salesforce step's Connection menu.

<figure><img src="/files/iCZ3haEbhE1yS4nGRbZ4" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Do the same for Salesforce's Consumer Secret and paste it into the "Client Secret" field of your MESA Salesforce step's Connection menu.

<figure><img src="/files/39TuvRhkQIXLL6amj7pU" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/CM4p9mIDQ6LlrS7g72kq" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
For MESA's Authorization URL field, enter: [**https://login.salesforce.com/services/oauth2/authorize**](https://login.salesforce.com/services/oauth2/authorize)
{% endstep %}

{% step %}
For MESA's Token URL field, enter: [**https://login.salesforce.com/services/oauth2/token**](https://login.salesforce.com/services/oauth2/token)

{% hint style="info" %}
If you are connecting to a Salesforce sandbox, you will need to:\
\- Replace the **Authorization URL** with: <https://test.salesforce.com/services/oauth2/authorize>\
\- Replace the **Token URL** with: <https://test.salesforce.com/services/oauth2/token>
{% endhint %}
{% endstep %}

{% step %}
Click Sign in with Salesforce. You may be asked to login to your Salesforce account. Once logged on, you will get a prompt asking for access. Click Allow.

<figure><img src="/files/JjdISd02MH5OE8eKrlDP" alt="Screenshot of the MESA Salesforce Connection menu, clicking Sign in with Salesforce and then Allow access. Spotlight the Sign in with Salesforce button."><figcaption></figcaption></figure>
{% endstep %}

{% step %}
You will be taken back to MESA, with a new Salesforce connection created.

<figure><img src="/files/5VasuqL2huaVry8grUN5" alt=""><figcaption></figcaption></figure>

You have now finished setting up your Salesforce connection. Click the Retrieve Fields button to import your fields.
{% endstep %}
{% endstepper %}

Salesforce plans that support API access are: Enterprise, Unlimited, Developer and Performance.

## Configure <a href="#configuring" id="configuring"></a>

### Retrieve Fields <a href="#synchronizing-salesforce-fields" id="synchronizing-salesforce-fields"></a>

Click the Retrieve Fields button to pull in the current fields associated with your Salesforce action.

<figure><img src="/files/y3DDPreJ3K2kquIKOCCh" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/wyotN6vYy7TqbKYzxYt4" alt=""><figcaption></figcaption></figure>

If you’ve made updates to your fields in Salesforce you will want to click the Retrieve Fields button to pull in the latest changes.

## Technical Notes

### Why can't I set the amount on an opportunity? <a href="#opportunity-amount" id="opportunity-amount"></a>

* If an opportunity includes products, the amount on the opportunity will be the total of its related products. For more information, please refer to [this Salesforce article](https://help.salesforce.com/s/articleView?language=en_US\&id=000335960\&mode=1\&type=1).

### Connection error codes <a href="#opportunity-amount" id="opportunity-amount"></a>

* If you experience any issues or see this error *`error=invalid_client_id&error_description=client%20identifier%20invalid`* when creating a Salesforce connection, please make sure that your Salesforce Client ID and Secret were copied over correctly and that your Salesforce App has the correct Callback URL.
* If you experience any issues or see this error *`error=redirect_url_mismatch&error_description=redirect_url&20must%20match%20configuration`* when creating a Salesforce connection, please make sure you have added the Callback URL in the External Client app while creating it in Salesforce.

{% hint style="info" %}
View Salesforce templates and tutorials [here](https://www.getmesa.com/apps/salesforce/integrate)!
{% endhint %}
