Skip to content

Documents

Generated at build time from packages/core/src/operations/documents.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.

documents.create

Upload a document

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

Store a document (signed quote, PO, drawing, manual, inspection report, photo) and link it to records. Two ways to send the bytes: include contentBase64 for files up to 10 MB (the usual way from Claude), or omit it to get an uploadUrl and then PUT the raw file to that URL. The document is pending until its bytes are stored. The account is taken from the first linked record when not given.

Input (object)

FieldTypeDescription
kindrequired"signed_quote" | "quote" | "purchase_order" | "drawing" | "manual" | "inspection_report" | "photo" | "training_record" | "invoice" | "email_attachment" | "export" | "other"
filenamerequiredstringmin length 1, max length 255
contentTypestringdefault "application/octet-stream", max length 100
titlestringDefaults to the filenamemax length 200
accountIdstringRecord id (UUID)min length 1, max length 64
linksobject[]Records to attach the document todefault []
entityTyperequired"account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in"
entityIdrequiredstringRecord id (UUID)min length 1, max length 64
customerVisiblebooleanShow it to the customer in the portaldefault false
contentBase64stringFile bytes, base64 encoded (max 10 MB)
source"upload" | "email" | "portal" | "system" | "import"default "upload"

Output (object)

FieldTypeDescription
documentrequiredobject
idrequiredstringRecord id (UUID)min length 1, max length 64
kindrequired"signed_quote" | "quote" | "purchase_order" | "drawing" | "manual" | "inspection_report" | "photo" | "training_record" | "invoice" | "email_attachment" | "export" | "other"
titlerequiredstring
filenamerequiredstring
contentTyperequiredstring
sizeBytesrequiredintegermin 0, max 9007199254740991
statusrequired"pending" | "stored"pending until the file bytes are stored
accountIdrequiredstring | nullRecord id (UUID)min length 1, max length 64
customerVisiblerequiredbooleanWhether the customer can open it in the portal
sourcerequired"upload" | "email" | "portal" | "system" | "import"
linksrequiredobject[]
entityTyperequired"account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in"
entityIdrequiredstringRecord id (UUID)min length 1, max length 64
uploadedByNamerequiredstring | null
createdAtrequiredstring (date-time)UTC timestamp, ISO 8601 with Z
uploadUrlrequiredstring | nullPUT the raw bytes here when contentBase64 was not sent; null once stored
Example request
                curl https://api.cemco.app/v1/ops/documents.create \
  -H "x-api-key: $CEMCO_API_KEY" \
  -H "content-type: application/json" \
  -d '{"kind":"signed_quote","filename":"example"}'
              
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "kind": {
        "type": "string",
        "enum": [
          "signed_quote",
          "quote",
          "purchase_order",
          "drawing",
          "manual",
          "inspection_report",
          "photo",
          "training_record",
          "invoice",
          "email_attachment",
          "export",
          "other"
        ]
      },
      "filename": {
        "type": "string",
        "minLength": 1,
        "maxLength": 255
      },
      "contentType": {
        "default": "application/octet-stream",
        "type": "string",
        "maxLength": 100
      },
      "title": {
        "description": "Defaults to the filename",
        "type": "string",
        "maxLength": 200
      },
      "accountId": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      },
      "links": {
        "default": [],
        "description": "Records to attach the document to",
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "entityType": {
              "type": "string",
              "enum": [
                "account",
                "contact",
                "site",
                "order",
                "machine",
                "ticket",
                "warranty_claim",
                "parts_order",
                "part",
                "opportunity",
                "check_in"
              ]
            },
            "entityId": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "description": "Record id (UUID)"
            }
          },
          "required": [
            "entityType",
            "entityId"
          ]
        }
      },
      "customerVisible": {
        "default": false,
        "description": "Show it to the customer in the portal",
        "type": "boolean"
      },
      "contentBase64": {
        "description": "File bytes, base64 encoded (max 10 MB)",
        "type": "string"
      },
      "source": {
        "default": "upload",
        "type": "string",
        "enum": [
          "upload",
          "email",
          "portal",
          "system",
          "import"
        ]
      }
    },
    "required": [
      "kind",
      "filename"
    ]
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "document": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Record id (UUID)"
          },
          "kind": {
            "type": "string",
            "enum": [
              "signed_quote",
              "quote",
              "purchase_order",
              "drawing",
              "manual",
              "inspection_report",
              "photo",
              "training_record",
              "invoice",
              "email_attachment",
              "export",
              "other"
            ]
          },
          "title": {
            "type": "string"
          },
          "filename": {
            "type": "string"
          },
          "contentType": {
            "type": "string"
          },
          "sizeBytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "stored"
            ],
            "description": "pending until the file bytes are stored"
          },
          "accountId": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "description": "Record id (UUID)"
              },
              {
                "type": "null"
              }
            ]
          },
          "customerVisible": {
            "type": "boolean",
            "description": "Whether the customer can open it in the portal"
          },
          "source": {
            "type": "string",
            "enum": [
              "upload",
              "email",
              "portal",
              "system",
              "import"
            ]
          },
          "links": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "entityType": {
                  "type": "string",
                  "enum": [
                    "account",
                    "contact",
                    "site",
                    "order",
                    "machine",
                    "ticket",
                    "warranty_claim",
                    "parts_order",
                    "part",
                    "opportunity",
                    "check_in"
                  ]
                },
                "entityId": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "description": "Record id (UUID)"
                }
              },
              "required": [
                "entityType",
                "entityId"
              ],
              "additionalProperties": false
            }
          },
          "uploadedByName": {
            "type": [
              "string",
              "null"
            ]
          },
          "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"
          }
        },
        "required": [
          "id",
          "kind",
          "title",
          "filename",
          "contentType",
          "sizeBytes",
          "status",
          "accountId",
          "customerVisible",
          "source",
          "links",
          "uploadedByName",
          "createdAt"
        ],
        "additionalProperties": false
      },
      "uploadUrl": {
        "description": "PUT the raw bytes here when contentBase64 was not sent; null once stored",
        "type": [
          "string",
          "null"
        ]
      }
    },
    "required": [
      "document",
      "uploadUrl"
    ],
    "additionalProperties": false
  }
}
            

