---
title: Calibration
description: The Calibration API teaches an environment your real costs: submit observations and auto-calibrate its prediction interval, learning curve, and machine policy…
---

# Calibration

The Calibration API teaches an environment your real costs: submit observations and auto-calibrate its prediction interval, learning curve, and machine policy from your actuals.

> **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)).

## Learn from time adjustments made on a cost sheet.

`POST /api/v1/calibration/environments/{env_id}/adjustments`

Store the time adjustments a user made on a priced calculation's cost sheet as evidence for its environment, and re-fit the environment's time factors from all stored evidence. Each adjustment is attributed to the processes and machines the part actually ran on and stated against the model before any learned factor, so learning from it again never compounds; a newer adjustment of the same part and time replaces the older one, and older evidence counts less than recent. An adjusted time further from the priced time than a time factor may correct (0.25–4×) is refused and not stored. A stored adjustment is taken back with the withdraw endpoint.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | path | string | yes | Identifier of the env. |

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `calculation_id` | string | yes | The priced calculation whose cost sheet was adjusted. |
| `learn` | boolean | no | Learn from the stored evidence now. On plans whose calibration re-fits on its own this always happens, unmetered; elsewhere it uses one of the plan's calibration runs, and without a run left the evidence is stored for the next one. |
| `rows` | AdjustmentRow[] | yes | One row per adjusted time plane (setup, prove-out, programming, cycle, Nebenzeit). |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/environments/{env_id}/adjustments \
  -H "X-API-Key: $ARCNM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "calculation_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "rows": [
      {
        "actual": 0,
        "predicted": 0,
        "target_metric": "setup_time_s"
      }
    ]
  }'
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/calibration/environments/{env_id}/adjustments",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "calculation_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "rows": [
            {
                "actual": 0,
                "predicted": 0,
                "target_metric": "setup_time_s"
            }
        ]
    },
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/environments/{env_id}/adjustments", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "calculation_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "rows": [
      {
        "actual": 0,
        "predicted": 0,
        "target_metric": "setup_time_s"
      }
    ]
  }),
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `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 |
| --- | --- | --- |
| `env_id` | string | The environment the evidence belongs to. |
| `fit` | object | The re-fit's report, when one ran. |
| `learn_reason` | `plan` \| `metered` \| `limit_reached` \| `not_requested` \| `refused` \| `out_of_band` \| `nothing_recorded` | 'plan' (re-fitted, included in the plan), 'metered' (re-fitted, one calibration run used), 'limit_reached' (stored; no run left this month), 'not_requested' (stored only), 'refused' (the evidence asks for more than a calibration may correct — see ``message``), 'out_of_band' (nothing stored: every adjustment was refused 'out_of_band' — see ``message``) or 'nothing_recorded'. |
| `learned` | boolean | Whether the environment's time factors were re-fitted now. A re-fit can leave a factor where it was: one the lever gate refused (too few parts stated, or no gain) is named in ``message``. |
| `message` | string | Why an adjustment was refused 'out_of_band', why a re-fit was refused, which time factor a re-fit left out because its stored statements are further from the prediction than it may correct (the other factors were re-fitted), which factor the re-fit did not move and why ('setup lever for process:milling refused: 1 of 3 parts needed'), or which part's machine, route or features the re-fit asks to check ('part <id> is a lower-layer suspect'). |
| `n_evidence` | integer | How many stored time observations the re-fit ran over. |
| `pinned_bins` | string[] | Processes whose time factor is set by hand on the tuning surface: the evidence is kept, but the stated factor keeps pricing until it is lifted. |
| `recorded` | integer | Adjustments stored as evidence. |
| `refused` | object[] | Adjustments that were not stored, each with its plane and a reason: 'not_attributable' (the calculation predates adjustment learning — price the part again), 'plane_not_priced', 'below_fixed_time', or 'out_of_band' (the stated time is further from the priced time than a time factor may correct, 0.25–4× — ``message`` names the plane and the ratio). |
| `run_id` | string | The calibration run the re-fit wrote, if any. |

**Example response**

```json
{
  "env_id": "string",
  "fit": {},
  "learn_reason": "plan",
  "learned": true,
  "message": "string",
  "n_evidence": 0,
  "pinned_bins": [
    "string"
  ],
  "recorded": 0,
  "refused": [
    {}
  ],
  "run_id": "string"
}
```

## Take a stated time back out of an environment's evidence.

`POST /api/v1/calibration/environments/{env_id}/adjustments/withdraw`

Withdraw the stored time statement of one part and time plane — a cost-sheet adjustment, or a time taught with its quote — so no later calibration learns from it. Nothing is deleted: the statement stays on record with when it was withdrawn, by whom and the reason given. The time factors that were fitted on it are retired at once, without a refit and without using a calibration run: quotes priced afterwards no longer apply them. The environment's next time-factor refit (a learned adjustment or a finalize) fits them again from the statements that remain, where enough remain. 404 when the part has no stored statement on that plane in this environment.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | path | string | yes | Identifier of the env. |

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `part_revision_id` | string | yes | The part revision whose stated time is taken back. |
| `reason` | string | yes | Why the statement is taken back, kept with it on record. |
| `target_metric` | `setup_time_s` \| `proveout_time_s` \| `programming_time_s` \| `cycle_time_s` \| `nebenzeit_time_s` | yes | The time plane whose statement is taken back. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/environments/{env_id}/adjustments/withdraw \
  -H "X-API-Key: $ARCNM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "part_revision_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "target_metric": "setup_time_s",
    "reason": "string"
  }'
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/calibration/environments/{env_id}/adjustments/withdraw",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "part_revision_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "target_metric": "setup_time_s",
        "reason": "string"
    },
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/environments/{env_id}/adjustments/withdraw", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "part_revision_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "target_metric": "setup_time_s",
    "reason": "string"
  }),
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `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 |
| --- | --- | --- |
| `env_id` | string | The environment the statements belong to. |
| `message` | string | What the withdrawal did to the time factors, and when they are fitted again. |
| `withdrawn` | integer | How many stored statements were withdrawn (at least one). |

**Example response**

```json
{
  "env_id": "string",
  "message": "string",
  "withdrawn": 0
}
```

## One-click environment calibration from (part_revision_id, actual_unit_cost) rows.

`POST /api/v1/calibration/environments/{env_id}/auto-calibrate`

The headline customer-facing endpoint — turn a list of ERP actual unit costs into a calibrated environment in one call. Each actual is paired with the most recent successful quote for its part at its lot size in this environment, priced by the current version of the costing model, and the calibration is fitted to the difference; nothing is re-quoted. Parts with no such quote — none at all, or only one priced before the costing model last changed — are returned in ``unmatched_part_ids`` so you can quote them and retry. Idempotent: the same set of actuals yields the same result.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | path | string | yes | Identifier of the env. |

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `actuals` | AutoCalibrateActualRow[] | yes | Up to 20,000 (part_revision_id, actual_unit_cost) rows. Designed for ERP exports: a tenant's history can be sent in one call. |
| `basis` | `herstellkosten` \| `selbstkosten` \| `angebotspreis` | no | Which rung of the cost sheet these actuals are measured at: 'herstellkosten' (manufacturing cost per unit — what a work order books), 'selbstkosten' (total cost per unit, including administration, selling, freight and duty) or 'angebotspreis' (the quoted price per unit, including the profit mark-up). Each is compared against the model's own figure at the same rung. Omit it only if you genuinely do not know: an unstated basis is read as manufacturing cost and the environment's calibration report flags how many rows were unstated. |
| `holdout_pct` | number | no | Fraction of rows held out to size the prediction interval. |
| `target_alpha` | number | no | Target miss rate for the prediction interval (default 0.10 → a 90% interval). |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/environments/{env_id}/auto-calibrate \
  -H "X-API-Key: $ARCNM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "actuals": [
      {
        "actual_unit_cost": 0,
        "annual_volume": 500,
        "bin": "string",
        "lot_size": 50,
        "part_revision_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "tooling_lifetime_units": 0
      }
    ]
  }'
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/calibration/environments/{env_id}/auto-calibrate",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "actuals": [
            {
                "actual_unit_cost": 0,
                "annual_volume": 500,
                "bin": "string",
                "lot_size": 50,
                "part_revision_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                "tooling_lifetime_units": 0
            }
        ]
    },
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/environments/{env_id}/auto-calibrate", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "actuals": [
      {
        "actual_unit_cost": 0,
        "annual_volume": 500,
        "bin": "string",
        "lot_size": 50,
        "part_revision_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "tooling_lifetime_units": 0
      }
    ]
  }),
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error — or a refused fit. `calibration_actuals_out_of_band`: your actuals sit further from this environment's predictions than calibration may correct, so nothing was fitted. `details.metric` is the target metric refused, `details.ratio` your actuals divided by the prediction (the median over that metric's observations), `details.observations` how many observations it was taken over, and `details.min` and `details.max` the widest correction calibration may apply to that metric (0.5–2× for a unit cost, 0.25–4× for a time). Correct the environment's inputs — machine and labour rates, material prices, shop-practice answers — first, then calibrate. `calibration_no_process_bin`: none of the rows is filed under a process a price reads (`process:<discipline>`), so a fit would change no price; `details.observations` is the number of rows and, when the rows state labels of their own, `details.labels` how many different ones and `details.label` the first. Label each row with the process its part is priced in, or leave the label out. Any other refusal answers `unprocessable_entity` with its reason in `message`. |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `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 |
| --- | --- | --- |
| `a` | number | Fitted first-unit cost coefficient of the curve. |
| `b` | number | Fitted log-log slope exponent of the learning curve. |
| `block_evidence` | BlockEvidencePublic | History import: what the block amounts stated beside the totals became — how many were recorded, and each one that was not with its reason. |
| `env_id` | string | Identifier of the calibrated environment. |
| `fit` | object | Structured object with the fitted parameters and fit diagnostics. |
| `fitted_accuracy` | number | Accuracy (0–1) of the fitted policy on the training rows. |
| `fitted_policy` | object | Structured object describing the fitted selection policy. |
| `grid_size` | integer | Number of policy candidates evaluated during the fit. |
| `history_received` | integer | Historical choice records supplied in the request. |
| `history_rejected` | object[] | Records that could not be used, each with its position in the request and why. Capped at 50 entries; the counts above are never truncated. |
| `history_used` | integer | Records the fit actually used. Lower than ``history_received`` means some could not be read; see ``history_rejected``. |
| `holdout_accuracy` | number | Accuracy (0–1) of the fitted policy on held-out rows. |
| `holdout_coverage` | number | Fraction (0–1) of held-out actuals inside the price range their quote is served, each part scored against a range fitted without it. |
| `holdout_mape` | number | Mean absolute percentage error of the prices this environment gave before the run, over every row the decision was measured on — the miss this run set out to close, not the outcome. Read mape_after for the result. |
| `holdout_pct` | number | History import: the fraction of parts the fit held out. Null on a replay of a fit stored before it was recorded. |
| `id` | string | Identifier of the resulting record, when applicable. |
| `ingested` | integer | Number of observations persisted by an ingest call. |
| `learning_rate` | number | Learning rate (0–1): cost retained each time output doubles. |
| `mape_after` | number | MAPE AFTER the fit, each row priced by a calibration fitted without its part (validation.mape_after). The run's headline outcome; null when the run fitted no unit-cost calibration. |
| `mape_before` | number | MAPE before the fit (same figure as holdout_mape, named for the before/after pair). |
| `matched` | integer | Number of supplied rows matched to an existing quote. |
| `message` | string | Human-readable note about the run, when present, in English. A history import states the same facts as fields: matched, rows_not_fitted and block_evidence. |
| `model` | string | Learning-curve model that was fit (crawford_unit or wright_cumulative). |
| `n_holdout` | integer | Number of rows held out to size the prediction interval. |
| `n_iterations` | integer | Iterations the midpoint solver ran before converging. |
| `n_lots` | integer | Number of production lots used in the curve fit. |
| `n_observations` | integer | Number of observations the calibration fit used. |
| `n_train` | integer | Number of rows used to fit the calibration. |
| `part_revision_id` | string | Identifier of the part revision that was fit. |
| `policy_history_id` | string | Identifier of the newly written selection-policy row. |
| `r_squared` | number | Coefficient of determination (0–1) of the curve fit. |
| `replayed` | boolean | History import: true when the import was already calibrated and this is its stored result, replayed without a new fit or a second metered run. The parameters sent are then not applied; target_alpha and holdout_pct say what the stored fit used. |
| `residual_sigma_log` | number | Standard deviation of the fit residuals in log space. |
| `rows_not_fitted` | RowsNotFittedPublic | History import: the rows the fit left out, counted per cause. All zero when every row was fitted (status 'complete' with no row left out). |
| `run_id` | string | Identifier of the calibration run, when one was created. |
| `samples` | integer | Number of samples considered by the run. |
| `samples_applied` | integer | Number of samples actually applied to the fit. |
| `scope` | `platform` \| `environment` | Scope the run applied to: 'platform' or 'environment'. |
| `seed_accuracy` | number | Accuracy (0–1) of the seed policy before calibration. |
| `status` | `complete` \| `partially_complete` \| `published` \| `deactivated` | Outcome status of the calibration run. |
| `target_alpha` | number | History import: the target miss rate the fit used. Null on a replay of a fit stored before it was recorded. |
| `target_metric` | string | Metric the calibration targeted (e.g. 'unit_cost'). |
| `unknown_part_numbers` | string[] | Part numbers that could not be resolved to a known part. |
| `unmatched_part_ids` | string[] | Part revision IDs with no quote at their lot size priced by the current version of the costing model, so they were skipped. |
| `validation` | CalibrationValidationPublic | How this run's calibration prices your parts against today's prices, whether it was applied (held only when worse) and why. Null when the run fitted no unit-cost calibration. |
| `work_orders_received` | integer | Number of ERP work-order rows received. |
| `work_orders_resolved` | integer | Number of work orders resolved to a known part revision. |

**Example response**

```json
{
  "a": 0,
  "b": 0,
  "block_evidence": {
    "refused": [
      {
        "block": "string",
        "part_revision_id": "string",
        "reason": "unknown_block"
      }
    ],
    "written": 0
  },
  "env_id": "string",
  "fit": {},
  "fitted_accuracy": 0,
  "fitted_policy": {},
  "grid_size": 0,
  "history_received": 0,
  "history_rejected": [
    {}
  ],
  "history_used": 0,
  "holdout_accuracy": 0,
  "holdout_coverage": 0.9,
  "holdout_mape": 0.05,
  "holdout_pct": 0,
  "id": "string",
  "ingested": 0,
  "learning_rate": 0,
  "mape_after": 0.05,
  "mape_before": 0.05,
  "matched": 0,
  "message": "string",
  "model": "string",
  "n_holdout": 0,
  "n_iterations": 0,
  "n_lots": 0,
  "n_observations": 0,
  "n_train": 0,
  "part_revision_id": "string",
  "policy_history_id": "string",
  "r_squared": 0,
  "replayed": true,
  "residual_sigma_log": 0,
  "rows_not_fitted": {
    "assumed_price": 0,
    "invalid": 0,
    "no_dataset": 0,
    "no_matching_calculation": 0,
    "partial_price": 0,
    "pricing_failed": 0,
    "unpriced": 0,
    "unresolved": 0
  },
  "run_id": "string",
  "samples": 0,
  "samples_applied": 0,
  "scope": "platform",
  "seed_accuracy": 0,
  "status": "complete",
  "target_alpha": 0,
  "target_metric": "string",
  "unknown_part_numbers": [
    "string"
  ],
  "unmatched_part_ids": [
    "string"
  ],
  "validation": {
    "error_after": 0,
    "error_before": 0,
    "gain": 0,
    "gain_lower": 0,
    "gain_upper": 0,
    "mape_after": 0.05,
    "mape_before": 0.05,
    "n_parts": 0,
    "n_rows": 0,
    "reasons": [
      {
        "code": "lot_total_as_unit_cost",
        "params": {}
      }
    ],
    "served": true,
    "verdict": "better"
  },
  "work_orders_received": 0,
  "work_orders_resolved": 0
}
```

