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

> Create a target material with an optional layer stack

Creates a new target material. A target material is the intended layer stack and substrate for a sample. Provide the sample details and, optionally, the layers that make up the stack.

<ParamField body="sample" type="object" required>
  Details of the target material sample.

  <Expandable title="sample">
    <ParamField body="sample_name" type="string" required>
      Name for the target material sample
    </ParamField>

    <ParamField body="substrate" type="string" required>
      Substrate the layers are grown on (e.g., `Si`)
    </ParamField>

    <ParamField body="sample_metadata" type="object">
      Arbitrary metadata to attach to the sample
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="layers" type="array">
  Array of layer definitions that make up the stack. Each layer can include `composition_string`, `layer_id`, `orientation`, `space_group`, `mp_id`, and `element_dict`.
</ParamField>

## Response

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

<ResponseField name="sample_name" type="string">
  Name of the target material sample
</ResponseField>

<ResponseField name="substrate" type="string">
  Substrate the layers are grown on
</ResponseField>

<ResponseField name="sample_metadata" type="object">
  Metadata attached to the sample
</ResponseField>

<ResponseField name="detail_notes_id" type="string">
  ID of the linked detail note, if any
</ResponseField>

<ResponseField name="user_id" type="string">
  ID of the user who created the record
</ResponseField>

<ResponseField name="version" type="string">
  Schema version of the record
</ResponseField>

<ResponseField name="last_updated" type="string">
  ISO 8601 timestamp of the last update
</ResponseField>

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

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

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

<ResponseExample>
  ```json 200 theme={null}
  {
    "sample_id": 42,
    "sample_name": "BaTiO3 on Si",
    "substrate": "Si",
    "sample_metadata": {},
    "detail_notes_id": null,
    "user_id": "user_abc123",
    "version": "0.269.1",
    "last_updated": "2024-01-15T11:00:00Z"
  }
  ```
</ResponseExample>