Link a document to a record

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

Attach an existing document to another record (account, contact, site, order, machine, ticket, warranty claim, parts order, part, opportunity or check-in), or remove a link with unlink true. A document can be linked to many records.

Input (object)

FieldTypeDescription
documentIdrequiredstringRecord id (UUID)min length 1, max length 64
entityTyperequired"account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in"
entityIdrequiredstringRecord id (UUID)min length 1, max length 64
unlinkbooleandefault false

Output (object)

FieldTypeDescription
documentrequiredobject
idrequiredstringRecord id (UUID)min length 1, max length 64
kindrequired"signed_quote" | "quote" | "purchase_order" | "drawing" | "manual" | "inspection_report" | "photo" | "training_record" | "invoice" | "email_attachment" | "export" | "other"
titlerequiredstring
filenamerequiredstring
contentTyperequiredstring
sizeBytesrequiredintegermin 0, max 9007199254740991
statusrequired"pending" | "stored"pending until the file bytes are stored
accountIdrequiredstring | nullRecord id (UUID)min length 1, max length 64
customerVisiblerequiredbooleanWhether the customer can open it in the portal
sourcerequired"upload" | "email" | "portal" | "system" | "import"
linksrequiredobject[]
entityTyperequired"account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in"
entityIdrequiredstringRecord id (UUID)min length 1, max length 64
uploadedByNamerequiredstring | null
createdAtrequiredstring (date-time)UTC timestamp, ISO 8601 with Z
Example request
                curl https://api.cemco.app/v1/ops/documents.link \
  -H "x-api-key: $CEMCO_API_KEY" \
  -H "content-type: application/json" \
  -d '{"documentId":"00000000-0000-4000-8000-000000000000","entityType":"account","entityId":"00000000-0000-4000-8000-000000000000"}'
              
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "documentId": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      },
      "entityType": {
        "type": "string",
        "enum": [
          "account",
          "contact",
          "site",
          "order",
          "machine",
          "ticket",
          "warranty_claim",
          "parts_order",
          "part",
          "opportunity",
          "check_in"
        ]
      },
      "entityId": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      },
      "unlink": {
        "default": false,
        "type": "boolean"
      }
    },
    "required": [
      "documentId",
      "entityType",
      "entityId"
    ]
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "document": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Record id (UUID)"
          },
          "kind": {
            "type": "string",
            "enum": [
              "signed_quote",
              "quote",
              "purchase_order",
              "drawing",
              "manual",
              "inspection_report",
              "photo",
              "training_record",
              "invoice",
              "email_attachment",
              "export",
              "other"
            ]
          },
          "title": {
            "type": "string"
          },
          "filename": {
            "type": "string"
          },
          "contentType": {
            "type": "string"
          },
          "sizeBytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "stored"
            ],
            "description": "pending until the file bytes are stored"
          },
          "accountId": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "description": "Record id (UUID)"
              },
              {
                "type": "null"
              }
            ]
          },
          "customerVisible": {
            "type": "boolean",
            "description": "Whether the customer can open it in the portal"
          },
          "source": {
            "type": "string",
            "enum": [
              "upload",
              "email",
              "portal",
              "system",
              "import"
            ]
          },
          "links": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "entityType": {
                  "type": "string",
                  "enum": [
                    "account",
                    "contact",
                    "site",
                    "order",
                    "machine",
                    "ticket",
                    "warranty_claim",
                    "parts_order",
                    "part",
                    "opportunity",
                    "check_in"
                  ]
                },
                "entityId": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "description": "Record id (UUID)"
                }
              },
              "required": [
                "entityType",
                "entityId"
              ],
              "additionalProperties": false
            }
          },
          "uploadedByName": {
            "type": [
              "string",
              "null"
            ]
          },
          "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"
          }
        },
        "required": [
          "id",
          "kind",
          "title",
          "filename",
          "contentType",
          "sizeBytes",
          "status",
          "accountId",
          "customerVisible",
          "source",
          "links",
          "uploadedByName",
          "createdAt"
        ],
        "additionalProperties": false
      }
    },
    "required": [
      "document"
    ],
    "additionalProperties": false
  }
}
            

