---
title: Setup
description: The Setup API imports one whole list — machines, tools, subcontractors, stock formats, prices or cutting data: preview what each row does, then write that plan.
---

# Setup

The Setup API imports one whole list — machines, tools, subcontractors, stock formats, prices or cutting data: preview what each row does, then write that plan.

> **Auto-generated** from the public OpenAPI spec — this page never
> drifts from the running API. Base URL `https://api.arcnm.io`. Authenticate with
> the `X-API-Key` header (see [Authentication](../authentication.md)).

## Write exactly the previewed plan of one list.

`POST /api/v1/setup/imports`

Send the same list as the preview with its `plan_digest` as `expected_plan_digest`. The list is planned again and written only when the plan is unchanged; otherwise nothing is written and the answer is `409 plan_changed`. Each row is written through the platform's own single-row route, so a row the platform refuses is reported `failed` with its reason and the other rows are still written. Free; new calculations in the environment price with it.

**Request body** (`application/json`)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `csv` | string | no | The list as CSV text with a header row (comma, semicolon or tab separated), instead of rows. |
| `data_source_id` | string | no | A confirmed .csv or .xlsx upload holding the list (POST /uploads/presign, then POST /uploads/confirm), read as the file has it. Needs the uploads:read scope. |
| `environment_id` | string | no | The costing environment to write to; your default environment when omitted. Stock formats and cutting data belong to the organization and ignore it. |
| `expected_plan_digest` | string | yes | The plan_digest of the preview being committed. |
| `kind` | `machines` \| `tools` \| `material_prices` \| `subcontractors` \| `subcontract_prices` \| `stock_formats` \| `cutting_data` | yes | Which list this is: machines, tools, material_prices (per kg per grade), subcontractors, subcontract_prices (per bought-in operation), stock_formats or cutting_data (your own rows on your tools). |
| `rows` | object[] | no | The list as JSON objects, one per row, keyed by column name. machines: name, class, hourly_rate_eur [, operator_eur_per_h, envelope_x_mm, envelope_y_mm, envelope_z_mm, spindle_power_kw, priority]. tools: name, kind [, diameter_mm, teeth, cutting_material, price_eur, tool_life_min, vendor, item_no]. material_prices: material (number or designation), price_per_kg [, valid_from]. subcontractors: name [, operations, region, lead_time_days, notes]. subcontract_prices: operation (e.g. heat_treatment:case_harden), unit_rate_eur, pricing_unit (kg, m2, part or m) [, lot_minimum_eur, order_fee_eur, subcontractor, valid_from]. stock_formats: label, kind (sheet, plate, bar, tube), length_mm [, width_mm, thickness_mm, diameter_mm, wall_mm, material_category, key]. cutting_data: tool (name or id), material_code, parameter (e.g. V_c, f_z), value [, value_min, value_max, operation, size_mm, quality, source]. Column names are matched tolerantly, German ones included. |
| `sheet` | string | no | Worksheet of an Excel upload to read; the first one when omitted. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/setup/imports \
  -H "X-API-Key: $ARCNM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "machines",
    "expected_plan_digest": "string"
  }'
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/setup/imports",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "kind": "machines",
        "expected_plan_digest": "string"
    },
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/setup/imports", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "kind": "machines",
    "expected_plan_digest": "string"
  }),
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `404` | The costing environment (or another resource the request names) is not one of your organization's — `environment_not_found` for an environment. Another organization's id answers exactly like one that never existed. |
| `409` | The plan is no longer what the preview showed — the list, or what the setup holds, changed since (`plan_changed`). Nothing was written; `details.plan_digest` names the plan now. Preview again. |
| `422` | Validation Error — or the request as a whole cannot be planned (`setup_refused`): no list, two lists, an unreadable file. |
| `default` | Error — the error envelope; branch on `error.code`. |

**Errors**

Standard error responses — see the [Errors catalog](../errors.md) for the full envelope, `request_id`, and retry-safety table.

| Status | Code | When |
| --- | --- | --- |
| `401` | `invalid_api_key` | Missing, malformed, or revoked API key. |
| `403` | `insufficient_scope` | The key is valid but lacks a scope this endpoint requires. |
| `409` | `conflict` | A conflicting change, or an `Idempotency-Key` reused with a different body. |
| `429` | `rate_limited` | Per-key or per-org rate limit exceeded — back off with jitter and retry. |


**Response body** `200`

| Field | Type | Description |
| --- | --- | --- |
| `applied` | boolean | False for a plan (nothing written). |
| `counts` | object | Rows per action. |
| `environment_id` | string | The costing environment written to; null for stock formats and cutting data, which belong to the organization. |
| `failed` | integer | Rows whose write was refused. |
| `guidance` | string | What the result means and what to do next. |
| `kind` | `machines` \| `tools` \| `material_prices` \| `subcontractors` \| `subcontract_prices` \| `stock_formats` \| `cutting_data` | What was imported. |
| `plan_digest` | string | Fingerprint of this plan. A commit that names it writes exactly this plan, or nothing when the list or the setup changed since. |
| `rows` | SetupRow[] | Every row with an error, then the others up to 100, in list order. |
| `rows_omitted` | integer | Rows counted but not listed. |
| `total_rows` | integer | Data rows in the list. |
| `unmapped_columns` | string[] | Header cells this kind does not read; their values are ignored. |
| `written` | integer | Rows written (0 for a plan). |

**Example response**