## Calibrate an env from raw ERP work-order rows.

`POST /api/v1/calibration/environments/{env_id}/auto-calibrate-from-erp`

ERP-native variant of ``auto-calibrate``: accepts the raw columns most ERPs export (part_number, work_order_id, quantity, total_cost) and handles part-number resolution + unit-cost derivation server-side. Idempotent on work_order_id.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | path | string | yes | Identifier of the env. |

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `basis` | `herstellkosten` \| `selbstkosten` \| `angebotspreis` | yes | Which rung of the cost sheet the work orders' costs are measured at: 'herstellkosten' (manufacturing cost — what a work order books to make the parts, before any selling cost or mark-up), 'selbstkosten' (total cost, including administration, selling, freight and duty) or 'angebotspreis' (the price, including the profit mark-up). Required: one basis per submission; each order is compared against the model's figure at that rung. |
| `holdout_pct` | number | no | Fraction of rows held out to size the prediction interval. |
| `target_alpha` | number | no | Target miss rate for the prediction interval (0.10 → a 90% interval). |
| `work_orders` | ErpWorkOrderPayload[] | yes | Up to 20 000 raw ERP work-order lines, e.g. an export of the last 12 months of WIP_DISCRETE_JOBS rows. From one submission the service resolves part numbers, decomposes setup vs variable cost from the lot-size diversity, and returns a calibrated env. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/environments/{env_id}/auto-calibrate-from-erp \
  -H "X-API-Key: $ARCNM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "work_orders": [
      {
        "annual_forecast": 0,
        "inspection_cost": 0,
        "labour_cost": 0,
        "machine_cost": 0,
        "material_cost": 0,
        "part_number": "BRACKET-001",
        "programming_cost": 0,
        "quantity": 0,
        "setup_cost": 52.5,
        "subcontract_costs": {},
        "tooling_cost": 0,
        "total_cost": 642,
        "work_order_id": "string"
      }
    ],
    "basis": "herstellkosten"
  }'
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/calibration/environments/{env_id}/auto-calibrate-from-erp",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "work_orders": [
            {
                "annual_forecast": 0,
                "inspection_cost": 0,
                "labour_cost": 0,
                "machine_cost": 0,
                "material_cost": 0,
                "part_number": "BRACKET-001",
                "programming_cost": 0,
                "quantity": 0,
                "setup_cost": 52.5,
                "subcontract_costs": {},
                "tooling_cost": 0,
                "total_cost": 642,
                "work_order_id": "string"
            }
        ],
        "basis": "herstellkosten"
    },
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/environments/{env_id}/auto-calibrate-from-erp", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "work_orders": [
      {
        "annual_forecast": 0,
        "inspection_cost": 0,
        "labour_cost": 0,
        "machine_cost": 0,
        "material_cost": 0,
        "part_number": "BRACKET-001",
        "programming_cost": 0,
        "quantity": 0,
        "setup_cost": 52.5,
        "subcontract_costs": {},
        "tooling_cost": 0,
        "total_cost": 642,
        "work_order_id": "string"
      }
    ],
    "basis": "herstellkosten"
  }),
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error — or a refused fit. `calibration_actuals_out_of_band`: your actuals sit further from this environment's predictions than calibration may correct, so nothing was fitted. `details.metric` is the target metric refused, `details.ratio` your actuals divided by the prediction (the median over that metric's observations), `details.observations` how many observations it was taken over, and `details.min` and `details.max` the widest correction calibration may apply to that metric (0.5–2× for a unit cost, 0.25–4× for a time). Correct the environment's inputs — machine and labour rates, material prices, shop-practice answers — first, then calibrate. `calibration_no_process_bin`: none of the rows is filed under a process a price reads (`process:<discipline>`), so a fit would change no price; `details.observations` is the number of rows and, when the rows state labels of their own, `details.labels` how many different ones and `details.label` the first. Label each row with the process its part is priced in, or leave the label out. Any other refusal answers `unprocessable_entity` with its reason in `message`. |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `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 |
| --- | --- | --- |
| `a` | number | Fitted first-unit cost coefficient of the curve. |
| `b` | number | Fitted log-log slope exponent of the learning curve. |
| `block_evidence` | BlockEvidencePublic | History import: what the block amounts stated beside the totals became — how many were recorded, and each one that was not with its reason. |
| `env_id` | string | Identifier of the calibrated environment. |
| `fit` | object | Structured object with the fitted parameters and fit diagnostics. |
| `fitted_accuracy` | number | Accuracy (0–1) of the fitted policy on the training rows. |
| `fitted_policy` | object | Structured object describing the fitted selection policy. |
| `grid_size` | integer | Number of policy candidates evaluated during the fit. |
| `history_received` | integer | Historical choice records supplied in the request. |
| `history_rejected` | object[] | Records that could not be used, each with its position in the request and why. Capped at 50 entries; the counts above are never truncated. |
| `history_used` | integer | Records the fit actually used. Lower than ``history_received`` means some could not be read; see ``history_rejected``. |
| `holdout_accuracy` | number | Accuracy (0–1) of the fitted policy on held-out rows. |
| `holdout_coverage` | number | Fraction (0–1) of held-out actuals inside the price range their quote is served, each part scored against a range fitted without it. |
| `holdout_mape` | number | Mean absolute percentage error of the prices this environment gave before the run, over every row the decision was measured on — the miss this run set out to close, not the outcome. Read mape_after for the result. |
| `holdout_pct` | number | History import: the fraction of parts the fit held out. Null on a replay of a fit stored before it was recorded. |
| `id` | string | Identifier of the resulting record, when applicable. |
| `ingested` | integer | Number of observations persisted by an ingest call. |
| `learning_rate` | number | Learning rate (0–1): cost retained each time output doubles. |
| `mape_after` | number | MAPE AFTER the fit, each row priced by a calibration fitted without its part (validation.mape_after). The run's headline outcome; null when the run fitted no unit-cost calibration. |
| `mape_before` | number | MAPE before the fit (same figure as holdout_mape, named for the before/after pair). |
| `matched` | integer | Number of supplied rows matched to an existing quote. |
| `message` | string | Human-readable note about the run, when present, in English. A history import states the same facts as fields: matched, rows_not_fitted and block_evidence. |
| `model` | string | Learning-curve model that was fit (crawford_unit or wright_cumulative). |
| `n_holdout` | integer | Number of rows held out to size the prediction interval. |
| `n_iterations` | integer | Iterations the midpoint solver ran before converging. |
| `n_lots` | integer | Number of production lots used in the curve fit. |
| `n_observations` | integer | Number of observations the calibration fit used. |
| `n_train` | integer | Number of rows used to fit the calibration. |
| `part_revision_id` | string | Identifier of the part revision that was fit. |
| `policy_history_id` | string | Identifier of the newly written selection-policy row. |
| `r_squared` | number | Coefficient of determination (0–1) of the curve fit. |
| `replayed` | boolean | History import: true when the import was already calibrated and this is its stored result, replayed without a new fit or a second metered run. The parameters sent are then not applied; target_alpha and holdout_pct say what the stored fit used. |
| `residual_sigma_log` | number | Standard deviation of the fit residuals in log space. |
| `rows_not_fitted` | RowsNotFittedPublic | History import: the rows the fit left out, counted per cause. All zero when every row was fitted (status 'complete' with no row left out). |
| `run_id` | string | Identifier of the calibration run, when one was created. |
| `samples` | integer | Number of samples considered by the run. |
| `samples_applied` | integer | Number of samples actually applied to the fit. |
| `scope` | `platform` \| `environment` | Scope the run applied to: 'platform' or 'environment'. |
| `seed_accuracy` | number | Accuracy (0–1) of the seed policy before calibration. |
| `status` | `complete` \| `partially_complete` \| `published` \| `deactivated` | Outcome status of the calibration run. |
| `target_alpha` | number | History import: the target miss rate the fit used. Null on a replay of a fit stored before it was recorded. |
| `target_metric` | string | Metric the calibration targeted (e.g. 'unit_cost'). |
| `unknown_part_numbers` | string[] | Part numbers that could not be resolved to a known part. |
| `unmatched_part_ids` | string[] | Part revision IDs with no quote at their lot size priced by the current version of the costing model, so they were skipped. |
| `validation` | CalibrationValidationPublic | How this run's calibration prices your parts against today's prices, whether it was applied (held only when worse) and why. Null when the run fitted no unit-cost calibration. |
| `work_orders_received` | integer | Number of ERP work-order rows received. |
| `work_orders_resolved` | integer | Number of work orders resolved to a known part revision. |

**Example response**

```json
{
  "a": 0,
  "b": 0,
  "block_evidence": {
    "refused": [
      {
        "block": "string",
        "part_revision_id": "string",
        "reason": "unknown_block"
      }
    ],
    "written": 0
  },
  "env_id": "string",
  "fit": {},
  "fitted_accuracy": 0,
  "fitted_policy": {},
  "grid_size": 0,
  "history_received": 0,
  "history_rejected": [
    {}
  ],
  "history_used": 0,
  "holdout_accuracy": 0,
  "holdout_coverage": 0.9,
  "holdout_mape": 0.05,
  "holdout_pct": 0,
  "id": "string",
  "ingested": 0,
  "learning_rate": 0,
  "mape_after": 0.05,
  "mape_before": 0.05,
  "matched": 0,
  "message": "string",
  "model": "string",
  "n_holdout": 0,
  "n_iterations": 0,
  "n_lots": 0,
  "n_observations": 0,
  "n_train": 0,
  "part_revision_id": "string",
  "policy_history_id": "string",
  "r_squared": 0,
  "replayed": true,
  "residual_sigma_log": 0,
  "rows_not_fitted": {
    "assumed_price": 0,
    "invalid": 0,
    "no_dataset": 0,
    "no_matching_calculation": 0,
    "partial_price": 0,
    "pricing_failed": 0,
    "unpriced": 0,
    "unresolved": 0
  },
  "run_id": "string",
  "samples": 0,
  "samples_applied": 0,
  "scope": "platform",
  "seed_accuracy": 0,
  "status": "complete",
  "target_alpha": 0,
  "target_metric": "string",
  "unknown_part_numbers": [
    "string"
  ],
  "unmatched_part_ids": [
    "string"
  ],
  "validation": {
    "error_after": 0,
    "error_before": 0,
    "gain": 0,
    "gain_lower": 0,
    "gain_upper": 0,
    "mape_after": 0.05,
    "mape_before": 0.05,
    "n_parts": 0,
    "n_rows": 0,
    "reasons": [
      {
        "code": "lot_total_as_unit_cost",
        "params": {}
      }
    ],
    "served": true,
    "verdict": "better"
  },
  "work_orders_received": 0,
  "work_orders_resolved": 0
}
```

## Calibration report for one environment.

`GET /api/v1/calibration/environments/{env_id}/calibration-report`

Calibration status for an environment: whether it has been calibrated to your actuals and which parent environment's calibration it inherits. An API key or an agent receives this status only; the per-driver adjustments behind it are shown in the Arcanum app.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | path | string | yes | Identifier of the env. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X GET https://api.arcnm.io/api/v1/calibration/environments/{env_id}/calibration-report \
  -H "X-API-Key: $ARCNM_API_KEY"
```

```python title="Python"
import requests

resp = requests.get(
    "https://api.arcnm.io/api/v1/calibration/environments/{env_id}/calibration-report",
    headers={"X-API-Key": "YOUR_API_KEY"},
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/environments/{env_id}/calibration-report", {
  method: "GET",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
  },
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `429` | `rate_limited` | Per-key or per-org rate limit exceeded — back off with jitter and retry. |


**Response body** `200`

| Field | Type | Description |
| --- | --- | --- |
| `calibrated` | boolean | True when this environment has been calibrated to your actuals. |
| `env_id` | string | Identifier of the environment this report describes. |
| `inherited_from` | InheritedCalibrationPublic[] | The environments this one inherits its calibration from. An environment with no active calibration of its own prices on its nearest parent environment's that has one; calibrating it replaces what it inherits (nothing is multiplied onto the parent's), and switching its own calibration off returns it to the parent's. Empty when the calibration is its own or it has none. |
| `note` | string | Present on the public API only: points integrations at the app for the per-driver detail. |

**Example response**

```json
{
  "calibrated": true,
  "env_id": "string",
  "inherited_from": [
    {
      "applies_to": [
        "unit_cost"
      ],
      "env_id": "string",
      "name": "string",
      "time_factors_replaced": 0
    }
  ],
  "note": "string"
}
```

## Turn an environment's calibration off.

`POST /api/v1/calibration/environments/{env_id}/deactivate`

