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

# Import Templates V1

> Bulk template import with explicit conflict policy. on_conflict=error is all-or-nothing: any pre-existing name aborts the whole import before any DB writes…

Bulk template import with explicit conflict policy.

`on_conflict=error` is all-or-nothing: any pre-existing name aborts
the whole import before any DB writes land. The `skip` and `replace`
modes apply per-row and report outcomes individually.

Built-in name collisions are rejected per-row regardless of the
conflict policy — you can never shadow a platform built-in.

### Request body

`ImportTemplatesRequest`

<ParamField body="templates" type="CreateTemplateRequest[]" required>
  List of templates to import (1..50). Each entry follows the `POST /templates` schema.
</ParamField>

<ParamField body="on_conflict" type="string">
  What to do when a template name already exists for the tenant: `skip` keeps the existing row and reports it in the response; `replace` overwrites description+defaults; `error` rejects the whole import (no partial writes).
</ParamField>

### Response

`ImportTemplatesResponse`

<ResponseField name="created" type="integer" required />

<ResponseField name="skipped" type="integer" required />

<ResponseField name="replaced" type="integer" required />

<ResponseField name="errored" type="integer" required />

<ResponseField name="rows" type="ImportTemplateRow[]" required>
  <Expandable title="ImportTemplateRow">
    <ResponseField name="name" type="string" required />

    <ResponseField name="action" type="string" required />

    <ResponseField name="error" type="string,null" />
  </Expandable>
</ResponseField>

### Status codes

| Code  | Meaning             |
| ----- | ------------------- |
| `200` | Successful Response |
| `422` | Validation Error    |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.computer.stateset.app/api/v1/templates/import' \
    --header 'X-API-Key: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "templates": [
      {
        "name": "Two-Person Tent",
        "description": "Two-person tent, green — replacement for damaged pole set.",
        "defaults": {}
      }
    ],
    "on_conflict": "skip"
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "created": 1,
    "skipped": 1,
    "replaced": 1,
    "errored": 1,
    "rows": [
      {
        "name": "Two-Person Tent",
        "action": "created",
        "error": "string"
      }
    ]
  }
  ```
</ResponseExample>