documents.update

Update a document's details

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

Change a document's title, kind or whether the customer can see it in the portal. The file itself cannot be changed.

Input (object)

FieldTypeDescription
idrequiredstringRecord id (UUID)min length 1, max length 64
titlestringmin length 1, max length 200
kind"signed_quote" | "quote" | "purchase_order" | "drawing" | "manual" | "inspection_report" | "photo" | "training_record" | "invoice" | "email_attachment" | "export" | "other"
customerVisibleboolean

Output (object)

FieldTypeDescription
documentrequiredobject
idrequiredstringRecord id (UUID)min length 1, max length 64
kindrequired"signed_quote" | "quote" | "purchase_order" | "drawing" | "manual" | "inspection_report" | "photo" | "training_record" | "invoice" | "email_attachment" | "export" | "other"
titlerequiredstring
filenamerequiredstring
contentTyperequiredstring
sizeBytesrequiredintegermin 0, max 9007199254740991
statusrequired"pending" | "stored"pending until the file bytes are stored
accountIdrequiredstring | nullRecord id (UUID)min length 1, max length 64
customerVisiblerequiredbooleanWhether the customer can open it in the portal
sourcerequired"upload" | "email" | "portal" | "system" | "import"
linksrequiredobject[]
entityTyperequired"account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in"
entityIdrequiredstringRecord id (UUID)min length 1, max length 64
uploadedByNamerequiredstring | null
createdAtrequiredstring (date-time)UTC timestamp, ISO 8601 with Z
Example request
                curl https://api.cemco.app/v1/ops/documents.update \
  -H "x-api-key: $CEMCO_API_KEY" \
  -H "content-type: application/json" \
  -d '{"id":"00000000-0000-4000-8000-000000000000"}'
              
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      },
      "title": {
        "type": "string",
        "minLength": 1,
        "maxLength": 200
      },
      "kind": {
        "type": "string",
        "enum": [
          "signed_quote",
          "quote",
          "purchase_order",
          "drawing",
          "manual",
          "inspection_report",
          "photo",
          "training_record",
          "invoice",
          "email_attachment",
          "export",
          "other"
        ]
      },
      "customerVisible": {
        "type": "boolean"
      }
    },
    "required": [
      "id"
    ]
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "document": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Record id (UUID)"
          },
          "kind": {
            "type": "string",
            "enum": [
              "signed_quote",
              "quote",
              "purchase_order",
              "drawing",
              "manual",
              "inspection_report",
              "photo",
              "training_record",
              "invoice",
              "email_attachment",
              "export",
              "other"
            ]
          },
          "title": {
            "type": "string"
          },
          "filename": {
            "type": "string"
          },
          "contentType": {
            "type": "string"
          },
          "sizeBytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "stored"
            ],
            "description": "pending until the file bytes are stored"
          },
          "accountId": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "description": "Record id (UUID)"
              },
              {
                "type": "null"
              }
            ]
          },
          "customerVisible": {
            "type": "boolean",
            "description": "Whether the customer can open it in the portal"
          },
          "source": {
            "type": "string",
            "enum": [
              "upload",
              "email",
              "portal",
              "system",
              "import"
            ]
          },
          "links": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "entityType": {
                  "type": "string",
                  "enum": [
                    "account",
                    "contact",
                    "site",
                    "order",
                    "machine",
                    "ticket",
                    "warranty_claim",
                    "parts_order",
                    "part",
                    "opportunity",
                    "check_in"
                  ]
                },
                "entityId": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "description": "Record id (UUID)"
                }
              },
              "required": [
                "entityType",
                "entityId"
              ],
              "additionalProperties": false
            }
          },
          "uploadedByName": {
            "type": [
              "string",
              "null"
            ]
          },
          "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"
          }
        },
        "required": [
          "id",
          "kind",
          "title",
          "filename",
          "contentType",
          "sizeBytes",
          "status",
          "accountId",
          "customerVisible",
          "source",
          "links",
          "uploadedByName",
          "createdAt"
        ],
        "additionalProperties": false
      }
    },
    "required": [
      "document"
    ],
    "additionalProperties": false
  }
}
            

