> ## Documentation Index
> Fetch the complete documentation index at: https://developer.verilock.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Salesforce

> Sync verification results to Salesforce Contacts and Cases.

The Salesforce integration syncs Verilock verification outcomes to your Salesforce CRM. Approved verifications create or update Contacts, while rejected verifications create Cases for compliance review.

## Prerequisites

* Salesforce Professional, Enterprise, or Unlimited edition
* System Administrator profile or Connected App permissions
* Verilock Enterprise plan

## Setup

<Steps>
  <Step title="Create a Connected App">
    In Salesforce Setup, navigate to **App Manager > New Connected App** and configure:

    * **Connected App Name**: `Verilock Integration`
    * **API (Enable OAuth Settings)**: Checked
    * **Callback URL**: `https://verilock.io/api/v1/integrations/salesforce/callback`
    * **OAuth Scopes**: `Full access (full)`, `Perform requests at any time (refresh_token, offline_access)`

    Click **Save** and wait 2-10 minutes for the app to activate.
  </Step>

  <Step title="Retrieve Consumer Credentials">
    After the Connected App is active, click **Manage Consumer Details**. Copy the **Consumer Key** and **Consumer Secret**.
  </Step>

  <Step title="Configure in Verilock">
    Go to **Dashboard > Settings > Integrations > Salesforce** and enter:

    * **Consumer Key**: From step 2
    * **Consumer Secret**: From step 2
    * **Username**: Your Salesforce username
    * **Password**: Your password + security token
    * **Environment**: `production` or `sandbox`

    <Note>
      Verilock uses the OAuth 2.0 Username-Password flow for server-to-server communication. Ensure the user has API access enabled.
    </Note>
  </Step>

  <Step title="Configure Sync Rules">
    Define how Verilock events map to Salesforce objects.
  </Step>

  <Step title="Test Connection">
    Click **Test Connection** to verify OAuth authentication. Verilock will query your Salesforce instance for available objects and fields.
  </Step>
</Steps>

## Sync Rules

| Verilock Outcome    | Salesforce Object | Action                 |
| ------------------- | ----------------- | ---------------------- |
| Session approved    | Contact           | Create or update       |
| Session declined    | Case              | Create                 |
| AML match found     | Case              | Create (high priority) |
| Transaction blocked | Case              | Create (high priority) |

## Field Mapping -- Contacts

When a session is approved, Verilock creates or updates a Salesforce Contact:

| Verilock Field            | Salesforce Field         | Notes              |
| ------------------------- | ------------------------ | ------------------ |
| `applicant.first_name`    | `FirstName`              |                    |
| `applicant.last_name`     | `LastName`               |                    |
| `applicant.email`         | `Email`                  | Used as lookup key |
| `applicant.phone`         | `Phone`                  |                    |
| `applicant.date_of_birth` | `Birthdate`              |                    |
| `applicant.address`       | `MailingStreet`          | Full address       |
| `applicant.country`       | `MailingCountry`         | ISO 3166-1 alpha-2 |
| `session_id`              | `Verilock_Session_ID__c` | Custom field       |
| `risk_score`              | `Verilock_Risk_Score__c` | Custom field       |
| `decision`                | `Verilock_Status__c`     | Custom field       |

<Warning>
  Custom fields (`Verilock_Session_ID__c`, `Verilock_Risk_Score__c`, `Verilock_Status__c`) must be created in Salesforce before enabling the integration. Use the provided package link in your dashboard to auto-create them.
</Warning>

## Field Mapping -- Cases

When a session is declined or an AML match is found, Verilock creates a Case:

| Verilock Field       | Salesforce Field                                         |
| -------------------- | -------------------------------------------------------- |
| Event type           | `Subject`                                                |
| Full event payload   | `Description`                                            |
| Risk score           | `Priority` (mapped: 0-30 Low, 31-60 Medium, 61-100 High) |
| Session/screening ID | `Verilock_Session_ID__c`                                 |
| `applicant.email`    | `SuppliedEmail`                                          |
| Event category       | `Type`                                                   |

## Example Payloads

<Tabs>
  <Tab title="Contact Creation">
    ```json theme={null}
    {
      "FirstName": "Jean",
      "LastName": "Dupont",
      "Email": "jean@example.com",
      "Phone": "+33612345678",
      "Birthdate": "1990-05-15",
      "MailingCountry": "FR",
      "Verilock_Session_ID__c": "ses_a1b2c3d4e5f6",
      "Verilock_Risk_Score__c": 12,
      "Verilock_Status__c": "Approved"
    }
    ```
  </Tab>

  <Tab title="Case Creation">
    ```json theme={null}
    {
      "Subject": "AML Match Found - aml_x7k9m2p4",
      "Description": "Verilock AML screening detected a potential PEP match.\n\nApplicant: Jean Dupont\nMatch Score: 92%",
      "Priority": "High",
      "Type": "Compliance",
      "SuppliedEmail": "jean@example.com",
      "Verilock_Session_ID__c": "aml_x7k9m2p4"
    }
    ```
  </Tab>
</Tabs>

## Duplicate Handling

Verilock uses the applicant's email address as the lookup key for Contacts. If a Contact with the same email exists, it is updated instead of creating a duplicate.

<Tip>
  Enable Salesforce duplicate rules to catch edge cases. Verilock respects Salesforce duplicate rules and will report errors if a duplicate is detected and the rule is set to block.
</Tip>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Authentication failed">
    Verify the username, password, and security token are correct. The password field should be your password concatenated with your security token (e.g., `mypasswordABCDEF123`). Ensure the user profile has API access enabled.
  </Accordion>

  <Accordion title="Custom fields not found">
    Install the Verilock managed package from the link in your dashboard, or manually create the custom fields on the Contact and Case objects.
  </Accordion>

  <Accordion title="Sandbox vs Production">
    Sandbox instances use `test.salesforce.com` for login. Ensure the correct environment is selected in the Verilock dashboard.
  </Accordion>
</AccordionGroup>
