# Create a component

Creates a component.

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

## Security:

  - `Bearer` (unknown)
    http Bearer

## Query parameters:

  - `environmentId` (string)
    The environment identifier.

## Request body:

  - `application/json, text/json, application/*+json` (unknown)
    Details of the component to create.

## Request fields (application/json):

  - `name` (string, required)
    The component name. 
Letters, numbers, spaces, underscores, and hyphens only.
    Example: Promo

  - `displayName` (string)
    The component display name.
    Example: Promo

  - `category` (object, required)
    Details of the component category.

  - `category.id` (string)
    The category identifier.
    Example: ae070691-099d-4081-856c-4c4a7e3543df

  - `category.name` (string)
    The category name. Letters, numbers, spaces, underscores, and hyphens only.
    Example: Page Content

  - `iconUrl` (string)
    The component icon URL.
    Example: Office/32x32/window_dialog.png

  - `modelId` (string)
    The content type ID.
    Example: dfed4457-d760-457a-bec1-c0dccdc44381

  - `renderingParameters` (array)
    The component rendering parameters.

  - `renderingParameters.name` (string, required)
    The parameter name.
    Example: Promo

  - `renderingParameters.displayName` (string)
    The parameter display name.
    Example: Promo

  - `renderingParameters.editingControl` (object, required)
    The rendering parameter editing control input.

  - `renderingParameters.editingControl.type` (string)
    The control type.
    Example: Single-Line Text

  - `renderingParameters.editingControl.value` (string)
    The control value.
    Example: Placeholder text

  - `settings` (object)
    The component settings.
    Example: {"IsRenderingsWithDynamicPlaceholders":"true","RandomNumber":"10"}

  - `description` (string)
    The component description.
    Example: This is a promo component.

  - `availability` (object)
    Represents the availability constraints for a component, specifying which sites, placeholders, and page models the component can be used with.

  - `availability.sites` (array)
    The list of sites where the component will be assigned.
    Example: ["4f2d7c8b9e1a4f0d8f3c2b176a4e9d22","c1378a9fe2bd4e56a1c4d9f87b33a6c4"]

  - `availability.placeholders` (array)
    The list of placeholders where the component can be used.
    Example: ["4f2d7c8b9e1a4f0d8f3c2b176a4e9d22","c1378a9fe2bd4e56a1c4d9f87b33a6c4"]

  - `availability.pageModels` (array)
    The list of allowed page models.
    Example: ["4f2d7c8b9e1a4f0d8f3c2b176a4e9d22","c1378a9fe2bd4e56a1c4d9f87b33a6c4"]

## Response 201:

  - `201` (unknown)
    Successful operation. The variants array in the response body will be empty on create as no variants exist yet

## Response 201 fields (application/json):

  - `id` (string)
    The identifier of the component.
    Example: 2492bac4-da07-4c86-87f0-9873d40e2276

  - `name` (string)
    The name of the component.
    Example: Hero Banner

  - `displayName` (string)
    The component displayName.
    Example: Banner

  - `systemName` (string)
    The component system name.
    Example: HeroBanner

  - `description` (string)
    The component description.
    Example: A promo component is a content block designed to showcase promotions using a combination of text and visuals

  - `category` (object)

  - `category.id` (string)
    The category identifier
    Example: ae070691-099d-4081-856c-4c4a7e3543df

  - `category.name` (string)
    The category name
    Example: Page Content

  - `category.path` (string)
    The path to category item
    Example: /sitecore/content/Tenant/Site/Home/Categories/Page-Content

  - `icon` (string)
    The component icon URL.
    Example: https://xmc-instance.sitecore-staging.cloud/-/icon/SXA_MDI/16x16/Promo.png

  - `datasourceTemplateField` (string)
    Datasource template item path.
    Example: /sitecore/templates/Feature/Promos

  - `modelId` (string)
    The content type identifier.
    Example: /sitecore/templates/Feature/Promos

  - `renderingParameters` (object)
    The component rendering parameters.
    Example: {"ButtonText":"Click me!"}

  - `settings` (object)
    The component settings.
    Example: {"IsRenderingsWithDynamicPlaceholders":"true","RandomNumber":"10"}

  - `variants` (array)
    The component variants.
    Example: [{"name":"Default","id":"2492bac4-da07-4c86-87f0-9873d40e2276","siteId":"497f6eca-6276-4993-bfeb-53cbbbba6f08"},{"name":"Advanced","id":"2f34355e-c52d-450e-b1b9-d4e9cbe64af2","siteId":"497f6eca-6276-4…

  - `variants.id` (string)
    The component variant identifier.
    Example: Default

  - `variants.name` (string)
    The component variant name.
    Example: Default

  - `variants.displayName` (string)
    The component variant display name.
    Example: Default

  - `variants.description` (string)
    The component variant description.
    Example: Sample variant description

  - `variants.siteName` (string)
    The site name.
    Example: skate-park

  - `variants.siteId` (string)
    The site identifier.
    Example: 497f6eca-6276-4993-bfeb-53cbbbba6f08

  - `variants.attributes` (object)
    The component variant attributes.

  - `system` (object)

  - `system.created` (string)
    Time of creation.
    Example: 2023-01-01T00:00:00Z

  - `system.createdBy` (string)
    Name of creator.
    Example: sitecore admin

  - `system.updated` (string)
    Time of last update.
    Example: 2023-01-01T00:00:00Z

  - `system.updatedBy` (string)
    The last  updater.
    Example: sitecore admin

  - `type` (string)
    Specifies the type of a component based on its rendering template.
    Enum: "Code", "Hosted"

## Response 400:

  - `400` (unknown)
    One or more validation errors occurred

## 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.

## Response 401:

  - `401` (unknown)
    Unauthorized

## Response 401 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.

## Response 404:

  - `404` (unknown)
    Provided content type not found

## Response 404 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.

