Skip to content

Import

Generated at build time from packages/core/src/operations/import.ts. Every operation below isPOST /v1/ops/{name} over HTTP, env.API.invoke(actor, name, input) over RPC, and, when staff may call it, an MCP tool. See the API overview for authentication and errors.

import.dry_run

Preview an import

Kind
Write (audited)
Who
Staff: admin, editor
MCP tool
import_dry_run

Step one of an import. Give rows read from a Google Sheet, a Drive file, a HubSpot export or a CSV (an array of objects keyed by column name) and the entity they hold: accounts, contacts, sites, products, parts or machines. Columns are mapped to fields automatically by name unless you give a mapping. Nothing is written except the preview itself. Each row comes back as create, update, skip_duplicate or error, with duplicate checks on normalized company name, contact email, SKU, part number and serial number. Review the preview, then call import.apply with the run id.

Input (object)

FieldTypeDescription
entityrequired"accounts" | "contacts" | "sites" | "products" | "parts" | "machines"
source"google_sheet" | "google_drive" | "csv" | "hubspot_export" | "pdf_extract"default "google_sheet"
sourceNamestring | nullFile or sheet name, for the recordmax length 300
rowsrequiredrecord of any[]at least 1, at most 5000
mappingrecord of stringSource column name to target field name; unmapped columns are ignored
onDuplicate"skip" | "update"What to do with rows that match an existing recorddefault "skip"
defaultsrecord of anyValues applied to every row when the field is empty, for example priceListDate

Output (object)

