Litelead-mcp

createOrder

Create a new order in the system.

Description

Creates a new order document with transactional ID generation. It automatically applies the current order stage configuration to the order. If responsible_staff is not provided, it attempts to use the account’s default responsible staff configuration.

Input Schema

{
  "type": "object",
  "properties": {
    "title": { "type": "string", "minLength": 1 },
    "orderNumber": { "type": "string", "minLength": 1 },
    "ticketNumber": { "type": "string", "minLength": 1 },
    "stage": { "type": "integer", "description": "Initial stage index (e.g., 0 or -1)" },
    "supplierOrderNumber": { "type": "string" },
    "customer": { "type": "string", "description": "Firestore path to the customer document (e.g., Accounts/acc123/Customers/cust456)" },
    "contact": { "type": "string", "description": "Firestore path to the contact document (e.g., Accounts/acc123/Customers/cust456/Contacts/cont789)" },
    "technician_staff": { "type": "string", "description": "Staff ID for technician" },
    "responsible_staff": { "type": "string", "description": "Staff ID for responsible person. If omitted, defaults to the account's default responsible staff." },
    "location": { "type": "string", "description": "Location value/ID" },
    "type": { "type": "string" },
    "deadline": { "type": "string", "description": "ISO date string or similar" },
    "users": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "email": { "type": "string", "format": "email" }
        },
        "required": ["name", "email"]
      }
    },
    "bcc": {
      "type": "array",
      "items": { "type": "string", "format": "email" }
    },
    "closed": { "type": "boolean", "default": false }
  },
  "required": ["title", "orderNumber", "ticketNumber", "stage"]
}

Output Schema

{
  "type": "object",
  "properties": {
    "success": { "type": "boolean" },
    "orderId": { "type": "number" },
    "id": { "type": "string" },
    "path": { "type": "string" }
  }
}

Example Usage

const result = await client.createOrder({
  title: "New Laptop Order",
  orderNumber: "ORD-2023-001",
  ticketNumber: "TICKET-123",
  stage: 0,
  customer: "Accounts/acc_123/Customers/cust_456",
  contact: "Accounts/acc_123/Customers/cust_456/Contacts/cont_789",
  users: [
    { "name": "John Doe", "email": "john@example.com" }
  ]
});