Working With Sandboxes | MuleSoft Documentation
# Working With Sandboxes
Use Salesforce sandbox organizations to test your portal in a sandbox environment under the same conditions as your production environment. With API Experience Hub, you can manage separate deployment environments for your API portal. You can connect to multiple Salesforce sandbox organizations and switch between them. Switching doesn’t impact the established connections with the Salesforce organization and Anypoint Platform. For example, if you switch from production to a sandbox, the connection with the production environment remains operational. The portal functions as it did before.
Manage Salesforce organizations from the **Manage your API portal** page by selecting sandbox environments that are available in the current Salesforce connection.
## Before You Begin
  1. Create a public group:
    1. Go to Salesforce > **Setup** > **Users** > **Public Groups**.
    2. Click **New** and enter a label and group name.
    3. From the **Available Members** list, select the members who you want to assign to the group. To move the selected members to the **Selected Members** list, click **Add**.
    4. Save your changes.
  2. Ensure that you have sandbox organizations already set up.
For more information about creating sandboxes, see Create a Sandbox in the Salesforce documentation.


Anypoint assets and applications aren’t copied to sandbox or production organizations.   
---  
## Manage Salesforce Organization Connections
  1. In the **Manage your API portal** page, click the connection control.
  2. Select an option:
     * To connect to a production organization, click **Connect production org** from the **Connected Salesforce Orgs** dialog.
The connection process restarts and you can to connect to the production organization.
     * To switch to another a sandbox for the connected production organization, click **Switch to this org** from the **Connected Salesforce Orgs** dialog.
     * To connect to a sandbox organization that isn’t connected, click **Connect**.
The connection process restarts and you can connect to the sandbox organization.
     * To connect to a new sandbox organization, click **Connect new sandbox org**.
The connection process restarts and you can connect to the new sandbox organization.
     * To switch to another sandbox organization, click **Switch to this org**.


## Manage Orphaned Sandboxes
Orphan sandboxes occur when you disconnect a production organization and child sandbox organizations are still connected. If you connect to a sandbox that isn’t a child of the production organization, the sandbox appears in the **More sandbox orgs** section of the **Connected Salesforce Organizations** dialog. You can still switch to this sandbox. A sandbox no longer appears as an orphan when you reconnect to the associated production organization.
## Manage Refreshed Sandbox Connections
Refreshing a sandbox updates the metadata from the source organization. If a sandbox refreshes after the production organization is connected, reconnect to switch to this sandbox.
If a sandbox refreshes before the production organization is connected, you can switch to this sandbox without reconnecting.
## Delete Sandbox Organizations
To delete a sandbox organizaton, see Delete a sandbox in the Salesforce documentation.
## Promoting a Sandbox to Production
After testing a portal in a sandbox environment and it’s is ready for production, deploy a subset of the Salesforce metadata using your CI/CD pipeline to production. Afterward, connect to the production instance with the subset of the Salesforce metadata to complete the installation and start curating APIs.
### Before You Begin
Ensure you have basic knowledge of the following:
  * Version control systems (VCS), for example, Git
  *   * CI/CD pipeline concepts
  * API portal created in a sandbox environment


### Promote a Sandbox to Production
Move the portal’s styling and customizations from the sandbox organization to the production organization:
  1. Create a Git repository to store the API Experience Hub metadata:
    1.     2. Clone it locally to your machine.
    3.     4. Create a manifest `package.xml` file in `./manifest`, using this example with your information:
Details
```
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
  <types>
    <members>homeroCompanyLogo</members>
    <members>homeroLoginBackground</members>
    <members>minionHomeBanner</members>
    <members>minionPageBanner</members>
    <name>ContentAsset</name>
  </types>
  <types>
    <members>API_Experience_Hub1_banner</members>
    <members>API_Experience_Hub1_logo</members>
    <name>StaticResource</name>
  </types>
  <types>
    <members>AEH</members>
    <members>AEH/API_Experience_Hub1_logo</members>
    <name>Document</name>
  </types>
  <types>
    <members>AEH</members>
    <members>AEH/ChangedPasswordEmailTemplate</members>
    <members>AEH/ForgotPasswordEmailTemplate</members>
    <members>AEH/NewMemberWelcomeEmailTemplate</members>
    <members>AEH/RejectedMemberEmailTemplate</members>
    <name>EmailTemplate</name>
  </types>
  <types>
    <members>AEHLetterhead</members>
    <name>Letterhead</name>
  </types>
  <types>
    <members>Anypoint</members>
    <members>AnypointDevx</members>
    <members>AnypointEu</members>
    <members>AnypointQax</members>
    <members>AnypointStgx</members>
    <members>ExchangeAssetIcons</members>
    <members>ExchangeAssetIconsDevx</members>
    <members>ExchangeAssetIconsEu</members>
    <members>ExchangeAssetIconsQax</members>
    <members>ExchangeAssetIconsStgx</members>
    <members>GStaticFonts</members>
    <members>GoogleFonts</members>
    <members>SegmentAPI</members>
    <members>SegmentCDN</members>
    <name>CspTrustedSite</name>
  </types>
  <types>
    <members>Anypoint</members>
    <members>AnypointDevx</members>
    <members>AnypointEu</members>
    <members>AnypointQax</members>
    <members>AnypointStgx</members>
    <members>ExchangeAssetIcons</members>
    <members>ExchangeAssetIconsDevx</members>
    <members>ExchangeAssetIconsEu</members>
    <members>ExchangeAssetIconsQax</members>
    <members>ExchangeAssetIconsStgx</members>
    <members>SegmentAPI</members>
    <name>RemoteSiteSetting</name>
  </types>
  <!--
  <types>
    <members>ExperienceBundle</members>
    <members>Communities</members>
    <name>Settings</name>
  </types>
  -->
  <types>
    <members>API_Experience_Hub_Manage_Networks</members>
    <name>PermissionSet</name>
  </types>
  <types>
    <members>API Experience Hub</members>
    <name>Network</name>
  </types>
  <types>
    <members>HTTP_API_Audience</members>
    <name>Audience</name>
  </types>
  <types>
    <members>API_Experience_Hub</members>
    <name>CustomSite</name>
  </types>
  <types>
    <members>API_Experience_Hub1</members>
    <name>ExperienceBundle</name>
  </types>
  <types>
    <members>AEH_Default_Navigation</members>
    <members>AEH_Default_User_Navigation</members>
    <name>NavigationMenu</name>
  </types>
  <types>
    <members>cbAPI_Experience_Hub</members>
    <name>NetworkBranding</name>
  </types>
  <!--
  <types>
    <members>API Experience Hub Member User</members>
    <name>Profile</name>
  </types>
  -->
  <version>60.0</version>
</Package>
```

    5. In a VCS, create a development branch.
    6. Download the metadata using the manifest created from the Salesforce sandbox organization.
  2. Retrieve the metadata from the Salesforce sandbox organization using Salesforce CLI commands:
    1. Log in to the Salesforce sandbox organization:
