--- title: imports.historyRun | Doing Work API description: Owner only: write a history import the owner confirmed in imports.historyPreview (send its preview_hash, plus the same csv, kind, source, on_match. url: https://doingwork.work/docs/reference/imports-historyrun/ --- # imports.historyRun Owner only: write a history import the owner confirmed in imports.historyPreview (send its preview_hash, plus the same csv, kind, source, on_match, include_won and mapping). Records already imported are matched by old id and skipped or updated, never duplicated. Imported open quotes and invoices are drafts and are not sent. With include_won, won and declined quotes are imported as history: they price later drafts, and they are never sent, invoiced, followed up, or shown as signed work to bill. Maintenance plans become service-due reminders (no invoice, no charge), or with plans_as billed, maintenance plans at the confirmed price with auto_send off and no invoice until the next due date; payments become read-only history records (no charge, no fee, no invoice change). flat_rate rows become price book tasks, matched by old id, then task code, then name. mode all_or_nothing (default) or per_row. The Jobber preset is beta: a row or column it cannot map is skipped, the rest are imported, and the summary says what was skipped and why. | | | |---|---| | Who | Agents can call this | | REST | `POST /v1/imports/history/run` | | MCP tool | `imports_historyRun` | | Writes | yes, send an Idempotency-Key | | Area | [Imports, custom fields, tags and search](https://doingwork.work/docs/reference/#imports-custom-fields-tags-and-search) | ## When to use it Owner only: write a history import the owner confirmed in imports.historyPreview (send its preview_hash, plus the same csv, kind, source, on_match, include_won and mapping). Records already imported are matched by old id and skipped or updated, never duplicated. ## What to tell the owner Say what you did in plain words and what happens next. ## Input | Field | Type | Required | |---|---|---| | `shop_id` | string (uuid) | yes | | `plans_as` | string (one of reminders, billed) | no | | `include_won` | boolean | no | | `kind` | string (one of jobs, quotes, invoices, pricebook, equipment, maintenance_plans, payments, flat_rate) | yes | | `csv` | string | yes | | `source` | string | no | | `on_match` | string (one of skip, update) | no | | `mapping` | array | yes | | `mapping[].column` | string | yes | | `mapping[].field` | string | yes | | `equipment_kind` | string | no | | `preview_hash` | string (sha256) | yes | | `mode` | string (one of all_or_nothing, per_row) | no | ## Example ```http POST https://doingwork.work/v1/imports/history/run content-type: application/json Idempotency-Key: 3f1c... { "shop_id": "00000000-0000-4000-8000-000000000000", "kind": "jobs", "csv": "...", "mapping": [ { "column": "...", "field": "..." } ], "preview_hash": "..." } ``` ## Output JSON. The response shape isn't published yet; read the fields you need and ignore the rest. Errors are `{code, message, status}`. ## Errors | Code | Status | What to do | |---|---|---| | `invalid_input`, `invalid_token`, `rate_limited` | | Can happen on any call. See [errors](https://doingwork.work/docs/errors/). |