documents.list

List documents

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

Documents on a record (entityType and entityId), on a whole account, or of one kind. Newest first.

Input (object)

FieldTypeDescription
accountIdstringRecord id (UUID)min length 1, max length 64
entityType"account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in"
entityIdstringRecord id (UUID)min length 1, max length 64
kind"signed_quote" | "quote" | "purchase_order" | "drawing" | "manual" | "inspection_report" | "photo" | "training_record" | "invoice" | "email_attachment" | "export" | "other"
querystringMatches title or filenamemax length 200
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
kindrequired"signed_quote" | "quote" | "purchase_order" | "drawing" | "manual" | "inspection_report" | "photo" | "training_record" | "invoice" | "email_attachment" | "export" | "other"
titlerequiredstring
filenamerequiredstring
contentTyperequiredstring
sizeBytesrequiredintegermin 0, max 9007199254740991
statusrequired"pending" | "stored"pending until the file bytes are stored
accountIdrequiredstring | nullRecord id (UUID)min length 1, max length 64
customerVisiblerequiredbooleanWhether the customer can open it in the portal
sourcerequired"upload" | "email" | "portal" | "system" | "import"
linksrequiredobject[]
entityTyperequired"account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in"
entityIdrequiredstringRecord id (UUID)min length 1, max length 64
uploadedByNamerequiredstring | null
createdAtrequiredstring (date-time)UTC 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/documents.list \
  -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": {
      "accountId": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      },
      "entityType": {
        "type": "string",
        "enum": [
          "account",
          "contact",
          "site",
          "order",
          "machine",
          "ticket",
          "warranty_claim",
          "parts_order",
          "part",
          "opportunity",
          "check_in"
        ]
      },
      "entityId": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      },
      "kind": {
        "type": "string",
        "enum": [
          "signed_quote",
          "quote",
          "purchase_order",
          "drawing",
          "manual",
          "inspection_report",
          "photo",
          "training_record",
          "invoice",
          "email_attachment",
          "export",
          "other"
        ]
      },
      "query": {
        "description": "Matches title or filename",
        "type": "string",
        "maxLength": 200
      },
      "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)"
            },
            "kind": {
              "type": "string",
              "enum": [
                "signed_quote",
                "quote",
                "purchase_order",
                "drawing",
                "manual",
                "inspection_report",
                "photo",
                "training_record",
                "invoice",
                "email_attachment",
                "export",
                "other"
              ]
            },
            "title": {
              "type": "string"
            },
            "filename": {
              "type": "string"
            },
            "contentType": {
              "type": "string"
            },
            "sizeBytes": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "status": {
              "type": "string",
              "enum": [
                "pending",
                "stored"
              ],
              "description": "pending until the file bytes are stored"
            },
            "accountId": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "description": "Record id (UUID)"
                },
                {
                  "type": "null"
                }
              ]
            },
            "customerVisible": {
              "type": "boolean",
              "description": "Whether the customer can open it in the portal"
            },
            "source": {
              "type": "string",
              "enum": [
                "upload",
                "email",
                "portal",
                "system",
                "import"
              ]
            },
            "links": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "entityType": {
                    "type": "string",
                    "enum": [
                      "account",
                      "contact",
                      "site",
                      "order",
                      "machine",
                      "ticket",
                      "warranty_claim",
                      "parts_order",
                      "part",
                      "opportunity",
                      "check_in"
                    ]
                  },
                  "entityId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64,
                    "description": "Record id (UUID)"
                  }
                },
                "required": [
                  "entityType",
                  "entityId"
                ],
                "additionalProperties": false
              }
            },
            "uploadedByName": {
              "type": [
                "string",
                "null"
              ]
            },
            "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"
            }
          },
          "required": [
            "id",
            "kind",
            "title",
            "filename",
            "contentType",
            "sizeBytes",
            "status",
            "accountId",
            "customerVisible",
            "source",
            "links",
            "uploadedByName",
            "createdAt"
          ],
          "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
  }
}
            