Retire the environment's own active calibration without replacing it: quotes priced after this call use the calibration of its nearest calibrated parent environment (`falls_back_to` of the status), or the uncalibrated defaults when there is none. The run history is kept, so any earlier run can be restored with the revert endpoint. Fails when the environment has no calibration of its own active; an inherited one is switched off on the environment it belongs to.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | path | string | yes | Identifier of the env. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/environments/{env_id}/deactivate \
  -H "X-API-Key: $ARCNM_API_KEY"
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/calibration/environments/{env_id}/deactivate",
    headers={"X-API-Key": "YOUR_API_KEY"},
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/environments/{env_id}/deactivate", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
  },
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `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 |
| --- | --- | --- |
| `a` | number | Fitted first-unit cost coefficient of the curve. |
| `b` | number | Fitted log-log slope exponent of the learning curve. |
| `block_evidence` | BlockEvidencePublic | History import: what the block amounts stated beside the totals became — how many were recorded, and each one that was not with its reason. |
| `env_id` | string | Identifier of the calibrated environment. |
| `fit` | object | Structured object with the fitted parameters and fit diagnostics. |
| `fitted_accuracy` | number | Accuracy (0–1) of the fitted policy on the training rows. |
| `fitted_policy` | object | Structured object describing the fitted selection policy. |
| `grid_size` | integer | Number of policy candidates evaluated during the fit. |
| `history_received` | integer | Historical choice records supplied in the request. |
| `history_rejected` | object[] | Records that could not be used, each with its position in the request and why. Capped at 50 entries; the counts above are never truncated. |
| `history_used` | integer | Records the fit actually used. Lower than ``history_received`` means some could not be read; see ``history_rejected``. |
| `holdout_accuracy` | number | Accuracy (0–1) of the fitted policy on held-out rows. |
| `holdout_coverage` | number | Fraction (0–1) of held-out actuals inside the price range their quote is served, each part scored against a range fitted without it. |
| `holdout_mape` | number | Mean absolute percentage error of the prices this environment gave before the run, over every row the decision was measured on — the miss this run set out to close, not the outcome. Read mape_after for the result. |
| `holdout_pct` | number | History import: the fraction of parts the fit held out. Null on a replay of a fit stored before it was recorded. |
| `id` | string | Identifier of the resulting record, when applicable. |
| `ingested` | integer | Number of observations persisted by an ingest call. |
| `learning_rate` | number | Learning rate (0–1): cost retained each time output doubles. |
| `mape_after` | number | MAPE AFTER the fit, each row priced by a calibration fitted without its part (validation.mape_after). The run's headline outcome; null when the run fitted no unit-cost calibration. |
| `mape_before` | number | MAPE before the fit (same figure as holdout_mape, named for the before/after pair). |
| `matched` | integer | Number of supplied rows matched to an existing quote. |
| `message` | string | Human-readable note about the run, when present, in English. A history import states the same facts as fields: matched, rows_not_fitted and block_evidence. |
| `model` | string | Learning-curve model that was fit (crawford_unit or wright_cumulative). |
| `n_holdout` | integer | Number of rows held out to size the prediction interval. |
| `n_iterations` | integer | Iterations the midpoint solver ran before converging. |
| `n_lots` | integer | Number of production lots used in the curve fit. |
| `n_observations` | integer | Number of observations the calibration fit used. |
| `n_train` | integer | Number of rows used to fit the calibration. |
| `part_revision_id` | string | Identifier of the part revision that was fit. |
| `policy_history_id` | string | Identifier of the newly written selection-policy row. |
| `r_squared` | number | Coefficient of determination (0–1) of the curve fit. |
| `replayed` | boolean | History import: true when the import was already calibrated and this is its stored result, replayed without a new fit or a second metered run. The parameters sent are then not applied; target_alpha and holdout_pct say what the stored fit used. |
| `residual_sigma_log` | number | Standard deviation of the fit residuals in log space. |
| `rows_not_fitted` | RowsNotFittedPublic | History import: the rows the fit left out, counted per cause. All zero when every row was fitted (status 'complete' with no row left out). |
| `run_id` | string | Identifier of the calibration run, when one was created. |
| `samples` | integer | Number of samples considered by the run. |
| `samples_applied` | integer | Number of samples actually applied to the fit. |
| `scope` | `platform` \| `environment` | Scope the run applied to: 'platform' or 'environment'. |
| `seed_accuracy` | number | Accuracy (0–1) of the seed policy before calibration. |
| `status` | `complete` \| `partially_complete` \| `published` \| `deactivated` | Outcome status of the calibration run. |
| `target_alpha` | number | History import: the target miss rate the fit used. Null on a replay of a fit stored before it was recorded. |
| `target_metric` | string | Metric the calibration targeted (e.g. 'unit_cost'). |
| `unknown_part_numbers` | string[] | Part numbers that could not be resolved to a known part. |
| `unmatched_part_ids` | string[] | Part revision IDs with no quote at their lot size priced by the current version of the costing model, so they were skipped. |
| `validation` | CalibrationValidationPublic | How this run's calibration prices your parts against today's prices, whether it was applied (held only when worse) and why. Null when the run fitted no unit-cost calibration. |
| `work_orders_received` | integer | Number of ERP work-order rows received. |
| `work_orders_resolved` | integer | Number of work orders resolved to a known part revision. |

**Example response**

```json
{
  "a": 0,
  "b": 0,
  "block_evidence": {
    "refused": [
      {
        "block": "string",
        "part_revision_id": "string",
        "reason": "unknown_block"
      }
    ],
    "written": 0
  },
  "env_id": "string",
  "fit": {},
  "fitted_accuracy": 0,
  "fitted_policy": {},
  "grid_size": 0,
  "history_received": 0,
  "history_rejected": [
    {}
  ],
  "history_used": 0,
  "holdout_accuracy": 0,
  "holdout_coverage": 0.9,
  "holdout_mape": 0.05,
  "holdout_pct": 0,
  "id": "string",
  "ingested": 0,
  "learning_rate": 0,
  "mape_after": 0.05,
  "mape_before": 0.05,
  "matched": 0,
  "message": "string",
  "model": "string",
  "n_holdout": 0,
  "n_iterations": 0,
  "n_lots": 0,
  "n_observations": 0,
  "n_train": 0,
  "part_revision_id": "string",
  "policy_history_id": "string",
  "r_squared": 0,
  "replayed": true,
  "residual_sigma_log": 0,
  "rows_not_fitted": {
    "assumed_price": 0,
    "invalid": 0,
    "no_dataset": 0,
    "no_matching_calculation": 0,
    "partial_price": 0,
    "pricing_failed": 0,
    "unpriced": 0,
    "unresolved": 0
  },
  "run_id": "string",
  "samples": 0,
  "samples_applied": 0,
  "scope": "platform",
  "seed_accuracy": 0,
  "status": "complete",
  "target_alpha": 0,
  "target_metric": "string",
  "unknown_part_numbers": [
    "string"
  ],
  "unmatched_part_ids": [
    "string"
  ],
  "validation": {
    "error_after": 0,
    "error_before": 0,
    "gain": 0,
    "gain_lower": 0,
    "gain_upper": 0,
    "mape_after": 0.05,
    "mape_before": 0.05,
    "n_parts": 0,
    "n_rows": 0,
    "reasons": [
      {
        "code": "lot_total_as_unit_cost",
        "params": {}
      }
    ],
    "served": true,
    "verdict": "better"
  },
  "work_orders_received": 0,
  "work_orders_resolved": 0
}
```

## Recalibrate an environment from its accumulated observations.

`POST /api/v1/calibration/environments/{env_id}/finalize`

Recalibrate this environment for the selected target metric using every observation submitted for it so far, then activate the result. Use after submitting observations. Only an observation whose predicted value comes from the current version of the costing model is fitted: one submitted before the model last changed, or naming a calculation priced before it, is left out and counted in ``message``, and a run with none left is refused. To start from raw ERP actuals without submitting observations first, use the one-click auto-calibrate endpoint instead.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | path | string | yes | Identifier of the env. |

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `notes` | string | no | Optional free-text note recorded with the run. |
| `target_alpha` | number | no | Target miss rate for the prediction interval (0.10 → a 90% interval). |
| `target_metric` | `cycle_time_s` \| `setup_time_s` \| `programming_time_s` \| `unit_cost` \| `machine_choice` | no | Metric to calibrate the environment for. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/environments/{env_id}/finalize \
  -H "X-API-Key: $ARCNM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "notes": "string",
    "target_alpha": 0.1,
    "target_metric": "cycle_time_s"
  }'
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/calibration/environments/{env_id}/finalize",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "notes": "string",
        "target_alpha": 0.1,
        "target_metric": "cycle_time_s"
    },
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/environments/{env_id}/finalize", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "notes": "string",
    "target_alpha": 0.1,
    "target_metric": "cycle_time_s"
  }),
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error — or a refused fit. `calibration_actuals_out_of_band`: your actuals sit further from this environment's predictions than calibration may correct, so nothing was fitted. `details.metric` is the target metric refused, `details.ratio` your actuals divided by the prediction (the median over that metric's observations), `details.observations` how many observations it was taken over, and `details.min` and `details.max` the widest correction calibration may apply to that metric (0.5–2× for a unit cost, 0.25–4× for a time). Correct the environment's inputs — machine and labour rates, material prices, shop-practice answers — first, then calibrate. `calibration_no_process_bin`: none of the rows is filed under a process a price reads (`process:<discipline>`), so a fit would change no price; `details.observations` is the number of rows and, when the rows state labels of their own, `details.labels` how many different ones and `details.label` the first. Label each row with the process its part is priced in, or leave the label out. Any other refusal answers `unprocessable_entity` with its reason in `message`. |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `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 |
| --- | --- | --- |
| `a` | number | Fitted first-unit cost coefficient of the curve. |
| `b` | number | Fitted log-log slope exponent of the learning curve. |
| `block_evidence` | BlockEvidencePublic | History import: what the block amounts stated beside the totals became — how many were recorded, and each one that was not with its reason. |
| `env_id` | string | Identifier of the calibrated environment. |
| `fit` | object | Structured object with the fitted parameters and fit diagnostics. |
| `fitted_accuracy` | number | Accuracy (0–1) of the fitted policy on the training rows. |
| `fitted_policy` | object | Structured object describing the fitted selection policy. |
| `grid_size` | integer | Number of policy candidates evaluated during the fit. |
| `history_received` | integer | Historical choice records supplied in the request. |
| `history_rejected` | object[] | Records that could not be used, each with its position in the request and why. Capped at 50 entries; the counts above are never truncated. |
| `history_used` | integer | Records the fit actually used. Lower than ``history_received`` means some could not be read; see ``history_rejected``. |
| `holdout_accuracy` | number | Accuracy (0–1) of the fitted policy on held-out rows. |
| `holdout_coverage` | number | Fraction (0–1) of held-out actuals inside the price range their quote is served, each part scored against a range fitted without it. |
| `holdout_mape` | number | Mean absolute percentage error of the prices this environment gave before the run, over every row the decision was measured on — the miss this run set out to close, not the outcome. Read mape_after for the result. |
| `holdout_pct` | number | History import: the fraction of parts the fit held out. Null on a replay of a fit stored before it was recorded. |
| `id` | string | Identifier of the resulting record, when applicable. |
| `ingested` | integer | Number of observations persisted by an ingest call. |
| `learning_rate` | number | Learning rate (0–1): cost retained each time output doubles. |
| `mape_after` | number | MAPE AFTER the fit, each row priced by a calibration fitted without its part (validation.mape_after). The run's headline outcome; null when the run fitted no unit-cost calibration. |
| `mape_before` | number | MAPE before the fit (same figure as holdout_mape, named for the before/after pair). |
| `matched` | integer | Number of supplied rows matched to an existing quote. |
| `message` | string | Human-readable note about the run, when present, in English. A history import states the same facts as fields: matched, rows_not_fitted and block_evidence. |
| `model` | string | Learning-curve model that was fit (crawford_unit or wright_cumulative). |
| `n_holdout` | integer | Number of rows held out to size the prediction interval. |
| `n_iterations` | integer | Iterations the midpoint solver ran before converging. |
| `n_lots` | integer | Number of production lots used in the curve fit. |
| `n_observations` | integer | Number of observations the calibration fit used. |
| `n_train` | integer | Number of rows used to fit the calibration. |
| `part_revision_id` | string | Identifier of the part revision that was fit. |
| `policy_history_id` | string | Identifier of the newly written selection-policy row. |
| `r_squared` | number | Coefficient of determination (0–1) of the curve fit. |
| `replayed` | boolean | History import: true when the import was already calibrated and this is its stored result, replayed without a new fit or a second metered run. The parameters sent are then not applied; target_alpha and holdout_pct say what the stored fit used. |
| `residual_sigma_log` | number | Standard deviation of the fit residuals in log space. |
| `rows_not_fitted` | RowsNotFittedPublic | History import: the rows the fit left out, counted per cause. All zero when every row was fitted (status 'complete' with no row left out). |
| `run_id` | string | Identifier of the calibration run, when one was created. |
| `samples` | integer | Number of samples considered by the run. |
| `samples_applied` | integer | Number of samples actually applied to the fit. |
| `scope` | `platform` \| `environment` | Scope the run applied to: 'platform' or 'environment'. |
| `seed_accuracy` | number | Accuracy (0–1) of the seed policy before calibration. |
| `status` | `complete` \| `partially_complete` \| `published` \| `deactivated` | Outcome status of the calibration run. |
| `target_alpha` | number | History import: the target miss rate the fit used. Null on a replay of a fit stored before it was recorded. |
| `target_metric` | string | Metric the calibration targeted (e.g. 'unit_cost'). |
| `unknown_part_numbers` | string[] | Part numbers that could not be resolved to a known part. |
| `unmatched_part_ids` | string[] | Part revision IDs with no quote at their lot size priced by the current version of the costing model, so they were skipped. |
| `validation` | CalibrationValidationPublic | How this run's calibration prices your parts against today's prices, whether it was applied (held only when worse) and why. Null when the run fitted no unit-cost calibration. |
| `work_orders_received` | integer | Number of ERP work-order rows received. |
| `work_orders_resolved` | integer | Number of work orders resolved to a known part revision. |

**Example response**

```json
{
  "a": 0,
  "b": 0,
  "block_evidence": {
    "refused": [
      {
        "block": "string",
        "part_revision_id": "string",
        "reason": "unknown_block"
      }
    ],
    "written": 0
  },
  "env_id": "string",
  "fit": {},
  "fitted_accuracy": 0,
  "fitted_policy": {},
  "grid_size": 0,
  "history_received": 0,
  "history_rejected": [
    {}
  ],
  "history_used": 0,
  "holdout_accuracy": 0,
  "holdout_coverage": 0.9,
  "holdout_mape": 0.05,
  "holdout_pct": 0,
  "id": "string",
  "ingested": 0,
  "learning_rate": 0,
  "mape_after": 0.05,
  "mape_before": 0.05,
  "matched": 0,
  "message": "string",
  "model": "string",
  "n_holdout": 0,
  "n_iterations": 0,
  "n_lots": 0,
  "n_observations": 0,
  "n_train": 0,
  "part_revision_id": "string",
  "policy_history_id": "string",
  "r_squared": 0,
  "replayed": true,
  "residual_sigma_log": 0,
  "rows_not_fitted": {
    "assumed_price": 0,
    "invalid": 0,
    "no_dataset": 0,
    "no_matching_calculation": 0,
    "partial_price": 0,
    "pricing_failed": 0,
    "unpriced": 0,
    "unresolved": 0
  },
  "run_id": "string",
  "samples": 0,
  "samples_applied": 0,
  "scope": "platform",
  "seed_accuracy": 0,
  "status": "complete",
  "target_alpha": 0,
  "target_metric": "string",
  "unknown_part_numbers": [
    "string"
  ],
  "unmatched_part_ids": [
    "string"
  ],
  "validation": {
    "error_after": 0,
    "error_before": 0,
    "gain": 0,
    "gain_lower": 0,
    "gain_upper": 0,
    "mape_after": 0.05,
    "mape_before": 0.05,
    "n_parts": 0,
    "n_rows": 0,
    "reasons": [
      {
        "code": "lot_total_as_unit_cost",
        "params": {}
      }
    ],
    "served": true,
    "verdict": "better"
  },
  "work_orders_received": 0,
  "work_orders_resolved": 0
}
```

## Calibrate cost-down-with-volume from lot-progression actuals.

`POST /api/v1/calibration/environments/{env_id}/learning-curve-fit`