```json
{
  "applied": true,
  "counts": {},
  "environment_id": "string",
  "failed": 0,
  "guidance": "string",
  "kind": "machines",
  "plan_digest": "string",
  "rows": [
    {
      "action": "create",
      "current": {},
      "detail": "string",
      "errors": [
        "string"
      ],
      "key": "string",
      "new": {},
      "row": 0,
      "status": "planned"
    }
  ],
  "rows_omitted": 0,
  "total_rows": 0,
  "unmapped_columns": [
    "string"
  ],
  "written": 0
}
```

## Plan an import of one whole list; nothing is written.

`POST /api/v1/setup/imports/preview`

Reads the list and answers, per row, what the import would do — create, attach, set, unchanged, skip or error — with today's value beside the new one, the columns it does not read, and a `plan_digest`. Machines, tools, subcontractors and stock formats are only added, never overwritten; prices and cutting data are set. Nothing is written and nothing is billed.

**Request body** (`application/json`)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `csv` | string | no | The list as CSV text with a header row (comma, semicolon or tab separated), instead of rows. |
| `data_source_id` | string | no | A confirmed .csv or .xlsx upload holding the list (POST /uploads/presign, then POST /uploads/confirm), read as the file has it. Needs the uploads:read scope. |
| `environment_id` | string | no | The costing environment to write to; your default environment when omitted. Stock formats and cutting data belong to the organization and ignore it. |
| `kind` | `machines` \| `tools` \| `material_prices` \| `subcontractors` \| `subcontract_prices` \| `stock_formats` \| `cutting_data` | yes | Which list this is: machines, tools, material_prices (per kg per grade), subcontractors, subcontract_prices (per bought-in operation), stock_formats or cutting_data (your own rows on your tools). |
| `rows` | object[] | no | The list as JSON objects, one per row, keyed by column name. machines: name, class, hourly_rate_eur [, operator_eur_per_h, envelope_x_mm, envelope_y_mm, envelope_z_mm, spindle_power_kw, priority]. tools: name, kind [, diameter_mm, teeth, cutting_material, price_eur, tool_life_min, vendor, item_no]. material_prices: material (number or designation), price_per_kg [, valid_from]. subcontractors: name [, operations, region, lead_time_days, notes]. subcontract_prices: operation (e.g. heat_treatment:case_harden), unit_rate_eur, pricing_unit (kg, m2, part or m) [, lot_minimum_eur, order_fee_eur, subcontractor, valid_from]. stock_formats: label, kind (sheet, plate, bar, tube), length_mm [, width_mm, thickness_mm, diameter_mm, wall_mm, material_category, key]. cutting_data: tool (name or id), material_code, parameter (e.g. V_c, f_z), value [, value_min, value_max, operation, size_mm, quality, source]. Column names are matched tolerantly, German ones included. |
| `sheet` | string | no | Worksheet of an Excel upload to read; the first one when omitted. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/setup/imports/preview \
  -H "X-API-Key: $ARCNM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "machines"
  }'
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/setup/imports/preview",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "kind": "machines"
    },
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/setup/imports/preview", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "kind": "machines"
  }),
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `404` | The costing environment (or another resource the request names) is not one of your organization's — `environment_not_found` for an environment. Another organization's id answers exactly like one that never existed. |
| `422` | Validation Error — or the request as a whole cannot be planned (`setup_refused`): no list, two lists, an unreadable file. |
| `default` | Error — the error envelope; branch on `error.code`. |

**Errors**

Standard error responses — see the [Errors catalog](../errors.md) for the full envelope, `request_id`, and retry-safety table.

| Status | Code | When |
| --- | --- | --- |
| `401` | `invalid_api_key` | Missing, malformed, or revoked API key. |
| `403` | `insufficient_scope` | The key is valid but lacks a scope this endpoint requires. |
| `409` | `conflict` | A conflicting change, or an `Idempotency-Key` reused with a different body. |
| `429` | `rate_limited` | Per-key or per-org rate limit exceeded — back off with jitter and retry. |


**Response body** `200`

| Field | Type | Description |
| --- | --- | --- |
| `applied` | boolean | False for a plan (nothing written). |
| `counts` | object | Rows per action. |
| `environment_id` | string | The costing environment written to; null for stock formats and cutting data, which belong to the organization. |
| `failed` | integer | Rows whose write was refused. |
| `guidance` | string | What the result means and what to do next. |
| `kind` | `machines` \| `tools` \| `material_prices` \| `subcontractors` \| `subcontract_prices` \| `stock_formats` \| `cutting_data` | What was imported. |
| `plan_digest` | string | Fingerprint of this plan. A commit that names it writes exactly this plan, or nothing when the list or the setup changed since. |
| `rows` | SetupRow[] | Every row with an error, then the others up to 100, in list order. |
| `rows_omitted` | integer | Rows counted but not listed. |
| `total_rows` | integer | Data rows in the list. |
| `unmapped_columns` | string[] | Header cells this kind does not read; their values are ignored. |
| `written` | integer | Rows written (0 for a plan). |

**Example response**

```json
{
  "applied": true,
  "counts": {},
  "environment_id": "string",
  "failed": 0,
  "guidance": "string",
  "kind": "machines",
  "plan_digest": "string",
  "rows": [
    {
      "action": "create",
      "current": {},
      "detail": "string",
      "errors": [
        "string"
      ],
      "key": "string",
      "new": {},
      "row": 0,
      "status": "planned"
    }
  ],
  "rows_omitted": 0,
  "total_rows": 0,
  "unmapped_columns": [
    "string"
  ],
  "written": 0
}
```
