# Install Uniform connector for Sitecore XM / XP

> Build modern web experiences by reusing content from your Sitecore XM or XP.

Source: https://docs.uniform.app/docs/integrations/content/sitecore/install-connector

> **Info:**
>
> The information in this section applies to the `v7.2` (or later) version of the
> Uniform for Sitecore connector.

## Step 1: Configure Sitecore Services Client

Uniform uses the Sitecore Services Client (SSC) to read content
from Sitecore, so SSC must be enabled and configured.

**Sitecore 10.x**

1. If SSC isn't enabled, you must enable it. The following is an
   example of a config file that enables SSC:

   ```xml
   <?xml version="1.0" encoding="utf-8" ?>
   <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
       <sitecore>
           <settings>
               <setting name="Sitecore.Services.AllowAnonymousUser" value="true" />
               <setting name="Sitecore.Services.AllowItemServiceAnonymousUser" value="true" />
               <setting name="Sitecore.Services.SecurityPolicy" value="Sitecore.Services.Infrastructure.Web.Http.Security.ServicesOnPolicy, Sitecore.Services.Infrastructure" />
           </settings>
           <api>
           <services>
               <configuration type="Sitecore.Services.Infrastructure.Configuration.ServicesConfiguration, Sitecore.Services.Infrastructure">
               <filters>
                   <filter desc="requiredApiKeyAttribute">Sitecore.Services.Infrastructure.Security.RequiredApiKeyAttribute, Sitecore.Services.Infrastructure</filter>              
               </filters>
               </configuration>
           </services>
           </api>
       </sitecore>
   </configuration>
   ```
2. In Sitecore, open Content Editor.
3. Open the `master` database
4. Navigate to **sitecore > system > Settings > Services > API Keys**.
5. Add the following item:

   - **Template**: `API Key`
   - **Name**: `Uniform API Key`
6. Set the following field values:

   - **CORS Origins**: _For the US region:_

     _For the EU region:_

   - **Allowed Controllers**: `Sitecore.Services.Infrastructure.*`
   - **Impersonation User**: Name of a Sitecore user with access
     to site items, `/sitecore/system/Languages`, `/sitecore/templates` and
     `/sitecore/system/Uniform` (for example, `sitecore\admin`)
7. Save the item.
8. Publish the item.
9. Note the item ID. This is your _Sitecore API key_. You will need this value later.

**Sitecore 9.3.0-9.0.2**

1. If SSC isn't enabled, you must enable it. The following is an
   example of a config file that enables SSC:

   ```xml
   <?xml version="1.0" encoding="utf-8" ?>
   <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
       <sitecore>
           <settings>
               <setting name="Sitecore.Services.AllowAnonymousUser" value="true" />
               <setting name="Sitecore.Services.AllowItemServiceAnonymousUser" value="true" />
               <setting name="Sitecore.Services.SecurityPolicy" value="Sitecore.Services.Infrastructure.Web.Http.Security.ServicesOnPolicy, Sitecore.Services.Infrastructure" />
           </settings>
           <api>
           <services>
               <configuration type="Sitecore.Services.Infrastructure.Configuration.ServicesConfiguration, Sitecore.Services.Infrastructure">
               <filters>
                   <filter desc="requiredApiKeyAttribute">Sitecore.Services.Infrastructure.Sitecore.Security.RequiredApiKeyAttribute, Sitecore.Services.Infrastructure.Sitecore</filter>
               </filters>
               </configuration>
           </services>
           </api>
       </sitecore>
   </configuration>
   ```
2. In Sitecore, open Content Editor.
3. Open the `master` database
4. Navigate to **sitecore > system > Settings > Services > API Keys**.
5. Add the following item:

   - **Template**: `API Key`
   - **Name**: `Uniform API Key`
6. Set the following field values:

   - **CORS Origins**: _For the US region:_

     _For the EU region:_

   - **Allowed Controllers**: `Sitecore.Services.Infrastructure.*`
   - **Impersonation User**: Name of a Sitecore user with access
     to site items, `/sitecore/system/Languages`, `/sitecore/templates` and
     `/sitecore/system/Uniform` (for example, `sitecore\admin`)