Calibrate how this environment's per-unit cost falls as cumulative production grows, using a sequence of production-lot actuals for one part. Choose the cumulative model (the safer default, observed directly) or the per-unit model. Submit at least three lots.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | path | string | yes | Identifier of the env. |

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `lots` | LearningCurveLotPayload[] | yes | Sequence of production-lot actuals to fit; at least three. |
| `model` | `crawford_unit` \| `wright_cumulative` | no | Learning-curve model to fit (per-unit or cumulative). |
| `part_revision_id` | string | yes | Identifier of the part revision the lots belong to. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/environments/{env_id}/learning-curve-fit \
  -H "X-API-Key: $ARCNM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "part_revision_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "lots": [
      {
        "lot_index": 0,
        "lot_size": 50,
        "lot_total_cost": 0
      }
    ]
  }'
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/calibration/environments/{env_id}/learning-curve-fit",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "part_revision_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "lots": [
            {
                "lot_index": 0,
                "lot_size": 50,
                "lot_total_cost": 0
            }
        ]
    },
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/environments/{env_id}/learning-curve-fit", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "part_revision_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "lots": [
      {
        "lot_index": 0,
        "lot_size": 50,
        "lot_total_cost": 0
      }
    ]
  }),
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `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 |
| --- | --- | --- |
| `a` | number | Fitted first-unit cost coefficient of the curve. |
| `b` | number | Fitted log-log slope exponent of the learning curve. |
| `block_evidence` | BlockEvidencePublic | History import: what the block amounts stated beside the totals became — how many were recorded, and each one that was not with its reason. |
| `env_id` | string | Identifier of the calibrated environment. |
| `fit` | object | Structured object with the fitted parameters and fit diagnostics. |
| `fitted_accuracy` | number | Accuracy (0–1) of the fitted policy on the training rows. |
| `fitted_policy` | object | Structured object describing the fitted selection policy. |
| `grid_size` | integer | Number of policy candidates evaluated during the fit. |
| `history_received` | integer | Historical choice records supplied in the request. |
| `history_rejected` | object[] | Records that could not be used, each with its position in the request and why. Capped at 50 entries; the counts above are never truncated. |
| `history_used` | integer | Records the fit actually used. Lower than ``history_received`` means some could not be read; see ``history_rejected``. |
| `holdout_accuracy` | number | Accuracy (0–1) of the fitted policy on held-out rows. |
| `holdout_coverage` | number | Fraction (0–1) of held-out actuals inside the price range their quote is served, each part scored against a range fitted without it. |
| `holdout_mape` | number | Mean absolute percentage error of the prices this environment gave before the run, over every row the decision was measured on — the miss this run set out to close, not the outcome. Read mape_after for the result. |
| `holdout_pct` | number | History import: the fraction of parts the fit held out. Null on a replay of a fit stored before it was recorded. |
| `id` | string | Identifier of the resulting record, when applicable. |
| `ingested` | integer | Number of observations persisted by an ingest call. |
| `learning_rate` | number | Learning rate (0–1): cost retained each time output doubles. |
| `mape_after` | number | MAPE AFTER the fit, each row priced by a calibration fitted without its part (validation.mape_after). The run's headline outcome; null when the run fitted no unit-cost calibration. |
| `mape_before` | number | MAPE before the fit (same figure as holdout_mape, named for the before/after pair). |
| `matched` | integer | Number of supplied rows matched to an existing quote. |
| `message` | string | Human-readable note about the run, when present, in English. A history import states the same facts as fields: matched, rows_not_fitted and block_evidence. |
| `model` | string | Learning-curve model that was fit (crawford_unit or wright_cumulative). |
| `n_holdout` | integer | Number of rows held out to size the prediction interval. |
| `n_iterations` | integer | Iterations the midpoint solver ran before converging. |
| `n_lots` | integer | Number of production lots used in the curve fit. |
| `n_observations` | integer | Number of observations the calibration fit used. |
| `n_train` | integer | Number of rows used to fit the calibration. |
| `part_revision_id` | string | Identifier of the part revision that was fit. |
| `policy_history_id` | string | Identifier of the newly written selection-policy row. |
| `r_squared` | number | Coefficient of determination (0–1) of the curve fit. |
| `replayed` | boolean | History import: true when the import was already calibrated and this is its stored result, replayed without a new fit or a second metered run. The parameters sent are then not applied; target_alpha and holdout_pct say what the stored fit used. |
| `residual_sigma_log` | number | Standard deviation of the fit residuals in log space. |
| `rows_not_fitted` | RowsNotFittedPublic | History import: the rows the fit left out, counted per cause. All zero when every row was fitted (status 'complete' with no row left out). |
| `run_id` | string | Identifier of the calibration run, when one was created. |
| `samples` | integer | Number of samples considered by the run. |
| `samples_applied` | integer | Number of samples actually applied to the fit. |
| `scope` | `platform` \| `environment` | Scope the run applied to: 'platform' or 'environment'. |
| `seed_accuracy` | number | Accuracy (0–1) of the seed policy before calibration. |
| `status` | `complete` \| `partially_complete` \| `published` \| `deactivated` | Outcome status of the calibration run. |
| `target_alpha` | number | History import: the target miss rate the fit used. Null on a replay of a fit stored before it was recorded. |
| `target_metric` | string | Metric the calibration targeted (e.g. 'unit_cost'). |
| `unknown_part_numbers` | string[] | Part numbers that could not be resolved to a known part. |
| `unmatched_part_ids` | string[] | Part revision IDs with no quote at their lot size priced by the current version of the costing model, so they were skipped. |
| `validation` | CalibrationValidationPublic | How this run's calibration prices your parts against today's prices, whether it was applied (held only when worse) and why. Null when the run fitted no unit-cost calibration. |
| `work_orders_received` | integer | Number of ERP work-order rows received. |
| `work_orders_resolved` | integer | Number of work orders resolved to a known part revision. |

**Example response**

```json
{
  "a": 0,
  "b": 0,
  "block_evidence": {
    "refused": [
      {
        "block": "string",
        "part_revision_id": "string",
        "reason": "unknown_block"
      }
    ],
    "written": 0
  },
  "env_id": "string",
  "fit": {},
  "fitted_accuracy": 0,
  "fitted_policy": {},
  "grid_size": 0,
  "history_received": 0,
  "history_rejected": [
    {}
  ],
  "history_used": 0,
  "holdout_accuracy": 0,
  "holdout_coverage": 0.9,
  "holdout_mape": 0.05,
  "holdout_pct": 0,
  "id": "string",
  "ingested": 0,
  "learning_rate": 0,
  "mape_after": 0.05,
  "mape_before": 0.05,
  "matched": 0,
  "message": "string",
  "model": "string",
  "n_holdout": 0,
  "n_iterations": 0,
  "n_lots": 0,
  "n_observations": 0,
  "n_train": 0,
  "part_revision_id": "string",
  "policy_history_id": "string",
  "r_squared": 0,
  "replayed": true,
  "residual_sigma_log": 0,
  "rows_not_fitted": {
    "assumed_price": 0,
    "invalid": 0,
    "no_dataset": 0,
    "no_matching_calculation": 0,
    "partial_price": 0,
    "pricing_failed": 0,
    "unpriced": 0,
    "unresolved": 0
  },
  "run_id": "string",
  "samples": 0,
  "samples_applied": 0,
  "scope": "platform",
  "seed_accuracy": 0,
  "status": "complete",
  "target_alpha": 0,
  "target_metric": "string",
  "unknown_part_numbers": [
    "string"
  ],
  "unmatched_part_ids": [
    "string"
  ],
  "validation": {
    "error_after": 0,
    "error_before": 0,
    "gain": 0,
    "gain_lower": 0,
    "gain_upper": 0,
    "mape_after": 0.05,
    "mape_before": 0.05,
    "n_parts": 0,
    "n_rows": 0,
    "reasons": [
      {
        "code": "lot_total_as_unit_cost",
        "params": {}
      }
    ],
    "served": true,
    "verdict": "better"
  },
  "work_orders_received": 0,
  "work_orders_resolved": 0
}
```

## What would improve this environment's calibration most.

`GET /api/v1/calibration/environments/{env_id}/next-best-evidence`

Ranks the missing evidence for an environment: which parts or lot sizes to submit actuals for next, and where the model is capped and needs a configuration review instead of more data. Read-only.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | path | string | yes | Identifier of the env. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X GET https://api.arcnm.io/api/v1/calibration/environments/{env_id}/next-best-evidence \
  -H "X-API-Key: $ARCNM_API_KEY"
```

```python title="Python"
import requests

resp = requests.get(
    "https://api.arcnm.io/api/v1/calibration/environments/{env_id}/next-best-evidence",
    headers={"X-API-Key": "YOUR_API_KEY"},
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/environments/{env_id}/next-best-evidence", {
  method: "GET",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
  },
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `429` | `rate_limited` | Per-key or per-org rate limit exceeded — back off with jitter and retry. |


**Response body** `200`

| Field | Type | Description |
| --- | --- | --- |
| `env_id` | string | The environment this advice is for. |
| `items` | NextBestEvidenceItem[] | Ranked asks; empty when the corpus is already rich. |

**Example response**

```json
{
  "env_id": "string",
  "items": [
    {
      "ask": "string",
      "code": "other",
      "count": 0,
      "process": "string",
      "rank": 0,
      "reason": "string"
    }
  ]
}
```

## Calibrate which machine an environment recommends from past choices.

`POST /api/v1/calibration/environments/{env_id}/policy/calibrate`

Calibrate how this environment chooses a machine, using a list of historical 'the shop actually picked machine X' decisions. Once calibrated, the environment's machine recommendations better match your shop's real choices.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | path | string | yes | Identifier of the env. |

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `history` | PolicyHistoryRow[] | yes | Past machine-choice records. Each row is {candidates: [{machine_id, unit_cost?, lead_time_days?, capability_score?, fleet_priority?, feasible?}, ...], chosen_machine_id}. A row without candidates or without chosen_machine_id is skipped and reported in history_rejected. |
| `region` | string | no | Region whose seed policy to start from (e.g. DE); null for the default. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/environments/{env_id}/policy/calibrate \
  -H "X-API-Key: $ARCNM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "history": [
      {
        "candidates": [
          {
            "capability_score": 0,
            "feasible": true,
            "fleet_priority": 0,
            "lead_time_days": 0,
            "machine_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
            "unit_cost": 12.84
          }
        ],
        "chosen_machine_id": "string"
      }
    ]
  }'
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/calibration/environments/{env_id}/policy/calibrate",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "history": [
            {
                "candidates": [
                    {
                        "capability_score": 0,
                        "feasible": True,
                        "fleet_priority": 0,
                        "lead_time_days": 0,
                        "machine_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                        "unit_cost": 12.84
                    }
                ],
                "chosen_machine_id": "string"
            }
        ]
    },
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/environments/{env_id}/policy/calibrate", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "history": [
      {
        "candidates": [
          {
            "capability_score": 0,
            "feasible": true,
            "fleet_priority": 0,
            "lead_time_days": 0,
            "machine_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
            "unit_cost": 12.84
          }
        ],
        "chosen_machine_id": "string"
      }
    ]
  }),
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `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 |
| --- | --- | --- |
| `a` | number | Fitted first-unit cost coefficient of the curve. |
| `b` | number | Fitted log-log slope exponent of the learning curve. |
| `block_evidence` | BlockEvidencePublic | History import: what the block amounts stated beside the totals became — how many were recorded, and each one that was not with its reason. |
| `env_id` | string | Identifier of the calibrated environment. |
| `fit` | object | Structured object with the fitted parameters and fit diagnostics. |
| `fitted_accuracy` | number | Accuracy (0–1) of the fitted policy on the training rows. |
| `fitted_policy` | object | Structured object describing the fitted selection policy. |
| `grid_size` | integer | Number of policy candidates evaluated during the fit. |
| `history_received` | integer | Historical choice records supplied in the request. |
| `history_rejected` | object[] | Records that could not be used, each with its position in the request and why. Capped at 50 entries; the counts above are never truncated. |
| `history_used` | integer | Records the fit actually used. Lower than ``history_received`` means some could not be read; see ``history_rejected``. |
| `holdout_accuracy` | number | Accuracy (0–1) of the fitted policy on held-out rows. |
| `holdout_coverage` | number | Fraction (0–1) of held-out actuals inside the price range their quote is served, each part scored against a range fitted without it. |
| `holdout_mape` | number | Mean absolute percentage error of the prices this environment gave before the run, over every row the decision was measured on — the miss this run set out to close, not the outcome. Read mape_after for the result. |
| `holdout_pct` | number | History import: the fraction of parts the fit held out. Null on a replay of a fit stored before it was recorded. |
| `id` | string | Identifier of the resulting record, when applicable. |
| `ingested` | integer | Number of observations persisted by an ingest call. |
| `learning_rate` | number | Learning rate (0–1): cost retained each time output doubles. |
| `mape_after` | number | MAPE AFTER the fit, each row priced by a calibration fitted without its part (validation.mape_after). The run's headline outcome; null when the run fitted no unit-cost calibration. |
| `mape_before` | number | MAPE before the fit (same figure as holdout_mape, named for the before/after pair). |
| `matched` | integer | Number of supplied rows matched to an existing quote. |
| `message` | string | Human-readable note about the run, when present, in English. A history import states the same facts as fields: matched, rows_not_fitted and block_evidence. |
| `model` | string | Learning-curve model that was fit (crawford_unit or wright_cumulative). |
| `n_holdout` | integer | Number of rows held out to size the prediction interval. |
| `n_iterations` | integer | Iterations the midpoint solver ran before converging. |
| `n_lots` | integer | Number of production lots used in the curve fit. |
| `n_observations` | integer | Number of observations the calibration fit used. |
| `n_train` | integer | Number of rows used to fit the calibration. |
| `part_revision_id` | string | Identifier of the part revision that was fit. |
| `policy_history_id` | string | Identifier of the newly written selection-policy row. |
| `r_squared` | number | Coefficient of determination (0–1) of the curve fit. |
| `replayed` | boolean | History import: true when the import was already calibrated and this is its stored result, replayed without a new fit or a second metered run. The parameters sent are then not applied; target_alpha and holdout_pct say what the stored fit used. |
| `residual_sigma_log` | number | Standard deviation of the fit residuals in log space. |
| `rows_not_fitted` | RowsNotFittedPublic | History import: the rows the fit left out, counted per cause. All zero when every row was fitted (status 'complete' with no row left out). |
| `run_id` | string | Identifier of the calibration run, when one was created. |
| `samples` | integer | Number of samples considered by the run. |
| `samples_applied` | integer | Number of samples actually applied to the fit. |
| `scope` | `platform` \| `environment` | Scope the run applied to: 'platform' or 'environment'. |
| `seed_accuracy` | number | Accuracy (0–1) of the seed policy before calibration. |
| `status` | `complete` \| `partially_complete` \| `published` \| `deactivated` | Outcome status of the calibration run. |
| `target_alpha` | number | History import: the target miss rate the fit used. Null on a replay of a fit stored before it was recorded. |
| `target_metric` | string | Metric the calibration targeted (e.g. 'unit_cost'). |
| `unknown_part_numbers` | string[] | Part numbers that could not be resolved to a known part. |
| `unmatched_part_ids` | string[] | Part revision IDs with no quote at their lot size priced by the current version of the costing model, so they were skipped. |
| `validation` | CalibrationValidationPublic | How this run's calibration prices your parts against today's prices, whether it was applied (held only when worse) and why. Null when the run fitted no unit-cost calibration. |
| `work_orders_received` | integer | Number of ERP work-order rows received. |
| `work_orders_resolved` | integer | Number of work orders resolved to a known part revision. |

**Example response**

```json
{
  "a": 0,
  "b": 0,
  "block_evidence": {
    "refused": [
      {
        "block": "string",
        "part_revision_id": "string",
        "reason": "unknown_block"
      }
    ],
    "written": 0
  },
  "env_id": "string",
  "fit": {},
  "fitted_accuracy": 0,
  "fitted_policy": {},
  "grid_size": 0,
  "history_received": 0,
  "history_rejected": [
    {}
  ],
  "history_used": 0,
  "holdout_accuracy": 0,
  "holdout_coverage": 0.9,
  "holdout_mape": 0.05,
  "holdout_pct": 0,
  "id": "string",
  "ingested": 0,
  "learning_rate": 0,
  "mape_after": 0.05,
  "mape_before": 0.05,
  "matched": 0,
  "message": "string",
  "model": "string",
  "n_holdout": 0,
  "n_iterations": 0,
  "n_lots": 0,
  "n_observations": 0,
  "n_train": 0,
  "part_revision_id": "string",
  "policy_history_id": "string",
  "r_squared": 0,
  "replayed": true,
  "residual_sigma_log": 0,
  "rows_not_fitted": {
    "assumed_price": 0,
    "invalid": 0,
    "no_dataset": 0,
    "no_matching_calculation": 0,
    "partial_price": 0,
    "pricing_failed": 0,
    "unpriced": 0,
    "unresolved": 0
  },
  "run_id": "string",
  "samples": 0,
  "samples_applied": 0,
  "scope": "platform",
  "seed_accuracy": 0,
  "status": "complete",
  "target_alpha": 0,
  "target_metric": "string",
  "unknown_part_numbers": [
    "string"
  ],
  "unmatched_part_ids": [
    "string"
  ],
  "validation": {
    "error_after": 0,
    "error_before": 0,
    "gain": 0,
    "gain_lower": 0,
    "gain_upper": 0,
    "mape_after": 0.05,
    "mape_before": 0.05,
    "n_parts": 0,
    "n_rows": 0,
    "reasons": [
      {
        "code": "lot_total_as_unit_cost",
        "params": {}
      }
    ],
    "served": true,
    "verdict": "better"
  },
  "work_orders_received": 0,
  "work_orders_resolved": 0
}
```