FieldTypeDescription
runrequiredobject
idrequiredstringRecord id (UUID)min length 1, max length 64
entityrequired"accounts" | "contacts" | "sites" | "products" | "parts" | "machines"
sourcerequired"google_sheet" | "google_drive" | "csv" | "hubspot_export" | "pdf_extract"
sourceNamerequiredstring | nullFile or sheet name
statusrequired"dry_run" | "applying" | "applied" | "failed"
mappingrequiredrecord of stringSource column name to target field name
totalRowsrequiredintegermin -9007199254740991, max 9007199254740991
createCountrequiredintegermin -9007199254740991, max 9007199254740991
updateCountrequiredintegermin -9007199254740991, max 9007199254740991
duplicateCountrequiredintegermin -9007199254740991, max 9007199254740991
errorCountrequiredintegermin -9007199254740991, max 9007199254740991
createdByNamerequiredstring
createdAtrequiredstring (date-time)UTC timestamp, ISO 8601 with Z
appliedAtrequiredstring (date-time) | nullUTC timestamp, ISO 8601 with Z
columnsrequiredstring[]Column names found in the source
targetFieldsrequiredstring[]Fields this entity accepts
unmappedColumnsrequiredstring[]
missingRequiredFieldsrequiredstring[]Required fields no column is mapped to
rowsrequiredobject[]Per-row result (first 200 rows)
rowNumberrequiredinteger1-based row number in the source, not counting the headermin -9007199254740991, max 9007199254740991
actionrequired"create" | "update" | "skip_duplicate" | "error"
datarequiredrecord of anyMapped values for this row
errorsrequiredstring[]
duplicateOfrequiredobject | nullExisting record this row matches
idrequiredstringRecord id (UUID)min length 1, max length 64
namerequiredstring
rowsTruncatedrequiredboolean
Example request
                curl https://api.cemco.app/v1/ops/import.dry_run \
  -H "x-api-key: $CEMCO_API_KEY" \
  -H "content-type: application/json" \
  -d '{"entity":"accounts","rows":[{}]}'
              
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "entity": {
        "type": "string",
        "enum": [
          "accounts",
          "contacts",
          "sites",
          "products",
          "parts",
          "machines"
        ]
      },
      "source": {
        "default": "google_sheet",
        "type": "string",
        "enum": [
          "google_sheet",
          "google_drive",
          "csv",
          "hubspot_export",
          "pdf_extract"
        ]
      },
      "sourceName": {
        "description": "File or sheet name, for the record",
        "anyOf": [
          {
            "type": "string",
            "maxLength": 300
          },
          {
            "type": "null"
          }
        ]
      },
      "rows": {
        "minItems": 1,
        "maxItems": 5000,
        "type": "array",
        "items": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        }
      },
      "mapping": {
        "description": "Source column name to target field name; unmapped columns are ignored",
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {
          "type": "string"
        }
      },
      "onDuplicate": {
        "default": "skip",
        "description": "What to do with rows that match an existing record",
        "type": "string",
        "enum": [
          "skip",
          "update"
        ]
      },
      "defaults": {
        "description": "Values applied to every row when the field is empty, for example priceListDate",
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {}
      }
    },
    "required": [
      "entity",
      "rows"
    ]
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "run": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Record id (UUID)"
          },
          "entity": {
            "type": "string",
            "enum": [
              "accounts",
              "contacts",
              "sites",
              "products",
              "parts",
              "machines"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "google_sheet",
              "google_drive",
              "csv",
              "hubspot_export",
              "pdf_extract"
            ]
          },
          "sourceName": {
            "description": "File or sheet name",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "dry_run",
              "applying",
              "applied",
              "failed"
            ]
          },
          "mapping": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "string"
            },
            "description": "Source column name to target field name"
          },
          "totalRows": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "createCount": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "updateCount": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "duplicateCount": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "errorCount": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "createdByName": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "UTC timestamp, ISO 8601 with Z"
          },
          "appliedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
                "description": "UTC timestamp, ISO 8601 with Z"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "entity",
          "source",
          "sourceName",
          "status",
          "mapping",
          "totalRows",
          "createCount",
          "updateCount",
          "duplicateCount",
          "errorCount",
          "createdByName",
          "createdAt",
          "appliedAt"
        ],
        "additionalProperties": false
      },
      "columns": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "Column names found in the source"
      },
      "targetFields": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "Fields this entity accepts"
      },
      "unmappedColumns": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "missingRequiredFields": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "Required fields no column is mapped to"
      },
      "rows": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "rowNumber": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991,
              "description": "1-based row number in the source, not counting the header"
            },
            "action": {
              "type": "string",
              "enum": [
                "create",
                "update",
                "skip_duplicate",
                "error"
              ]
            },
            "data": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {},
              "description": "Mapped values for this row"
            },
            "errors": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "duplicateOf": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64,
                      "description": "Record id (UUID)"
                    },
                    "name": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "null"
                }
              ],
              "description": "Existing record this row matches"
            }
          },
          "required": [
            "rowNumber",
            "action",
            "data",
            "errors",
            "duplicateOf"
          ],
          "additionalProperties": false
        },
        "description": "Per-row result (first 200 rows)"
      },
      "rowsTruncated": {
        "type": "boolean"
      }
    },
    "required": [
      "run",
      "columns",
      "targetFields",
      "unmappedColumns",
      "missingRequiredFields",
      "rows",
      "rowsTruncated"
    ],
    "additionalProperties": false
  }
}
            

import.apply

Apply a previewed import

Kind
Write (audited)
Who
Staff: admin, editor
MCP tool
import_apply

Step two of an import: write the rows of a dry run to the CRM. Rows marked error are skipped. Duplicates are re-checked at apply time. Each run can be applied once. Returns the final counts and the ids created.

Input (object)

FieldTypeDescription
runIdrequiredstringRecord id (UUID)min length 1, max length 64
confirmrequiredtrueMust be true: confirms the preview was reviewed

Output (object)

