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

# Replace Target Material Layers

> Replace the full layer stack of a target material

Replaces a target material's entire layer stack. Send an array of layer objects, and they become the new stack for the target material.

<ParamField path="target_material_id" type="integer" required>
  ID of the target material whose layers you are replacing
</ParamField>

The request body is an array of layer objects. Each layer supports the fields below.

<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

Returns an empty response on success.

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

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

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

<ResponseExample>
  ```json 200 theme={null}
  {}
  ```
</ResponseExample>