## Calibration run history for one environment.

`GET /api/v1/calibration/environments/{env_id}/runs`

Reverse-chronological list of this environment's calibration runs: when each ran, how many observations it used, and whether it has a live correction (``is_active`` — a unit-cost run and a time run can both be active), and its before/after holdout accuracy. ``run_kind`` 'teach' covers teach and auto-calibrate. Use it to compare runs and pick the one to revert to. Read-only.

> **Paginated.** Pass `limit` and `offset` to page through results.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | path | string | yes | Identifier of the env. |
| `limit` | query | integer | no | Runs per page. |
| `offset` | query | integer | no | Runs to skip. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X GET https://api.arcnm.io/api/v1/calibration/environments/{env_id}/runs \
  -H "X-API-Key: $ARCNM_API_KEY"
```

```python title="Python"
import requests

resp = requests.get(
    "https://api.arcnm.io/api/v1/calibration/environments/{env_id}/runs",
    headers={"X-API-Key": "YOUR_API_KEY"},
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/environments/{env_id}/runs", {
  method: "GET",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
  },
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `429` | `rate_limited` | Per-key or per-org rate limit exceeded — back off with jitter and retry. |


**Response body** `200`

| Field | Type | Description |
| --- | --- | --- |
| `env_id` | string | Environment this history belongs to. |
| `limit` | integer | Page size used for this response. |
| `offset` | integer | Runs skipped before this page. |
| `runs` | CalibrationRunHistoryItem[] | Runs, newest first. |
| `total` | integer | Total runs in the environment's history. |

**Example response**

```json
{
  "env_id": "string",
  "limit": 0,
  "offset": 0,
  "runs": [
    {
      "accuracy": {},
      "created_at": "string",
      "fitted_at": "string",
      "id": "string",
      "is_active": true,
      "n_observations": 0,
      "reverted_from_run_id": "string",
      "run_kind": "teach",
      "status": "pending",
      "target_metric": "string",
      "validation": {
        "error_after": 0,
        "error_before": 0,
        "gain": 0,
        "gain_lower": 0,
        "gain_upper": 0,
        "mape_after": 0.05,
        "mape_before": 0.05,
        "n_parts": 0,
        "n_rows": 0,
        "reasons": [],
        "served": true,
        "verdict": "better"
      }
    }
  ],
  "total": 0
}
```

## Restore an earlier calibration run's result.

`POST /api/v1/calibration/environments/{env_id}/runs/{run_id}/revert`

Make an earlier run's calibration the active one again: the current result is retired and the selected run's is restored, exactly as it was fitted — except an adjustment calibration no longer makes, which is not restored. Nothing is refit and no history is lost — every run stays in the history and can be restored again. Quotes priced after this call use the restored calibration.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | path | string | yes | Identifier of the env. |
| `run_id` | path | string | yes | Identifier of the run. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/environments/{env_id}/runs/{run_id}/revert \
  -H "X-API-Key: $ARCNM_API_KEY"
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/calibration/environments/{env_id}/runs/{run_id}/revert",
    headers={"X-API-Key": "YOUR_API_KEY"},
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/environments/{env_id}/runs/{run_id}/revert", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
  },
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `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 |
| --- | --- | --- |
| `a` | number | Fitted first-unit cost coefficient of the curve. |
| `b` | number | Fitted log-log slope exponent of the learning curve. |
| `block_evidence` | BlockEvidencePublic | History import: what the block amounts stated beside the totals became — how many were recorded, and each one that was not with its reason. |
| `env_id` | string | Identifier of the calibrated environment. |
| `fit` | object | Structured object with the fitted parameters and fit diagnostics. |
| `fitted_accuracy` | number | Accuracy (0–1) of the fitted policy on the training rows. |
| `fitted_policy` | object | Structured object describing the fitted selection policy. |
| `grid_size` | integer | Number of policy candidates evaluated during the fit. |
| `history_received` | integer | Historical choice records supplied in the request. |
| `history_rejected` | object[] | Records that could not be used, each with its position in the request and why. Capped at 50 entries; the counts above are never truncated. |
| `history_used` | integer | Records the fit actually used. Lower than ``history_received`` means some could not be read; see ``history_rejected``. |
| `holdout_accuracy` | number | Accuracy (0–1) of the fitted policy on held-out rows. |
| `holdout_coverage` | number | Fraction (0–1) of held-out actuals inside the price range their quote is served, each part scored against a range fitted without it. |
| `holdout_mape` | number | Mean absolute percentage error of the prices this environment gave before the run, over every row the decision was measured on — the miss this run set out to close, not the outcome. Read mape_after for the result. |
| `holdout_pct` | number | History import: the fraction of parts the fit held out. Null on a replay of a fit stored before it was recorded. |
| `id` | string | Identifier of the resulting record, when applicable. |
| `ingested` | integer | Number of observations persisted by an ingest call. |
| `learning_rate` | number | Learning rate (0–1): cost retained each time output doubles. |
| `mape_after` | number | MAPE AFTER the fit, each row priced by a calibration fitted without its part (validation.mape_after). The run's headline outcome; null when the run fitted no unit-cost calibration. |
| `mape_before` | number | MAPE before the fit (same figure as holdout_mape, named for the before/after pair). |
| `matched` | integer | Number of supplied rows matched to an existing quote. |
| `message` | string | Human-readable note about the run, when present, in English. A history import states the same facts as fields: matched, rows_not_fitted and block_evidence. |
| `model` | string | Learning-curve model that was fit (crawford_unit or wright_cumulative). |
| `n_holdout` | integer | Number of rows held out to size the prediction interval. |
| `n_iterations` | integer | Iterations the midpoint solver ran before converging. |
| `n_lots` | integer | Number of production lots used in the curve fit. |
| `n_observations` | integer | Number of observations the calibration fit used. |
| `n_train` | integer | Number of rows used to fit the calibration. |
| `part_revision_id` | string | Identifier of the part revision that was fit. |
| `policy_history_id` | string | Identifier of the newly written selection-policy row. |
| `r_squared` | number | Coefficient of determination (0–1) of the curve fit. |
| `replayed` | boolean | History import: true when the import was already calibrated and this is its stored result, replayed without a new fit or a second metered run. The parameters sent are then not applied; target_alpha and holdout_pct say what the stored fit used. |
| `residual_sigma_log` | number | Standard deviation of the fit residuals in log space. |
| `rows_not_fitted` | RowsNotFittedPublic | History import: the rows the fit left out, counted per cause. All zero when every row was fitted (status 'complete' with no row left out). |
| `run_id` | string | Identifier of the calibration run, when one was created. |
| `samples` | integer | Number of samples considered by the run. |
| `samples_applied` | integer | Number of samples actually applied to the fit. |
| `scope` | `platform` \| `environment` | Scope the run applied to: 'platform' or 'environment'. |
| `seed_accuracy` | number | Accuracy (0–1) of the seed policy before calibration. |
| `status` | `complete` \| `partially_complete` \| `published` \| `deactivated` | Outcome status of the calibration run. |
| `target_alpha` | number | History import: the target miss rate the fit used. Null on a replay of a fit stored before it was recorded. |
| `target_metric` | string | Metric the calibration targeted (e.g. 'unit_cost'). |
| `unknown_part_numbers` | string[] | Part numbers that could not be resolved to a known part. |
| `unmatched_part_ids` | string[] | Part revision IDs with no quote at their lot size priced by the current version of the costing model, so they were skipped. |
| `validation` | CalibrationValidationPublic | How this run's calibration prices your parts against today's prices, whether it was applied (held only when worse) and why. Null when the run fitted no unit-cost calibration. |
| `work_orders_received` | integer | Number of ERP work-order rows received. |
| `work_orders_resolved` | integer | Number of work orders resolved to a known part revision. |

**Example response**

```json
{
  "a": 0,
  "b": 0,
  "block_evidence": {
    "refused": [
      {
        "block": "string",
        "part_revision_id": "string",
        "reason": "unknown_block"
      }
    ],
    "written": 0
  },
  "env_id": "string",
  "fit": {},
  "fitted_accuracy": 0,
  "fitted_policy": {},
  "grid_size": 0,
  "history_received": 0,
  "history_rejected": [
    {}
  ],
  "history_used": 0,
  "holdout_accuracy": 0,
  "holdout_coverage": 0.9,
  "holdout_mape": 0.05,
  "holdout_pct": 0,
  "id": "string",
  "ingested": 0,
  "learning_rate": 0,
  "mape_after": 0.05,
  "mape_before": 0.05,
  "matched": 0,
  "message": "string",
  "model": "string",
  "n_holdout": 0,
  "n_iterations": 0,
  "n_lots": 0,
  "n_observations": 0,
  "n_train": 0,
  "part_revision_id": "string",
  "policy_history_id": "string",
  "r_squared": 0,
  "replayed": true,
  "residual_sigma_log": 0,
  "rows_not_fitted": {
    "assumed_price": 0,
    "invalid": 0,
    "no_dataset": 0,
    "no_matching_calculation": 0,
    "partial_price": 0,
    "pricing_failed": 0,
    "unpriced": 0,
    "unresolved": 0
  },
  "run_id": "string",
  "samples": 0,
  "samples_applied": 0,
  "scope": "platform",
  "seed_accuracy": 0,
  "status": "complete",
  "target_alpha": 0,
  "target_metric": "string",
  "unknown_part_numbers": [
    "string"
  ],
  "unmatched_part_ids": [
    "string"
  ],
  "validation": {
    "error_after": 0,
    "error_before": 0,
    "gain": 0,
    "gain_lower": 0,
    "gain_upper": 0,
    "mape_after": 0.05,
    "mape_before": 0.05,
    "n_parts": 0,
    "n_rows": 0,
    "reasons": [
      {
        "code": "lot_total_as_unit_cost",
        "params": {}
      }
    ],
    "served": true,
    "verdict": "better"
  },
  "work_orders_received": 0,
  "work_orders_resolved": 0
}
```

## Calibration health summary for one environment.

`GET /api/v1/calibration/environments/{env_id}/status`

Read view of an environment's calibration health: whether it is calibrated, when it was last calibrated, how many submitted observations are waiting to be applied, how well the latest calibration predicts your actuals before and after it, and any drift alerts. Use it to decide whether to submit fresh observations, recalibrate or revert.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | path | string | yes | Identifier of the env. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X GET https://api.arcnm.io/api/v1/calibration/environments/{env_id}/status \
  -H "X-API-Key: $ARCNM_API_KEY"
```