FieldTypeDescription
runrequiredobject
idrequiredstringRecord id (UUID)min length 1, max length 64
entityrequired"accounts" | "contacts" | "sites" | "products" | "parts" | "machines"
sourcerequired"google_sheet" | "google_drive" | "csv" | "hubspot_export" | "pdf_extract"
sourceNamerequiredstring | nullFile or sheet name
statusrequired"dry_run" | "applying" | "applied" | "failed"
mappingrequiredrecord of stringSource column name to target field name
totalRowsrequiredintegermin -9007199254740991, max 9007199254740991
createCountrequiredintegermin -9007199254740991, max 9007199254740991
updateCountrequiredintegermin -9007199254740991, max 9007199254740991
duplicateCountrequiredintegermin -9007199254740991, max 9007199254740991
errorCountrequiredintegermin -9007199254740991, max 9007199254740991
createdByNamerequiredstring
createdAtrequiredstring (date-time)UTC timestamp, ISO 8601 with Z
appliedAtrequiredstring (date-time) | nullUTC timestamp, ISO 8601 with Z
createdrequiredintegermin -9007199254740991, max 9007199254740991
updatedrequiredintegermin -9007199254740991, max 9007199254740991
skippedrequiredintegermin -9007199254740991, max 9007199254740991
errorsrequiredobject[]
rowNumberrequiredintegermin -9007199254740991, max 9007199254740991
messagerequiredstring
createdIdsrequiredstring[]
Example request
                curl https://api.cemco.app/v1/ops/import.apply \
  -H "x-api-key: $CEMCO_API_KEY" \
  -H "content-type: application/json" \
  -d '{"runId":"00000000-0000-4000-8000-000000000000","confirm":true}'
              
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "runId": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      },
      "confirm": {
        "type": "boolean",
        "const": true,
        "description": "Must be true: confirms the preview was reviewed"
      }
    },
    "required": [
      "runId",
      "confirm"
    ]
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "run": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Record id (UUID)"
          },
          "entity": {
            "type": "string",
            "enum": [
              "accounts",
              "contacts",
              "sites",
              "products",
              "parts",
              "machines"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "google_sheet",
              "google_drive",
              "csv",
              "hubspot_export",
              "pdf_extract"
            ]
          },
          "sourceName": {
            "description": "File or sheet name",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "dry_run",
              "applying",
              "applied",
              "failed"
            ]
          },
          "mapping": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "string"
            },
            "description": "Source column name to target field name"
          },
          "totalRows": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "createCount": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "updateCount": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "duplicateCount": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "errorCount": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "createdByName": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "UTC timestamp, ISO 8601 with Z"
          },
          "appliedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
                "description": "UTC timestamp, ISO 8601 with Z"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "entity",
          "source",
          "sourceName",
          "status",
          "mapping",
          "totalRows",
          "createCount",
          "updateCount",
          "duplicateCount",
          "errorCount",
          "createdByName",
          "createdAt",
          "appliedAt"
        ],
        "additionalProperties": false
      },
      "created": {
        "type": "integer",
        "minimum": -9007199254740991,
        "maximum": 9007199254740991
      },
      "updated": {
        "type": "integer",
        "minimum": -9007199254740991,
        "maximum": 9007199254740991
      },
      "skipped": {
        "type": "integer",
        "minimum": -9007199254740991,
        "maximum": 9007199254740991
      },
      "errors": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "rowNumber": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "message": {
              "type": "string"
            }
          },
          "required": [
            "rowNumber",
            "message"
          ],
          "additionalProperties": false
        }
      },
      "createdIds": {
        "type": "array",
        "items": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "description": "Record id (UUID)"
        }
      }
    },
    "required": [
      "run",
      "created",
      "updated",
      "skipped",
      "errors",
      "createdIds"
    ],
    "additionalProperties": false
  }
}
            

import.get_run

Get an import run

Kind
Read
Who
Staff: admin, editor, viewer
MCP tool
import_get_run

Read an import run and its per-row results again, optionally only rows with one action (for example error).

Input (object)

FieldTypeDescription
runIdrequiredstringRecord id (UUID)min length 1, max length 64
action"create" | "update" | "skip_duplicate" | "error"
limitintegerMaximum rows to return (default 50, max 500)default 50, min 1, max 500
offsetintegerRows to skip, for pagingdefault 0, min 0, max 9007199254740991

Output (object)

