> 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="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2Foxgcpm1X3Cvdr1fDsF4R%2Fimage.png?alt=media&amp;token=87d4482f-e8b7-4ba6-b4a3-27cd68bfed1a" 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="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2F8o61C0xhE634SQxpnien%2FScreenshot%202025-02-28%20at%204.28.22%E2%80%AFPM.png?alt=media&amp;token=ad0f9f58-ad71-494f-b1c7-fa5d267ae7d9" 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="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FZcvLNRQ9yize8GuPLvxx%2FScreenshot%202025-02-28%20at%204.39.33%E2%80%AFPM.png?alt=media&amp;token=4da344e3-f38f-4ae7-ac86-a923033edfd1" 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="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FRrm0BdrCRWE2GheL5o8n%2Fimage.png?alt=media&amp;token=19de3051-353a-4936-87a5-c9ce549454f2" 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="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FrbKrNPb3eeg8xQaTFeJM%2Fimage.png?alt=media&amp;token=aa647f9f-c077-4c3a-9a14-f217bd04c0a0" alt=""><figcaption></figcaption></figure>
{% endstep %}

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

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FaZzwr6cSJhqDR3fksupd%2Fimage.png?alt=media&amp;token=7093c9f9-7bb4-4343-90e5-def705ff9079" alt=""><figcaption></figcaption></figure>
{% endstep %}

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

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FaRkmBBcmJIJYDcq457ru%2Fimage.png?alt=media&amp;token=12dca6f0-e26f-4645-ab7e-aafd820ff453" 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="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FEFvc9rqgeuX2o1HhBC1E%2Fimage.png?alt=media&amp;token=f32a44cf-ec74-4ddb-807a-cc4483c223a9" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FvoIkk6Ta5uX1zPxd60PX%2Fimage.png?alt=media&amp;token=0e424b3b-6530-45bc-b550-7ac72bd161ef" 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="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FcfvqoZP2PWqN9CbRroSG%2Fimage.png?alt=media&amp;token=6c2f82ae-9283-4020-aed1-7a4244ce4df4" alt=""><figcaption></figcaption></figure>
{% endstep %}

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

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FD3E9IOrKcLKLfAMzUn4z%2Fimage.png?alt=media&amp;token=ecec1361-e9ea-4227-a9e3-f629d54f5ba6" 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="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FePOSNLhEjQ2lUg23bPtB%2Fimage.png?alt=media&amp;token=c893d2bc-00b0-4de5-af92-a966aed5bf24" alt=""><figcaption></figcaption></figure>
{% endstep %}

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

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FAmA4DN2K73o9DqdWjS4J%2Fimage.png?alt=media&amp;token=dedca57d-27d9-48a5-bc86-f6079f33baf9" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FTEVJcjv007zp0KgVMUwL%2Fimage.png?alt=media&amp;token=510b811e-deab-4b84-9cc9-c4adf25db0a0" alt=""><figcaption></figcaption></figure>
{% endstep %}

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

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FCBkqVy0wGwOsbVknLmVM%2Fimage.png?alt=media&amp;token=07bbb550-4e09-4f2f-bcc0-486ee8b9a673" 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="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FO370H0HBDbcjziof8puu%2Fimage.png?alt=media&amp;token=0ea05b4e-3b1a-4c71-bc77-d77563743e52" 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="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FGzapCjvl2KUamHu56QfV%2Fimage.png?alt=media&amp;token=632cb67b-0dd5-4f66-9c00-845c8a1b470a" 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="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FsMAJYsBBpSj3nSNITtEF%2Fimage.png?alt=media&amp;token=5a6ca1cb-a6bf-4693-b5f4-23bb8b13b9e8" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FmRxutoxRSdF4CeDvwjjI%2Fimage.png?alt=media&amp;token=174c956d-c00e-4f58-bcc2-4d4f46abd959" 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="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2F0QX2ZaN1eLIy9eQrxyxz%2FConnect_Mesa_with_Salesforce_Automation_Guide_-_Step_1.png?alt=media&amp;token=484e40ae-21cf-4766-9862-37401d8fffb8" 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="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FgQ3gi79KbwEDYbyniXYn%2Fimage.png?alt=media&amp;token=c11cb74f-8dce-4456-adfd-52fb4b5bb3d1" 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="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2FgQ3gi79KbwEDYbyniXYn%2Fimage.png?alt=media&amp;token=c11cb74f-8dce-4456-adfd-52fb4b5bb3d1" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3425906282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1H6u1HQc3Iew7ATmmiCi%2Fuploads%2F4JGzmCF0FKy5gm1vxriH%2Fimage.png?alt=media&amp;token=c8721450-b11f-4e45-8539-86666bbd7eb2" 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.
* If you experience any issues or see this error *`error=unknown_error_description=retry_your_request`* when creating a Salesforce connection via Sandbox, the External Client App's Permitted Users OAuth policy is likely set to "Admin approved users are pre-authorized", and as the connecting user, you aren't assigned to the app.
  * Salesforce refuses at the consent step and redirects back to MESA's callback with error=OAUTH\_APP\_ACCESS\_DENIED and no authorization code.
    * To fix this, you should go to Setup in the sandbox → External Client App Manager → your app → Policies → Edit → OAuth Policies:
      * set Permitted Users to "All users may self-authorize", or
      * keep pre-approval and assign your user Profile (Connected App Access) or a Permission Set (Assigned Connected App) to the app.

### Specify the API User in the External Client App

* To specify the API User in an External Client App, you will need to configure your Salesforce connected app accordingly by following this Salesforce thread: <https://salesforce.stackexchange.com/a/431770>
  * You will also need to ensure the app has the `refresh_token` and `offline_access` enabled

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