```python title="Python"
import requests

resp = requests.get(
    "https://api.arcnm.io/api/v1/calibration/environments/{env_id}/status",
    headers={"X-API-Key": "YOUR_API_KEY"},
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/environments/{env_id}/status", {
  method: "GET",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
  },
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `429` | `rate_limited` | Per-key or per-org rate limit exceeded — back off with jitter and retry. |


**Response body** `200`

| Field | Type | Description |
| --- | --- | --- |
| `accuracy` | object | How well the calibration this environment's prices apply predicts your own actuals on rows it was not fitted on: mape_before and mape_after (mean absolute percentage error, 0–1, of the prices before the run and of the calibration, each row priced by a calibration fitted without its part; n_rows is how many rows, null on a run measured before), coverage (share of the held-out actuals inside the price range, 0–1, each part scored against a range fitted without it) and n_holdout (how many rows were held out). calibration_run_id names the run measured — the one that set the price correction quotes here apply — and inherited is true when that run is a parent environment's (see `inherited_from`), whose price range quotes here are then served. Null when no calibration applies or its run carries no measurement (time adjustments learned from cost sheets carry none). |
| `drift_alerts` | object[] | Open drift alerts, newest first (an alert closes once its price range passes again or is no longer served), each with its code (calibration_moved, accuracy_degraded, price_range_too_narrow, input_readings_disagree or other), its severity (info, warn or crit) and when it was detected. |
| `env_id` | string | Identifier of the environment this status describes. |
| `falls_back_to` | InheritedCalibrationPublic[] | The parent environments whose calibration this one prices on once its own is switched off. Equal to `inherited_from` while it has none of its own; empty when no parent environment is calibrated, and switching its own off then leaves it uncalibrated. |
| `inherited_from` | InheritedCalibrationPublic[] | The environments this one inherits its calibration from. An environment with no active calibration of its own prices on its nearest parent environment's that has one; calibrating it replaces what it inherits (nothing is multiplied onto the parent's), and switching its own calibration off returns it to the parent's. Empty when the calibration is its own or it has none. |
| `is_calibrated` | boolean | Whether this environment has been calibrated to your actuals. |
| `last_fit_at` | string | ISO 8601 timestamp of this environment's own last calibration; null if it never ran one. |
| `observations` | object[] | Per-source counts of submitted observations awaiting application. |

**Example response**

```json
{
  "accuracy": {},
  "drift_alerts": [
    {}
  ],
  "env_id": "string",
  "falls_back_to": [
    {
      "applies_to": [
        "unit_cost"
      ],
      "env_id": "string",
      "name": "string",
      "time_factors_replaced": 0
    }
  ],
  "inherited_from": [
    {
      "applies_to": [
        "unit_cost"
      ],
      "env_id": "string",
      "name": "string",
      "time_factors_replaced": 0
    }
  ],
  "is_calibrated": true,
  "last_fit_at": "string",
  "observations": [
    {}
  ]
}
```

## Calibrate an environment from (predicted, actual) pairs.

`POST /api/v1/calibration/environments/{env_id}/teach`

Calibrate an environment from caller-supplied (predicted, actual) rows. Each ``predicted`` value must come from a current quote for the part: a part this environment priced only before the costing model last changed has none, and a request naming one is refused until the part is priced again. A unit_cost row without a bin is learned in the process its part's current quote was priced in; a part with no such quote here is refused by name, and so is a time row without a bin — state a cost sheet's times with the adjustments endpoint, which attributes them to the processes the part ran on. If you only have actuals, use the one-click auto-calibrate endpoint, which pairs each actual with the part's current quote server-side.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | path | string | yes | Identifier of the env. |

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `holdout_pct` | number | no | Fraction (0.05–0.5) of rows held out to size the prediction interval. |
| `rows` | TeachRow[] | yes | Between 1 and 20,000 (predicted, actual) rows to calibrate from. |
| `target_alpha` | number | no | Target miss rate for the prediction interval (0.10 → a 90% interval). |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/environments/{env_id}/teach \
  -H "X-API-Key: $ARCNM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "rows": [
      {
        "actual": 0,
        "bin": "string",
        "part_revision_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "predicted": 0,
        "target_metric": "unit_cost"
      }
    ]
  }'
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/calibration/environments/{env_id}/teach",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "rows": [
            {
                "actual": 0,
                "bin": "string",
                "part_revision_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                "predicted": 0,
                "target_metric": "unit_cost"
            }
        ]
    },
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/environments/{env_id}/teach", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "rows": [
      {
        "actual": 0,
        "bin": "string",
        "part_revision_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "predicted": 0,
        "target_metric": "unit_cost"
      }
    ]
  }),
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error — or a refused fit. `calibration_actuals_out_of_band`: your actuals sit further from this environment's predictions than calibration may correct, so nothing was fitted. `details.metric` is the target metric refused, `details.ratio` your actuals divided by the prediction (the median over that metric's observations), `details.observations` how many observations it was taken over, and `details.min` and `details.max` the widest correction calibration may apply to that metric (0.5–2× for a unit cost, 0.25–4× for a time). Correct the environment's inputs — machine and labour rates, material prices, shop-practice answers — first, then calibrate. `calibration_no_process_bin`: none of the rows is filed under a process a price reads (`process:<discipline>`), so a fit would change no price; `details.observations` is the number of rows and, when the rows state labels of their own, `details.labels` how many different ones and `details.label` the first. Label each row with the process its part is priced in, or leave the label out. Any other refusal answers `unprocessable_entity` with its reason in `message`. |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `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 |
| --- | --- | --- |
| `a` | number | Fitted first-unit cost coefficient of the curve. |
| `b` | number | Fitted log-log slope exponent of the learning curve. |
| `block_evidence` | BlockEvidencePublic | History import: what the block amounts stated beside the totals became — how many were recorded, and each one that was not with its reason. |
| `env_id` | string | Identifier of the calibrated environment. |
| `fit` | object | Structured object with the fitted parameters and fit diagnostics. |
| `fitted_accuracy` | number | Accuracy (0–1) of the fitted policy on the training rows. |
| `fitted_policy` | object | Structured object describing the fitted selection policy. |
| `grid_size` | integer | Number of policy candidates evaluated during the fit. |
| `history_received` | integer | Historical choice records supplied in the request. |
| `history_rejected` | object[] | Records that could not be used, each with its position in the request and why. Capped at 50 entries; the counts above are never truncated. |
| `history_used` | integer | Records the fit actually used. Lower than ``history_received`` means some could not be read; see ``history_rejected``. |
| `holdout_accuracy` | number | Accuracy (0–1) of the fitted policy on held-out rows. |
| `holdout_coverage` | number | Fraction (0–1) of held-out actuals inside the price range their quote is served, each part scored against a range fitted without it. |
| `holdout_mape` | number | Mean absolute percentage error of the prices this environment gave before the run, over every row the decision was measured on — the miss this run set out to close, not the outcome. Read mape_after for the result. |
| `holdout_pct` | number | History import: the fraction of parts the fit held out. Null on a replay of a fit stored before it was recorded. |
| `id` | string | Identifier of the resulting record, when applicable. |
| `ingested` | integer | Number of observations persisted by an ingest call. |
| `learning_rate` | number | Learning rate (0–1): cost retained each time output doubles. |
| `mape_after` | number | MAPE AFTER the fit, each row priced by a calibration fitted without its part (validation.mape_after). The run's headline outcome; null when the run fitted no unit-cost calibration. |
| `mape_before` | number | MAPE before the fit (same figure as holdout_mape, named for the before/after pair). |
| `matched` | integer | Number of supplied rows matched to an existing quote. |
| `message` | string | Human-readable note about the run, when present, in English. A history import states the same facts as fields: matched, rows_not_fitted and block_evidence. |
| `model` | string | Learning-curve model that was fit (crawford_unit or wright_cumulative). |
| `n_holdout` | integer | Number of rows held out to size the prediction interval. |
| `n_iterations` | integer | Iterations the midpoint solver ran before converging. |
| `n_lots` | integer | Number of production lots used in the curve fit. |
| `n_observations` | integer | Number of observations the calibration fit used. |
| `n_train` | integer | Number of rows used to fit the calibration. |
| `part_revision_id` | string | Identifier of the part revision that was fit. |
| `policy_history_id` | string | Identifier of the newly written selection-policy row. |
| `r_squared` | number | Coefficient of determination (0–1) of the curve fit. |
| `replayed` | boolean | History import: true when the import was already calibrated and this is its stored result, replayed without a new fit or a second metered run. The parameters sent are then not applied; target_alpha and holdout_pct say what the stored fit used. |
| `residual_sigma_log` | number | Standard deviation of the fit residuals in log space. |
| `rows_not_fitted` | RowsNotFittedPublic | History import: the rows the fit left out, counted per cause. All zero when every row was fitted (status 'complete' with no row left out). |
| `run_id` | string | Identifier of the calibration run, when one was created. |
| `samples` | integer | Number of samples considered by the run. |
| `samples_applied` | integer | Number of samples actually applied to the fit. |
| `scope` | `platform` \| `environment` | Scope the run applied to: 'platform' or 'environment'. |
| `seed_accuracy` | number | Accuracy (0–1) of the seed policy before calibration. |
| `status` | `complete` \| `partially_complete` \| `published` \| `deactivated` | Outcome status of the calibration run. |
| `target_alpha` | number | History import: the target miss rate the fit used. Null on a replay of a fit stored before it was recorded. |
| `target_metric` | string | Metric the calibration targeted (e.g. 'unit_cost'). |
| `unknown_part_numbers` | string[] | Part numbers that could not be resolved to a known part. |
| `unmatched_part_ids` | string[] | Part revision IDs with no quote at their lot size priced by the current version of the costing model, so they were skipped. |
| `validation` | CalibrationValidationPublic | How this run's calibration prices your parts against today's prices, whether it was applied (held only when worse) and why. Null when the run fitted no unit-cost calibration. |
| `work_orders_received` | integer | Number of ERP work-order rows received. |
| `work_orders_resolved` | integer | Number of work orders resolved to a known part revision. |

**Example response**

```json
{
  "a": 0,
  "b": 0,
  "block_evidence": {
    "refused": [
      {
        "block": "string",
        "part_revision_id": "string",
        "reason": "unknown_block"
      }
    ],
    "written": 0
  },
  "env_id": "string",
  "fit": {},
  "fitted_accuracy": 0,
  "fitted_policy": {},
  "grid_size": 0,
  "history_received": 0,
  "history_rejected": [
    {}
  ],
  "history_used": 0,
  "holdout_accuracy": 0,
  "holdout_coverage": 0.9,
  "holdout_mape": 0.05,
  "holdout_pct": 0,
  "id": "string",
  "ingested": 0,
  "learning_rate": 0,
  "mape_after": 0.05,
  "mape_before": 0.05,
  "matched": 0,
  "message": "string",
  "model": "string",
  "n_holdout": 0,
  "n_iterations": 0,
  "n_lots": 0,
  "n_observations": 0,
  "n_train": 0,
  "part_revision_id": "string",
  "policy_history_id": "string",
  "r_squared": 0,
  "replayed": true,
  "residual_sigma_log": 0,
  "rows_not_fitted": {
    "assumed_price": 0,
    "invalid": 0,
    "no_dataset": 0,
    "no_matching_calculation": 0,
    "partial_price": 0,
    "pricing_failed": 0,
    "unpriced": 0,
    "unresolved": 0
  },
  "run_id": "string",
  "samples": 0,
  "samples_applied": 0,
  "scope": "platform",
  "seed_accuracy": 0,
  "status": "complete",
  "target_alpha": 0,
  "target_metric": "string",
  "unknown_part_numbers": [
    "string"
  ],
  "unmatched_part_ids": [
    "string"
  ],
  "validation": {
    "error_after": 0,
    "error_before": 0,
    "gain": 0,
    "gain_lower": 0,
    "gain_upper": 0,
    "mape_after": 0.05,
    "mape_before": 0.05,
    "n_parts": 0,
    "n_rows": 0,
    "reasons": [
      {
        "code": "lot_total_as_unit_cost",
        "params": {}
      }
    ],
    "served": true,
    "verdict": "better"
  },
  "work_orders_received": 0,
  "work_orders_resolved": 0
}
```

## Ask whether your ERP part numbers resolve, before you calibrate.

`POST /api/v1/calibration/erp-preflight`

Resolves the `part_number` column of an ERP export against the parts you hold and returns how many match. Reads only — it needs no environment and it writes nothing.

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `part_numbers` | string[] | yes | The `part_number` column of the work orders you are about to send, in any order. Duplicates are fine. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/erp-preflight \
  -H "X-API-Key: $ARCNM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "part_numbers": [
      "string"
    ]
  }'
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/calibration/erp-preflight",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "part_numbers": [
            "string"
        ]
    },
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/erp-preflight", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "part_numbers": [
      "string"
    ]
  }),
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error |
| `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 |
| --- | --- | --- |
| `matched` | integer | How many of them resolve to a part you hold. |
| `requested` | integer | Distinct part numbers you asked about. |
| `unknown` | integer | How many do not. |
| `unknown_part_numbers` | string[] | The ones that do not, up to 100 of them — the list to fix before you run the calibration. |

**Example response**

```json
{
  "matched": 0,
  "requested": 0,
  "unknown": 0,
  "unknown_part_numbers": [
    "string"
  ]
}
```

## An environment's calibration imports, newest first.

`GET /api/v1/calibration/imports`

Finds a run again, a page at a time: filter by ``status`` (e.g. ``pricing`` for the imports whose calculations are still running or parked on billing) and read each one with GET /calibration/imports/{id}. Counts are read live; nothing is reconciled or changed by this call.

> **Paginated.** Pass `limit` and `offset` to page through results.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `env_id` | query | string | yes | Identifier of the env. |
| `status` | query | `received` \| `resolving` \| `preflight_ready` \| `pricing` \| `fitting` \| `review_ready` \| `complete` \| `partially_complete` \| `failed` \| `cancelled`[] | no | Only imports in these states. |
| `limit` | query | integer | no | Maximum number of results to return. |
| `offset` | query | integer | no | Number of results to skip before the returned page. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X GET https://api.arcnm.io/api/v1/calibration/imports \
  -H "X-API-Key: $ARCNM_API_KEY"
```

```python title="Python"
import requests

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

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/imports", {
  method: "GET",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
  },
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error |
| `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. |
| `429` | `rate_limited` | Per-key or per-org rate limit exceeded — back off with jitter and retry. |


**Response body** `200`

| Field | Type | Description |
| --- | --- | --- |
| `items` | CalibrationImportSummaryPublic[] |  |
| `limit` | integer |  |
| `offset` | integer |  |
| `total` | integer | Imports that match, all pages. |

**Example response**

```json
{
  "items": [
    {
      "calculations_required": 0,
      "completed_at": "2026-06-01T12:00:00Z",
      "created_at": "2026-06-01T12:00:00Z",
      "env_id": "string",
      "import_id": "string",
      "parked_calculations": 0,
      "pending_calculations": 0,
      "rows_received": 0,
      "rows_usable": 0,
      "source_filename": "bracket.step",
      "status": "received",
      "updated_at": "2026-06-01T12:00:00Z"
    }
  ],
  "limit": 0,
  "offset": 0,
  "total": 0
}
```

## Create a calibration import and disclose what pricing it will cost.

`POST /api/v1/calibration/imports`

Upload historical actuals as rows. Every row is resolved against your part library and bucketed: already priced (free), needs a new calculation (billable), or unusable (with the fix named). Only a quote priced by the current version of the costing model counts as already priced; a part quoted only before the model last changed needs a new calculation. NOTHING is priced or spent by this call — the disclosed ``calculations_required`` is committed explicitly via POST /calibration/imports/{id}/price. Re-posting the same rows returns the same import until the costing model changes; after that, the same rows start a new import.

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `basis` | `herstellkosten` \| `selbstkosten` \| `angebotspreis` | yes | Which rung of the cost sheet the whole file is measured at: 'herstellkosten' (manufacturing cost per unit — what a work order books), 'selbstkosten' (total cost per unit, including administration, selling, freight and duty) or 'angebotspreis' (the price per unit, including the profit mark-up). Required: one basis per file, like one currency per file. Each row is compared against the model's own figure at the same rung. A column header cannot answer this — 'unit cost' and 'unit price' are used interchangeably in exports — so it is asked rather than guessed; a file without it is refused before anything is read. Fixed when the import is created; re-posting the same rows returns the existing import unchanged. |
| `block_columns` | object | no | With csv or data_source_id: how to read named columns, header text → a block of the cost sheet ('tooling', 'setup', 'subcontract:hardening', ...) or 'ignore'. Headers not named here are read by their name as described under csv. A block name not in the list is refused by name (`calibration_block_unknown`). |
| `csv` | string | no | The history as CSV text with a header row, instead of rows. Columns are matched by name, German ERP headers included: a part number (part_number, Artikelnummer, Material, MATNR, SKU), the lot (lot_size, quantity, Menge, Losgröße), a price per part (unit_price, Stückpreis) or for the lot (total_price, Gesamtpreis), and optionally annual_volume (Jahresmenge) and source_ref (Auftrag, work order). Optional block columns state an amount per block of the cost sheet beside the price, on the price's footing (per part, or for the lot): Materialkosten / material_cost, Maschine / machine, Lohn / labour, Rüsten / setup, Programmierung / programming, Prüfung / inspection, Werkzeug / tooling, and one column per outsourced operation named Fremdbearbeitung_<operation> or subcontract_<operation> (e.g. Fremdbearbeitung_Härten). An optional material_grade column (grade, Werkstoff, Werkstoffnummer) names the material of each line's part, read as the rows' material_grade reads it; a bare Material column is the part number (SAP's Materialnummer). A line whose material names no grade is unreadable, its reason naming the text. Other columns are ignored. |
| `currency` | string | no | Currency the actuals are denominated in. Must match the environment's currency; defaults to it. |
| `data_source_id` | string | no | A confirmed .csv or .xlsx upload holding the history, instead of rows: read exactly as the file has it, with the columns csv takes. Naming an upload needs uploads:read. |
| `decimal_mark` | `auto` \| `point` \| `comma` | no | With csv or data_source_id: the decimal mark of a CSV file. 'auto' (the default) is the one its delimiter implies: the comma for a semicolon-separated file, the point for a comma- or tab-separated one. 'point' or 'comma' states it. An Excel file's numbers are numbers, and its text cells are read with the point. A number is an optional sign, digits, and optionally the decimal mark and digits; a cell with anything else (a thousands separator, a currency sign or unit, the other mark) is an unreadable line whose reason says what was found. |
| `env_id` | string | yes | The costing environment to calibrate. |
| `rows` | CalibrationImportRowIn[] | no | Up to 20,000 historical actuals. Send the history as exactly one of rows, csv or data_source_id. |
| `sheet` | string | no | Worksheet of an Excel upload, by name; the first one when omitted. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/imports \
  -H "X-API-Key: $ARCNM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "env_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "basis": "herstellkosten"
  }'
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/calibration/imports",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "env_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "basis": "herstellkosten"
    },
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/imports", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "env_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "basis": "herstellkosten"
  }),
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `201` | Successful Response |
| `422` | Validation Error |
| `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** `201`

| Field | Type | Description |
| --- | --- | --- |
| `calculations_free` | integer | Rows already priced — free. |
| `calculations_remaining` | integer | Your plan's remaining calculation allowance at the time of this response, when known — read on every call, not stored with the import. |
| `calculations_required` | integer | Distinct (part, lot) pairs that need a NEW calculation — the billable spend POST /price will commit. Nothing is priced by this call. |
| `columns` | object | For csv or a file: each column read (part_number, lot_size, unit_price or total_price, annual_volume, source_ref, material_grade) and the header your file used for it. |
| `created` | boolean | False when these exact rows were already imported into this environment — the existing import is returned instead of a duplicate. |
| `default_material` | string | The environment's default material, by the name a reader knows it by (C45 (1.0503)), when a row is priced in it. |
| `distinct_lot_sizes` | integer | Distinct lot sizes across usable rows. Below two the fit cannot split setup cost from per-part cost. |
| `env_id` | string | The environment this import calibrates. |
| `import_id` | string | Identifier of the created import. |
| `lines_unreadable` | integer | For csv or a file: lines that could not be used. |
| `message` | string | The cost disclosure, in plain language. |
| `parts_assumed_price` | string[] | Parts whose price in this environment rests on stated assumptions. Left out and free, like parts_partial_price; each row's calculation_id shows what the price assumes. |
| `parts_material_from_files` | string[] | Parts with no price here whose rows name no material: each is priced in the material its drawing or STEP file names, else in the environment's default material (default_material). |
| `parts_on_default_material` | string[] | Parts whose rows name no material, priced or reused in the environment's default material (default_material): nothing names theirs, and the environment prices them in it. Name the material (material_grade) of any made of something else: calibrating on the wrong material moves the rates instead. |
| `parts_partial_price` | string[] | Parts whose price in this environment leaves work out. Such a price cannot be compared with an actual and pricing the part again returns it, so these rows are left out and nothing is spent on them. Each row's calculation_id shows what is left out; resolve it, price the part again, then check again. |
| `parts_priced_again_for_material` | string[] | Parts priced again in their material — the one the row names, or the one the part's prices here name — because their price here at that lot is in another material. Counted in calculations_required. |
| `parts_without_cad` | string[] | Parts with no STEP file to calculate from — upload one. |
| `parts_without_material` | string[] | Parts whose rows are left out (state invalid) because the row names no material and the part is priced here in several materials. Name the material (material_grade) and send the rows again. |
| `rows_received` | integer | Rows submitted. |
| `rows_usable` | integer | Rows that can become calibration observations. |
| `status` | `received` \| `resolving` \| `preflight_ready` \| `pricing` \| `fitting` \| `review_ready` \| `complete` \| `partially_complete` \| `failed` \| `cancelled` | Import lifecycle status. |
| `unreadable` | CalibrationImportLineError[] | The first 50 unreadable lines, and why. |
| `unresolved_part_numbers` | string[] | Part numbers not in your library — add the parts. |

**Example response**

```json
{
  "calculations_free": 0,
  "calculations_remaining": 0,
  "calculations_required": 0,
  "columns": {},
  "created": true,
  "default_material": "string",
  "distinct_lot_sizes": 0,
  "env_id": "string",
  "import_id": "string",
  "lines_unreadable": 0,
  "message": "string",
  "parts_assumed_price": [
    "string"
  ],
  "parts_material_from_files": [
    "string"
  ],
  "parts_on_default_material": [
    "string"
  ],
  "parts_partial_price": [
    "string"
  ],
  "parts_priced_again_for_material": [
    "string"
  ],
  "parts_without_cad": [
    "string"
  ],
  "parts_without_material": [
    "string"
  ],
  "rows_received": 0,
  "rows_usable": 0,
  "status": "received",
  "unreadable": [
    {
      "line": 0,
      "reason": "string"
    }
  ],
  "unresolved_part_numbers": [
    "string"
  ]
}
```

## Import status: per-row states and whether the priced pairs settled.

`GET /api/v1/calibration/imports/{import_id}`

Joins every priced row to its calculation and folds terminal outcomes back onto the rows (succeeded → priced, failed → pricing_failed, verbatim reason attached), and links a row still waiting for a price to a calculation priced in this environment since the import was created. ``settled`` only says nothing is still running; ``ready_to_calibrate`` is the green light to calibrate. Rows are capped at 1000 in the response; the counts never are. Carries the cost disclosure the create call returned, with the remaining allowance read at this request.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `import_id` | path | string | yes | Identifier of the import. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X GET https://api.arcnm.io/api/v1/calibration/imports/{import_id} \
  -H "X-API-Key: $ARCNM_API_KEY"
```