```
sf auth web login --instance-url=https://<SANBOX-INSTANCE_URL> --alias sandboxOrg
```

    2. Edit the `manifest/package.xml` file before retrieving the metadata from the sandbox organization.
Your sandbox organization can contain metadata from multiple products because it’s a copy of the Salesforce production organization. API Experience Hub is a subset of the sandbox organization specified in the `manifest/package.xml` file created when you created the Git repository in a previous step.
    3. If the portal contains branding images, add them in the `ContentAsset` section of the `manifest/package.xml`. For example:
```
...
<types>
  <members>homeroCompanyLogo</members>
  <members>homeroLoginBackground</members>
  <members>minionHomeBanner</members>
  <members>minionPageBanner</members>
  <name>ContentAsset</name>
</types>
...
```

    4. Review the metadata and retrieve it by running this command:
```
sf project retrieve start --manifest ./manifest/package.xml --target-org sandboxOrg
```
5. In a VCS, create a development branch.
    6. Download the metadata using the manifest created from the Salesforce sandbox organization.
  2. Retrieve the metadata from the Salesforce sandbox organization using Salesforce CLI commands:
    1. Log in to the Salesforce sandbox organization:
```
sf auth web login --instance-url=https://<SANBOX-INSTANCE_URL> --alias sandboxOrg
```

    2. Edit the `manifest/package.xml` file before retrieving the metadata from the sandbox organization.
Your sandbox organization can contain metadata from multiple products because it’s a copy of the Salesforce production organization. API Experience Hub is a subset of the sandbox organization specified in the `manifest/package.xml` file created when you created the Git repository in a previous step.
    3. If the portal contains branding images, add them in the `ContentAsset` section of the `manifest/package.xml`. For example:
```
...
<types>
  <members>homeroCompanyLogo</members>
  <members>homeroLoginBackground</members>
  <members>minionHomeBanner</members>
  <members>minionPageBanner</members>
  <name>ContentAsset</name>
</types>
...
```

    4. Review the metadata and retrieve it by running this command:
```
sf project retrieve start --manifest ./manifest/package.xml --target-org sandboxOrg
```

    5. Confirm the metadata and commit all the metadata changes into the Git repository, or modify the `manifest/package.xml` and repeat the process if some metadata is missing or unnecessary.
  3. Move the API Experience Hub portal from the sandbox organization to the production organization:
    1. Log in to the production organization:
```
sf auth web login --instance-url=https://<ENTERPRISE-INSTANCE_URL> --alias productionOrg
```

    2. Install the package in production if it’s not installed already.
Before installing the API Experience Hub Manage package in your production organization, get the managed package version ID from the `SubscriberPackageVersionId` field that’s installed in the sandbox organization.
      1. Run the following command to get the managed package version ID. The `SubscriberPackageVersionId` field from the API Experience Hub managed package begins with `04t`:
```
sf package installed list --target-org sandboxOrg --json
```

      2. Install the API Experience Hub managed package in the production organization:
```
sf package install --package 04t... --target-org productionOrg --no-prompt --wait 30
```

    3. Deploy the API Experience Hub metadata to the production organization using Jenkins or other CI/CD tools, for example:
```
sf project deploy start --manifest=manifest/package.xml --target-org productionOrg
```

All configurations deploy in the production organization and you’re ready to connect this organization with API Experience Hub.
  4. Configure API Experience Hub in the production organization:
    1. Navigate to Anypoint Platform, enter your username and password, and click **Sign in**.
    2. From Anypoint Platform, select **API Experience Hub**.
    3. Connect the Salesforce production organization (Enterprise organization).
    4. Click **Use existing portal** to reuse the portal that already exists.
    5. From the **API management** page, add assets to the portal.
    6. Click **Preview and publish your portal** to preview the portal, and then click **Publish**.


## See Also
  *   * Deploy an Experience Cloud Site from Sandbox to Production
  * Maintaining User References
  *   * Setting Up the API Portal