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
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)
| Field | Type | Description |
|---|---|---|
entityrequired | "accounts" | "contacts" | "sites" | "products" | "parts" | "machines" | |
source | "google_sheet" | "google_drive" | "csv" | "hubspot_export" | "pdf_extract" | default "google_sheet" |
sourceName | string | null | File or sheet name, for the recordmax length 300 |
rowsrequired | record of any[] | at least 1, at most 5000 |
mapping | record of string | Source column name to target field name; unmapped columns are ignored |
onDuplicate | "skip" | "update" | What to do with rows that match an existing recorddefault "skip" |
defaults | record of any | Values applied to every row when the field is empty, for example priceListDate |
Output (object)
| Field | Type | Description |
|---|---|---|
runrequired | object | |
idrequired | string | Record 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" | |
sourceNamerequired | string | null | File or sheet name |
statusrequired | "dry_run" | "applying" | "applied" | "failed" | |
mappingrequired | record of string | Source column name to target field name |
totalRowsrequired | integer | min -9007199254740991, max 9007199254740991 |
createCountrequired | integer | min -9007199254740991, max 9007199254740991 |
updateCountrequired | integer | min -9007199254740991, max 9007199254740991 |
duplicateCountrequired | integer | min -9007199254740991, max 9007199254740991 |
errorCountrequired | integer | min -9007199254740991, max 9007199254740991 |
createdByNamerequired | string | |
createdAtrequired | string (date-time) | UTC timestamp, ISO 8601 with Z |
appliedAtrequired | string (date-time) | null | UTC timestamp, ISO 8601 with Z |
columnsrequired | string[] | Column names found in the source |
targetFieldsrequired | string[] | Fields this entity accepts |
unmappedColumnsrequired | string[] | |
missingRequiredFieldsrequired | string[] | Required fields no column is mapped to |
rowsrequired | object[] | Per-row result (first 200 rows) |
rowNumberrequired | integer | 1-based row number in the source, not counting the headermin -9007199254740991, max 9007199254740991 |
actionrequired | "create" | "update" | "skip_duplicate" | "error" | |
datarequired | record of any | Mapped values for this row |
errorsrequired | string[] | |
duplicateOfrequired | object | null | Existing record this row matches |
idrequired | string | Record id (UUID)min length 1, max length 64 |
namerequired | string | |
rowsTruncatedrequired | boolean |
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
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)
| Field | Type | Description |
|---|---|---|
runIdrequired | string | Record id (UUID)min length 1, max length 64 |
confirmrequired | true | Must be true: confirms the preview was reviewed |
Output (object)
| Field | Type | Description |
|---|---|---|
runrequired | object | |
idrequired | string | Record 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" | |
sourceNamerequired | string | null | File or sheet name |
statusrequired | "dry_run" | "applying" | "applied" | "failed" | |
mappingrequired | record of string | Source column name to target field name |
totalRowsrequired | integer | min -9007199254740991, max 9007199254740991 |
createCountrequired | integer | min -9007199254740991, max 9007199254740991 |
updateCountrequired | integer | min -9007199254740991, max 9007199254740991 |
duplicateCountrequired | integer | min -9007199254740991, max 9007199254740991 |
errorCountrequired | integer | min -9007199254740991, max 9007199254740991 |
createdByNamerequired | string | |
createdAtrequired | string (date-time) | UTC timestamp, ISO 8601 with Z |
appliedAtrequired | string (date-time) | null | UTC timestamp, ISO 8601 with Z |
createdrequired | integer | min -9007199254740991, max 9007199254740991 |
updatedrequired | integer | min -9007199254740991, max 9007199254740991 |
skippedrequired | integer | min -9007199254740991, max 9007199254740991 |
errorsrequired | object[] | |
rowNumberrequired | integer | min -9007199254740991, max 9007199254740991 |
messagerequired | string | |
createdIdsrequired | string[] |
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
Read an import run and its per-row results again, optionally only rows with one action (for example error).
Input (object)
| Field | Type | Description |
|---|---|---|
runIdrequired | string | Record id (UUID)min length 1, max length 64 |
action | "create" | "update" | "skip_duplicate" | "error" | |
limit | integer | Maximum rows to return (default 50, max 500)default 50, min 1, max 500 |
offset | integer | Rows to skip, for pagingdefault 0, min 0, max 9007199254740991 |
Output (object)
| Field | Type | Description |
|---|---|---|
runrequired | object | |
idrequired | string | Record 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" | |
sourceNamerequired | string | null | File or sheet name |
statusrequired | "dry_run" | "applying" | "applied" | "failed" | |
mappingrequired | record of string | Source column name to target field name |
totalRowsrequired | integer | min -9007199254740991, max 9007199254740991 |
createCountrequired | integer | min -9007199254740991, max 9007199254740991 |
updateCountrequired | integer | min -9007199254740991, max 9007199254740991 |
duplicateCountrequired | integer | min -9007199254740991, max 9007199254740991 |
errorCountrequired | integer | min -9007199254740991, max 9007199254740991 |
createdByNamerequired | string | |
createdAtrequired | string (date-time) | UTC timestamp, ISO 8601 with Z |
appliedAtrequired | string (date-time) | null | UTC timestamp, ISO 8601 with Z |
rowsrequired | object | |
itemsrequired | object[] | |
rowNumberrequired | integer | 1-based row number in the source, not counting the headermin -9007199254740991, max 9007199254740991 |
actionrequired | "create" | "update" | "skip_duplicate" | "error" | |
datarequired | record of any | Mapped values for this row |
errorsrequired | string[] | |
duplicateOfrequired | object | null | Existing record this row matches |
idrequired | string | Record id (UUID)min length 1, max length 64 |
namerequired | string | |
totalrequired | integer | Total rows matching the filters, ignoring limit and offsetmin 0, max 9007199254740991 |
limitrequired | integer | min -9007199254740991, max 9007199254740991 |
offsetrequired | integer | min -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
Past imports and dry runs, newest first, with their counts and who ran them.
Input (object)
| Field | Type | Description |
|---|---|---|
entity | "accounts" | "contacts" | "sites" | "products" | "parts" | "machines" | |
status | "dry_run" | "applying" | "applied" | "failed" | |
limit | integer | Maximum rows to return (default 50, max 500)default 50, min 1, max 500 |
offset | integer | Rows to skip, for pagingdefault 0, min 0, max 9007199254740991 |
Output (object)
| Field | Type | Description |
|---|---|---|
itemsrequired | object[] | |
idrequired | string | Record 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" | |
sourceNamerequired | string | null | File or sheet name |
statusrequired | "dry_run" | "applying" | "applied" | "failed" | |
mappingrequired | record of string | Source column name to target field name |
totalRowsrequired | integer | min -9007199254740991, max 9007199254740991 |
createCountrequired | integer | min -9007199254740991, max 9007199254740991 |
updateCountrequired | integer | min -9007199254740991, max 9007199254740991 |
duplicateCountrequired | integer | min -9007199254740991, max 9007199254740991 |
errorCountrequired | integer | min -9007199254740991, max 9007199254740991 |
createdByNamerequired | string | |
createdAtrequired | string (date-time) | UTC timestamp, ISO 8601 with Z |
appliedAtrequired | string (date-time) | null | UTC timestamp, ISO 8601 with Z |
totalrequired | integer | Total rows matching the filters, ignoring limit and offsetmin 0, max 9007199254740991 |
limitrequired | integer | min -9007199254740991, max 9007199254740991 |
offsetrequired | integer | min -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
Delete a dry run that will not be applied, with its stored preview rows. Applied runs cannot be discarded.
Input (object)
| Field | Type | Description |
|---|---|---|
runIdrequired | string | Record id (UUID)min length 1, max length 64 |
Output (object)
| Field | Type | Description |
|---|---|---|
okrequired | true | |
idrequired | string | Record 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
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)
| Field | Type | Description |
|---|---|---|
sheetrequired | string | Google Sheets link (https://docs.google.com/spreadsheets/d/...) or spreadsheet idmin length 10, max length 500 |
tab | string | Tab name; defaults to the tab in the link, else the first tabmax length 200 |
Output (object)
| Field | Type | Description |
|---|---|---|
connectedrequired | boolean | |
titlerequired | string | null | Spreadsheet title |
tabrequired | string | null | |
columnsrequired | string[] | |
rowsrequired | record of string[] | at most 5000 |
truncatedrequired | boolean | True 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
}
}