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

# Connect Salesforce

> Create client-credential OAuth access in Salesforce, connect it in Demand-Genius with the consumer key, secret and token URL, choose Lead or Contact handling and select funnel stages.

Demand-Genius connects to Salesforce with OAuth 2.0 client credentials. You create an app in Salesforce that grants API access, copy its consumer key and secret, and paste them into Demand-Genius along with your Salesforce domain.

<Warning>
  Salesforce runs through the same sync path as HubSpot, but parity has not been verified end to end. Expect to check the first figures against Salesforce with Demand-Genius.
</Warning>

## Prerequisites

* Salesforce admin rights.
* The **Modify / Connect / Disconnect Integrations** permission in Demand-Genius.

## Part 1: create API access in Salesforce

<Steps>
  <Step title="Create an External Client App">
    In Setup, go to **Platform Tools > Apps > External Client Apps** and create a new app with a recognisable name and an admin contact email.
  </Step>

  <Step title="Enable OAuth with the client credentials flow">
    Enable OAuth, select the **Manage user data via APIs (api)** scope and enable the **Client Credentials Flow**. Set a callback URL (Salesforce requires one even though it is not used here). Under the app's policies, assign a run-as user for the client credentials flow; a dedicated integration user is recommended.
  </Step>

  <Step title="Copy the Consumer Key and Consumer Secret">
    From the app's OAuth settings, view and copy both values.
  </Step>

  <Step title="Note your My Domain URL">
    In Setup, search **My Domain** and copy the current URL, for example `https://yourcompany.my.salesforce.com`.
  </Step>
</Steps>

## Part 2: connect in Demand-Genius

<Steps>
  <Step title="Open Settings > CRM and click Connect on the Salesforce tile">
    The **Add Integration** dialog opens.
  </Step>

  <Step title="Enter the credentials">
    * **Consumer Key** from Salesforce
    * **Consumer Secret** from Salesforce
    * **Token URL**: your My Domain URL. It must start with `https://`.
  </Step>

  <Step title="Choose how you handle new inquiries">
    **Lead** if new people enter Salesforce as leads and are converted later. **Contact** if you work account-based and record people directly as contacts on accounts.
  </Step>

  <Step title="Submit and select funnel stages">
    Demand-Genius pulls your opportunity stages. Untick any you do not want reported on and click **Save**.
  </Step>
</Steps>

## Update or remove the connection

* **Update the credentials** with the pencil next to the API key on the configure screen. The dialog warns that existing data will be lost.
* **Delete Integration** requires typing DELETE to confirm.

## Troubleshooting

* **Connection fails.** Check the Token URL is your My Domain URL with `https://`, and that the client credentials flow has a run-as user assigned in Salesforce.
* **Stages are missing.** Only stages the integration user can see are pulled. Check the user's permissions in Salesforce.
* **Figures differ from Salesforce.** Report what you see to Demand-Genius; see the note at the top of this page.