7. Save the item.
8. Publish the item.
9. Note the item ID. This is your _Sitecore API key_. You will need this value later.

**Sitecore 9.0.2-9.0.0**

1. If SSC isn't enabled, you must enable it. The following is an
   example of a config file that enables SSC:

   ```xml
   <?xml version="1.0" encoding="utf-8" ?>
   <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
       <sitecore>
           <settings>
               <setting name="Sitecore.Services.AllowAnonymousUser" value="true" />
               <setting name="Sitecore.Services.AllowItemServiceAnonymousUser" value="true" />
               <setting name="Sitecore.Services.SecurityPolicy" value="Sitecore.Services.Infrastructure.Web.Http.Security.ServicesOnPolicy, Sitecore.Services.Infrastructure" />
           </settings>
           <api>
           <services>
               <configuration type="Sitecore.Services.Infrastructure.Configuration.ServicesConfiguration, Sitecore.Services.Infrastructure">
               <filters>
                   <filter desc="requiredApiKeyAttribute">Sitecore.Services.Infrastructure.Sitecore.Security.RequiredApiKeyAttribute, Sitecore.Services.Infrastructure.Sitecore</filter>
               </filters>
               </configuration>
           </services>
           </api>
       </sitecore>
   </configuration>
   ```
2. In Sitecore, open Content Editor.
3. Open the `core` database.
4. Navigate to **sitecore > system > Settings > Services > API Keys**.
5. Add the following item:

   - **Template**: `API Key`
   - **Name**: `Uniform API Key`
6. Set the following field values:

   - **CORS Origins**: _For the US region:_

     _For the EU region:_

   - **Allowed Controllers**: `Sitecore.Services.Infrastructure.*`
   - **Impersonation User**: Name of a Sitecore user with access
     to site items, `/sitecore/system/Languages`, `/sitecore/templates` and
     `/sitecore/system/Uniform` (for example, `sitecore\admin`)
7. Save the item.
8. Note the item ID. This is your _Sitecore API key_. You will need this value later.

**Sitecore 8.2**

1. If SSC isn't enabled, you must enable it. The following is an
   example of a config file that enables SSC:

   ```xml
   <?xml version="1.0" encoding="utf-8" ?>
   <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
       <sitecore>
           <settings>
               <setting name="Sitecore.Services.AllowAnonymousUser" value="true" />
               <setting name="Sitecore.Services.AllowItemServiceAnonymousUser" value="true" />
               <setting name="Sitecore.Services.SecurityPolicy" value="Sitecore.Services.Infrastructure.Web.Http.Security.ServicesOnPolicy, Sitecore.Services.Infrastructure" />
           </settings>
           <api>
           <services>
               <configuration type="Sitecore.Services.Infrastructure.Configuration.ServicesConfiguration, Sitecore.Services.Infrastructure">
               <filters>
                   <filter desc="requiredApiKeyAttribute">Uniform.Filters.RequiredApiKeyAsUniformToken, Uniform.Platform.Canvas.SSC</filter>    
               </filters>
               </configuration>
           </services>
           </api>
       </sitecore>
   </configuration>
   ```
2. In Website folder, open **Web.config** and config CORS header

   ```xml
   <system.webServer>
       <httpProtocol>
       <customHeaders>
           <remove name="X-Powered-By" />
           <add name="Access-Control-Allow-Origin" value="https://sitecore.mesh.uniform.app" />
       </customHeaders>
       </httpProtocol>
   </system.webServer>
   ```
3. Grant `sitecore\servicesAPI` user with access to site items,
   `/sitecore/system/Languages`, `/sitecore/templates` and
   `/sitecore/system/Uniform`

> **Tip:**
>
> We also recommend that the user `sitecore\servicesAPI` have
> permissions configured that explicitly deny access to the
> remaining parts of content tree. This is the account SSC uses by default
> for calls when an API key isn't specified.

## Step 2: Install Sitecore package

You must install Uniform Canvas for Sitecore on your Sitecore
instances.

