> For the complete documentation index, see [llms.txt](https://docs.medicare.healthsherpa.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.medicare.healthsherpa.com/integration-guide/integration-patterns/sync-from-your-crm-to-healthsherpa.md).

# Sync from your CRM to HealthSherpa

This pattern demonstrates how to synchronize contacts between your CRM and HealthSherpa's system. The flow ensures that each contact in your CRM has a corresponding record in HealthSherpa, and stays up-to-date.

## Overview

1. **Initial Setup**
   * Choose the API version your integration will use:
     * For v1 API key integrations:
       * Create an API client with your HealthSherpa API key
       * Store the API key securely in your system
       * Include the agent's email address in each search request - **must match their HealthSherpa account**
     * For v2 OAuth integrations:
       * Configure OAuth with HealthSherpa, request the `partner_api_v2` scope
       * Store and refresh OAuth access tokens securely
       * Search requests are performed on behalf of the authenticated agent, so `agent_email` is not required
2. **Agent Authentication**
   * Provide a "Login to HealthSherpa" button in your CRM
   * When clicked, opens [HealthSherpa login page](https://medicare.healthsherpa.com/sessions/new) in a new tab
   * Agent logs in to HealthSherpa separately
3. **Contact Synchronization Flow**
   * When a user clicks the "Sync to HealthSherpa" button in your CRM:
     1. Check if the contact has a HealthSherpa ID stored in your CRM
        1. If no HealthSherpa ID exists:
           * Create a new contact in HealthSherpa
           * Store the returned HealthSherpa ID in your CRM
        2. If HealthSherpa ID exists:
           * Update the existing contact in HealthSherpa
     2. Redirect the user to the quote page in HealthSherpa (the redirect URL will be returned from both the create and update contact endpoints).
        1. If a zip code was provided, it will be pre-populated. If not, the agent will be prompted to provide one. In either case, the agent has to confirm the county in order to access the quote.
4. **Data Mapping**
   * Map your CRM fields to HealthSherpa fields
   * Required fields: `external_id`, `first_name`, `last_name`
   * Optional fields: email, phone, address, Medicare information
5. **Error Handling**
   * Handle API errors and show user-friendly error messages


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.medicare.healthsherpa.com/integration-guide/integration-patterns/sync-from-your-crm-to-healthsherpa.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.