FieldTypeDescription
runrequiredobject
idrequiredstringRecord id (UUID)min length 1, max length 64
entityrequired"accounts" | "contacts" | "sites" | "products" | "parts" | "machines"
sourcerequired"google_sheet" | "google_drive" | "csv" | "hubspot_export" | "pdf_extract"
sourceNamerequiredstring | nullFile or sheet name
statusrequired"dry_run" | "applying" | "applied" | "failed"
mappingrequiredrecord of stringSource column name to target field name
totalRowsrequiredintegermin -9007199254740991, max 9007199254740991
createCountrequiredintegermin -9007199254740991, max 9007199254740991
updateCountrequiredintegermin -9007199254740991, max 9007199254740991
duplicateCountrequiredintegermin -9007199254740991, max 9007199254740991
errorCountrequiredintegermin -9007199254740991, max 9007199254740991
createdByNamerequiredstring
createdAtrequiredstring (date-time)UTC timestamp, ISO 8601 with Z
appliedAtrequiredstring (date-time) | nullUTC timestamp, ISO 8601 with Z
rowsrequiredobject
itemsrequiredobject[]
rowNumberrequiredinteger1-based row number in the source, not counting the headermin -9007199254740991, max 9007199254740991
actionrequired"create" | "update" | "skip_duplicate" | "error"
datarequiredrecord of anyMapped values for this row
errorsrequiredstring[]
duplicateOfrequiredobject | nullExisting record this row matches
idrequiredstringRecord id (UUID)min length 1, max length 64
namerequiredstring
totalrequiredintegerTotal rows matching the filters, ignoring limit and offsetmin 0, max 9007199254740991
limitrequiredintegermin -9007199254740991, max 9007199254740991
offsetrequiredintegermin -9007199254740991, max 9007199254740991
Example request
                curl https://api.cemco.app/v1/ops/import.get_run \
  -H "x-api-key: $CEMCO_API_KEY" \
  -H "content-type: application/json" \
  -d '{"runId":"00000000-0000-4000-8000-000000000000"}'
              
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "runId": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      },
      "action": {
        "type": "string",
        "enum": [
          "create",
          "update",
          "skip_duplicate",
          "error"
        ]
      },
      "limit": {
        "default": 50,
        "description": "Maximum rows to return (default 50, max 500)",
        "type": "integer",
        "minimum": 1,
        "maximum": 500
      },
      "offset": {
        "default": 0,
        "description": "Rows to skip, for paging",
        "type": "integer",
        "minimum": 0,
        "maximum": 9007199254740991
      }
    },
    "required": [
      "runId"
    ]
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "run": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Record id (UUID)"
          },
          "entity": {
            "type": "string",
            "enum": [
              "accounts",
              "contacts",
              "sites",
              "products",
              "parts",
              "machines"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "google_sheet",
              "google_drive",
              "csv",
              "hubspot_export",
              "pdf_extract"
            ]
          },
          "sourceName": {
            "description": "File or sheet name",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "dry_run",
              "applying",
              "applied",
              "failed"
            ]
          },
          "mapping": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "string"
            },
            "description": "Source column name to target field name"
          },
          "totalRows": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "createCount": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "updateCount": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "duplicateCount": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "errorCount": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "createdByName": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "UTC timestamp, ISO 8601 with Z"
          },
          "appliedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
                "description": "UTC timestamp, ISO 8601 with Z"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "entity",
          "source",
          "sourceName",
          "status",
          "mapping",
          "totalRows",
          "createCount",
          "updateCount",
          "duplicateCount",
          "errorCount",
          "createdByName",
          "createdAt",
          "appliedAt"
        ],
        "additionalProperties": false
      },
      "rows": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "rowNumber": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991,
                  "description": "1-based row number in the source, not counting the header"
                },
                "action": {
                  "type": "string",
                  "enum": [
                    "create",
                    "update",
                    "skip_duplicate",
                    "error"
                  ]
                },
                "data": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {},
                  "description": "Mapped values for this row"
                },
                "errors": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "duplicateOf": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64,
                          "description": "Record id (UUID)"
                        },
                        "name": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ],
                  "description": "Existing record this row matches"
                }
              },
              "required": [
                "rowNumber",
                "action",
                "data",
                "errors",
                "duplicateOf"
              ],
              "additionalProperties": false
            }
          },
          "total": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Total rows matching the filters, ignoring limit and offset"
          },
          "limit": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "offset": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "items",
          "total",
          "limit",
          "offset"
        ],
        "additionalProperties": false
      }
    },
    "required": [
      "run",
      "rows"
    ],
    "additionalProperties": false
  }
}
            