documents.get

Get a document's details

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

Metadata of one document: kind, filename, size, links and who uploaded it. Use documents.signed_link to open the file.

Input (object)

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

Output (object)

FieldTypeDescription
idrequiredstringRecord id (UUID)min length 1, max length 64
kindrequired"signed_quote" | "quote" | "purchase_order" | "drawing" | "manual" | "inspection_report" | "photo" | "training_record" | "invoice" | "email_attachment" | "export" | "other"
titlerequiredstring
filenamerequiredstring
contentTyperequiredstring
sizeBytesrequiredintegermin 0, max 9007199254740991
statusrequired"pending" | "stored"pending until the file bytes are stored
accountIdrequiredstring | nullRecord id (UUID)min length 1, max length 64
customerVisiblerequiredbooleanWhether the customer can open it in the portal
sourcerequired"upload" | "email" | "portal" | "system" | "import"
linksrequiredobject[]
entityTyperequired"account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in"
entityIdrequiredstringRecord id (UUID)min length 1, max length 64
uploadedByNamerequiredstring | null
createdAtrequiredstring (date-time)UTC timestamp, ISO 8601 with Z
Example request
                curl https://api.cemco.app/v1/ops/documents.get \
  -H "x-api-key: $CEMCO_API_KEY" \
  -H "content-type: application/json" \
  -d '{"id":"00000000-0000-4000-8000-000000000000"}'
              
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      }
    },
    "required": [
      "id"
    ]
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      },
      "kind": {
        "type": "string",
        "enum": [
          "signed_quote",
          "quote",
          "purchase_order",
          "drawing",
          "manual",
          "inspection_report",
          "photo",
          "training_record",
          "invoice",
          "email_attachment",
          "export",
          "other"
        ]
      },
      "title": {
        "type": "string"
      },
      "filename": {
        "type": "string"
      },
      "contentType": {
        "type": "string"
      },
      "sizeBytes": {
        "type": "integer",
        "minimum": 0,
        "maximum": 9007199254740991
      },
      "status": {
        "type": "string",
        "enum": [
          "pending",
          "stored"
        ],
        "description": "pending until the file bytes are stored"
      },
      "accountId": {
        "anyOf": [
          {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Record id (UUID)"
          },
          {
            "type": "null"
          }
        ]
      },
      "customerVisible": {
        "type": "boolean",
        "description": "Whether the customer can open it in the portal"
      },
      "source": {
        "type": "string",
        "enum": [
          "upload",
          "email",
          "portal",
          "system",
          "import"
        ]
      },
      "links": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "entityType": {
              "type": "string",
              "enum": [
                "account",
                "contact",
                "site",
                "order",
                "machine",
                "ticket",
                "warranty_claim",
                "parts_order",
                "part",
                "opportunity",
                "check_in"
              ]
            },
            "entityId": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "description": "Record id (UUID)"
            }
          },
          "required": [
            "entityType",
            "entityId"
          ],
          "additionalProperties": false
        }
      },
      "uploadedByName": {
        "type": [
          "string",
          "null"
        ]
      },
      "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"
      }
    },
    "required": [
      "id",
      "kind",
      "title",
      "filename",
      "contentType",
      "sizeBytes",
      "status",
      "accountId",
      "customerVisible",
      "source",
      "links",
      "uploadedByName",
      "createdAt"
    ],
    "additionalProperties": false
  }
}
            

