# Sites API

Use the Sites API for managing sites, site collections and languages in the XM Apps system.

This API lets you interact with:
- The Site Collection object. Use a site collection to group together related sites that share the same resources.
- The Site object. The site object is the core entity that represents a website in the customer portfolio.
- The Language object. The language object is used to manage the languages available to a tenant and site.
- The Job object. The job object is used to manage running background jobs.

Note the following:
   - All API requests are made in your production environment.

 For more information, see the [official SitecoreAI developer documentation](https://doc.sitecore.com/xmc/en/developers/xm-cloud/getting-started-with-xm-cloud.html).

# Authorization
To authorize your requests, use environment automation client credentials and generate a JSON Web Token (JWT).

Note: To create client credentials, you must be an [Organization Admin](https://doc.sitecore.com/portal/en/developers/sitecore-cloud-portal/roles.html) or Organization Owner.

## Create an automation client
 1. In the Sitecore Cloud Portal, open SitecoreAI Deploy.
 2. Click **Credentials** > **Environment** > **Create credentials** > **Automation**.
 3. Fill out the automation client details, then click **Create**.
 4. Copy the client ID and the client secret because you won't be able to view them again in SitecoreAI Deploy. You'll use them to request a JWT.

## Request a JWT

Run the following cURL command to request a JWT. Replace the placeholder values with your client ID and client secret.
```curl
  curl -X POST 'https://auth.sitecorecloud.io/oauth/token' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'client_id={YOUR_CLIENT_ID}' \
  --data-urlencode 'client_secret={YOUR_CLIENT_SECRET}' \
  --data-urlencode 'grant_type=client_credentials' \
  --data-urlencode 'audience=https://api.sitecorecloud.io'
```

In the response, the `access_token` key contains the JWT:

```json
  {
    "access_token": "{YOUR_JWT}",
    "scope": "xmcloud.cm:admin",
    "expires_in": 86400,
    "token_type": "Bearer"
  }
```

The JWT expires in 24 hours. If your requests unexpectedly return a response with status `401 Unauthorized`, request a new JWT by repeating this `POST` request.

We recommend that you cache the JWT for 24 hours to avoid repeating this `POST` request while the JWT is still valid.

## Include the JWT in the request header

You can now start making REST API requests. You must include the JWT in the request header of every request. For example:
  ```curl
  curl -X GET '{YOUR_BASE_URL}/...' \
  -H 'Authorization: Bearer {YOUR_JWT}' \
  -H 'Accept: application/json'
  ```

Version: v1
License: Apache 2.0

Metadata:
  - product: SitecoreAI

## Servers

Production server
```
https://xmapps-api.sitecorecloud.io
```

## Security

### Bearer

Enter your bearer token in the text input below.

Type: http
Scheme: Bearer

## Download OpenAPI description

 - [Sites API](https://api-docs.sitecore.com/_bundle/sai/sites-api/index.yaml)

## Jobs

 - [GET /api/v1/jobs](https://api-docs.sitecore.com/sai/sites-api/jobs/listjobs.md): Fetches information about background jobs. Returns empty array if no jobs are running.
 - [GET /api/v1/jobs/{jobHandle}/status](https://api-docs.sitecore.com/sai/sites-api/jobs/retrievejob.md): Fetches information about a background job.
## Collections

 - [GET /api/v1/collections](https://api-docs.sitecore.com/sai/sites-api/collections/listcollections.md): Fetches the list of site collections in the environment, with associated details.
 - [POST /api/v1/collections](https://api-docs.sitecore.com/sai/sites-api/collections/createcollection.md): Creates a collection by specifying a name and, optionally, a display name and description.
 - [GET /api/v1/collections/{collectionId}](https://api-docs.sitecore.com/sai/sites-api/collections/retrievecollection.md): Fetches information about a site collection.
 - [PATCH /api/v1/collections/{collectionId}](https://api-docs.sitecore.com/sai/sites-api/collections/updatecollection.md): Updates the display name and the description of the site collection. To change the system name of a collection, see [rename a site collection](#tag/Collections/operation/Rename).
 - [DELETE /api/v1/collections/{collectionId}](https://api-docs.sitecore.com/sai/sites-api/collections/deletecollection.md): Deletes a site collection, including sites in that collection.
 - [POST /api/v1/collections/{collectionId}/rename](https://api-docs.sitecore.com/sai/sites-api/collections/renamecollection.md): Changes the system name of a site collection.
 - [POST /api/v1/collections/sort](https://api-docs.sitecore.com/sai/sites-api/collections/sortcollections.md): By assigning a sort value to site collection IDs, you can use this endpoint to apply an order by which collections are sorted in the Sites user interface and in Content Editor. The lower the sort valu
 - [POST /api/v1/collections/name/validate](https://api-docs.sitecore.com/sai/sites-api/collections/validatecollectionname.md): Validates a site collection name to ensure it meets the required criteria. The validations applied to the collection name: - Is a string and can't be null. - Is unique. - The length of the name is a m
 - [GET /api/v1/collections/{collectionId}/sites](https://api-docs.sitecore.com/sai/sites-api/collections/listcollectionsites.md): Fetches a list of sites in a site collection.
## Favorites

 - [GET /api/v1/favorites/sites](https://api-docs.sitecore.com/sai/sites-api/favorites/getfavoritesites.md): Fetches a list of your favorite sites
 - [POST /api/v1/favorites/sites](https://api-docs.sitecore.com/sai/sites-api/favorites/addfavoritesite.md): Adds a site to your list of favorites
 - [GET /api/v1/favorites/sitetemplates](https://api-docs.sitecore.com/sai/sites-api/favorites/getfavoritesitetemplates.md): Fetches a list of your favorite site templates
 - [POST /api/v1/favorites/sitetemplates](https://api-docs.sitecore.com/sai/sites-api/favorites/addfavoritesitetemplate.md): Adds a site template to your list of favorites
 - [DELETE /api/v1/favorites/sites/{siteId}](https://api-docs.sitecore.com/sai/sites-api/favorites/removefavoritesite.md): Removes a site from your list of favorites
 - [DELETE /api/v1/favorites/sitetemplates/{siteTemplateId}](https://api-docs.sitecore.com/sai/sites-api/favorites/removefavoritesitetemplate.md): Removes a site template from your list of favorites
## Languages

 - [GET /api/v1/languages](https://api-docs.sitecore.com/sai/sites-api/languages/listlanguages.md): Retrieves the list of languages added to the environment.
 - [POST /api/v1/languages](https://api-docs.sitecore.com/sai/sites-api/languages/createlanguage.md): Adds a language to your environment, so you can create content and build websites in that language. You can choose from the language supported by SitecoreAI. If you do not know the language code of th
 - [GET /api/v1/languages/supported](https://api-docs.sitecore.com/sai/sites-api/languages/listsupportedlanguages.md): Retrieves the list of languages supported by SitecoreAI, and associated data.
 - [PATCH /api/v1/languages/{isoCode}](https://api-docs.sitecore.com/sai/sites-api/languages/updatelanguage.md): Updates a [language supported](https://doc.sitecore.com/xmc/en/users/xm-cloud/add-a-language-to-your-xm-cloud-environment.html#add-a-custom-language) by SitecoreAI. To update a language, you must prov
 - [DELETE /api/v1/languages/{isoCode}](https://api-docs.sitecore.com/sai/sites-api/languages/deletelanguage.md): Deletes a language from the SitecoreAI environment. To delete a language from the system, you must provide the regional ISO code of the language. If you do not know the ISO code of the lan
## Editor Profiles

 - [GET /api/ui/v1/editorprofiles](https://api-docs.sitecore.com/sai/sites-api/editor-profiles/listprofiles.md): Fetches a list of all profiles in the environment, with associated details.
 - [POST /api/ui/v1/editorprofiles](https://api-docs.sitecore.com/sai/sites-api/editor-profiles/createprofile.md): Creates a new profile in the environment.
 - [GET /api/ui/v1/editorprofiles/{id}](https://api-docs.sitecore.com/sai/sites-api/editor-profiles/getprofile.md): Fetches the details of a profile.
 - [PATCH /api/ui/v1/editorprofiles/{id}](https://api-docs.sitecore.com/sai/sites-api/editor-profiles/updateprofile.md): Updates the properties of a profile.
 - [DELETE /api/ui/v1/editorprofiles/{id}](https://api-docs.sitecore.com/sai/sites-api/editor-profiles/deleteprofile.md): Deletes a profile, including the toolbar configuration associated with that profile.
## Sites

 - [GET /api/v1/sites](https://api-docs.sitecore.com/sai/sites-api/sites/listsites.md): Fetches the list of sites in the environment, with associated details.
 - [POST /api/v1/sites](https://api-docs.sitecore.com/sai/sites-api/sites/createsite.md): [Creates a site](https://doc.sitecore.com/xmc/en/users/xm-cloud/create-a-site.html) for the environment. Sites are created using [site templates](https://doc.sitecore.com/xmc/en/developers/xm-cloud/c
 - [GET /api/v1/sites/{siteId}](https://api-docs.sitecore.com/sai/sites-api/sites/retrievesite.md): Fetches information about a site.
 - [PATCH /api/v1/sites/{siteId}](https://api-docs.sitecore.com/sai/sites-api/sites/updatesite.md): Updates various parameters of a site. To change the name of a site, see [rename a site](#tag/Sites/operation/Rename).
 - [DELETE /api/v1/sites/{siteId}](https://api-docs.sitecore.com/sai/sites-api/sites/deletesite.md): Deletes a site, including its pages, settings, media files, data sources, presentation elements, dictionaries, components, variants, and page designs. Everyone in the environment will lose access to t
 - [POST /api/v1/sites/{siteId}/copy](https://api-docs.sitecore.com/sai/sites-api/sites/copysite.md): You can create a site by duplicating an existing one. When you duplicate a site, its content items (such as pages and images, folder structure, and links) are copied. Most of the settings are also cop
 - [POST /api/v1/sites/{siteId}/rename](https://api-docs.sitecore.com/sai/sites-api/sites/renamesite.md): Changes the system name of a site.
 - [POST /api/v1/sites/sort](https://api-docs.sitecore.com/sai/sites-api/sites/sortsites.md): By assigning a sort value to site IDs, you can use this endpoint to apply an order by which sites are sorted in the Sites user interface and in Content Editor. The lower the sort value, the higher the
 - [POST /api/v1/sites/name/validate](https://api-docs.sitecore.com/sai/sites-api/sites/validatesitename.md): Validates a site name to ensure it meets the required criteria. The validations applied to the site name: - Is a string and can't be null. - Is unique. - The length of the name is a maximum of 50 char
 - [GET /api/v1/sites/analytics-identifiers/{analyticsIdentifier}](https://api-docs.sitecore.com/sai/sites-api/sites/listtrackedsites.md): Fetches a list of sites that use an [analytics identifier](https://doc.sitecore.com/xmc/en/users/xm-cloud/manage-personalization-and-analytics-for-sites.html).
 - [POST /api/v1/sites/analytics-identifiers/{analyticsIdentifier}/detach](https://api-docs.sitecore.com/sai/sites-api/sites/detachanalyticsidentifier.md): Removes the analytics identifiers from one or more sites.
 - [GET /api/v1/sites/{siteId}/hierarchy](https://api-docs.sitecore.com/sai/sites-api/sites/retrievesitehierarchy.md): Fetches hierarchy information about the main page of a site, including its children, ancestors, and siblings.
 - [GET /api/v1/sites/{siteId}/hierarchy/{pageId}](https://api-docs.sitecore.com/sai/sites-api/sites/retrievepagehierarchy.md): Fetches hierarchy information about a page, including its children, ancestors, and siblings.
 - [GET /api/v1/sites/{siteId}/hierarchy/{pageId}/ancestors](https://api-docs.sitecore.com/sai/sites-api/sites/listpageancestors.md): Fetches information about the ancestors of a page.
 - [GET /api/v1/sites/{siteId}/hierarchy/{pageId}/children](https://api-docs.sitecore.com/sai/sites-api/sites/listpagechildren.md): Fetches information about the children of a page.
 - [GET /api/v1/sites/{siteId}/hosts](https://api-docs.sitecore.com/sai/sites-api/sites/listhosts.md): Retrieves the list of hosts for a site.
 - [POST /api/v1/sites/{siteId}/hosts](https://api-docs.sitecore.com/sai/sites-api/sites/createhost.md): Creates a host for a site.
 - [GET /api/v1/sites/{siteId}/hosts/{hostId}](https://api-docs.sitecore.com/sai/sites-api/sites/retrievehost.md): Fetches details about a site host.
 - [PATCH /api/v1/sites/{siteId}/hosts/{hostId}](https://api-docs.sitecore.com/sai/sites-api/sites/updatehost.md): Modifies the properties of a host.
 - [DELETE /api/v1/sites/{siteId}/hosts/{hostId}](https://api-docs.sitecore.com/sai/sites-api/sites/deletehost.md): Deletes a site using a hostID. Deletes a site, including its pages, settings, media files, data sources, presentation elements, dictionaries, components, variants, and page designs. Everyone in the en
 - [GET /api/v1/sites/{siteId}/editinghosts](https://api-docs.sitecore.com/sai/sites-api/sites/geteditinghosts.md): Fetches a list of editing hosts for a site.
 - [GET /api/v1/sites/templates](https://api-docs.sitecore.com/sai/sites-api/sites/listsitetemplates.md): Gets the site templates available in the environment that can be used for creating sites. Learn more about [site templates](https://doc.sitecore.com/xmc/en/developers/xm-cloud/create-a-site-template-f
 - [POST /api/v1/sites/{siteId}/upload-thumbnail](https://api-docs.sitecore.com/sai/sites-api/sites/uploadsitethumbnail.md): Uploads an image to be used as [thumbnail](https://doc.sitecore.com/xmc/en/users/ea-xm-cloud/manage-sites.html#manage-general-site-settings) for a site when it is displayed in the [SitecoreAI Sites ap
 - [GET /api/v1/sites/{siteId}/statistics/localization](https://api-docs.sitecore.com/sai/sites-api/sites/retrievelocalizationstatistics.md): Fetches localization statistics for a site, including the number of pages in each locale.
 - [GET /api/v1/sites/{siteId}/configuration/sitemap](https://api-docs.sitecore.com/sai/sites-api/sites/retrievesitemapconfiguration.md): Fetches a [sitemap](https://doc.sitecore.com/xmc/en/developers/xm-cloud/configure-a-sitemap.html) configuration.
 - [PATCH /api/v1/sites/{siteId}/configuration/sitemap](https://api-docs.sitecore.com/sai/sites-api/sites/updatesitemapconfiguration.md): Updates a [sitemap](https://doc.sitecore.com/xmc/en/developers/xm-cloud/configure-a-sitemap.html) configuration.
 - [GET /api/v1/sites/{siteId}/statistics/workflow](https://api-docs.sitecore.com/sai/sites-api/sites/retrieveworkflowstatistics.md): Fetches the workflows defined for a site, their states, and the number of pages in each state.
 - [POST /api/v1/sites/{siteId}/translate](https://api-docs.sitecore.com/sai/sites-api/sites/translatesite.md): Creates new translated versions of all items for a specific site using the Stream API.
 - [GET /api/v1/sites/{siteId}/renderinghosts](https://api-docs.sitecore.com/sai/sites-api/sites/getrenderinghosts.md): **Deprecated:** Use GetEditingHosts endpoint instead. Fetches a list of rendering hosts for a site.
