# Create a site

[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/create-a-site-template-for-the-xm-cloud-dashboard.html). Every site belongs to a [site collection](https://doc.sitecore.com/xmc/en/users/xm-cloud/create-a-site-collection.html). You can either create a site inside an existing collection or create a new one.
It is also possible to create a site by duplicating a site.

Endpoint: POST /api/v1/sites
Version: v1
Security: Bearer

## Security:

  - `Bearer` (unknown)
    http Bearer

## Query parameters:

  - `environmentId` (string)
    The identifier of the environment

## Request body:

  - `application/json, text/json, application/*+json` (unknown)
    Input model

## Request fields (application/json):

  - `siteName` (string, required)
    The name of the site.
Example value: skate-park
    Example: skate-park

  - `displayName` (string)
    The display name for the site.
Example value: Skate Park Site
    Example: Skate Park Site

  - `templateId` (string, required)
    The ID of the template used to create the site. If you don't know the template ID, first [retrieve site templates](#tag/Sites/operation/GetTemplates).
Example value: 5aae1eeaea2440bf96f11f43da82c77b
    Example: 5aae1eeaea2440bf96f11f43da82c77b

  - `collectionId` (string)
    The ID of the collection you want the new site to belong to. If you don't know the collection ID, first [retrieve collections](#tag/Collections/operation/Get).
Required if Sitecore.XmApps.Sites.Models.REST.NewSiteInput.CollectionName is not provided. If left empty, you must provide collectionName instead and a new collection will be created along with the newly created site.
If both collectionId and collectionName are provided, collectionName will be ignored.
Example value: 5aae1eeaea2440bf96f11f43da82c77b
    Example: 5aae1eeaea2440bf96f11f43da82c77b

  - `language` (string, required)
    The language for the site. If you do not know what languages are available in the environment, first [retrieve the list of languages](#tag/Languages/operation/Get).
If the language you want is not available in the environment, [add the language](#tag/Languages/operation/Create) first.
Example value: en
    Example: en

  - `languages` (array)
    The list of supported languages for the site.
Example value: [
"en",
"da"
]
    Example: ["en","da"]

  - `hostName` (string)
    Optional hostname for the new site. Default value: *
Example value: dev.skate-park.com
    Example: dev.skate-park.com

  - `description` (string)
    Optional text that provides a meaningful description of the site.
Example value: New site for Brand A in English-speaking countries.
    Example: New site for Brand A in English-speaking countries.

  - `collectionName` (string)
    The name of the new collection you want the new site to belong to.
Required if Sitecore.XmApps.Sites.Models.REST.NewSiteInput.CollectionId is not provided. If left empty, you must provide collectionId of an existing collection you want the new site to belong to.
If both collectionId and collectionName are provided, collectionName will be ignored.
Example value: Brand A
    Example: Brand A

  - `collectionDisplayName` (string)
    The display name for the collection.
Example value: Skate Park Site
    Example: Skate Park Site

  - `collectionDescription` (string)
    If you want to create a new site collection while creating a new site, you can provide a collection description.
Example value: Sample description for the site collection containing Sites for Brand A
    Example: Sample description for the site collection containing Sites for Brand A

  - `posMappings` (array)
    The [site identifier](https://doc.sitecore.com/xmc/en/users/xm-cloud/manage-personalization-and-analytics-for-sites.html) for the site.
This identifier lets you control analytics and personalization for the site.

  - `posMappings.name` (string, required)
    The name of the analytics identifier.
Example value: skate-park
    Example: skate-park

  - `posMappings.language` (string, required)
    The language for the analytics identifier.
Example value: en
    Example: en

## Response 200:

  - `200` (unknown)
    Success

## Response 200 fields (application/json):

  - `handle` (string)

## Response 400:

  - `400` (unknown)
    Bad request

## Response 400 fields (application/json):

  - `type` (string)
    The type of the error response entity.

  - `title` (string)
    The title of the error response entity.

  - `status` (integer)
    The response status code.

  - `detail` (string)
    A detailed explanation, specific to this occurrence of the problem.

  - `instance` (string)
    If available, a URI reference that identifies the specific occurrence of the problem.

