> ## Documentation Index
> Fetch the complete documentation index at: https://docs.atomscale.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Target Material Layer

> Add a single layer to a target material

Adds one layer to a target material's stack. The `layer_id` sets the layer position, and `sample_id` links the layer to its parent target material.

<ParamField body="layer_id" type="integer" required>
  Layer position within the stack
</ParamField>

<ParamField body="sample_id" type="integer">
  ID of the parent target material
</ParamField>

<ParamField body="composition_string" type="string">
  Chemical composition of the layer (e.g., `BaTiO3`)
</ParamField>

<ParamField body="element_dict" type="object">
  Element counts or fractions that make up the layer
</ParamField>

<ParamField body="orientation" type="string">
  Crystallographic orientation of the layer
</ParamField>

<ParamField body="space_group" type="string">
  Space group of the layer
</ParamField>

<ParamField body="mp_id" type="string">
  Materials Project ID for the layer material
</ParamField>

<ParamField body="id" type="integer">
  Explicit record ID for the layer
</ParamField>

## Response

<ResponseField name="id" type="integer">
  Layer record ID
</ResponseField>

<ResponseField name="layer_id" type="integer">
  Layer position within the stack
</ResponseField>

<ResponseField name="sample_id" type="integer">
  ID of the parent target material
</ResponseField>

<ResponseField name="composition_string" type="string">
  Chemical composition of the layer
</ResponseField>

<ResponseField name="element_dict" type="object">
  Element counts or fractions that make up the layer
</ResponseField>

<ResponseField name="orientation" type="string">
  Crystallographic orientation of the layer
</ResponseField>

<ResponseField name="space_group" type="string">
  Space group of the layer
</ResponseField>

<ResponseField name="mp_id" type="string">
  Materials Project ID for the layer material
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.atomscale.ai/target-materials/layers/" \
    -H "X-API-KEY: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "layer_id": 1,
      "sample_id": 42,
      "composition_string": "BaTiO3",
      "orientation": "001"
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.atomscale.ai/target-materials/layers/",
      headers={
          "X-API-KEY": "YOUR_API_KEY",
          "Content-Type": "application/json"
      },
      json={
          "layer_id": 1,
          "sample_id": 42,
          "composition_string": "BaTiO3",
          "orientation": "001"
      }
  )
  layer = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": 100,
    "layer_id": 1,
    "sample_id": 42,
    "composition_string": "BaTiO3",
    "element_dict": { "Ba": 1, "Ti": 1, "O": 3 },
    "orientation": "001",
    "space_group": "P4mm",
    "mp_id": "mp-5020"
  }
  ```
</ResponseExample>
