{
 "openapi": "3.1.0",
 "info": {
  "title": "Leads (CRM)",
  "version": "20261030b",
  "description": "Read and maintain leads records (crm.leads)."
 },
 "servers": [
  {
   "url": "https://{tenant}.tranxact.ai",
   "variables": {
    "tenant": {
     "default": "demo"
    }
   }
  }
 ],
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer"
   }
  },
  "schemas": {
   "leads": {
    "type": "object",
    "required": [
     "company"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "description": "Id",
      "readOnly": true
     },
     "org_id": {
      "type": "string",
      "format": "uuid",
      "description": "Org id",
      "readOnly": true
     },
     "source": {
      "type": "string",
      "description": "Source",
      "enum": [
       "web",
       "event",
       "referral",
       "partner",
       "import",
       "campaign",
       "outbound",
       "other"
      ]
     },
     "company": {
      "type": "string",
      "description": "Company"
     },
     "contact_name": {
      "type": "string",
      "description": "Contact name"
     },
     "email": {
      "type": "string",
      "description": "Email"
     },
     "phone": {
      "type": "string",
      "description": "Phone"
     },
     "score": {
      "type": "integer",
      "description": "Score",
      "readOnly": true
     },
     "score_factors": {
      "type": "object",
      "description": "Score factors",
      "readOnly": true
     },
     "status": {
      "type": "string",
      "description": "Status"
     },
     "owner_id": {
      "type": "string",
      "format": "uuid",
      "description": "Owner id",
      "readOnly": true
     },
     "converted_account_id": {
      "type": "string",
      "format": "uuid",
      "description": "Converted account id",
      "readOnly": true
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "Created at",
      "readOnly": true
     },
     "org_unit_id": {
      "type": "string",
      "format": "uuid",
      "description": "Org unit id",
      "readOnly": true
     },
     "location_id": {
      "type": "string",
      "format": "uuid",
      "description": "Location id",
      "readOnly": true
     },
     "warehouse_id": {
      "type": "string",
      "format": "uuid",
      "description": "Warehouse id",
      "readOnly": true
     },
     "website": {
      "type": "string",
      "description": "Website"
     },
     "job_title": {
      "type": "string",
      "description": "Job title"
     },
     "industry": {
      "type": "string",
      "description": "Industry",
      "enum": [
       "Manufacturing",
       "Healthcare",
       "Financial services",
       "Retail",
       "Technology",
       "Professional services",
       "Education",
       "Government",
       "Construction",
       "Logistics",
       "Energy",
       "Hospitality",
       "Information technology",
       "Aerospace and defense",
       "Automotive",
       "Telecommunications",
       "Pharmaceuticals and life sciences",
       "Other"
      ]
     },
     "company_size": {
      "type": "string",
      "description": "Company size",
      "enum": [
       "1-10",
       "11-50",
       "51-200",
       "201-500",
       "501-1000",
       "1001-5000",
       "5000+"
      ]
     },
     "linkedin_url": {
      "type": "string",
      "description": "LinkedIn profile"
     },
     "city": {
      "type": "string",
      "description": "City"
     },
     "country": {
      "type": "string",
      "description": "Country"
     },
     "notes": {
      "type": "string",
      "description": "Notes"
     },
     "state": {
      "type": "string",
      "description": "State / province"
     },
     "postal_code": {
      "type": "string",
      "description": "Postal / ZIP code"
     },
     "address_line1": {
      "type": "string",
      "description": "Address line 1"
     },
     "address_line2": {
      "type": "string",
      "description": "Address line 2"
     },
     "metro_area": {
      "type": "string",
      "description": "Metro area"
     },
     "annual_revenue": {
      "type": "string",
      "format": "decimal",
      "description": "Annual revenue"
     },
     "sic_code": {
      "type": "string",
      "description": "SIC code"
     },
     "naics_code": {
      "type": "string",
      "description": "NAICS code"
     },
     "locations_count": {
      "type": "integer",
      "description": "Number of locations"
     },
     "fiscal_year_end": {
      "type": "string",
      "description": "Fiscal year end"
     },
     "owner_name": {
      "type": "string",
      "description": "Lead owner"
     },
     "ownership_type": {
      "type": "string",
      "description": "Ownership type",
      "enum": [
       "Public",
       "Private",
       "Subsidiary",
       "Government",
       "Partnership",
       "Non-profit",
       "Other"
      ]
     },
     "description": {
      "type": "string",
      "description": "About the company"
     },
     "lead_group": {
      "type": "string",
      "description": "Lead group"
     },
     "contact_first_name": {
      "type": "string",
      "description": "Contact first name"
     },
     "contact_last_name": {
      "type": "string",
      "description": "Contact last name"
     },
     "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
     },
     "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
     },
     "score_grade": {
      "type": "string",
      "description": "Score grade",
      "readOnly": true
     },
     "score_model_id": {
      "type": "string",
      "format": "uuid",
      "description": "Score model id",
      "readOnly": true
     },
     "scored_at": {
      "type": "string",
      "format": "date-time",
      "description": "Scored at",
      "readOnly": true
     },
     "routed_at": {
      "type": "string",
      "format": "date-time",
      "description": "Routed at",
      "readOnly": true
     },
     "closed_reason": {
      "type": "string",
      "description": "Closed reason",
      "readOnly": true
     },
     "campaign_id": {
      "type": "string",
      "format": "uuid",
      "description": "Campaign"
     },
     "personal_email": {
      "type": "string",
      "description": "Personal email"
     }
    }
   }
  }
 },
 "security": [
  {
   "bearer": []
  }
 ],
 "paths": {
  "/api/crm/leads": {
   "get": {
    "summary": "list leads",
    "operationId": "list_leads_0_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "create leads",
    "operationId": "create_leads_1_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/leads/{id}": {
   "get": {
    "summary": "get leads",
    "operationId": "get_leads_0_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "put": {
    "summary": "change leads",
    "operationId": "change_leads_1_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "delete leads",
    "operationId": "delete_leads_2_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/leads/{id}/score-explanation": {
   "get": {
    "summary": "Score explanation",
    "operationId": "action_leads_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/leads/{id}/copy": {
   "post": {
    "summary": "Copy",
    "operationId": "action_leads_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/leads/{parentId}/contacts": {
   "get": {
    "summary": "Contacts",
    "operationId": "action_leads_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "Contacts",
    "operationId": "action_leads_1_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/leads/{parentId}/contacts/{lineId}": {
   "put": {
    "summary": "Contacts",
    "operationId": "action_leads_0_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "Contacts",
    "operationId": "action_leads_1_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/leads/{parentId}/activities": {
   "get": {
    "summary": "Activities",
    "operationId": "action_leads_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "Activities",
    "operationId": "action_leads_1_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/leads/{parentId}/activities/{lineId}": {
   "put": {
    "summary": "Activities",
    "operationId": "action_leads_0_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "Activities",
    "operationId": "action_leads_1_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/leads/{id}/score": {
   "post": {
    "summary": "Score",
    "operationId": "action_leads_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/leads/{id}/convert": {
   "post": {
    "summary": "Convert",
    "operationId": "action_leads_0_6",
    "description": "Body keys: accountId",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  }
 }
}