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

# Salesforce

## Overview

Stigg's native integration with [Salesforce](https://www.salesforce.com/) streamlines sales processes by automating fine-grained provisioning of bespoke enterprise accounts directly from Salesforce.

<img src="https://mintcdn.com/stigg/tWlJkHU9GfoKBEmJ/images/docs/47f92ce-image.png?fit=max&auto=format&n=tWlJkHU9GfoKBEmJ&q=85&s=9088c4834663eec85c5bb0a69ad69302" alt="" width="1910" height="1042" data-path="images/docs/47f92ce-image.png" />

### Benefits

1. **Reduce time** from opportunity close to account provisioned from days and hours to 0.
2. **Ensure alignment** between the customer's contract and the level of access that they were provisioned.
3. Leverage the **same** entitlement management and metering infrastructure for access enforcement and usage reporting regardless of how your product is sold - via self-service, sales-led, sales-assisted, or all of the above.

### Example use-cases

1. Provisioning trial access when an opportunity reaches a POC status.
2. Provisioning subscriptions upon opportunity close.
3. Updating customers' entitlements upon contract amendment and renewals.

### Customization

The integration can be fully customized to your existing business process and needs by leveraging [Salesforce Flow](https://help.salesforce.com/s/articleView?id=sf.flow.htm\&type=5) workflows.

## Integration with Salesforce CPQ

Stigg's native integration with Salesforce works seamlessly with Salesforce CPQ.

## Availability

<Note>
  Stigg's native integration with Salesforce is included in the Scale plan, and is also available as an optional add-on to the Growth plan. See Stigg's pricing for more details.
</Note>

## Setting up the integration

### Prerequisites

* A Salesforce organization with Enterprise edition or higher
* A user with admin access to the Salesforce organization, that you'll be integrating with Stigg

### Connect your Salesforce domain

In the [Stigg app](https://app.stigg.io), navigate to the Integrations section and click on the Salesforce tile.

Enter the domain of the Salesforce instance that will be integrated with Stigg.

Click **Continue**.

### Install the Stigg app

Install the Stigg app for Salesforce by clicking on **Stigg app for Salesforce installation** link:

<img src="https://mintcdn.com/stigg/8tviKNnHCor59SIf/images/docs/ff694c3-image.png?fit=max&auto=format&n=8tviKNnHCor59SIf&q=85&s=dd8ace0b45099e72bd05a67f9cc8a8a0" alt="" width="796" height="313" data-path="images/docs/ff694c3-image.png" />

Click on **Install for Admins Only**.

<img src="https://mintcdn.com/stigg/ghlUDOmd1mRIOf61/images/docs/286be94-image.png?fit=max&auto=format&n=ghlUDOmd1mRIOf61&q=85&s=385da0f7dca9b555133e8d948b671521" alt="" width="920" height="317" data-path="images/docs/286be94-image.png" />

### Configure API key

1. In the [Stigg app](https://app.stigg.io), copy the generated API key.
2. [In Salesforce](https://login.salesforce.com), click the settings icon in the right corner of the screen.

<img src="https://mintcdn.com/stigg/8tviKNnHCor59SIf/images/docs/salesforce-api1.png?fit=max&auto=format&n=8tviKNnHCor59SIf&q=85&s=32be64a0973c604f36f7d18ebc1d976d" alt="" width="361" height="366" data-path="images/docs/salesforce-api1.png" />

3. Click **Setup**.
4. In the search bar on the right, type **Named Credentials** and select it from the results.
5. In the **Named Credentials** screen, click the **External Credentials** tab at the top.
6. Locate and select **Stigg** from the list.

<img src="https://mintcdn.com/stigg/8tviKNnHCor59SIf/images/docs/salesforce-api2.png?fit=max&auto=format&n=8tviKNnHCor59SIf&q=85&s=662fbc6519c435181514a3c99db648b5" alt="" width="1049" height="598" data-path="images/docs/salesforce-api2.png" />

7. Local the **Principals** panel and select the **Edit** action on the right side.

<img src="https://mintcdn.com/stigg/8tviKNnHCor59SIf/images/docs/salesforce-api3.png?fit=max&auto=format&n=8tviKNnHCor59SIf&q=85&s=16b253269a1e87af464fdbf058578197" alt="" width="1533" height="878" data-path="images/docs/salesforce-api3.png" />

8. In the **Edit Principal** modal, set:

* **Name**: api\_key
* **Value**: Integration API key that you copied from the Stigg app

<img src="https://mintcdn.com/stigg/8tviKNnHCor59SIf/images/docs/salesforce-api4.png?fit=max&auto=format&n=8tviKNnHCor59SIf&q=85&s=6d5125784599f3fbbd84bc2bc72e63aa" alt="" width="1288" height="826" data-path="images/docs/salesforce-api4.png" />

9. Click **Save**.
10. Go to **Setup > Users**.

<img src="https://mintcdn.com/stigg/8tviKNnHCor59SIf/images/docs/salesforce-api5.png?fit=max&auto=format&n=8tviKNnHCor59SIf&q=85&s=5a568a2e12f0d4350450a354473e3e31" alt="" width="1532" height="627" data-path="images/docs/salesforce-api5.png" />

11. Select the required user and click their name or email address.
12. Locate the **Permission Set Assignments** section and click **Edit Assignments**.

<img src="https://mintcdn.com/stigg/8tviKNnHCor59SIf/images/docs/salesforce-api6.png?fit=max&auto=format&n=8tviKNnHCor59SIf&q=85&s=4127ec9927da1e9bc222e67d5bf26cdd" alt="" width="1531" height="757" data-path="images/docs/salesforce-api6.png" />

13. In the **Available Permission Sets** section, find **Stigg** and move it to the right side.

<img src="https://mintcdn.com/stigg/8tviKNnHCor59SIf/images/docs/salesforce-api7.png?fit=max&auto=format&n=8tviKNnHCor59SIf&q=85&s=dc90ac41ff07fcf87d19db3fae61a0df" alt="" width="1041" height="703" data-path="images/docs/salesforce-api7.png" />

14. Click **Save**.

15. Now, on the user page, you should see **Stigg** listed under **Permission Set Assignments**.

### Map Salesforce and Stigg entities

Provisioning entities in Stigg according to entities in Salesforce requires mapping between these two entities to be defined. This mapping is defined in Salesforce.

[In Salesforce](https://login.salesforce.com), under the relevant Salesforce entity that you'd like to map to Stigg:

1. Stigg type - an **enum** with following possible values:

   1. **Plan** - represents a [custom plan](../../modeling-your-pricing-in-stigg/plans/custom-plans) in Stigg
   2. **Add-on** - represents an [add-on](../../modeling-your-pricing-in-stigg/add-ons/overview) Stigg
   3. **Entitlement** - represents plan's a [custom entitlement](../../modeling-your-pricing-in-stigg/plans/variable-entitlement-values)
   4. **Credit entitlement** - represents a recurring credit grant entitlement in Stigg. The credit amount is passed dynamically via the **Subscription Credit Entitlements** parameter during provisioning.

2. Stigg ID - the ID of the matching entity in Stigg, for example: plans would start with a "plan-" prefix, add-ons start with an "addon-" prefix, and entitlements start with a "feature-" prefix

Add these new custom fields to the entity's [default page layout](https://help.salesforce.com/s/articleView?id=000385416\&type=1).

If you're using Salesforce price books, Salesforce products or Salesforce CPQ, it's high recommended to add these custom fields to the Salesforce **product** entity, as can seen below:

<img src="https://mintcdn.com/stigg/zZAY_sXPTSVMcwio/images/docs/c5d7351-image.png?fit=max&auto=format&n=zZAY_sXPTSVMcwio&q=85&s=3d69e335e1558e8e9d53521678ad3f66" alt="" width="1900" height="921" data-path="images/docs/c5d7351-image.png" />

When creating or editing the relevant Salesforce entities that are mapped to Stigg entities, set the values of these custom fields:

<img src="https://mintcdn.com/stigg/ghlUDOmd1mRIOf61/images/docs/210ca1e-image.png?fit=max&auto=format&n=ghlUDOmd1mRIOf61&q=85&s=01ebe49b08417749b326ba90886f4115" alt="" width="880" height="621" data-path="images/docs/210ca1e-image.png" />

### Create provisioning automation flows

[In Salesforce](https://login.salesforce.com) click on the **Setup** icon and open the **Setup** action.

<img src="https://mintcdn.com/stigg/zZAY_sXPTSVMcwio/images/docs/d2f5fc0-Screenshot_2024-03-20_at_13.32.41.png?fit=max&auto=format&n=zZAY_sXPTSVMcwio&q=85&s=c4c4bda19a231b6742504fd4957d8cfc" alt="" width="2864" height="268" data-path="images/docs/d2f5fc0-Screenshot_2024-03-20_at_13.32.41.png" />

In the search box that appears at the top of the page, enter "flows".

Select the **Flows** item under **Process Automation**.

#### Default template

To help you get up-and-running, the Stigg app for Salesforce includes a default [Salesforce Flow](https://help.salesforce.com/s/articleView?id=sf.flow.htm) template for automating provisioning of customers and subscriptions in Stigg when an opportunity in Salesforce is marked as **Closed - Won**.

This template can be fully customized to cater to your business needs.

<img src="https://mintcdn.com/stigg/cwvUR-sZ1iKIoz2m/images/docs/b63d931-Screenshot_2024-03-20_at_13.31.37.png?fit=max&auto=format&n=cwvUR-sZ1iKIoz2m&q=85&s=97e05b24a5612217f69b3ac528462671" alt="" width="2866" height="436" data-path="images/docs/b63d931-Screenshot_2024-03-20_at_13.31.37.png" />

In the opened list, search for a flow called **Opportunity - Stigg Subscription Template**.

<img src="https://mintcdn.com/stigg/zZAY_sXPTSVMcwio/images/docs/c1db724-image.png?fit=max&auto=format&n=zZAY_sXPTSVMcwio&q=85&s=254e5f4a087c31384be0d6f168e3e8fc" alt="" width="1916" height="520" data-path="images/docs/c1db724-image.png" />

The default template flow does the following:

1. Triggered when the status of Opportunity in Salesforce changes to **Closed won**.
2. Iterates over the opportunity's products and compiles the input for provisioning subscriptions in Stigg using the [defined entity mapping](#map-salesforce-and-stigg-entities).
3. Provisions a customer in Stigg.
4. Provisions a subscription in Stigg.
5. Updates the opportunity's account with the **Stigg Customer ID** and **Stigg Customer URL**. The latter serves as a deep-link to the relevant customer in Stigg.

<Frame caption="Default template flow in Salesforce">
  <img src="https://mintcdn.com/stigg/ghlUDOmd1mRIOf61/images/docs/2ac42ad-Screenshot_2024-03-20_at_15.21.58.png?fit=max&auto=format&n=ghlUDOmd1mRIOf61&q=85&s=17784682b0b4e83b7236608175b04b79" width="1008" height="1354" data-path="images/docs/2ac42ad-Screenshot_2024-03-20_at_15.21.58.png" />
</Frame>

#### Creating your own flow

Leverage the default template flow to create flows that meet your business needs.

To do so, apply the relevant changes to the default template flow.

Specifically, provision resources (i.e. accounts, organizations, workspaces) in your application **before** provisioning the resources in Stigg (between steps 2 and 3 of the [default template](#default-template)) by adding a new [HTTP callout action](https://help.salesforce.com/s/articleView?id=sf.flow_http_callout_configure.htm) which will make an API request to your application to provision those resources.

<img src="https://mintcdn.com/stigg/tWlJkHU9GfoKBEmJ/images/docs/633ec5e-image.png?fit=max&auto=format&n=tWlJkHU9GfoKBEmJ&q=85&s=f977162686655eaf6e00a3247ce7b439" alt="" width="2865" height="840" data-path="images/docs/633ec5e-image.png" />

Update the **Create Stigg Customer** and **Create Stigg Subscription** actions to use IDs of the generated resources when creating customers and subscriptions in Stigg.

One done, click on the **Save as** link to create a new flow with your changes.

<img src="https://mintcdn.com/stigg/_E1NPxWRKvYZ5hDE/images/docs/7d96a8a-image.png?fit=max&auto=format&n=_E1NPxWRKvYZ5hDE&q=85&s=653578c14f2b28d861ea4e846bace0db" alt="" width="1149" height="641" data-path="images/docs/7d96a8a-image.png" />

Ensure that the default flow is deactivated and that the new flow is active.

<img src="https://mintcdn.com/stigg/vKl0Sj1YLcCT0yUv/images/docs/3ca1626-Screenshot_2024-03-20_at_15.26.20.png?fit=max&auto=format&n=vKl0Sj1YLcCT0yUv&q=85&s=dfaf537e19c8455ef33e7f681df75a84" alt="" width="2350" height="612" data-path="images/docs/3ca1626-Screenshot_2024-03-20_at_15.26.20.png" />

## Deep-links

When customer and subscriptions are created in Stigg through the Salesforce integration, in both places you will see a deep link to the matching entity in the other system, so it's easier to navigate and find the corresponding entity in the other system:

<Frame caption="Customers in the Stigg app have a deep-link to the Account object in Salesforce">
  <img src="https://mintcdn.com/stigg/vKl0Sj1YLcCT0yUv/images/docs/3234e76-image.png?fit=max&auto=format&n=vKl0Sj1YLcCT0yUv&q=85&s=6cbdcfba3d48d6fdbc1f1fdcfa112677" width="1620" height="420" data-path="images/docs/3234e76-image.png" />
</Frame>

<Frame caption="Accounts in Salesforce have a deep-link to the Customer object in the Stigg app">
  <img src="https://mintcdn.com/stigg/vKl0Sj1YLcCT0yUv/images/docs/30f62bd-image.png?fit=max&auto=format&n=vKl0Sj1YLcCT0yUv&q=85&s=2c3f54c98891d2fc58ebe9b6a281ae53" width="1281" height="920" data-path="images/docs/30f62bd-image.png" />
</Frame>

## Removing the integration

To remove the integration, click on the dotted menu icon and select the **Remove** action.

Confirm the action by clicking on the **Remove** button in the opened modal.

## Package components

### Pages

| Action | Component Name       | Parent Object | Component Type | Installation Notes             |
| ------ | -------------------- | ------------- | -------------- | ------------------------------ |
| Create | Stigg\_UtilityBar    |               | Lightning Page | This is a brand new component. |
| Create | Stigg\_Configuration |               | Lightning Page | This is a brand new component. |
| Create | API Configuration    |               | Lightning Page | This is a brand new component. |

### Tabs

| Action | Component Name      | Parent Object | Component Type | Installation Notes             |
| ------ | ------------------- | ------------- | -------------- | ------------------------------ |
| Create | Stigg Configuration |               | Tab            | This is a brand new component. |
| Create | API Configuration   |               | Tab            | This is a brand new component. |

### Flows

| Action | Component Name                   | Parent Object | Component Type | Installation Notes             |
| ------ | -------------------------------- | ------------- | -------------- | ------------------------------ |
| Create | Stigg Configuration Screen       |               | Flow Version   | This is a brand new component. |
| Create | Opportunity - Stigg Subscription |               | Flow Version   | This is a brand new component. |

### Code

| Action | Component Name                    | Parent Object      | Component Type | Installation Notes                                                                                                                                      |
| ------ | --------------------------------- | ------------------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Create | MockProvider                      | Package Components | Apex Class     | This is a brand new component.                                                                                                                          |
| Create | StiggCreateCustomer               | Package Components | Apex Class     | This is a brand new component.                                                                                                                          |
| Create | SubscriptionEntitlement           | Package Components | Apex Class     | This is a brand new component.                                                                                                                          |
| Update | StiggCreateSubscription           | Package Components | Apex Class     | Updated to support credit entitlements (`subscriptionCreditEntitlements`).                                                                              |
| Create | StiggCreateSubscriptionWithReturn | Package Components | Apex Class     | This is a brand new component. Includes support for credit entitlements.                                                                                |
| Create | SubscriptionCreditEntitlement     | Package Components | Apex Class     | This is a brand new component. DTO for credit entitlements with fields: `customCurrencyId`, `amount`, `cadence` (`MONTH`/`YEAR`), and optional `price`. |
| Create | StiggCreateCreditGrant            | Package Components | Apex Class     | This is a brand new component. Invocable method for granting credits to a customer.                                                                     |
| Create | SubscriptionPlan                  | Package Components | Apex Class     | This is a brand new component.                                                                                                                          |
| Create | SubscriptionAddon                 | Package Components | Apex Class     | This is a brand new component.                                                                                                                          |
| Create | StiggCreateCustomerTests          | Package Components | Apex Class     | This is a brand new component.                                                                                                                          |
| Create | GraphQLClient                     | Package Components | Apex Class     | This is a brand new component.                                                                                                                          |

### Fields

| Action | Component Name       | Parent Object          | Component Type | Installation Notes                                                                                                                                                                            |
| ------ | -------------------- | ---------------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Create | Stigg Type           | Product                | Custom Field   | This is a brand new component.                                                                                                                                                                |
| Create | API Key              | Stigg\_Configuration\_ | Custom Field   | This is a brand new component.                                                                                                                                                                |
| Create | Stigg ID             | Product                | Custom Field   | This is a brand new component.                                                                                                                                                                |
| Create | Stigg Customer ID    | Account                | Custom Field   | This is a brand new component.                                                                                                                                                                |
| Create | Stigg Customer URL   | Account                | Custom Field   | This is a brand new component.                                                                                                                                                                |
| Create | Stigg Billing Period | Product                | Custom Field   | This is a brand new component. For upgraded installations, you must manually set this field to Active under “Fields & Relationships” in the Product Object Manager, and add it to the layout. |

### Objects

| Action | Component Name      | Parent Object | Component Type | Installation Notes             |
| ------ | ------------------- | ------------- | -------------- | ------------------------------ |
| Create | Stigg Configuration |               | Custom Object  | This is a brand new component. |

### Apps

| Action | Component Name | Parent Object | Component Type | Installation Notes             |
| ------ | -------------- | ------------- | -------------- | ------------------------------ |
| Create | Stigg          |               | App            | This is a brand new component. |

### Resources

| Action | Component Name | Parent Object | Component Type  | Installation Notes                                                   |
| ------ | -------------- | ------------- | --------------- | -------------------------------------------------------------------- |
| Update | Account Layout | Account       | Page Layout     | This is an upgraded component. It will be updated to the new version |
| Create | Stiggicon      |               | Static Resource | This is a brand new component.                                       |
| Create | Group\_19769   |               | Asset File      | This is a brand new component.                                       |
| Create | Stigg \_API    |               | Remote Site     | This is a brand new component.                                       |
| Update | Product Layout | Product       | Page Layout     | This is an upgraded component. It will be updated to the new version |