import.list_runs

List import runs

Kind
Read
Who
Staff: admin, editor, viewer
MCP tool
import_list_runs

Past imports and dry runs, newest first, with their counts and who ran them.

Input (object)

FieldTypeDescription
entity"accounts" | "contacts" | "sites" | "products" | "parts" | "machines"
status"dry_run" | "applying" | "applied" | "failed"
limitintegerMaximum rows to return (default 50, max 500)default 50, min 1, max 500
offsetintegerRows to skip, for pagingdefault 0, min 0, max 9007199254740991

Output (object)

FieldTypeDescription
itemsrequiredobject[]
idrequiredstringRecord id (UUID)min length 1, max length 64
entityrequired"accounts" | "contacts" | "sites" | "products" | "parts" | "machines"
sourcerequired"google_sheet" | "google_drive" | "csv" | "hubspot_export" | "pdf_extract"
sourceNamerequiredstring | nullFile or sheet name
statusrequired"dry_run" | "applying" | "applied" | "failed"
mappingrequiredrecord of stringSource column name to target field name
totalRowsrequiredintegermin -9007199254740991, max 9007199254740991
createCountrequiredintegermin -9007199254740991, max 9007199254740991
updateCountrequiredintegermin -9007199254740991, max 9007199254740991
duplicateCountrequiredintegermin -9007199254740991, max 9007199254740991
errorCountrequiredintegermin -9007199254740991, max 9007199254740991
createdByNamerequiredstring
createdAtrequiredstring (date-time)UTC timestamp, ISO 8601 with Z
appliedAtrequiredstring (date-time) | nullUTC timestamp, ISO 8601 with Z
totalrequiredintegerTotal rows matching the filters, ignoring limit and offsetmin 0, max 9007199254740991
limitrequiredintegermin -9007199254740991, max 9007199254740991
offsetrequiredintegermin -9007199254740991, max 9007199254740991
Example request
                curl https://api.cemco.app/v1/ops/import.list_runs \
  -H "x-api-key: $CEMCO_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
              
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "entity": {
        "type": "string",
        "enum": [
          "accounts",
          "contacts",
          "sites",
          "products",
          "parts",
          "machines"
        ]
      },
      "status": {
        "type": "string",
        "enum": [
          "dry_run",
          "applying",
          "applied",
          "failed"
        ]
      },
      "limit": {
        "default": 50,
        "description": "Maximum rows to return (default 50, max 500)",
        "type": "integer",
        "minimum": 1,
        "maximum": 500
      },
      "offset": {
        "default": 0,
        "description": "Rows to skip, for paging",
        "type": "integer",
        "minimum": 0,
        "maximum": 9007199254740991
      }
    }
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "items": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "description": "Record id (UUID)"
            },
            "entity": {
              "type": "string",
              "enum": [
                "accounts",
                "contacts",
                "sites",
                "products",
                "parts",
                "machines"
              ]
            },
            "source": {
              "type": "string",
              "enum": [
                "google_sheet",
                "google_drive",
                "csv",
                "hubspot_export",
                "pdf_extract"
              ]
            },
            "sourceName": {
              "description": "File or sheet name",
              "type": [
                "string",
                "null"
              ]
            },
            "status": {
              "type": "string",
              "enum": [
                "dry_run",
                "applying",
                "applied",
                "failed"
              ]
            },
            "mapping": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              },
              "description": "Source column name to target field name"
            },
            "totalRows": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "createCount": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "updateCount": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "duplicateCount": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "errorCount": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "createdByName": {
              "type": "string"
            },
            "createdAt": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
              "description": "UTC timestamp, ISO 8601 with Z"
            },
            "appliedAt": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
                  "description": "UTC timestamp, ISO 8601 with Z"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "id",
            "entity",
            "source",
            "sourceName",
            "status",
            "mapping",
            "totalRows",
            "createCount",
            "updateCount",
            "duplicateCount",
            "errorCount",
            "createdByName",
            "createdAt",
            "appliedAt"
          ],
          "additionalProperties": false
        }
      },
      "total": {
        "type": "integer",
        "minimum": 0,
        "maximum": 9007199254740991,
        "description": "Total rows matching the filters, ignoring limit and offset"
      },
      "limit": {
        "type": "integer",
        "minimum": -9007199254740991,
        "maximum": 9007199254740991
      },
      "offset": {
        "type": "integer",
        "minimum": -9007199254740991,
        "maximum": 9007199254740991
      }
    },
    "required": [
      "items",
      "total",
      "limit",
      "offset"
    ],
    "additionalProperties": false
  }
}
            

