# Connecting Salesforce

This guide walks you through connecting Spara to Salesforce so that lead conversations and field data sync automatically to your CRM.

For a full feature reference, see [Salesforce](/integrations/crm-integrations/salesforce.md).

## What Syncs

Once connected, Spara can:

* Write conversation data and field values to matching Salesforce Leads and Contacts (Push)
* Create new Salesforce records when no match is found
* Import existing Salesforce records into Spara as Leads (Pull)
* Read Account and Owner data to personalize agent behavior

{% stepper %}
{% step %}

#### Navigate to Integrations

Go to [**Settings > Integrations**](https://app.spara.co/organization/integrations) and find the Salesforce card. Click **Authorize**.

{% hint style="info" %}
You need Manager or Integrator permissions to connect integrations. See [https://docs.spara.com/platform/settings/user-management](https://docs.spara.com/platform/settings/user-management "mention") for role details.
{% endhint %}
{% endstep %}

{% step %}

#### Enter your Salesforce URL and authorize

Enter your Salesforce instance URL (e.g., `https://yourcompany.salesforce.com`). Use your main Salesforce domain — not a `.force.com` URL.

Click **Authorize** and complete the Salesforce authentication flow.
{% endstep %}

{% step %}

#### Configure Push Rules

On the Manage page, use the **Contacts** and **Leads** tabs to configure Push Rules independently for each object type:

* **Update existing records** — Spara writes data to matching Salesforce Contacts or Leads
* **Create records when no match is found** — Spara creates a new record if no match exists (requires the update option to be enabled)

Spara matches records by email address or Salesforce object ID automatically.
{% endstep %}

{% step %}

#### Map fields

Under **Data Model Sync**, set up field mappings between Spara Lead fields and Salesforce fields. Configure mappings separately for Contacts and Leads using the tabs.

For each mapping:

1. Choose a **Spara field** (e.g., First name, Company, or any custom field)
2. Choose the corresponding **Salesforce field**
3. Set the **Write rule** — overwrite existing values, or only write when the field is empty

To sync the full conversation history, map the **Conversation** Spara field to any Salesforce text field.

For a full list of available Spara fields, go to [**Data Model**](https://app.spara.co/data-model).
{% endstep %}

{% step %}

#### Save and verify

Click **Save** to activate the connection. New lead activity will begin syncing to Salesforce immediately.

To verify, have a test lead interact with your Spara agent and confirm that a corresponding Lead or Contact record appears or is updated in Salesforce.
{% endstep %}
{% endstepper %}

## Troubleshooting

### OAuth Error

If you see an OAuth Error, have your Salesforce admin connect directly from Spara, or create an external connected app with API read/create/edit access on Leads and Contacts.

### Reconnection required

Go to [**Settings > Integrations > Salesforce**](https://app.spara.co/organization/integrations/salesforce/manage), click **Deauthorize**, then authorize again.

### Disconnecting

Click **Deauthorize** on the Salesforce manage page. Your sync configuration and field mappings are preserved for when you reconnect.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.spara.com/guides/integration-guides/connecting-salesforce.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
