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
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)
| Field | Type | Description |
|---|---|---|
kindrequired | "signed_quote" | "quote" | "purchase_order" | "drawing" | "manual" | "inspection_report" | "photo" | "training_record" | "invoice" | "email_attachment" | "export" | "other" | |
filenamerequired | string | min length 1, max length 255 |
contentType | string | default "application/octet-stream", max length 100 |
title | string | Defaults to the filenamemax length 200 |
accountId | string | Record id (UUID)min length 1, max length 64 |
links | object[] | Records to attach the document todefault [] |
entityTyperequired | "account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in" | |
entityIdrequired | string | Record id (UUID)min length 1, max length 64 |
customerVisible | boolean | Show it to the customer in the portaldefault false |
contentBase64 | string | File bytes, base64 encoded (max 10 MB) |
source | "upload" | "email" | "portal" | "system" | "import" | default "upload" |
Output (object)
| Field | Type | Description |
|---|---|---|
documentrequired | object | |
idrequired | string | Record 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" | |
titlerequired | string | |
filenamerequired | string | |
contentTyperequired | string | |
sizeBytesrequired | integer | min 0, max 9007199254740991 |
statusrequired | "pending" | "stored" | pending until the file bytes are stored |
accountIdrequired | string | null | Record id (UUID)min length 1, max length 64 |
customerVisiblerequired | boolean | Whether the customer can open it in the portal |
sourcerequired | "upload" | "email" | "portal" | "system" | "import" | |
linksrequired | object[] | |
entityTyperequired | "account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in" | |
entityIdrequired | string | Record id (UUID)min length 1, max length 64 |
uploadedByNamerequired | string | null | |
createdAtrequired | string (date-time) | UTC timestamp, ISO 8601 with Z |
uploadUrlrequired | string | null | PUT 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
}
}
documents.link
Link a document to a record
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)
| Field | Type | Description |
|---|---|---|
documentIdrequired | string | Record id (UUID)min length 1, max length 64 |
entityTyperequired | "account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in" | |
entityIdrequired | string | Record id (UUID)min length 1, max length 64 |
unlink | boolean | default false |
Output (object)
| Field | Type | Description |
|---|---|---|
documentrequired | object | |
idrequired | string | Record 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" | |
titlerequired | string | |
filenamerequired | string | |
contentTyperequired | string | |
sizeBytesrequired | integer | min 0, max 9007199254740991 |
statusrequired | "pending" | "stored" | pending until the file bytes are stored |
accountIdrequired | string | null | Record id (UUID)min length 1, max length 64 |
customerVisiblerequired | boolean | Whether the customer can open it in the portal |
sourcerequired | "upload" | "email" | "portal" | "system" | "import" | |
linksrequired | object[] | |
entityTyperequired | "account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in" | |
entityIdrequired | string | Record id (UUID)min length 1, max length 64 |
uploadedByNamerequired | string | null | |
createdAtrequired | string (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
Change a document's title, kind or whether the customer can see it in the portal. The file itself cannot be changed.
Input (object)
| Field | Type | Description |
|---|---|---|
idrequired | string | Record id (UUID)min length 1, max length 64 |
title | string | min length 1, max length 200 |
kind | "signed_quote" | "quote" | "purchase_order" | "drawing" | "manual" | "inspection_report" | "photo" | "training_record" | "invoice" | "email_attachment" | "export" | "other" | |
customerVisible | boolean |
Output (object)
| Field | Type | Description |
|---|---|---|
documentrequired | object | |
idrequired | string | Record 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" | |
titlerequired | string | |
filenamerequired | string | |
contentTyperequired | string | |
sizeBytesrequired | integer | min 0, max 9007199254740991 |
statusrequired | "pending" | "stored" | pending until the file bytes are stored |
accountIdrequired | string | null | Record id (UUID)min length 1, max length 64 |
customerVisiblerequired | boolean | Whether the customer can open it in the portal |
sourcerequired | "upload" | "email" | "portal" | "system" | "import" | |
linksrequired | object[] | |
entityTyperequired | "account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in" | |
entityIdrequired | string | Record id (UUID)min length 1, max length 64 |
uploadedByNamerequired | string | null | |
createdAtrequired | string (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
Documents on a record (entityType and entityId), on a whole account, or of one kind. Newest first.
Input (object)
| Field | Type | Description |
|---|---|---|
accountId | string | Record id (UUID)min length 1, max length 64 |
entityType | "account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in" | |
entityId | string | Record 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" | |
query | string | Matches title or filenamemax length 200 |
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 |
kindrequired | "signed_quote" | "quote" | "purchase_order" | "drawing" | "manual" | "inspection_report" | "photo" | "training_record" | "invoice" | "email_attachment" | "export" | "other" | |
titlerequired | string | |
filenamerequired | string | |
contentTyperequired | string | |
sizeBytesrequired | integer | min 0, max 9007199254740991 |
statusrequired | "pending" | "stored" | pending until the file bytes are stored |
accountIdrequired | string | null | Record id (UUID)min length 1, max length 64 |
customerVisiblerequired | boolean | Whether the customer can open it in the portal |
sourcerequired | "upload" | "email" | "portal" | "system" | "import" | |
linksrequired | object[] | |
entityTyperequired | "account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in" | |
entityIdrequired | string | Record id (UUID)min length 1, max length 64 |
uploadedByNamerequired | string | null | |
createdAtrequired | string (date-time) | 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/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
Metadata of one document: kind, filename, size, links and who uploaded it. Use documents.signed_link to open the file.
Input (object)
| Field | Type | Description |
|---|---|---|
idrequired | string | Record id (UUID)min length 1, max length 64 |
Output (object)
| Field | Type | Description |
|---|---|---|
idrequired | string | Record 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" | |
titlerequired | string | |
filenamerequired | string | |
contentTyperequired | string | |
sizeBytesrequired | integer | min 0, max 9007199254740991 |
statusrequired | "pending" | "stored" | pending until the file bytes are stored |
accountIdrequired | string | null | Record id (UUID)min length 1, max length 64 |
customerVisiblerequired | boolean | Whether the customer can open it in the portal |
sourcerequired | "upload" | "email" | "portal" | "system" | "import" | |
linksrequired | object[] | |
entityTyperequired | "account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in" | |
entityIdrequired | string | Record id (UUID)min length 1, max length 64 |
uploadedByNamerequired | string | null | |
createdAtrequired | string (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
}
}
documents.signed_link
Get a short-lived link to a document
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)
| Field | Type | Description |
|---|---|---|
idrequired | string | Record id (UUID)min length 1, max length 64 |
disposition | "inline" | "attachment" | inline opens in the browser, attachment downloadsdefault "inline" |
Output (object)
| Field | Type | Description |
|---|---|---|
documentIdrequired | string | Record id (UUID)min length 1, max length 64 |
urlrequired | string | Absolute URL that opens the file without signing in; valid for 15 minutes |
expiresAtrequired | string (date-time) | UTC timestamp, ISO 8601 with Z |
filenamerequired | string | |
contentTyperequired | string |
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
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)
| Field | Type | Description |
|---|---|---|
idrequired | 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/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
Internal: returns the R2 key of a document for the upload and download routes.
Input (object)
| Field | Type | Description |
|---|---|---|
idrequired | string | Record id (UUID)min length 1, max length 64 |
Output (object)
| Field | Type | Description |
|---|---|---|
documentrequired | object | |
idrequired | string | Record 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" | |
titlerequired | string | |
filenamerequired | string | |
contentTyperequired | string | |
sizeBytesrequired | integer | min 0, max 9007199254740991 |
statusrequired | "pending" | "stored" | pending until the file bytes are stored |
accountIdrequired | string | null | Record id (UUID)min length 1, max length 64 |
customerVisiblerequired | boolean | Whether the customer can open it in the portal |
sourcerequired | "upload" | "email" | "portal" | "system" | "import" | |
linksrequired | object[] | |
entityTyperequired | "account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in" | |
entityIdrequired | string | Record id (UUID)min length 1, max length 64 |
uploadedByNamerequired | string | null | |
createdAtrequired | string (date-time) | UTC timestamp, ISO 8601 with Z |
r2Keyrequired | string |
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
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)
| Field | Type | Description |
|---|---|---|
idrequired | string | Record id (UUID)min length 1, max length 64 |
sizeBytesrequired | integer | min 0, max 9007199254740991 |
sha256 | string | null | |
contentType | string | max length 100 |
r2Key | string | Where 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)
| Field | Type | Description |
|---|---|---|
documentrequired | object | |
idrequired | string | Record 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" | |
titlerequired | string | |
filenamerequired | string | |
contentTyperequired | string | |
sizeBytesrequired | integer | min 0, max 9007199254740991 |
statusrequired | "pending" | "stored" | pending until the file bytes are stored |
accountIdrequired | string | null | Record id (UUID)min length 1, max length 64 |
customerVisiblerequired | boolean | Whether the customer can open it in the portal |
sourcerequired | "upload" | "email" | "portal" | "system" | "import" | |
linksrequired | object[] | |
entityTyperequired | "account" | "contact" | "site" | "order" | "machine" | "ticket" | "warranty_claim" | "parts_order" | "part" | "opportunity" | "check_in" | |
entityIdrequired | string | Record id (UUID)min length 1, max length 64 |
uploadedByNamerequired | string | null | |
createdAtrequired | string (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
}
}