import.discard_run

Discard a dry run

Kind
Write (audited)
Who
Staff: admin
MCP tool
import_discard_run

Delete a dry run that will not be applied, with its stored preview rows. Applied runs cannot be discarded.

Input (object)

FieldTypeDescription
runIdrequiredstringRecord id (UUID)min length 1, max length 64

Output (object)

FieldTypeDescription
okrequiredtrue
idrequiredstringRecord id (UUID)min length 1, max length 64
Example request
                curl https://api.cemco.app/v1/ops/import.discard_run \
  -H "x-api-key: $CEMCO_API_KEY" \
  -H "content-type: application/json" \
  -d '{"runId":"00000000-0000-4000-8000-000000000000"}'
              
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "runId": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      }
    },
    "required": [
      "runId"
    ]
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "ok": {
        "type": "boolean",
        "const": true
      },
      "id": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      }
    },
    "required": [
      "ok",
      "id"
    ],
    "additionalProperties": false
  }
}
            

import.read_google_sheet

Read a Google Sheet for import

Kind
Read
Who
Staff: admin, editor
MCP tool
import_read_google_sheet

Read one tab of a Google Sheet with the caller's own Google access (they connect Google Sheets once, read only) and return its rows keyed by the header row, ready for import.dry_run. Give the sheet's link or id; the tab in the link (gid) is used, else the named tab, else the first. connected is false, with no rows, until the caller has connected Google Sheets. Writes nothing.

Input (object)

FieldTypeDescription
sheetrequiredstringGoogle Sheets link (https://docs.google.com/spreadsheets/d/...) or spreadsheet idmin length 10, max length 500
tabstringTab name; defaults to the tab in the link, else the first tabmax length 200

Output (object)

FieldTypeDescription
connectedrequiredboolean
titlerequiredstring | nullSpreadsheet title
tabrequiredstring | null
columnsrequiredstring[]
rowsrequiredrecord of string[]at most 5000
truncatedrequiredbooleanTrue when the tab has more than 5,000 data rows; only the first 5,000 are returned
Example request
                curl https://api.cemco.app/v1/ops/import.read_google_sheet \
  -H "x-api-key: $CEMCO_API_KEY" \
  -H "content-type: application/json" \
  -d '{"sheet":"examplexxx"}'
              
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "sheet": {
        "type": "string",
        "minLength": 10,
        "maxLength": 500,
        "description": "Google Sheets link (https://docs.google.com/spreadsheets/d/...) or spreadsheet id"
      },
      "tab": {
        "description": "Tab name; defaults to the tab in the link, else the first tab",
        "type": "string",
        "maxLength": 200
      }
    },
    "required": [
      "sheet"
    ]
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "connected": {
        "type": "boolean"
      },
      "title": {
        "description": "Spreadsheet title",
        "type": [
          "string",
          "null"
        ]
      },
      "tab": {
        "type": [
          "string",
          "null"
        ]
      },
      "columns": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "rows": {
        "maxItems": 5000,
        "type": "array",
        "items": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "truncated": {
        "type": "boolean",
        "description": "True when the tab has more than 5,000 data rows; only the first 5,000 are returned"
      }
    },
    "required": [
      "connected",
      "title",
      "tab",
      "columns",
      "rows",
      "truncated"
    ],
    "additionalProperties": false
  }
}