{
  "openapi": "3.0.0",
  "components": {
    "schemas": {
      "Lead.Create": {
        "type": "object",
        "required": [
          "name",
          "firstName",
          "lastName",
          "phone",
          "email",
          "type",
          "externalId"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Full name of the lead sender. If provided then firstName and lastName are inferred."
          },
          "firstName": {
            "type": "string",
            "description": "First name of the lead sender. If provided it always overwrites the firstName inferred from the `name` field."
          },
          "lastName": {
            "type": "string",
            "description": "Last name of the lead sender.  If provided it always overwrites the lastNAme inferred from the `name` field."
          },
          "phone": {
            "type": "string",
            "description": "Mobile phone of the lead sender"
          },
          "email": {
            "type": "string",
            "description": "Email of the lead sender"
          },
          "source": {
            "type": "string",
            "description": "The lead source, eg. \"Website Enquiries\". Defaults to the name of the API Key"
          },
          "type": {
            "type": "string",
            "enum": [
              "Buyer Enquiry",
              "Tenant Enquiry",
              "Buyer Inspection",
              "Tenant Inspection",
              "Appraisal",
              "General",
              "Finance",
              "Investor"
            ]
          },
          "externalId": {
            "type": "string",
            "description": "A unique, arbitrary ID used to allow lead tracking between systems"
          },
          "comments": {
            "type": "string",
            "description": "The enquiry text, or request"
          },
          "allocation": {
            "type": "string",
            "description": "The allocation of a lead. eg. An office name or a suburb"
          },
          "date": {
            "type": "string",
            "format": "date-time",
            "description": "The date of the enquiry/walk-in/lead. Defaults to time received"
          },
          "property": {
            "type": "object",
            "description": "The property relating to the lead. eg. The address to appraise for an appraisal lead.",
            "properties": {
              "unit": {
                "type": "string"
              },
              "streetNumber": {
                "type": "string"
              },
              "streetName": {
                "type": "string"
              },
              "suburb": {
                "type": "string",
                "description": "The full suburb name of the lead. eg. Spring Hill"
              },
              "state": {
                "type": "string",
                "description": "The state abbreviation of the lead. eg. QLD"
              },
              "postCode": {
                "type": "string",
                "description": "The Area Code of the lead e.g. 4000"
              }
            }
          },
          "leadAssignee": {
            "type": "object",
            "properties": {
              "email": {
                "type": "string",
                "description": "The email of the lead assignee. eg. The primary listing agent"
              },
              "crmUserId": {
                "type": "string",
                "description": "The source ID for the user to be assigned this lead"
              }
            }
          },
          "listing": {
            "type": "object",
            "properties": {
              "advertisedAddress": {
                "type": "string",
                "description": "For listing type leads, this is the address for the listing"
              },
              "listingId": {
                "type": "string",
                "description": "For listing type leads, this is a source reference ID"
              },
              "portalId": {
                "type": "string",
                "description": "For listing type leads, this is the portal reference ID"
              },
              "listingUrl": {
                "type": "string",
                "description": "For listing type leads, this is a marketing URL"
              }
            }
          }
        }
      },
      "MessageWith.Lead.Created": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "data": {
            "$ref": "#/components/schemas/Lead.Created"
          }
        }
      },
      "Lead.Created": {
        "type": "object",
        "properties": {
          "leadId": {
            "type": "string"
          }
        }
      },
      "Paginated.Lead": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "totalRecords": {
                "type": "number"
              },
              "totalPages": {
                "type": "number"
              },
              "currentPage": {
                "type": "number"
              },
              "results": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Lead"
                }
              }
            }
          }
        }
      },
      "Lead": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "Pending",
              "Processing",
              "Automating",
              "Qualified",
              "Failed"
            ]
          },
          "automation": {
            "type": "string",
            "description": "The ID of the automation which processed this lead"
          },
          "automationExecution": {
            "type": "string",
            "description": "The ID of the automation execution which processed this lead"
          },
          "contact": {
            "type": "object",
            "properties": {
              "firstName": {
                "type": "string"
              },
              "lastName": {
                "type": "string"
              },
              "email": {
                "type": "object",
                "properties": {
                  "value": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string",
                    "description": "Invalidation reason"
                  },
                  "verified": {
                    "type": "boolean",
                    "description": "Has this field been verified"
                  },
                  "lastVerifiedDate": {
                    "type": "string",
                    "format": "date-time",
                    "description": "The last time this field was verified"
                  }
                }
              },
              "mobile": {
                "type": "object",
                "properties": {
                  "value": {
                    "type": "string"
                  },
                  "display": {
                    "type": "string",
                    "description": "Human friendly display format of the number"
                  },
                  "status": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string",
                    "description": "Invalidation reason"
                  },
                  "verified": {
                    "type": "boolean",
                    "description": "Has this field been verified"
                  },
                  "lastVerifiedDate": {
                    "type": "string",
                    "format": "date-time",
                    "description": "The last time this field was verified"
                  }
                }
              }
            }
          },
          "sender": {
            "type": "object",
            "properties": {
              "firstName": {
                "type": "string",
                "description": "The received first name"
              },
              "lastName": {
                "type": "string",
                "description": "The received last name"
              },
              "email": {
                "type": "string",
                "description": "The received email"
              },
              "phone": {
                "type": "string",
                "description": "The received phone"
              }
            }
          },
          "source": {
            "type": "string"
          },
          "dateEnquired": {
            "type": "string",
            "format": "date-time"
          },
          "type": {
            "type": "string",
            "enum": [
              "Buyer Enquiry",
              "Tenant Enquiry",
              "Buyer Inspection",
              "Tenant Inspection",
              "Appraisal"
            ]
          },
          "externalId": {
            "type": "string",
            "description": "ID used to link this lead between systems"
          },
          "allocation": {
            "type": "string"
          },
          "followUpResult": {
            "type": "string",
            "description": "The outcome of the follow up"
          },
          "lastModified": {
            "type": "string",
            "format": "date-time"
          },
          "property": {
            "type": "object",
            "properties": {
              "address": {
                "type": "string",
                "description": "The display address of the received lead"
              },
              "suburb": {
                "type": "string"
              },
              "state": {
                "type": "string",
                "description": "The state abbreviation of the lead. eg. ACT"
              },
              "streetNumber": {
                "type": "string"
              },
              "streetName": {
                "type": "string"
              },
              "unit": {
                "type": "string"
              },
              "property": {
                "type": "string",
                "description": "The RiTA property ID"
              }
            }
          },
          "listing": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string"
              },
              "advertisedAddress": {
                "type": "string"
              },
              "sourceId": {
                "type": "string"
              },
              "portalId": {
                "type": "string"
              },
              "property": {
                "type": "string",
                "description": "The RiTA property ID"
              }
            }
          },
          "transcript": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date-time"
                },
                "sentBy": {
                  "type": "string"
                },
                "origin": {
                  "type": "string",
                  "enum": [
                    "RiTA",
                    "Outbound",
                    "Inbound"
                  ]
                },
                "message": {
                  "type": "string"
                }
              }
            }
          },
          "properties": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "dateCreated": {
                  "type": "string",
                  "format": "date-time"
                },
                "displayAddress": {
                  "type": "string"
                },
                "propertyType": {
                  "type": "string",
                  "enum": [
                    "HOUSE",
                    "UNIT",
                    "LAND",
                    "OTHER"
                  ]
                },
                "property": {
                  "type": "string",
                  "description": "The RiTA property ID"
                },
                "addressValidation": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "reason": {
                      "type": "string",
                      "description": "Invalidation reason"
                    },
                    "verified": {
                      "type": "boolean",
                      "description": "Has this field been verified"
                    },
                    "lastVerifiedDate": {
                      "type": "string",
                      "description": "The last time this field was verified"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "List.External.Create": {
        "type": "object",
        "required": [
          "agentId",
          "segmentName",
          "contacts"
        ],
        "properties": {
          "list": {
            "type": "object",
            "properties": {
              "segmentName": {
                "type": "string",
                "description": "Name of the segment/list."
              },
              "clPropertyId": {
                "type": "string",
                "description": "CoreLogic ID for the property to add as topic."
              },
              "contacts": {
                "type": "array",
                "description": "Array of contacts",
                "items": {
                  "type": "object",
                  "required": [
                    "crmId"
                  ],
                  "properties": {
                    "crmId": {
                      "type": "string",
                      "description": "ID of contact in the CRM."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "MessageWith.List.External.Created": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "data": {
            "$ref": "#/components/schemas/List.External.Created"
          }
        }
      },
      "List.External.Created": {
        "type": "object",
        "properties": {
          "list": {
            "$ref": "#/components/schemas/List"
          }
        }
      },
      "List": {
        "type": "object",
        "properties": {
          "account": {
            "type": "string"
          },
          "assignee": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "size": {
            "description": "The maximum number of contacts that should be in the list",
            "type": "string"
          },
          "contacts": {
            "description": "The contacts selected for the list",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "contact": {
                  "type": "string",
                  "description": "The contact id"
                },
                "sortModifiers": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SortValue"
                  }
                },
                "inOtherLists": {
                  "description": "other in-progress lists that this contact is currently in (if provided)",
                  "nullable": true,
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "_id": {
                        "type": "string",
                        "description": "list id"
                      },
                      "name": {
                        "type": "string",
                        "description": "list name"
                      }
                    }
                  }
                }
              }
            }
          },
          "originalContacts": {
            "description": "The original (not skipped) contacts selected for the list",
            "type": "array",
            "nullable": true,
            "items": {
              "type": "object",
              "properties": {
                "contact": {
                  "type": "string",
                  "description": "The contact id"
                }
              }
            }
          },
          "actionedContacts": {
            "type": "array",
            "description": "The contacts which have been actioned",
            "items": {
              "type": "object",
              "properties": {
                "contact": {
                  "type": "string",
                  "description": "contact id"
                }
              }
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "Pending",
              "Complete",
              "In Progress"
            ]
          },
          "dateCreated": {
            "type": "string",
            "format": "date-time"
          },
          "criteria": {
            "$ref": "#/components/schemas/ListCriteria"
          }
        }
      },
      "SortValue": {
        "type": "object",
        "properties": {
          "value": {
            "description": "The raw value of the field",
            "type": "number"
          },
          "normalised": {
            "description": "A scaled number between 0 and 1 relative to the other contacts in this list",
            "type": "number"
          }
        }
      },
      "ListCriteria": {
        "type": "array",
        "description": "The following shape is recursive",
        "items": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "operator": {
                  "description": "The operation to perform on the field name",
                  "type": "string",
                  "enum": [
                    "$or",
                    "$and",
                    "$eq"
                  ]
                },
                "criteria": {
                  "$ref": "#/components/schemas/ListCriteria"
                }
              }
            },
            {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string",
                  "description": "The name of the field to search"
                },
                "operator": {
                  "description": "The operation to perform on the field name",
                  "type": "string",
                  "enum": [
                    "$or",
                    "$and",
                    "$eq"
                  ]
                },
                "value": {
                  "description": "The value to compare the field to"
                }
              }
            }
          ]
        }
      }
    }
  },
  "info": {
    "title": "RiTA by CoreLogic Open API Documentation",
    "description": "# Introduction\nThis API is documented in **OpenAPI format** and is used to support the [RiTA](https://app.ritabyaire.com) platform.\n\nThe recommended development experience is to browse these docs for intended functionality, then load the OpenAPI specification into Postman or a similar API testing tool.\n\nAll response and ingestion formats for this API are Javascript Object Notation - [see JSON](https://www.rfc-editor.org/rfc/rfc7159.txt).\n\nAll `date-time` fields are expected to be in ISO8601 format to avoid any ambiguity.\n\n# Authentication\nThis API requires authentication to be generated inside of the [RiTA](https://app.ritabyaire.com/integrations) platform from the integrations page.\nPlease visit that page to generate an API Key.\n\nAll requests to this API take will require an `Authorization: Bearer <api_key>` header to successfully authenticate.\n\nEach RiTA account can have multiple API Keys - it is important to note that these API Keys are independent of one another, eg. Key A cannot read information ingested via Key B\n\n# Cross-Origin Resource Sharing\nThis API features Cross-Origin Resource Sharing (CORS) implemented in compliance with  [W3C spec](https://www.w3.org/TR/cors/).\nAnd that allows cross-domain communication from the browser.\nAll responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site.\n",
    "version": "prod",
    "x-logo": {
      "url": "https://docs.ritabyaire.com/CL-logo-rita-orange.svg",
      "altText": "RiTA by CoreLogic"
    }
  },
  "paths": {
    "/leads": {
      "post": {
        "operationId": "leads_management_create",
        "summary": "Create Lead",
        "description": "Receives a lead and queues it to be processed by RiTA.",
        "tags": [
          "Leads"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Lead.Create"
              }
            }
          },
          "description": "Lead"
        },
        "parameters": [],
        "responses": {
          "200": {
            "description": "Lead saved and processing queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageWith.Lead.Created"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "leads_management_get",
        "summary": "Get Leads",
        "description": "Gets leads created with the provided API key",
        "tags": [
          "Leads"
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "The page number to request",
            "required": false,
            "allowEmptyValue": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "The number of records per page. Max is 50",
            "required": false,
            "allowEmptyValue": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sortOrder",
            "in": "query",
            "description": "The direction to sort results in. Defaults to asc",
            "required": false,
            "allowEmptyValue": false,
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            }
          },
          {
            "name": "lastModifiedAfter",
            "in": "query",
            "description": "Filter to records modified after provided date",
            "required": false,
            "allowEmptyValue": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "lastModifiedBefore",
            "in": "query",
            "description": "Filter to records modified before provided date",
            "required": false,
            "allowEmptyValue": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Leads",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Paginated.Lead"
                }
              }
            }
          }
        }
      }
    },
    "/leads/{leadId}": {
      "get": {
        "operationId": "leads_management_getById",
        "summary": "Get Single Lead",
        "description": "Retrieves a single lead by ID",
        "tags": [
          "Leads"
        ],
        "parameters": [
          {
            "name": "leadId",
            "in": "path",
            "description": "The lead ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Lead",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Lead"
                }
              }
            }
          }
        }
      }
    },
    "/lists/external": {
      "post": {
        "operationId": "lists_external",
        "summary": "Create List",
        "description": "Receives an external list and processes it.",
        "tags": [
          "Lists"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/List.External.Create"
              }
            }
          },
          "description": "The external list"
        },
        "parameters": [],
        "responses": {
          "201": {
            "description": "External list received and processed, list successfully created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageWith.List.External.Created"
                }
              }
            }
          }
        }
      }
    }
  },
  "servers": [
    {
      "url": "https://api.ritabyaire.com",
      "description": "Production API"
    }
  ],
  "x-tagGroups": [
    {
      "name": "General",
      "tags": [
        "Leads",
        "Lists"
      ]
    }
  ]
}