Get a short-lived link to a document

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

Issue a signed link that opens or downloads the file for 15 minutes without signing in. Share it only with people who should see the document.

Input (object)

FieldTypeDescription
idrequiredstringRecord id (UUID)min length 1, max length 64
disposition"inline" | "attachment"inline opens in the browser, attachment downloadsdefault "inline"

Output (object)

FieldTypeDescription
documentIdrequiredstringRecord id (UUID)min length 1, max length 64
urlrequiredstringAbsolute URL that opens the file without signing in; valid for 15 minutes
expiresAtrequiredstring (date-time)UTC timestamp, ISO 8601 with Z
filenamerequiredstring
contentTyperequiredstring
Example request
                curl https://api.cemco.app/v1/ops/documents.signed_link \
  -H "x-api-key: $CEMCO_API_KEY" \
  -H "content-type: application/json" \
  -d '{"id":"00000000-0000-4000-8000-000000000000"}'
              
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      },
      "disposition": {
        "default": "inline",
        "description": "inline opens in the browser, attachment downloads",
        "type": "string",
        "enum": [
          "inline",
          "attachment"
        ]
      }
    },
    "required": [
      "id"
    ]
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "documentId": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      },
      "url": {
        "type": "string",
        "description": "Absolute URL that opens the file without signing in; valid for 15 minutes"
      },
      "expiresAt": {
        "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"
      },
      "filename": {
        "type": "string"
      },
      "contentType": {
        "type": "string"
      }
    },
    "required": [
      "documentId",
      "url",
      "expiresAt",
      "filename",
      "contentType"
    ],
    "additionalProperties": false
  }
}
            

documents.delete

Delete a document

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

Delete a document and its file. Fails with a conflict if it is the signed quote of an order; replace the signed quote on the order first.

