{
 "openapi": "3.1.0",
 "info": {
  "title": "Scale Up CRM API",
  "version": "1.0.0",
  "description": "External REST API for Scale Up CRM. Send an organisation-scoped API key in the X-Api-Key header. Make and revoke keys in the CRM under Settings > API keys. List endpoints take limit (1 to 200) and offset."
 },
 "servers": [
  {
   "url": "https://crm.scaleupsolutions.asia/api/v1/external"
  }
 ],
 "security": [
  {
   "ApiKeyAuth": []
  }
 ],
 "paths": {
  "/companies": {
   "get": {
    "tags": [
     "companies"
    ],
    "summary": "List companies",
    "operationId": "list_companies_api_v1_external_companies_get",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "description": "Match on English or Khmer name.",
       "title": "Q"
      },
      "description": "Match on English or Khmer name."
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "maximum": 200,
       "minimum": 1,
       "description": "Page size (1 to 200).",
       "default": 50,
       "title": "Limit"
      },
      "description": "Page size (1 to 200)."
     },
     {
      "name": "offset",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "minimum": 0,
       "description": "Number of items to skip.",
       "default": 0,
       "title": "Offset"
      },
      "description": "Number of items to skip."
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Page_CompanyOut_"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   },
   "post": {
    "tags": [
     "companies"
    ],
    "summary": "Create a company",
    "operationId": "create_company_api_v1_external_companies_post",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/CompanyIn"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CompanyOut"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/companies/{company_id}": {
   "get": {
    "tags": [
     "companies"
    ],
    "summary": "Get one company",
    "operationId": "get_company_api_v1_external_companies__company_id__get",
    "parameters": [
     {
      "name": "company_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid",
       "title": "Company Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CompanyOut"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   },
   "patch": {
    "tags": [
     "companies"
    ],
    "summary": "Update a company",
    "operationId": "update_company_api_v1_external_companies__company_id__patch",
    "parameters": [
     {
      "name": "company_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid",
       "title": "Company Id"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/CompanyPatch"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CompanyOut"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/persons": {
   "get": {
    "tags": [
     "persons"
    ],
    "summary": "List contacts",
    "operationId": "list_persons_api_v1_external_persons_get",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "description": "Match on name or email.",
       "title": "Q"
      },
      "description": "Match on name or email."
     },
     {
      "name": "company_id",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string",
         "format": "uuid"
        },
        {
         "type": "null"
        }
       ],
       "title": "Company Id"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "maximum": 200,
       "minimum": 1,
       "description": "Page size (1 to 200).",
       "default": 50,
       "title": "Limit"
      },
      "description": "Page size (1 to 200)."
     },
     {
      "name": "offset",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "minimum": 0,
       "description": "Number of items to skip.",
       "default": 0,
       "title": "Offset"
      },
      "description": "Number of items to skip."
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Page_PersonOut_"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   },
   "post": {
    "tags": [
     "persons"
    ],
    "summary": "Create a contact",
    "operationId": "create_person_api_v1_external_persons_post",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/PersonIn"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PersonOut"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/persons/{person_id}": {
   "get": {
    "tags": [
     "persons"
    ],
    "summary": "Get one contact",
    "operationId": "get_person_api_v1_external_persons__person_id__get",
    "parameters": [
     {
      "name": "person_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid",
       "title": "Person Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PersonOut"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   },
   "patch": {
    "tags": [
     "persons"
    ],
    "summary": "Update a contact",
    "operationId": "update_person_api_v1_external_persons__person_id__patch",
    "parameters": [
     {
      "name": "person_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid",
       "title": "Person Id"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/PersonPatch"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PersonOut"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/pipelines": {
   "get": {
    "tags": [
     "pipelines"
    ],
    "summary": "List pipelines with their stages",
    "operationId": "list_pipelines_api_v1_external_pipelines_get",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/PipelineOut"
         },
         "title": "Response List Pipelines Api V1 External Pipelines Get"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/lost-reasons": {
   "get": {
    "tags": [
     "pipelines"
    ],
    "summary": "List lost reasons",
    "operationId": "list_lost_reasons_api_v1_external_lost_reasons_get",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/LostReasonOut"
         },
         "title": "Response List Lost Reasons Api V1 External Lost Reasons Get"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/products": {
   "get": {
    "tags": [
     "pipelines"
    ],
    "summary": "List products",
    "operationId": "list_products_api_v1_external_products_get",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/ProductOut"
         },
         "title": "Response List Products Api V1 External Products Get"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/deals": {
   "get": {
    "tags": [
     "deals"
    ],
    "summary": "List deals",
    "operationId": "list_deals_api_v1_external_deals_get",
    "parameters": [
     {
      "name": "stage_id",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string",
         "format": "uuid"
        },
        {
         "type": "null"
        }
       ],
       "title": "Stage Id"
      }
     },
     {
      "name": "company_id",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string",
         "format": "uuid"
        },
        {
         "type": "null"
        }
       ],
       "title": "Company Id"
      }
     },
     {
      "name": "person_id",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string",
         "format": "uuid"
        },
        {
         "type": "null"
        }
       ],
       "title": "Person Id"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "maximum": 200,
       "minimum": 1,
       "description": "Page size (1 to 200).",
       "default": 50,
       "title": "Limit"
      },
      "description": "Page size (1 to 200)."
     },
     {
      "name": "offset",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "minimum": 0,
       "description": "Number of items to skip.",
       "default": 0,
       "title": "Offset"
      },
      "description": "Number of items to skip."
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Page_DealOut_"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   },
   "post": {
    "tags": [
     "deals"
    ],
    "summary": "Create a deal",
    "operationId": "create_deal_api_v1_external_deals_post",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DealIn"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DealOut"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/deals/{deal_id}": {
   "get": {
    "tags": [
     "deals"
    ],
    "summary": "Get one deal",
    "operationId": "get_deal_api_v1_external_deals__deal_id__get",
    "parameters": [
     {
      "name": "deal_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid",
       "title": "Deal Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DealOut"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   },
   "patch": {
    "tags": [
     "deals"
    ],
    "summary": "Update a deal",
    "operationId": "update_deal_api_v1_external_deals__deal_id__patch",
    "parameters": [
     {
      "name": "deal_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid",
       "title": "Deal Id"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DealPatch"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DealOut"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/deals/{deal_id}/stage": {
   "post": {
    "tags": [
     "deals"
    ],
    "summary": "Move a deal to another stage",
    "operationId": "move_deal_stage_api_v1_external_deals__deal_id__stage_post",
    "parameters": [
     {
      "name": "deal_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid",
       "title": "Deal Id"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/StageMoveIn"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DealOut"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/deals/{deal_id}/line-items": {
   "get": {
    "tags": [
     "deals"
    ],
    "summary": "List a deal's line items",
    "operationId": "list_line_items_api_v1_external_deals__deal_id__line_items_get",
    "parameters": [
     {
      "name": "deal_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid",
       "title": "Deal Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/LineItemOut"
         },
         "title": "Response List Line Items Api V1 External Deals  Deal Id  Line Items Get"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   },
   "post": {
    "tags": [
     "deals"
    ],
    "summary": "Add a line item to a deal",
    "operationId": "add_line_item_api_v1_external_deals__deal_id__line_items_post",
    "parameters": [
     {
      "name": "deal_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid",
       "title": "Deal Id"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/LineItemIn"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/LineItemOut"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/deals/{deal_id}/line-items/{item_id}": {
   "delete": {
    "tags": [
     "deals"
    ],
    "summary": "Delete a line item",
    "operationId": "delete_line_item_api_v1_external_deals__deal_id__line_items__item_id__delete",
    "parameters": [
     {
      "name": "deal_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid",
       "title": "Deal Id"
      }
     },
     {
      "name": "item_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid",
       "title": "Item Id"
      }
     }
    ],
    "responses": {
     "204": {
      "description": "Successful Response"
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/deals/{deal_id}/contracts": {
   "get": {
    "tags": [
     "contracts"
    ],
    "summary": "List a deal's contracts",
    "operationId": "list_contracts_api_v1_external_deals__deal_id__contracts_get",
    "parameters": [
     {
      "name": "deal_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid",
       "title": "Deal Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/ContractOut"
         },
         "title": "Response List Contracts Api V1 External Deals  Deal Id  Contracts Get"
        }
       }
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  },
  "/contracts/{contract_id}/file": {
   "get": {
    "tags": [
     "contracts"
    ],
    "summary": "Download a contract file",
    "operationId": "download_contract_api_v1_external_contracts__contract_id__file_get",
    "parameters": [
     {
      "name": "contract_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid",
       "title": "Contract Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "The file bytes.",
      "content": {
       "application/octet-stream": {}
      }
     },
     "422": {
      "description": "Validation Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/HTTPValidationError"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "CompanyIn": {
    "properties": {
     "name_en": {
      "type": "string",
      "title": "Name En"
     },
     "name_kh": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Name Kh"
     },
     "address_en": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Address En"
     },
     "address_kh": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Address Kh"
     },
     "vat_tin": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Vat Tin",
      "description": "VAT TIN, the Cambodian tax number."
     },
     "phone": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Phone"
     },
     "email": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Email"
     },
     "website": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Website"
     },
     "payment_terms": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Payment Terms"
     },
     "notes": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Notes"
     }
    },
    "type": "object",
    "required": [
     "name_en"
    ],
    "title": "CompanyIn"
   },
   "CompanyOut": {
    "properties": {
     "name_en": {
      "type": "string",
      "title": "Name En"
     },
     "name_kh": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Name Kh"
     },
     "address_en": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Address En"
     },
     "address_kh": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Address Kh"
     },
     "vat_tin": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Vat Tin",
      "description": "VAT TIN, the Cambodian tax number."
     },
     "phone": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Phone"
     },
     "email": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Email"
     },
     "website": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Website"
     },
     "payment_terms": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Payment Terms"
     },
     "notes": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Notes"
     },
     "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
     },
     "primary_contact_person_id": {
      "anyOf": [
       {
        "type": "string",
        "format": "uuid"
       },
       {
        "type": "null"
       }
      ],
      "title": "Primary Contact Person Id"
     },
     "ledger_contact_id": {
      "anyOf": [
       {
        "type": "string",
        "format": "uuid"
       },
       {
        "type": "null"
       }
      ],
      "title": "Ledger Contact Id",
      "description": "The matching contact in Scale Up Books, once synced."
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At"
     }
    },
    "type": "object",
    "required": [
     "name_en",
     "id",
     "created_at"
    ],
    "title": "CompanyOut"
   },
   "CompanyPatch": {
    "properties": {
     "name_en": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Name En"
     },
     "name_kh": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Name Kh"
     },
     "address_en": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Address En"
     },
     "address_kh": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Address Kh"
     },
     "vat_tin": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Vat Tin"
     },
     "phone": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Phone"
     },
     "email": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Email"
     },
     "website": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Website"
     },
     "payment_terms": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Payment Terms"
     },
     "notes": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Notes"
     },
     "primary_contact_person_id": {
      "anyOf": [
       {
        "type": "string",
        "format": "uuid"
       },
       {
        "type": "null"
       }
      ],
      "title": "Primary Contact Person Id"
     }
    },
    "type": "object",
    "title": "CompanyPatch"
   },
   "ContractOut": {
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
     },
     "deal_id": {
      "type": "string",
      "format": "uuid",
      "title": "Deal Id"
     },
     "file_name": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "File Name"
     },
     "mime_type": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Mime Type"
     },
     "uploaded_at": {
      "type": "string",
      "format": "date-time",
      "title": "Uploaded At"
     }
    },
    "type": "object",
    "required": [
     "id",
     "deal_id",
     "uploaded_at"
    ],
    "title": "ContractOut"
   },
   "DealIn": {
    "properties": {
     "title": {
      "type": "string",
      "title": "Title"
     },
     "company_id": {
      "type": "string",
      "format": "uuid",
      "title": "Company Id"
     },
     "stage_id": {
      "type": "string",
      "format": "uuid",
      "title": "Stage Id"
     },
     "person_id": {
      "anyOf": [
       {
        "type": "string",
        "format": "uuid"
       },
       {
        "type": "null"
       }
      ],
      "title": "Person Id"
     },
     "amount": {
      "anyOf": [
       {
        "type": "number"
       },
       {
        "type": "string",
        "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
       },
       {
        "type": "null"
       }
      ],
      "title": "Amount"
     },
     "invoice_description": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Invoice Description"
     },
     "follow_up_date": {
      "anyOf": [
       {
        "type": "string",
        "format": "date"
       },
       {
        "type": "null"
       }
      ],
      "title": "Follow Up Date"
     }
    },
    "type": "object",
    "required": [
     "title",
     "company_id",
     "stage_id"
    ],
    "title": "DealIn"
   },
   "DealOut": {
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
     },
     "title": {
      "type": "string",
      "title": "Title"
     },
     "company_id": {
      "type": "string",
      "format": "uuid",
      "title": "Company Id"
     },
     "person_id": {
      "anyOf": [
       {
        "type": "string",
        "format": "uuid"
       },
       {
        "type": "null"
       }
      ],
      "title": "Person Id"
     },
     "stage_id": {
      "type": "string",
      "format": "uuid",
      "title": "Stage Id"
     },
     "amount": {
      "anyOf": [
       {
        "type": "string",
        "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
       },
       {
        "type": "null"
       }
      ],
      "title": "Amount"
     },
     "invoice_description": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Invoice Description"
     },
     "follow_up_date": {
      "anyOf": [
       {
        "type": "string",
        "format": "date"
       },
       {
        "type": "null"
       }
      ],
      "title": "Follow Up Date"
     },
     "lost_reason_id": {
      "anyOf": [
       {
        "type": "string",
        "format": "uuid"
       },
       {
        "type": "null"
       }
      ],
      "title": "Lost Reason Id"
     },
     "lost_reason_other": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Lost Reason Other"
     },
     "ledger_invoice_id": {
      "anyOf": [
       {
        "type": "string",
        "format": "uuid"
       },
       {
        "type": "null"
       }
      ],
      "title": "Ledger Invoice Id",
      "description": "The invoice in Scale Up Books, once raised."
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time",
      "title": "Updated At"
     }
    },
    "type": "object",
    "required": [
     "id",
     "title",
     "company_id",
     "stage_id",
     "created_at",
     "updated_at"
    ],
    "title": "DealOut"
   },
   "DealPatch": {
    "properties": {
     "title": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Title"
     },
     "person_id": {
      "anyOf": [
       {
        "type": "string",
        "format": "uuid"
       },
       {
        "type": "null"
       }
      ],
      "title": "Person Id"
     },
     "amount": {
      "anyOf": [
       {
        "type": "number"
       },
       {
        "type": "string",
        "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
       },
       {
        "type": "null"
       }
      ],
      "title": "Amount"
     },
     "invoice_description": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Invoice Description"
     },
     "follow_up_date": {
      "anyOf": [
       {
        "type": "string",
        "format": "date"
       },
       {
        "type": "null"
       }
      ],
      "title": "Follow Up Date"
     }
    },
    "type": "object",
    "title": "DealPatch"
   },
   "HTTPValidationError": {
    "properties": {
     "detail": {
      "items": {
       "$ref": "#/components/schemas/ValidationError"
      },
      "type": "array",
      "title": "Detail"
     }
    },
    "type": "object",
    "title": "HTTPValidationError"
   },
   "LineItemIn": {
    "properties": {
     "description": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Description"
     },
     "product_id": {
      "anyOf": [
       {
        "type": "string",
        "format": "uuid"
       },
       {
        "type": "null"
       }
      ],
      "title": "Product Id"
     },
     "quantity": {
      "anyOf": [
       {
        "type": "number"
       },
       {
        "type": "string",
        "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
       }
      ],
      "title": "Quantity",
      "default": "1"
     },
     "unit_price": {
      "anyOf": [
       {
        "type": "number"
       },
       {
        "type": "string",
        "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
       },
       {
        "type": "null"
       }
      ],
      "title": "Unit Price"
     }
    },
    "type": "object",
    "title": "LineItemIn"
   },
   "LineItemOut": {
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
     },
     "product_id": {
      "anyOf": [
       {
        "type": "string",
        "format": "uuid"
       },
       {
        "type": "null"
       }
      ],
      "title": "Product Id"
     },
     "description": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Description"
     },
     "quantity": {
      "type": "string",
      "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
      "title": "Quantity"
     },
     "unit_price": {
      "anyOf": [
       {
        "type": "string",
        "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
       },
       {
        "type": "null"
       }
      ],
      "title": "Unit Price"
     },
     "line_amount": {
      "anyOf": [
       {
        "type": "string",
        "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
       },
       {
        "type": "null"
       }
      ],
      "title": "Line Amount"
     },
     "sort_order": {
      "type": "integer",
      "title": "Sort Order"
     }
    },
    "type": "object",
    "required": [
     "id",
     "quantity",
     "sort_order"
    ],
    "title": "LineItemOut"
   },
   "LostReasonOut": {
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
     },
     "label": {
      "type": "string",
      "title": "Label"
     },
     "sort_order": {
      "type": "integer",
      "title": "Sort Order"
     }
    },
    "type": "object",
    "required": [
     "id",
     "label",
     "sort_order"
    ],
    "title": "LostReasonOut"
   },
   "Page_CompanyOut_": {
    "properties": {
     "items": {
      "items": {
       "$ref": "#/components/schemas/CompanyOut"
      },
      "type": "array",
      "title": "Items"
     },
     "total": {
      "type": "integer",
      "title": "Total",
      "description": "Number of items that match, before paging."
     },
     "limit": {
      "type": "integer",
      "title": "Limit"
     },
     "offset": {
      "type": "integer",
      "title": "Offset"
     }
    },
    "type": "object",
    "required": [
     "items",
     "total",
     "limit",
     "offset"
    ],
    "title": "Page[CompanyOut]"
   },
   "Page_DealOut_": {
    "properties": {
     "items": {
      "items": {
       "$ref": "#/components/schemas/DealOut"
      },
      "type": "array",
      "title": "Items"
     },
     "total": {
      "type": "integer",
      "title": "Total",
      "description": "Number of items that match, before paging."
     },
     "limit": {
      "type": "integer",
      "title": "Limit"
     },
     "offset": {
      "type": "integer",
      "title": "Offset"
     }
    },
    "type": "object",
    "required": [
     "items",
     "total",
     "limit",
     "offset"
    ],
    "title": "Page[DealOut]"
   },
   "Page_PersonOut_": {
    "properties": {
     "items": {
      "items": {
       "$ref": "#/components/schemas/PersonOut"
      },
      "type": "array",
      "title": "Items"
     },
     "total": {
      "type": "integer",
      "title": "Total",
      "description": "Number of items that match, before paging."
     },
     "limit": {
      "type": "integer",
      "title": "Limit"
     },
     "offset": {
      "type": "integer",
      "title": "Offset"
     }
    },
    "type": "object",
    "required": [
     "items",
     "total",
     "limit",
     "offset"
    ],
    "title": "Page[PersonOut]"
   },
   "PersonIn": {
    "properties": {
     "name": {
      "type": "string",
      "title": "Name"
     },
     "company_id": {
      "anyOf": [
       {
        "type": "string",
        "format": "uuid"
       },
       {
        "type": "null"
       }
      ],
      "title": "Company Id"
     },
     "salutation": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Salutation"
     },
     "title": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Title"
     },
     "role": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Role"
     },
     "phone": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Phone"
     },
     "email": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Email"
     },
     "email_opt_in": {
      "type": "boolean",
      "title": "Email Opt In",
      "default": true
     },
     "notes": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Notes"
     }
    },
    "type": "object",
    "required": [
     "name"
    ],
    "title": "PersonIn"
   },
   "PersonOut": {
    "properties": {
     "name": {
      "type": "string",
      "title": "Name"
     },
     "company_id": {
      "anyOf": [
       {
        "type": "string",
        "format": "uuid"
       },
       {
        "type": "null"
       }
      ],
      "title": "Company Id"
     },
     "salutation": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Salutation"
     },
     "title": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Title"
     },
     "role": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Role"
     },
     "phone": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Phone"
     },
     "email": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Email"
     },
     "email_opt_in": {
      "type": "boolean",
      "title": "Email Opt In",
      "default": true
     },
     "notes": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Notes"
     },
     "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
     },
     "unsubscribed_at": {
      "anyOf": [
       {
        "type": "string",
        "format": "date-time"
       },
       {
        "type": "null"
       }
      ],
      "title": "Unsubscribed At"
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At"
     }
    },
    "type": "object",
    "required": [
     "name",
     "id",
     "created_at"
    ],
    "title": "PersonOut"
   },
   "PersonPatch": {
    "properties": {
     "name": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Name"
     },
     "company_id": {
      "anyOf": [
       {
        "type": "string",
        "format": "uuid"
       },
       {
        "type": "null"
       }
      ],
      "title": "Company Id"
     },
     "salutation": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Salutation"
     },
     "title": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Title"
     },
     "role": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Role"
     },
     "phone": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Phone"
     },
     "email": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Email"
     },
     "email_opt_in": {
      "anyOf": [
       {
        "type": "boolean"
       },
       {
        "type": "null"
       }
      ],
      "title": "Email Opt In"
     },
     "notes": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Notes"
     }
    },
    "type": "object",
    "title": "PersonPatch"
   },
   "PipelineOut": {
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
     },
     "name": {
      "type": "string",
      "title": "Name"
     },
     "sort_order": {
      "type": "integer",
      "title": "Sort Order"
     },
     "stages": {
      "items": {
       "$ref": "#/components/schemas/StageOut"
      },
      "type": "array",
      "title": "Stages"
     }
    },
    "type": "object",
    "required": [
     "id",
     "name",
     "sort_order",
     "stages"
    ],
    "title": "PipelineOut"
   },
   "ProductOut": {
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
     },
     "name": {
      "type": "string",
      "title": "Name"
     },
     "description": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Description"
     },
     "unit_price": {
      "anyOf": [
       {
        "type": "string",
        "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$"
       },
       {
        "type": "null"
       }
      ],
      "title": "Unit Price"
     }
    },
    "type": "object",
    "required": [
     "id",
     "name"
    ],
    "title": "ProductOut"
   },
   "StageMoveIn": {
    "properties": {
     "stage_id": {
      "type": "string",
      "format": "uuid",
      "title": "Stage Id"
     },
     "lost_reason_id": {
      "anyOf": [
       {
        "type": "string",
        "format": "uuid"
       },
       {
        "type": "null"
       }
      ],
      "title": "Lost Reason Id",
      "description": "Required when the new stage is a lost stage, unless lost_reason_other is set."
     },
     "lost_reason_other": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Lost Reason Other"
     }
    },
    "type": "object",
    "required": [
     "stage_id"
    ],
    "title": "StageMoveIn"
   },
   "StageOut": {
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
     },
     "name": {
      "type": "string",
      "title": "Name"
     },
     "sort_order": {
      "type": "integer",
      "title": "Sort Order"
     },
     "is_won_stage": {
      "type": "boolean",
      "title": "Is Won Stage"
     },
     "is_lost_stage": {
      "type": "boolean",
      "title": "Is Lost Stage"
     }
    },
    "type": "object",
    "required": [
     "id",
     "name",
     "sort_order",
     "is_won_stage",
     "is_lost_stage"
    ],
    "title": "StageOut"
   },
   "ValidationError": {
    "properties": {
     "loc": {
      "items": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "integer"
        }
       ]
      },
      "type": "array",
      "title": "Location"
     },
     "msg": {
      "type": "string",
      "title": "Message"
     },
     "type": {
      "type": "string",
      "title": "Error Type"
     },
     "input": {
      "title": "Input"
     },
     "ctx": {
      "type": "object",
      "title": "Context"
     }
    },
    "type": "object",
    "required": [
     "loc",
     "msg",
     "type"
    ],
    "title": "ValidationError"
   }
  },
  "securitySchemes": {
   "ApiKeyAuth": {
    "type": "apiKey",
    "in": "header",
    "name": "X-Api-Key"
   }
  }
 }
}