```python title="Python"
import requests

resp = requests.get(
    "https://api.arcnm.io/api/v1/calibration/imports/{import_id}",
    headers={"X-API-Key": "YOUR_API_KEY"},
)
resp.raise_for_status()
print(resp.json())
```

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/imports/{import_id}", {
  method: "GET",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
  },
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `429` | `rate_limited` | Per-key or per-org rate limit exceeded — back off with jitter and retry. |


**Response body** `200`

| Field | Type | Description |
| --- | --- | --- |
| `calculations_free` | integer | Rows already priced — free. |
| `calculations_remaining` | integer | Your plan's remaining calculation allowance at the time of this response, when known — read on every call, not stored with the import. |
| `calculations_required` | integer | Billable pairs disclosed at preflight. |
| `calculations_run` | integer | Calculations actually created by the price commits. |
| `default_material` | string | The environment's default material, by the name a reader knows it by (C45 (1.0503)), when a row is priced in it. |
| `distinct_lot_sizes` | integer | Distinct lot sizes across usable rows. Below two the fit cannot split setup cost from per-part cost. |
| `env_id` | string |  |
| `error` | string | Import-level failure, when one happened. |
| `failure_code` | `calibration_actuals_out_of_band` \| `calibration_no_process_bin` \| `no_comparable_prices` \| `unknown` | Why the import failed, set exactly when status is failed. 'calibration_actuals_out_of_band': your actuals sit further from this environment's predictions than calibration may correct — correct the environment's inputs (machine and labour rates, material prices, shop-practice answers) first. 'calibration_no_process_bin': none of the rows is filed under a process a price reads, so a fit would change no price — label each row with the process its part is priced in ('process:<discipline>'), or leave the label out. 'no_comparable_prices': no row has a price that can be compared with its actual — see failure_params and each row's state. 'unknown': a failure with no code of its own; error says what happened. |
| `failure_params` | object | The figures behind failure_code, when it has any. For 'calibration_actuals_out_of_band': ratio (your actuals divided by the prediction, the median over the fit's observations), observations, min and max, the widest correction calibration may apply, and metric, the target metric the band belongs to ('unit_cost' for an import). For 'calibration_no_process_bin': observations (the rows of the fit) and, when the rows state labels of their own, labels (how many different ones) and label (the first). For 'no_comparable_prices': rows left out per cause — partial_price, assumed_price, pricing_failed, unpriced, unresolved (part number not in your library), no_dataset (no STEP file), no_matching_calculation (no current price at the row's lot size in its material) and invalid (the part is priced here in several materials and the row names none). |
| `import_id` | string |  |
| `message` | string | The cost disclosure, in plain language. |
| `parked_calculations` | integer | Of pending_calculations, the rows whose calculation is parked on billing: it runs once the organization has calculations left, its payment is settled and any API-key spend limit allows it. Parked rows are in the queued state in state_counts. |
| `parts_assumed_price` | string[] | Parts whose price in this environment rests on stated assumptions. Left out and free, like parts_partial_price; each row's calculation_id shows what the price assumes. |
| `parts_material_from_files` | string[] | Parts with no price here whose rows name no material: each is priced in the material its drawing or STEP file names, else in the environment's default material (default_material). |
| `parts_on_default_material` | string[] | Parts whose rows name no material, priced or reused in the environment's default material (default_material): nothing names theirs, and the environment prices them in it. Name the material (material_grade) of any made of something else: calibrating on the wrong material moves the rates instead. |
| `parts_partial_price` | string[] | Parts whose price in this environment leaves work out. Such a price cannot be compared with an actual and pricing the part again returns it, so these rows are left out and nothing is spent on them. Each row's calculation_id shows what is left out; resolve it, price the part again, then check again. |
| `parts_priced_again_for_material` | string[] | Parts priced again in their material — the one the row names, or the one the part's prices here name — because their price here at that lot is in another material. Counted in calculations_required. |
| `parts_without_cad` | string[] | Parts with no STEP file to calculate from — upload one. |
| `parts_without_material` | string[] | Parts whose rows are left out (state invalid) because the row names no material and the part is priced here in several materials. Name the material (material_grade) and send the rows again. |
| `pending_calculations` | integer | Rows whose calculation is still queued or running, parked ones included. |
| `ready_to_calibrate` | boolean | True when the import can be calibrated with every row it could use: at least one row is priced and none is still waiting for a calculation (needs_calc) or running. |
| `rows` | CalibrationImportRowPublic[] |  |
| `rows_received` | integer | Rows submitted. |
| `rows_truncated` | boolean | True when more than 1000 rows exist; counts are never truncated. |
| `rows_usable` | integer | Rows that can become calibration observations. |
| `settled` | boolean | True when no calculation this import started is still running. Not a readiness signal on its own: rows that still need a calculation are unpriced, not settled-and-usable. Read ready_to_calibrate. |
| `state_counts` | object | Row count per disposition state. |
| `status` | `received` \| `resolving` \| `preflight_ready` \| `pricing` \| `fitting` \| `review_ready` \| `complete` \| `partially_complete` \| `failed` \| `cancelled` |  |
| `unresolved_part_numbers` | string[] | Part numbers not in your library — add the parts. |

**Example response**

```json
{
  "calculations_free": 0,
  "calculations_remaining": 0,
  "calculations_required": 0,
  "calculations_run": 0,
  "default_material": "string",
  "distinct_lot_sizes": 0,
  "env_id": "string",
  "error": "string",
  "failure_code": "calibration_actuals_out_of_band",
  "failure_params": {},
  "import_id": "string",
  "message": "string",
  "parked_calculations": 0,
  "parts_assumed_price": [
    "string"
  ],
  "parts_material_from_files": [
    "string"
  ],
  "parts_on_default_material": [
    "string"
  ],
  "parts_partial_price": [
    "string"
  ],
  "parts_priced_again_for_material": [
    "string"
  ],
  "parts_without_cad": [
    "string"
  ],
  "parts_without_material": [
    "string"
  ],
  "pending_calculations": 0,
  "ready_to_calibrate": false,
  "rows": [
    {
      "actual_unit_cost": 0,
      "annual_volume": 500,
      "calculation_id": "string",
      "detail": "string",
      "lot_size": 50,
      "material_grade": "string",
      "part_number": "BRACKET-001",
      "reason_code": "calculation_failed",
      "row_ordinal": 0,
      "state": "pending"
    }
  ],
  "rows_received": 0,
  "rows_truncated": false,
  "rows_usable": 0,
  "settled": true,
  "state_counts": {},
  "status": "received",
  "unresolved_part_numbers": [
    "string"
  ]
}
```

## Fit the environment on every settled (part, lot) actual.

`POST /api/v1/calibration/imports/{import_id}/calibrate`

Calibrates the environment on every now-matching row, exactly as the one-click auto-calibrate endpoint would, and returns the same result shape (mape_before → mape_after). Refused (409) while priced pairs are still running. Metered as one calibration run. Idempotent: a completed import replays its stored result without metering a second run. A replay says so (replayed is true): parameters sent then are not applied, and target_alpha and holdout_pct name the ones the fit used.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `import_id` | path | string | yes | Identifier of the import. |

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `holdout_pct` | number | no | Fraction of rows held out to size the prediction interval. |
| `target_alpha` | number | no | Target miss rate for the prediction interval (0.10 → 90%). |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/imports/{import_id}/calibrate \
  -H "X-API-Key: $ARCNM_API_KEY"
```

```python title="Python"
import requests

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

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/imports/{import_id}/calibrate", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
  },
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error — or a refused fit. `calibration_actuals_out_of_band`: your actuals sit further from this environment's predictions than calibration may correct, so nothing was fitted. `details.metric` is the target metric refused, `details.ratio` your actuals divided by the prediction (the median over that metric's observations), `details.observations` how many observations it was taken over, and `details.min` and `details.max` the widest correction calibration may apply to that metric (0.5–2× for a unit cost, 0.25–4× for a time). Correct the environment's inputs — machine and labour rates, material prices, shop-practice answers — first, then calibrate. `calibration_no_process_bin`: none of the rows is filed under a process a price reads (`process:<discipline>`), so a fit would change no price; `details.observations` is the number of rows and, when the rows state labels of their own, `details.labels` how many different ones and `details.label` the first. Label each row with the process its part is priced in, or leave the label out. Any other refusal answers `unprocessable_entity` with its reason in `message`. |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `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 |
| --- | --- | --- |
| `a` | number | Fitted first-unit cost coefficient of the curve. |
| `b` | number | Fitted log-log slope exponent of the learning curve. |
| `block_evidence` | BlockEvidencePublic | History import: what the block amounts stated beside the totals became — how many were recorded, and each one that was not with its reason. |
| `env_id` | string | Identifier of the calibrated environment. |
| `fit` | object | Structured object with the fitted parameters and fit diagnostics. |
| `fitted_accuracy` | number | Accuracy (0–1) of the fitted policy on the training rows. |
| `fitted_policy` | object | Structured object describing the fitted selection policy. |
| `grid_size` | integer | Number of policy candidates evaluated during the fit. |
| `history_received` | integer | Historical choice records supplied in the request. |
| `history_rejected` | object[] | Records that could not be used, each with its position in the request and why. Capped at 50 entries; the counts above are never truncated. |
| `history_used` | integer | Records the fit actually used. Lower than ``history_received`` means some could not be read; see ``history_rejected``. |
| `holdout_accuracy` | number | Accuracy (0–1) of the fitted policy on held-out rows. |
| `holdout_coverage` | number | Fraction (0–1) of held-out actuals inside the price range their quote is served, each part scored against a range fitted without it. |
| `holdout_mape` | number | Mean absolute percentage error of the prices this environment gave before the run, over every row the decision was measured on — the miss this run set out to close, not the outcome. Read mape_after for the result. |
| `holdout_pct` | number | History import: the fraction of parts the fit held out. Null on a replay of a fit stored before it was recorded. |
| `id` | string | Identifier of the resulting record, when applicable. |
| `ingested` | integer | Number of observations persisted by an ingest call. |
| `learning_rate` | number | Learning rate (0–1): cost retained each time output doubles. |
| `mape_after` | number | MAPE AFTER the fit, each row priced by a calibration fitted without its part (validation.mape_after). The run's headline outcome; null when the run fitted no unit-cost calibration. |
| `mape_before` | number | MAPE before the fit (same figure as holdout_mape, named for the before/after pair). |
| `matched` | integer | Number of supplied rows matched to an existing quote. |
| `message` | string | Human-readable note about the run, when present, in English. A history import states the same facts as fields: matched, rows_not_fitted and block_evidence. |
| `model` | string | Learning-curve model that was fit (crawford_unit or wright_cumulative). |
| `n_holdout` | integer | Number of rows held out to size the prediction interval. |
| `n_iterations` | integer | Iterations the midpoint solver ran before converging. |
| `n_lots` | integer | Number of production lots used in the curve fit. |
| `n_observations` | integer | Number of observations the calibration fit used. |
| `n_train` | integer | Number of rows used to fit the calibration. |
| `part_revision_id` | string | Identifier of the part revision that was fit. |
| `policy_history_id` | string | Identifier of the newly written selection-policy row. |
| `r_squared` | number | Coefficient of determination (0–1) of the curve fit. |
| `replayed` | boolean | History import: true when the import was already calibrated and this is its stored result, replayed without a new fit or a second metered run. The parameters sent are then not applied; target_alpha and holdout_pct say what the stored fit used. |
| `residual_sigma_log` | number | Standard deviation of the fit residuals in log space. |
| `rows_not_fitted` | RowsNotFittedPublic | History import: the rows the fit left out, counted per cause. All zero when every row was fitted (status 'complete' with no row left out). |
| `run_id` | string | Identifier of the calibration run, when one was created. |
| `samples` | integer | Number of samples considered by the run. |
| `samples_applied` | integer | Number of samples actually applied to the fit. |
| `scope` | `platform` \| `environment` | Scope the run applied to: 'platform' or 'environment'. |
| `seed_accuracy` | number | Accuracy (0–1) of the seed policy before calibration. |
| `status` | `complete` \| `partially_complete` \| `published` \| `deactivated` | Outcome status of the calibration run. |
| `target_alpha` | number | History import: the target miss rate the fit used. Null on a replay of a fit stored before it was recorded. |
| `target_metric` | string | Metric the calibration targeted (e.g. 'unit_cost'). |
| `unknown_part_numbers` | string[] | Part numbers that could not be resolved to a known part. |
| `unmatched_part_ids` | string[] | Part revision IDs with no quote at their lot size priced by the current version of the costing model, so they were skipped. |
| `validation` | CalibrationValidationPublic | How this run's calibration prices your parts against today's prices, whether it was applied (held only when worse) and why. Null when the run fitted no unit-cost calibration. |
| `work_orders_received` | integer | Number of ERP work-order rows received. |
| `work_orders_resolved` | integer | Number of work orders resolved to a known part revision. |