Input (object)

FieldTypeDescription
idrequiredstringRecord 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/documents.delete \
  -H "x-api-key: $CEMCO_API_KEY" \
  -H "content-type: application/json" \
  -d '{"id":"00000000-0000-4000-8000-000000000000"}'
              
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      }
    },
    "required": [
      "id"
    ]
  },
  "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
  }
}
            

documents.resolve

Resolve a document to its storage key

Kind
Read
Who
Internal only (system)

Internal: returns the R2 key of a document for the upload and download routes.

Input (object)

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

Output (object)

FieldTypeDescription
documentrequiredobject
idrequiredstringRecord id (UUID)min length 1, max length 64
kindrequired"signed_quote" | "quote" | "purchase_order" | "drawing" | "manual" | "inspection_report" | "photo" | "training_record" | "invoice" | "email_attachment" | "export" | "other"
titlerequiredstring
filenamerequiredstring
contentTyperequiredstring
sizeBytesrequiredintegermin 0, max 9007199254740991
statusrequired"pending" | "stored"pending until the file bytes are stored
accountIdrequiredstring | nullRecord id (UUID)min length 1, max length 64
customerVisiblerequiredbooleanWhether the customer can open it in the portal
sourcerequired"upload" | "email" | "portal" | "system" | "import"
linksrequiredobject[]
entityTyperequired"account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in"
entityIdrequiredstringRecord id (UUID)min length 1, max length 64
uploadedByNamerequiredstring | null
createdAtrequiredstring (date-time)UTC timestamp, ISO 8601 with Z
r2Keyrequiredstring
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      }
    },
    "required": [
      "id"
    ]
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "document": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Record id (UUID)"
          },
          "kind": {
            "type": "string",
            "enum": [
              "signed_quote",
              "quote",
              "purchase_order",
              "drawing",
              "manual",
              "inspection_report",
              "photo",
              "training_record",
              "invoice",
              "email_attachment",
              "export",
              "other"
            ]
          },
          "title": {
            "type": "string"
          },
          "filename": {
            "type": "string"
          },
          "contentType": {
            "type": "string"
          },
          "sizeBytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "stored"
            ],
            "description": "pending until the file bytes are stored"
          },
          "accountId": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "description": "Record id (UUID)"
              },
              {
                "type": "null"
              }
            ]
          },
          "customerVisible": {
            "type": "boolean",
            "description": "Whether the customer can open it in the portal"
          },
          "source": {
            "type": "string",
            "enum": [
              "upload",
              "email",
              "portal",
              "system",
              "import"
            ]
          },
          "links": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "entityType": {
                  "type": "string",
                  "enum": [
                    "account",
                    "contact",
                    "site",
                    "order",
                    "machine",
                    "ticket",
                    "warranty_claim",
                    "parts_order",
                    "part",
                    "opportunity",
                    "check_in"
                  ]
                },
                "entityId": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "description": "Record id (UUID)"
                }
              },
              "required": [
                "entityType",
                "entityId"
              ],
              "additionalProperties": false
            }
          },
          "uploadedByName": {
            "type": [
              "string",
              "null"
            ]
          },
          "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"
          }
        },
        "required": [
          "id",
          "kind",
          "title",
          "filename",
          "contentType",
          "sizeBytes",
          "status",
          "accountId",
          "customerVisible",
          "source",
          "links",
          "uploadedByName",
          "createdAt"
        ],
        "additionalProperties": false
      },
      "r2Key": {
        "type": "string"
      }
    },
    "required": [
      "document",
      "r2Key"
    ],
    "additionalProperties": false
  }
}
            

documents.finalize

Mark a document's bytes as stored

Kind
Write (audited)
Who
Internal only (system)

Internal: called by the upload route after the file is in R2. Sets size, checksum and status stored. Fails with conflict when the document already has its file, so only one of two concurrent uploads wins.

Input (object)

