Skip to content

Search

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

search.query

Search everything

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

One search across accounts, contacts, sites, machines (by serial number), orders, tickets, parts, parts orders and documents. Matches prefixes, so 'M300-24' finds serial M300-2417. Returns the best matches with the record type, a title, a snippet and the path of the record in the web app.

Input (object)

FieldTypeDescription
queryrequiredstringmin length 1, max length 200
types("account" | "contact" | "site" | "machine" | "order" | "ticket" | "part" | "parts_order" | "document")[]Limit to these record types
limitintegerdefault 20, min 1, max 50

Output (object)

FieldTypeDescription
queryrequiredstring
resultsrequiredobject[]
entityTyperequired"account" | "contact" | "site" | "machine" | "order" | "ticket" | "part" | "parts_order" | "document"
entityIdrequiredstringRecord id (UUID)min length 1, max length 64
titlerequiredstring
subtitlerequiredstring | null
snippetrequiredstring | nullMatching text with the hit wrapped in <mark> tags
accountIdrequiredstring | nullRecord id (UUID)min length 1, max length 64
pathrequiredstringPath of the record in the web app, for example /orders/{id}
countsrequiredrecord of integerNumber of results per record type
Example request
                curl https://api.cemco.app/v1/ops/search.query \
  -H "x-api-key: $CEMCO_API_KEY" \
  -H "content-type: application/json" \
  -d '{"query":"example"}'
              
JSON Schema
              {
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "query": {
        "type": "string",
        "minLength": 1,
        "maxLength": 200
      },
      "types": {
        "description": "Limit to these record types",
        "type": "array",
        "items": {
          "type": "string",
          "enum": [
            "account",
            "contact",
            "site",
            "machine",
            "order",
            "ticket",
            "part",
            "parts_order",
            "document"
          ]
        }
      },
      "limit": {
        "default": 20,
        "type": "integer",
        "minimum": 1,
        "maximum": 50
      }
    },
    "required": [
      "query"
    ]
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "query": {
        "type": "string"
      },
      "results": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "entityType": {
              "type": "string",
              "enum": [
                "account",
                "contact",
                "site",
                "machine",
                "order",
                "ticket",
                "part",
                "parts_order",
                "document"
              ]
            },
            "entityId": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "description": "Record id (UUID)"
            },
            "title": {
              "type": "string"
            },
            "subtitle": {
              "type": [
                "string",
                "null"
              ]
            },
            "snippet": {
              "description": "Matching text with the hit wrapped in <mark> tags",
              "type": [
                "string",
                "null"
              ]
            },
            "accountId": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "description": "Record id (UUID)"
                },
                {
                  "type": "null"
                }
              ]
            },
            "path": {
              "type": "string",
              "description": "Path of the record in the web app, for example /orders/{id}"
            }
          },
          "required": [
            "entityType",
            "entityId",
            "title",
            "subtitle",
            "snippet",
            "accountId",
            "path"
          ],
          "additionalProperties": false
        }
      },
      "counts": {
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "description": "Number of results per record type"
      }
    },
    "required": [
      "query",
      "results",
      "counts"
    ],
    "additionalProperties": false
  }
}
            

search.reindex

Rebuild the search index

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

Rebuild the full-text search index from the tables. Run after a bulk import or if search results look out of date.

Input (object)

FieldTypeDescription
types("account" | "contact" | "site" | "machine" | "order" | "ticket" | "part" | "parts_order" | "document")[]Only these record types; all when omitted

Output (object)

FieldTypeDescription
indexedrequiredintegermin -9007199254740991, max 9007199254740991
byTyperequiredrecord of integer
Example request
                curl https://api.cemco.app/v1/ops/search.reindex \
  -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": {
      "types": {
        "description": "Only these record types; all when omitted",
        "type": "array",
        "items": {
          "type": "string",
          "enum": [
            "account",
            "contact",
            "site",
            "machine",
            "order",
            "ticket",
            "part",
            "parts_order",
            "document"
          ]
        }
      }
    }
  },
  "output": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "indexed": {
        "type": "integer",
        "minimum": -9007199254740991,
        "maximum": 9007199254740991
      },
      "byType": {
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        }
      }
    },
    "required": [
      "indexed",
      "byType"
    ],
    "additionalProperties": false
  }
}