{
 "openapi": "3.1.0",
 "info": {
  "title": "Lead Scoring Models (CRM)",
  "version": "20261030b",
  "description": "How leads are scored: weighted rules on what a lead is and what it has done, or a model trained from the leads you converted and lost. One is active; grades A-D, and what happens at each threshold."
 },
 "servers": [
  {
   "url": "https://{tenant}.tranxact.ai",
   "variables": {
    "tenant": {
     "default": "demo"
    }
   }
  }
 ],
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer"
   }
  },
  "schemas": {
   "lead-scoring-models": {
    "type": "object",
    "required": [
     "name"
    ],
    "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
     },
     "model_no": {
      "type": "string",
      "description": "Model no",
      "readOnly": true
     },
     "name": {
      "type": "string",
      "description": "Name"
     },
     "kind": {
      "type": "string",
      "description": "Kind",
      "enum": [
       "rules",
       "logistic"
      ]
     },
     "status": {
      "type": "string",
      "description": "Status",
      "readOnly": true
     },
     "is_active": {
      "type": "boolean",
      "description": "Is active",
      "readOnly": true
     },
     "grade_a_min": {
      "type": "string",
      "format": "decimal",
      "description": "Grade A from"
     },
     "grade_b_min": {
      "type": "string",
      "format": "decimal",
      "description": "Grade B from"
     },
     "grade_c_min": {
      "type": "string",
      "format": "decimal",
      "description": "Grade C from"
     },
     "auto_qualify": {
      "type": "boolean",
      "description": "Qualify automatically"
     },
     "qualify_threshold": {
      "type": "string",
      "format": "decimal",
      "description": "Qualify at score"
     },
     "route_threshold": {
      "type": "string",
      "format": "decimal",
      "description": "Route at score"
     },
     "route_to_user_id": {
      "type": "string",
      "format": "uuid",
      "description": "Route to"
     },
     "decay_half_life_days": {
      "type": "integer",
      "description": "Engagement half-life (days)"
     },
     "rescore_on_change": {
      "type": "boolean",
      "description": "Rescore when a lead changes"
     },
     "intercept": {
      "type": "string",
      "format": "decimal",
      "description": "Intercept",
      "readOnly": true
     },
     "coefficients": {
      "type": "object",
      "description": "Coefficients",
      "readOnly": true
     },
     "training": {
      "type": "object",
      "description": "Training",
      "readOnly": true
     },
     "trained_at": {
      "type": "string",
      "format": "date-time",
      "description": "Trained at",
      "readOnly": true
     },
     "description": {
      "type": "string",
      "description": "Description"
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "Created at",
      "readOnly": true
     },
     "created_by": {
      "type": "string",
      "format": "uuid",
      "description": "Created by",
      "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
     },
     "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
     }
    }
   }
  }
 },
 "security": [
  {
   "bearer": []
  }
 ],
 "paths": {
  "/api/crm/lead-scoring-models": {
   "get": {
    "summary": "list lead-scoring-models",
    "operationId": "list_lead_scoring_models_0_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "create lead-scoring-models",
    "operationId": "create_lead_scoring_models_1_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/lead-scoring-models/{id}": {
   "get": {
    "summary": "get lead-scoring-models",
    "operationId": "get_lead_scoring_models_0_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "put": {
    "summary": "change lead-scoring-models",
    "operationId": "change_lead_scoring_models_1_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "delete lead-scoring-models",
    "operationId": "delete_lead_scoring_models_2_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/lead-scoring-models/{id}/activate": {
   "post": {
    "summary": "Activate",
    "operationId": "action_lead_scoring_models_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/lead-scoring-models/{id}/deactivate": {
   "post": {
    "summary": "Deactivate",
    "operationId": "action_lead_scoring_models_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/lead-scoring-models/{id}/train": {
   "post": {
    "summary": "Train",
    "operationId": "action_lead_scoring_models_0_6",
    "description": "Body keys: holdoutPct",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/lead-scoring-models/{id}/rescore-all": {
   "post": {
    "summary": "Rescore all",
    "operationId": "action_lead_scoring_models_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/lead-scoring-models/{id}/preview": {
   "post": {
    "summary": "Preview",
    "operationId": "action_lead_scoring_models_0_6",
    "description": "Body keys: leadId",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/lead-scoring-models/{id}/copy": {
   "post": {
    "summary": "Copy",
    "operationId": "action_lead_scoring_models_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"
     }
    }
   }
  }
 }
}