{
 "openapi": "3.1.0",
 "info": {
  "title": "Sales Orders (CRM)",
  "version": "20261030b",
  "description": "Read and maintain sales orders records (crm.sales_orders)."
 },
 "servers": [
  {
   "url": "https://{tenant}.tranxact.ai",
   "variables": {
    "tenant": {
     "default": "demo"
    }
   }
  }
 ],
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer"
   }
  },
  "schemas": {
   "sales-orders": {
    "type": "object",
    "required": [
     "account_id",
     "currency"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "description": "Id",
      "readOnly": true
     },
     "org_id": {
      "type": "string",
      "format": "uuid",
      "description": "Org id",
      "readOnly": true
     },
     "org_unit_id": {
      "type": "string",
      "format": "uuid",
      "description": "Org unit id",
      "readOnly": true
     },
     "so_no": {
      "type": "string",
      "description": "So no",
      "readOnly": true
     },
     "account_id": {
      "type": "string",
      "format": "uuid",
      "description": "Account id"
     },
     "contact_id": {
      "type": "string",
      "format": "uuid",
      "description": "Contact id"
     },
     "quotation_id": {
      "type": "string",
      "format": "uuid",
      "description": "Quotation id"
     },
     "opportunity_id": {
      "type": "string",
      "format": "uuid",
      "description": "Opportunity id"
     },
     "order_date": {
      "type": "string",
      "format": "date",
      "description": "Order date"
     },
     "requested_date": {
      "type": "string",
      "format": "date",
      "description": "Requested delivery date"
     },
     "currency": {
      "type": "string",
      "description": "Currency"
     },
     "status": {
      "type": "string",
      "description": "Status"
     },
     "subtotal": {
      "type": "string",
      "format": "decimal",
      "description": "Subtotal",
      "readOnly": true
     },
     "tax_total": {
      "type": "string",
      "format": "decimal",
      "description": "Tax total",
      "readOnly": true
     },
     "total": {
      "type": "string",
      "format": "decimal",
      "description": "Total",
      "readOnly": true
     },
     "customer_po_ref": {
      "type": "string",
      "description": "Customer PO reference"
     },
     "ship_to_address": {
      "type": "string",
      "description": "Ship to"
     },
     "notes": {
      "type": "string",
      "description": "Notes"
     },
     "created_by": {
      "type": "string",
      "format": "uuid",
      "description": "Created by",
      "readOnly": true
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "Created at",
      "readOnly": true
     },
     "location_id": {
      "type": "string",
      "format": "uuid",
      "description": "Location",
      "readOnly": true
     },
     "warehouse_id": {
      "type": "string",
      "format": "uuid",
      "description": "Ships from warehouse",
      "readOnly": true
     },
     "cost_center_id": {
      "type": "string",
      "format": "uuid",
      "description": "Cost center id",
      "readOnly": true
     },
     "profit_center_id": {
      "type": "string",
      "format": "uuid",
      "description": "Profit center id",
      "readOnly": true
     },
     "cancelled_at": {
      "type": "string",
      "format": "date-time",
      "description": "Cancelled at",
      "readOnly": true
     },
     "cancelled_by": {
      "type": "string",
      "format": "uuid",
      "description": "Cancelled by",
      "readOnly": true
     },
     "cancel_reason": {
      "type": "string",
      "description": "Cancel reason",
      "readOnly": true
     },
     "reversed_by_id": {
      "type": "string",
      "format": "uuid",
      "description": "Reversed by id",
      "readOnly": true
     },
     "reverses_id": {
      "type": "string",
      "format": "uuid",
      "description": "Reverses id",
      "readOnly": true
     },
     "exchange_rate": {
      "type": "string",
      "format": "decimal",
      "description": "Exchange rate"
     },
     "base_total": {
      "type": "string",
      "format": "decimal",
      "description": "Base total",
      "readOnly": true
     },
     "xf_text_1": {
      "type": "string",
      "description": "Xf text 1",
      "readOnly": true
     },
     "xf_text_2": {
      "type": "string",
      "description": "Xf text 2",
      "readOnly": true
     },
     "xf_text_3": {
      "type": "string",
      "description": "Xf text 3",
      "readOnly": true
     },
     "xf_text_4": {
      "type": "string",
      "description": "Xf text 4",
      "readOnly": true
     },
     "xf_text_5": {
      "type": "string",
      "description": "Xf text 5",
      "readOnly": true
     },
     "xf_num_1": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 1",
      "readOnly": true
     },
     "xf_num_2": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 2",
      "readOnly": true
     },
     "xf_num_3": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 3",
      "readOnly": true
     },
     "xf_date_1": {
      "type": "string",
      "format": "date",
      "description": "Xf date 1",
      "readOnly": true
     },
     "xf_date_2": {
      "type": "string",
      "format": "date",
      "description": "Xf date 2",
      "readOnly": true
     },
     "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "Updated at",
      "readOnly": true
     },
     "updated_by": {
      "type": "string",
      "format": "uuid",
      "description": "Updated by",
      "readOnly": true
     },
     "edi_interchange_id": {
      "type": "string",
      "format": "uuid",
      "description": "Edi interchange id",
      "readOnly": true
     },
     "customer_po_date": {
      "type": "string",
      "format": "date",
      "description": "Customer po date",
      "readOnly": true
     },
     "source_channel": {
      "type": "string",
      "description": "Source channel",
      "readOnly": true
     },
     "channel_order_ref": {
      "type": "string",
      "description": "Channel order ref",
      "readOnly": true
     },
     "commerce_connector_id": {
      "type": "string",
      "format": "uuid",
      "description": "Commerce connector id",
      "readOnly": true
     },
     "supplier_gstin": {
      "type": "string",
      "description": "Supplier gstin",
      "readOnly": true
     },
     "buyer_gstin": {
      "type": "string",
      "description": "Buyer gstin",
      "readOnly": true
     },
     "place_of_supply": {
      "type": "string",
      "description": "Place of supply",
      "readOnly": true
     },
     "is_interstate": {
      "type": "boolean",
      "description": "Is interstate",
      "readOnly": true
     },
     "is_reverse_charge": {
      "type": "boolean",
      "description": "Is reverse charge",
      "readOnly": true
     },
     "export_type": {
      "type": "string",
      "description": "Export type",
      "readOnly": true
     },
     "cgst_total": {
      "type": "string",
      "format": "decimal",
      "description": "Cgst total",
      "readOnly": true
     },
     "sgst_total": {
      "type": "string",
      "format": "decimal",
      "description": "Sgst total",
      "readOnly": true
     },
     "igst_total": {
      "type": "string",
      "format": "decimal",
      "description": "Igst total",
      "readOnly": true
     },
     "cess_total": {
      "type": "string",
      "format": "decimal",
      "description": "Cess total",
      "readOnly": true
     },
     "order_type_id": {
      "type": "string",
      "format": "uuid",
      "description": "Order type id"
     },
     "charges_total": {
      "type": "string",
      "format": "decimal",
      "description": "Charges total",
      "readOnly": true
     },
     "accrued_charges_total": {
      "type": "string",
      "format": "decimal",
      "description": "Accrued charges total",
      "readOnly": true
     }
    }
   }
  }
 },
 "security": [
  {
   "bearer": []
  }
 ],
 "paths": {
  "/api/crm/sales-orders": {
   "get": {
    "summary": "list sales-orders",
    "operationId": "list_sales_orders_0_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "create sales-orders",
    "operationId": "create_sales_orders_1_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/{id}": {
   "get": {
    "summary": "get sales-orders",
    "operationId": "get_sales_orders_0_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "put": {
    "summary": "change sales-orders",
    "operationId": "change_sales_orders_1_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "delete sales-orders",
    "operationId": "delete_sales_orders_2_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/line-template": {
   "get": {
    "summary": "Line template",
    "operationId": "action_sales_orders_0_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/line-upload": {
   "post": {
    "summary": "Line upload",
    "operationId": "action_sales_orders_0_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/line-upload/error-file": {
   "post": {
    "summary": "Line upload error file",
    "operationId": "action_sales_orders_0_6",
    "description": "Body keys: rows: [{ problems, sheet, rowNo, itemNo }]",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/line-upload/360": {
   "get": {
    "summary": "Line upload 360",
    "operationId": "action_sales_orders_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/line-upload/discard": {
   "post": {
    "summary": "Line upload discard",
    "operationId": "action_sales_orders_0_6",
    "description": "Body keys: configIds",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/{id}/mrp": {
   "get": {
    "summary": "Mrp",
    "operationId": "action_sales_orders_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/{id}/run-mrp": {
   "post": {
    "summary": "Run mrp",
    "operationId": "action_sales_orders_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/{id}/run-mrp/firm": {
   "post": {
    "summary": "Run mrp firm",
    "operationId": "action_sales_orders_0_7",
    "description": "Body keys: kinds, itemIds",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/{id}/run-mrp/fulfilment": {
   "post": {
    "summary": "Run mrp fulfilment",
    "operationId": "action_sales_orders_0_7",
    "description": "Body keys: itemId, method, supplierId, reason",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/{id}/annexure": {
   "get": {
    "summary": "Annexure",
    "operationId": "action_sales_orders_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/{id}/mrp/trace": {
   "get": {
    "summary": "Mrp trace",
    "operationId": "action_sales_orders_0_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/{id}/copy": {
   "post": {
    "summary": "Copy",
    "operationId": "action_sales_orders_0_6",
    "description": "Body keys: overrides, preview, withLines",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/{parentId}/lines": {
   "get": {
    "summary": "Lines",
    "operationId": "action_sales_orders_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "Lines",
    "operationId": "action_sales_orders_1_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/{parentId}/lines/{lineId}": {
   "put": {
    "summary": "Lines",
    "operationId": "action_sales_orders_0_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "Lines",
    "operationId": "action_sales_orders_1_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/create": {
   "post": {
    "summary": "Create",
    "operationId": "action_sales_orders_0_5",
    "description": "Body keys: shipTo, shipToSiteId, shipFrom, soNo, orderTypeId, order_type_id, accountId*, contactId, requestedDate, currency, exchangeRate, customerPoRef, shipToAddress, costCenterId, warehouseId, locationId, notes; lines: [{ itemId, uom, currency, exchangeRate, requestedDate, description, quantity, unitPrice, discountPct, warehouseId, configId, configUnitPrice, costCenterId, profitCenterId, projectId, customerItemNo, customerTagNo, lineNotes, taxCategory, taxExemptionCode, tariffCode, placeOfSupply, taxCode, attributes, productionVersionId, fulfilment, dropShip, dropShipSupplierId }]",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/{id}/confirm": {
   "post": {
    "summary": "Confirm",
    "operationId": "action_sales_orders_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/{id}/create-delivery": {
   "post": {
    "summary": "Create delivery",
    "operationId": "action_sales_orders_0_6",
    "description": "Body keys: exchangeRate, warehouseId, deliveryDate, incoterms; lines: [{ salesOrderLineId, quantity, id, configured_item_id }]",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/sales-orders/{id}/invoice": {
   "post": {
    "summary": "Invoice",
    "operationId": "action_sales_orders_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  }
 }
}