> **Info:**
>
> Uniform provides a Sitecore installation package. Contact
> the [support team](mailto:support@uniform.dev)
> for this package, or if you need instructions for
> alternative installation options.

> **Tip:**
>
> Uniform Canvas for Sitecore must be installed on your
> content management (CM) and content delivery (CD) instances.

## Step 3: Configure Sitecore site

Canvas will read content from your Sitecore site, but some
configuration is needed. This configuration comes in the
form of something called _site configuration_. The Uniform
connector on your Sitecore instance uses the site configuration
to determine which Uniform functionality to enable. You must
create a site configuration for your web app.

> **Tip:**
>
> Site configuration can be created using Sitecore configuration files
> or Sitecore items. These instructions use Sitecore items.
> The config file approach is recommended for production
> environments, but using Sitecore items may be easier
> for some users during development and testing.

1. In Content Editor, navigate to **sitecore > system > Uniform > Site Configurations**.
2. Add the following item:

   - **Template**: `Site Configuration`
   - **Name**: `website`

   > **Info:**
   >
   > You use `website` here because this example uses the default
   > Sitecore site. If you have multiple sites on your Sitecore
   > server you must use the appropriate site name.
3. Add an item using the template `Configure Site`.
4. Select the child item `Configuration`.
5. Set the following field values:

   - **Inherits**: `website`

   > **Info:**
   >
   > You use `website` here because this example uses the default
   > Sitecore site. If you have multiple sites on your Sitecore
   > server you must use the appropriate site name.
6. Save the item.
7. Publish the site.

## Step 4: Configure cache purge

Uniform data types come with native support for edge caching. To ensure content remains current after publishing Sitecore items, configuring the data type purge service is necessary.

> **Info:**
>
> You can skip this step if you don't intend to utilize data types.

> **Tip:**
>
> Site configuration can be created using Sitecore configuration files
> or Sitecore items. These instructions use Sitecore items.
> The config file approach is recommended for production
> environments, but using Sitecore items may be easier
> for some users during development and testing.

> **Warning:**
>
> This functionality requires latest `v7.2-patch-2` version of the Uniform connector (Sitecore package named `Uniform Canvas v7.2.230517-1 Upgrade Package for UFS v7.2`) which needs to be installed on top of previously installed `v7.2` or `v7.2-patch-1` (Sitecore package named `Uniform Canvas v7.2.23XXXX for Sitecore 8.2.0-10.3.0`). If you use .NET SDK please make sure to update your dependencies per [packages.config](https://github.com/uniformdev/sitecore-canvas-dotnet-sdk/blob/main/Uniform.SDK/packages.config)

1. In Content Editor, navigate to **sitecore > system > Uniform > Site Configurations > website > Configuration**.

   > **Note:**
   >
   > You use `website` here because this example uses the default
   > Sitecore site. If you have multiple sites on your Sitecore
   > server you must use the appropriate site name.
2. Add an item using the template `Configure: Canvas Data Type Purge Service`
3. Set the following field values:

   - **ProjectId**: Uniform project id
   - **ApiKey**: Uniform API key
   - **Archetypes** _(optional)_: defines the list of archetypes to purge. Supported values: `sitecoreItem`, `sitecoreItemByPath`. Default: [`sitecoreItem`]

   > **Info:**
   >
   > If you intend to utilize **[Sitecore Item by Path](./sitecore/sitecore-data-types#sitecore-item-by-path)**, you need to register `sitecoreItem` and `sitecoreItemByPath` archetypes here.

   - **IncrementalEnabled** _(optional)_: `true` or `false`

   > **Warning:**
   >
   > You may need a developer to use incremental purge. [Read more](https://docs.uniform.app/docs/integrations/content/sitecore/use-model-builders#define-model-dependencies) how to define model dependencies.

   - **IncrementalEventsThreshold** _(optional)_: defines the number of item events to be processed incrementally; otherwise purge all caches.
   - **IncrementalItemsThreshold** _(optional)_: defines the number of unique items to be purged incrementally; otherwise purge all caches.
   - **IncrementalRequestsThreshold** _(optional)_: defines the maximum estimated number of incremental purge requests; otherwise purge all caches.
4. Save the item.