**Example response**

```json
{
  "a": 0,
  "b": 0,
  "block_evidence": {
    "refused": [
      {
        "block": "string",
        "part_revision_id": "string",
        "reason": "unknown_block"
      }
    ],
    "written": 0
  },
  "env_id": "string",
  "fit": {},
  "fitted_accuracy": 0,
  "fitted_policy": {},
  "grid_size": 0,
  "history_received": 0,
  "history_rejected": [
    {}
  ],
  "history_used": 0,
  "holdout_accuracy": 0,
  "holdout_coverage": 0.9,
  "holdout_mape": 0.05,
  "holdout_pct": 0,
  "id": "string",
  "ingested": 0,
  "learning_rate": 0,
  "mape_after": 0.05,
  "mape_before": 0.05,
  "matched": 0,
  "message": "string",
  "model": "string",
  "n_holdout": 0,
  "n_iterations": 0,
  "n_lots": 0,
  "n_observations": 0,
  "n_train": 0,
  "part_revision_id": "string",
  "policy_history_id": "string",
  "r_squared": 0,
  "replayed": true,
  "residual_sigma_log": 0,
  "rows_not_fitted": {
    "assumed_price": 0,
    "invalid": 0,
    "no_dataset": 0,
    "no_matching_calculation": 0,
    "partial_price": 0,
    "pricing_failed": 0,
    "unpriced": 0,
    "unresolved": 0
  },
  "run_id": "string",
  "samples": 0,
  "samples_applied": 0,
  "scope": "platform",
  "seed_accuracy": 0,
  "status": "complete",
  "target_alpha": 0,
  "target_metric": "string",
  "unknown_part_numbers": [
    "string"
  ],
  "unmatched_part_ids": [
    "string"
  ],
  "validation": {
    "error_after": 0,
    "error_before": 0,
    "gain": 0,
    "gain_lower": 0,
    "gain_upper": 0,
    "mape_after": 0.05,
    "mape_before": 0.05,
    "n_parts": 0,
    "n_rows": 0,
    "reasons": [
      {
        "code": "lot_total_as_unit_cost",
        "params": {}
      }
    ],
    "served": true,
    "verdict": "better"
  },
  "work_orders_received": 0,
  "work_orders_resolved": 0
}
```

## Commit the disclosed spend: price every unpriced (part, lot) pair.

`POST /api/v1/calibration/imports/{import_id}/price`

Creates and enqueues one calculation per unpriced (part, lot) pair. Each is billed and admitted exactly like a calculation you run directly. Idempotent: rows already priced or queued are skipped, so a retry resumes instead of duplicating. A retry also starts this import's calculations parked on billing once billing allows them (``resumed``); the rest stay parked (``still_parked``). Send ``expected_calculations`` (the disclosed ``calculations_required``): it is the spend you confirm, and the call never starts more. If the import would start more than you confirmed — or any, when you confirmed none — nothing is priced and the answer is 409 ``calculations_changed``. Poll GET /calibration/imports/{id} until ``settled``.

**Parameters**

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `import_id` | path | string | yes | Identifier of the import. |

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `expected_calculations` | integer | no | The most new calculations you confirm this call may start: send the calculations_required the import disclosed. If it would start more — or you send none and it would start any — nothing is priced and the answer is 409 calculations_changed with the count in details.calculations_required. Needed whenever the call would start a calculation; a call that starts none (a retry, a resume of parked rows) may omit it. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/imports/{import_id}/price \
  -H "X-API-Key: $ARCNM_API_KEY"
```

```python title="Python"
import requests

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

```typescript title="TypeScript"
const resp = await fetch("https://api.arcnm.io/api/v1/calibration/imports/{import_id}/price", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.ARCNM_API_KEY!,
  },
})
const data = await resp.json()
```

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `202` | Successful Response |
| `409` | The import is finished (``import_already_finished``), it would start more calculations than ``expected_calculations`` confirms — none, when omitted — (``calculations_changed``; ``details.calculations_required`` is the count now), or another request is pricing it (``pricing_in_progress``). Nothing was priced. |
| `422` | Validation Error |
| `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. |
| `404` | `not_found` | A referenced resource doesn't exist or isn't visible to your organisation. |
| `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** `202`

| Field | Type | Description |
| --- | --- | --- |
| `accepted` | integer | Rows whose calculation was created and enqueued. |
| `calculations_created` | integer | New calculation rows this call created. |
| `import_id` | string |  |
| `pairs_priced` | integer | Distinct (part, lot) pairs fanned out by THIS call. |
| `parked` | integer | Rows whose calculation was created but parked on billing (see each calculation's coverage); not running. Each starts by itself once the block lifts, or when you resume it. |
| `remaining_needs_calc` | integer | Rows still unpriced after this call (0 when fully committed). |
| `resumed` | integer | This import's calculations that were parked on billing and were started by this call (they were confirmed when priced). |
| `skipped` | integer | Rows already priced or already queued before this call — a re-POST resumes, it never duplicates. |
| `status` | `received` \| `resolving` \| `preflight_ready` \| `pricing` \| `fitting` \| `review_ready` \| `complete` \| `partially_complete` \| `failed` \| `cancelled` | Import lifecycle status after the commit. |
| `still_parked` | integer | This import's calculations still parked on billing after this call: each one's coverage says why. |

**Example response**

```json
{
  "accepted": 0,
  "calculations_created": 0,
  "import_id": "string",
  "pairs_priced": 0,
  "parked": 0,
  "remaining_needs_calc": 0,
  "resumed": 0,
  "skipped": 0,
  "status": "received",
  "still_parked": 0
}
```

## Submit calibration observations for an environment.

`POST /api/v1/calibration/outcomes`

Submit a batch of observations (predicted vs. actual outcomes) for an environment so it can be calibrated. Tenant-bound; ``scope='environment'`` only. Idempotent on each observation's natural key and rate-limited by the global tenant policy. Recalibrate the environment afterwards to apply the accumulated observations. Take each predicted value from a current quote: an observation is recorded with the version of the costing model current when it is submitted, and once the model changes, recalibration leaves it out until it is submitted again with a predicted value from the new model.

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `basis` | `herstellkosten` \| `selbstkosten` \| `angebotspreis` | no | Which rung of the cost sheet these numbers are measured at: 'herstellkosten' (manufacturing cost per unit — what a work order books), 'selbstkosten' (total cost per unit, including administration, selling, freight and duty) or 'angebotspreis' (the quoted price per unit, including the profit mark-up). Each is compared against the model's own figure at the same rung. Omit it only if you genuinely do not know: an unstated basis is read as manufacturing cost and the environment's calibration report flags how many rows were unstated. |
| `env_id` | string | no | Target environment; required when scope is 'environment'. |
| `observations` | OutcomeObservation[] | no | Up to 20,000 observations; each carries target_metric, observation_type, predicted, and actual. |
| `oracle` | string | yes | Source of the observations (e.g. operator report, MES, supplier quote). |
| `scope` | `environment` | yes | Scope of the observations: `environment`, the environment named by `env_id`. |

**Request**

<CodeTabs>

```bash title="cURL"
curl -X POST https://api.arcnm.io/api/v1/calibration/outcomes \
  -H "X-API-Key: $ARCNM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "scope": "environment",
    "oracle": "string"
  }'
```

```python title="Python"
import requests

resp = requests.post(
    "https://api.arcnm.io/api/v1/calibration/outcomes",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={
        "scope": "environment",
        "oracle": "string"
    },
)
resp.raise_for_status()
print(resp.json())
```

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

</CodeTabs>

**Responses**

| Status | Description |
| --- | --- |
| `200` | Successful Response |
| `422` | Validation Error — or a refused evidence kind. `calibration_evidence_kind_refused`: a row states a `kind` this route does not record, or one that does not measure what its `target_metric` measures, so nothing in the batch was stored. `message` names the kind, why it is refused and the kinds this route records; `details.observation` is the row's index in the batch, `details.kind` the refused name and `details.accepted` the kinds this route records. Omit `kind` to record a row as what its `target_metric` and `observation_type` state. Any other refusal answers `unprocessable_entity` with its reason in `message`. |
| `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 |
| --- | --- | --- |
| `a` | number | Fitted first-unit cost coefficient of the curve. |
| `b` | number | Fitted log-log slope exponent of the learning curve. |
| `block_evidence` | BlockEvidencePublic | History import: what the block amounts stated beside the totals became — how many were recorded, and each one that was not with its reason. |
| `env_id` | string | Identifier of the calibrated environment. |
| `fit` | object | Structured object with the fitted parameters and fit diagnostics. |
| `fitted_accuracy` | number | Accuracy (0–1) of the fitted policy on the training rows. |
| `fitted_policy` | object | Structured object describing the fitted selection policy. |
| `grid_size` | integer | Number of policy candidates evaluated during the fit. |
| `history_received` | integer | Historical choice records supplied in the request. |
| `history_rejected` | object[] | Records that could not be used, each with its position in the request and why. Capped at 50 entries; the counts above are never truncated. |
| `history_used` | integer | Records the fit actually used. Lower than ``history_received`` means some could not be read; see ``history_rejected``. |
| `holdout_accuracy` | number | Accuracy (0–1) of the fitted policy on held-out rows. |
| `holdout_coverage` | number | Fraction (0–1) of held-out actuals inside the price range their quote is served, each part scored against a range fitted without it. |
| `holdout_mape` | number | Mean absolute percentage error of the prices this environment gave before the run, over every row the decision was measured on — the miss this run set out to close, not the outcome. Read mape_after for the result. |
| `holdout_pct` | number | History import: the fraction of parts the fit held out. Null on a replay of a fit stored before it was recorded. |
| `id` | string | Identifier of the resulting record, when applicable. |
| `ingested` | integer | Number of observations persisted by an ingest call. |
| `learning_rate` | number | Learning rate (0–1): cost retained each time output doubles. |
| `mape_after` | number | MAPE AFTER the fit, each row priced by a calibration fitted without its part (validation.mape_after). The run's headline outcome; null when the run fitted no unit-cost calibration. |
| `mape_before` | number | MAPE before the fit (same figure as holdout_mape, named for the before/after pair). |
| `matched` | integer | Number of supplied rows matched to an existing quote. |
| `message` | string | Human-readable note about the run, when present, in English. A history import states the same facts as fields: matched, rows_not_fitted and block_evidence. |
| `model` | string | Learning-curve model that was fit (crawford_unit or wright_cumulative). |
| `n_holdout` | integer | Number of rows held out to size the prediction interval. |
| `n_iterations` | integer | Iterations the midpoint solver ran before converging. |
| `n_lots` | integer | Number of production lots used in the curve fit. |
| `n_observations` | integer | Number of observations the calibration fit used. |
| `n_train` | integer | Number of rows used to fit the calibration. |
| `part_revision_id` | string | Identifier of the part revision that was fit. |
| `policy_history_id` | string | Identifier of the newly written selection-policy row. |
| `r_squared` | number | Coefficient of determination (0–1) of the curve fit. |
| `replayed` | boolean | History import: true when the import was already calibrated and this is its stored result, replayed without a new fit or a second metered run. The parameters sent are then not applied; target_alpha and holdout_pct say what the stored fit used. |
| `residual_sigma_log` | number | Standard deviation of the fit residuals in log space. |
| `rows_not_fitted` | RowsNotFittedPublic | History import: the rows the fit left out, counted per cause. All zero when every row was fitted (status 'complete' with no row left out). |
| `run_id` | string | Identifier of the calibration run, when one was created. |
| `samples` | integer | Number of samples considered by the run. |
| `samples_applied` | integer | Number of samples actually applied to the fit. |
| `scope` | `platform` \| `environment` | Scope the run applied to: 'platform' or 'environment'. |
| `seed_accuracy` | number | Accuracy (0–1) of the seed policy before calibration. |
| `status` | `complete` \| `partially_complete` \| `published` \| `deactivated` | Outcome status of the calibration run. |
| `target_alpha` | number | History import: the target miss rate the fit used. Null on a replay of a fit stored before it was recorded. |
| `target_metric` | string | Metric the calibration targeted (e.g. 'unit_cost'). |
| `unknown_part_numbers` | string[] | Part numbers that could not be resolved to a known part. |
| `unmatched_part_ids` | string[] | Part revision IDs with no quote at their lot size priced by the current version of the costing model, so they were skipped. |
| `validation` | CalibrationValidationPublic | How this run's calibration prices your parts against today's prices, whether it was applied (held only when worse) and why. Null when the run fitted no unit-cost calibration. |
| `work_orders_received` | integer | Number of ERP work-order rows received. |
| `work_orders_resolved` | integer | Number of work orders resolved to a known part revision. |

**Example response**

```json
{
  "a": 0,
  "b": 0,
  "block_evidence": {
    "refused": [
      {
        "block": "string",
        "part_revision_id": "string",
        "reason": "unknown_block"
      }
    ],
    "written": 0
  },
  "env_id": "string",
  "fit": {},
  "fitted_accuracy": 0,
  "fitted_policy": {},
  "grid_size": 0,
  "history_received": 0,
  "history_rejected": [
    {}
  ],
  "history_used": 0,
  "holdout_accuracy": 0,
  "holdout_coverage": 0.9,
  "holdout_mape": 0.05,
  "holdout_pct": 0,
  "id": "string",
  "ingested": 0,
  "learning_rate": 0,
  "mape_after": 0.05,
  "mape_before": 0.05,
  "matched": 0,
  "message": "string",
  "model": "string",
  "n_holdout": 0,
  "n_iterations": 0,
  "n_lots": 0,
  "n_observations": 0,
  "n_train": 0,
  "part_revision_id": "string",
  "policy_history_id": "string",
  "r_squared": 0,
  "replayed": true,
  "residual_sigma_log": 0,
  "rows_not_fitted": {
    "assumed_price": 0,
    "invalid": 0,
    "no_dataset": 0,
    "no_matching_calculation": 0,
    "partial_price": 0,
    "pricing_failed": 0,
    "unpriced": 0,
    "unresolved": 0
  },
  "run_id": "string",
  "samples": 0,
  "samples_applied": 0,
  "scope": "platform",
  "seed_accuracy": 0,
  "status": "complete",
  "target_alpha": 0,
  "target_metric": "string",
  "unknown_part_numbers": [
    "string"
  ],
  "unmatched_part_ids": [
    "string"
  ],
  "validation": {
    "error_after": 0,
    "error_before": 0,
    "gain": 0,
    "gain_lower": 0,
    "gain_upper": 0,
    "mape_after": 0.05,
    "mape_before": 0.05,
    "n_parts": 0,
    "n_rows": 0,
    "reasons": [
      {
        "code": "lot_total_as_unit_cost",
        "params": {}
      }
    ],
    "served": true,
    "verdict": "better"
  },
  "work_orders_received": 0,
  "work_orders_resolved": 0
}
```