FieldTypeDescription
idrequiredstringRecord id (UUID)min length 1, max length 64
sizeBytesrequiredintegermin 0, max 9007199254740991
sha256string | null
contentTypestringmax length 100
r2KeystringWhere the upload wrote the bytes, when not the document's own keymax length 1000
uploadedByKind"staff" | "customer" | "agent" | "system"Who uploaded, for the audit row

Output (object)

FieldTypeDescription
documentrequiredobject
idrequiredstringRecord id (UUID)min length 1, max length 64
kindrequired"signed_quote" | "quote" | "purchase_order" | "drawing" | "manual" | "inspection_report" | "photo" | "training_record" | "invoice" | "email_attachment" | "export" | "other"
titlerequiredstring
filenamerequiredstring
contentTyperequiredstring
sizeBytesrequiredintegermin 0, max 9007199254740991
statusrequired"pending" | "stored"pending until the file bytes are stored
accountIdrequiredstring | nullRecord id (UUID)min length 1, max length 64
customerVisiblerequiredbooleanWhether the customer can open it in the portal
sourcerequired"upload" | "email" | "portal" | "system" | "import"
linksrequiredobject[]
entityTyperequired"account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in"
entityIdrequiredstringRecord id (UUID)min length 1, max length 64
uploadedByNamerequiredstring | null
createdAtrequiredstring (date-time)UTC timestamp, ISO 8601 with Z
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "description": "Record id (UUID)"
      },
      "sizeBytes": {
        "type": "integer",
        "minimum": 0,
        "maximum": 9007199254740991
      },
      "sha256": {
        "type": [
          "string",
          "null"
        ]
      },
      "contentType": {
        "type": "string",
        "maxLength": 100
      },
      "r2Key": {
        "description": "Where the upload wrote the bytes, when not the document's own key",
        "type": "string",
        "maxLength": 1000
      },
      "uploadedByKind": {
        "description": "Who uploaded, for the audit row",
        "type": "string",
        "enum": [
          "staff",
          "customer",
          "agent",
          "system"
        ]
      }
    },
    "required": [
      "id",
      "sizeBytes"
    ]
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "document": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Record id (UUID)"
          },
          "kind": {
            "type": "string",
            "enum": [
              "signed_quote",
              "quote",
              "purchase_order",
              "drawing",
              "manual",
              "inspection_report",
              "photo",
              "training_record",
              "invoice",
              "email_attachment",
              "export",
              "other"
            ]
          },
          "title": {
            "type": "string"
          },
          "filename": {
            "type": "string"
          },
          "contentType": {
            "type": "string"
          },
          "sizeBytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "stored"
            ],
            "description": "pending until the file bytes are stored"
          },
          "accountId": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "description": "Record id (UUID)"
              },
              {
                "type": "null"
              }
            ]
          },
          "customerVisible": {
            "type": "boolean",
            "description": "Whether the customer can open it in the portal"
          },
          "source": {
            "type": "string",
            "enum": [
              "upload",
              "email",
              "portal",
              "system",
              "import"
            ]
          },
          "links": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "entityType": {
                  "type": "string",
                  "enum": [
                    "account",
                    "contact",
                    "site",
                    "order",
                    "machine",
                    "ticket",
                    "warranty_claim",
                    "parts_order",
                    "part",
                    "opportunity",
                    "check_in"
                  ]
                },
                "entityId": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "description": "Record id (UUID)"
                }
              },
              "required": [
                "entityType",
                "entityId"
              ],
              "additionalProperties": false
            }
          },
          "uploadedByName": {
            "type": [
              "string",
              "null"
            ]
          },
          "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"
          }
        },
        "required": [
          "id",
          "kind",
          "title",
          "filename",
          "contentType",
          "sizeBytes",
          "status",
          "accountId",
          "customerVisible",
          "source",
          "links",
          "uploadedByName",
          "createdAt"
        ],
        "additionalProperties": false
      }
    },
    "required": [
      "document"
    ],
    "additionalProperties": false
  }
}