# Leads API

The Leads API is a Bulk API that provides only two endpoints, one to get existing leads from Keaze and another to import new leads to Keaze from other sources. As it is a bulk API you can import several leads in a single request.

::: info Info This API is only available for Premium accounts. :::


# On this page

# Get leads

The endpoint to get leads from Keaze is:

GET to /api/bulk/open/leads

Remember you need to pass the QueryString parameter api_key with your API key to get access to the resources.

# Export payload

All responses are JSON encoded, and as they are paginated, the data is contained into an envelope:

{
  "data": [items],
  "pagination": {
    "currentPage": 2, // current page number
    "perPage": 10,    // number of items to be shown per page
    "total": 212,     // total number of items
    "from": 11,       // number of the first item in the result
    "to": 20,         // number of the last item in the result  
    "lastPage": 23,   // last page number
  },
  "links": {
    "first": "url to the first page",
    "prev": "url to the previous page",
    "next": "url to the next page",
    "last": "url to the last page",
  }
}

where items is the collection of leads. Each lead is an object with the following fields:

Field name Type Nullable Description
id number false Lead reference in Keaze
housingProvider object false Object containing details of the housing provider that the lead's enquiry is with. Contains the housing provider's id, name and slug
externalRef string true Lead external reference if added from an external source
listing object true Listing details
property object true Property details
development object true Development details
site object false Object with the id, code and name of the source the lead came in from
eligibilityStatus string false passed, considered, incomplete or failed
email string false E-mail address
title string true Title
firstName string true Given and middle name
lastName string true Family name
fullName string true Concatenation of given, middle and family name
phone string true Phone number
dateOfBirth string true Date of birth using the format YYYY-MM-DD
annualHouseholdIncome number true Annual household income
deposit number true Deposit or savings
livingCircumstance object true Object with the id and name of the customer living circumstance
homeAddress string true Address where the customer lives
homePostcode string true Postcode where the customer lives
homeLocalAuthority object true Object containing the id, name, slug, longName and mapitId (for integration with the MapIt API) of the local authority that the lead lives in.
dependants number true Total of dependants
workingCircumstance object true Object with the id and name of the customer working circumstance
workAddress string true Address where the customer works
workPostcode string true Postcode where the customer works
workLocalAuthority object true Object containing the id, name, slug, longName and mapitId (for integration with the MapIt API) of the local authority that the lead works in.
occupation string true Occupation
employerName string true Employer name
armedForcesMember boolean true The customer is a member of the armed forces
keyworker boolean true The customer is a key worker
hasDisability boolean true The customer has any known disability
housingWaitingList boolean true The customer is in the council waiting list
firstTimeBuyer boolean true The customer is a first time buyer
eligibleCitizen boolean true The customer has British, EU/EEA citizen or have indefinite leave to remain
buyingInterestPeriod object true Object with the id and name of the customer interest period to buy
additionalInfo string true Additional information
updatedAt string false ATOM format Date-time when the lead was updated
createdAt string false ATOM format Date-time when the lead was created

# Listing details

Field name Type Nullable Description
id number false Listing reference in Keaze
externalRef string true Listing external reference, if provided
name string false Listing name
availabilityStatus string false Coming soon, For Sale, Sale Under Offer, Sold, ...
schemeGroup string false Shared ownership, Discounted market sale, ...
schemes array false Array with the schemes codes, usually only one, but in some cases it could contain two, help-to-buy and first-dibs
development object true When the listing advertise properties from a development, this object will contain the details of the development

# Development details

Field name Type Nullable Description
id number false Development reference in Keaze
externalRef string true Development external reference, if provided
name string false Development name
building string true Building name if applicable
street string true Street name
postcode string true Postcode
town string true Town

# Property details

Field name Type Nullable Description
id number false Property reference in Keaze
externalRef string true Property external reference, if provided
propertyNumber string true Property number when it belongs to a development
name string true Independent unit name, when it does not belong to a development
newBuild boolean false If it is a new build or not, when it belongs to a development it is always true
bedrooms number true Total of bedrooms
bathrooms number true Total of bathrooms

# Available sources

New sources might be added in the future.

ID Code Name
1 KZ Keaze
2 HFL Homes For Londoners
3 ZPL Zoopla
4 RM Rightmove
5 STB Share to Buy
6 API KPro API
7 NHFS New Homes For Sale
8 FC Full Circle
11 KPRO KPro (Customer Portal)
14 HTBS Help to Buy - Agent 3 (South)
17 99H 99home
20 OTM On The Market
22 HTB2 Help to Buy - Agent 2 (Midlands and London)
26 CSRC Client sources

Some housing providers will also have custom sources set up for importing leads via their own portals.

# Schemes list

Code Name
shared-ownership Shared ownership
help-to-buy Help to Buy
first-dibs First Dibs
discounted-market-sale Discounted market sale
private-sale Private sale
london-living-rent London living rent
discount-market-rent Discounted market rent
rent-to-buy Rent to Buy (Outside London)
private-rent Private rent

# Filtering

The API provides several fields that can be used to filter the results:

  • createdAt: the timestamp when the lead was created.
  • isArchived: true if the lead has been archived, otherwise it is false.
  • externalRef: the external reference.
  • eligibilityStatus: the eligibility status, one of these possible values: passed, considered, incomplete, failed
  • site.id: the portal or platform id the lead came in from. See below the list of all possible values.
  • site.code: the portal or platform code the lead came in from. See below the list of all possible values.
  • site.name: the portal or platform name the lead came in from. See below the list of all possible values.
  • listing.id: the ID of this listing linked to the lead.
  • listing.name: the name of this listing linked to the lead.
  • listing.development.id: the id of the development for the listing that the lead is linked.
  • development.id: id of the development linked to the lead.
  • property.id: id of the property linked to the lead.
  • property.propertyNumber: number/name of the property linked to the lead.
  • housingProvider.id: id of the housing provider linked to the lead.
  • housingProvider.name: name of the housing provided linked to the lead.
  • customer.id: the lead's customer id.
  • customer.firstName: the lead's first name.
  • customer.lastName: the lead's last name.
  • customer.fullName: the lead's full name.
  • customer.phone: the lead's phone number.
  • customer.email: the lead's email address.

and several operators to be used in conjunction with the fields:

  • eq: equal
  • not: not equal
  • gt: greater than (for numbers, date and timestamps)
  • lt: less than (for numbers, date and timestamps)
  • gte: greater than or equal to (for numbers, date and timestamps)
  • lte: less than or equal to (for numbers, date and timestamps)
  • ltt: less than tomorrow's date, useful for datetime or timestamp fields when the filter value is a date without the time component
  • in: in a list of values separated by commas
  • notin: not in a list of values separated by commas
  • like: standard like operator, use * for any amount of chars and _ for a single one

Operators should be placed after the fields, separated by a dot (.). When multiple filters are specified, the AND logic operator will be used (except when using square brackets at the end of the parameter name to replace in and notin operators). When no operator is specified for a filter, the usual equal comparison is applied.

In order to filter dates and timestamps, use the ISO date format YYYY-MM-DD for dates, and if you want to include hours and minutes, use YYYY-MM-DD HH:mm. Notice that in all cases, UTC date/time is used.

Examples

  • To get leads created between 01-Mar-2021 and 10-Mar-2021, inclusive. Notice as the createdAt field is a timestamp, you should use the operator ltt to include leads created at any time on 10-Mar-2021.

/api/bulk/open/leads?createdAt.gte=2021-03-01&createdAt.ltt=2021-03-10

  • To get leads created between 11-Mar-2021 10:00 and 11:00, inclusive.

/api/bulk/open/leads?createdAt.gte=2021-03-11 10:00&createdAt.lte=2021-03-11 11:00

  • To get leads created on or after 01-Mar-2021 and coming from site id 1 or 2.

/api/bulk/open/leads?createdAt.gte=2021-03-01&site.id.in=1,2

  • To get leads created on or after 01-Mar-2021 and where eligibility status is not incomplete or failed.

/api/bulk/open/leads?createdAt.gte=2021-03-01&eligibilityStatus.notin=incomplete,failed

# Bracket option

Brackets can be used instead of values separated by commas to replace the operators in and notin.

Examples

  • site.id[]=1&site.id[]=2 is the same as site.id.in=1,3
  • site.id.not[]=1&site.id.not[]=2 is the same as site.id.notin=1,3

# Sorting

By default results are sorting by createdAt descending, but you can change it by using parameter sort and the list of fields you want to sort by, separated by comma, as the value. Fields are sorted ascending, but you use the minus symbol (-) in front of any of fields to change the order to descending.

Example, to sort first by site.id descending, and then by createdAt also descending, use: sort=-site.id,-createdAt

# Pagination

Results are paginated based on parameters page (page number, optional, default is 1) and size (maximum number of records to return per page, optional, default is 100, maximum possible value is 1000).

# Importing leads

To import leads into Keaze, issue a POST to /api/bulk/open/leads.

# Import payload

The payload must be JSON encoded, and as this is a bulk API, it must be an object with the field data, which value must be an array containing all the leads you want to import as json objects, no matter if it is only one lead or several.

{
  "data": [leads to import],
}

For every lead, only the email address is mandatory. You should only include the fields that exist in your system, although null values are permitted for all of the other fields.

Field name Type Description
externalRef string \ integer External reference, useful to check if the lead was already imported. Maximum 255 characters.
siteId integer ID of the lead's source. May include sources that aren't websites.
email string Customer email address. Mandatory.
sendEmailConfirmation boolean Boolean to specify if when the lead has been imported, an email should be sent to the customer on behalf of the Housing Provider. If not present or null it is considered false.
title string Customer title. Maximum 100 characters.
firstName string Given names. Maximum 100 characters.
lastName string Family name. Maximum 100 characters.
phone string Phone number. Maximum 20 characters.
dateOfBirth string Date of birth using the format YYYY-MM-DD.
annualHouseholdIncome number Annual household income. Maximum 1000000.
deposit number Deposit or savings. Maximum 1000000.
livingCircumstance number Integer matching one of the ID values in the list of Living Circumstances.
homePostcode string Home post code. Valid UK postcode.
homeAddress string Home address. Maximum 255 characters.
dependants number Integer indicating the total of dependants: it could be zero.
workingCircumstance number Integer matching one of the ID values in the list of Working Circumstances.
workPostcode string Work post code. Valid UK postcode.
workAddress string Work address. Maximum 255 characters.
occupation string Occupation. Maximum 255 characters.
employerName string Employer name. Maximum 255 characters.
armedForcesMember boolean Boolean to specify if the customer is a member of the armed forces.
keyworker boolean Boolean to specify if the customer is a key worker.
hasDisability boolean Boolean to specify if the customer has any known disability.
housingWaitingList boolean Boolean to specify if the customer is in the council waiting list.
firstTimeBuyer boolean Boolean to specify if the customer is a first time buyer.
eligibleCitizen boolean Boolean to specify if the customer has British, EU/EEA citizen or have indefinite leave to remain.
homeOwnershipStatus number Integer matching one of the ID values in the list of Home Ownership Statuses. If not present and firstTimeBuyer is true, this will be set to 1 by default.
additionalInfo string Any additional information.
listingId number Reference of the listing in Keaze. Used to associate this lead with a listing.
listingExternalRef string Listing reference in your system. Used to associate this lead with a listing. For Keaze to be able to identify the listing when you include this value, listings should have been previously updated with your system's references.
propertyId number Reference of the property in Keaze. Used to associate this lead with a property.
propertyExternalRef string Property reference in your system. Used to associate this lead with a property. For Keaze to be able to identify the property when you include this value, properties should have been previously updated with your system's references.
bedrooms array Array containing the amount of bedrooms the customer is interested in, example: [2,3]

Warning

It is important to include the externalRef field to every lead in the payload, to avoid Keaze adding leads twice in case some of them are included in another request. Ensure that each lead has a unique externalRef. Any leads with an externalReference and source combination matching an existing application will be skipped. If using your own references for the externalRef for leads assigned to a source that is listed, and not a portal of your own, you may want to prepend a slug representing your housing provider's name to ensure it doesn't match any externalRef used by any other housing providers.

# Assignable Sources

New sources might be added in the future.

ID Name
1 Keaze
2 Homes For Londoners
3 Zoopla
4 Rightmove
5 Share to Buy
7 New Homes For Sale
8 Full Circle
17 99home
20 On The Market
22 Help to Buy - Agent 2 (Midlands and London)

Some housing providers will also have custom sources set up for importing leads via their own portals.

If a lead is not assigned to any of the above sources or a custom portal, it will be assigned to the source KPro API (6).

# Living Circumstances

ID Description label
1 Renting privately
2 London living rent
3 Home owner
4 Housing benefits
5 Council tenant
6 Living in armed forces accommodation
7 A housing association tenant
8 Living with friends or family

# Working Circumstances

ID Description label
1 Not working - disabled
2 Not working - Looking after children
3 Not working - retired
4 Other
5 Student
6 Unemployed
7 Working full time
8 Working part-time
9 Self employed

# Home Ownership Statuses

ID Description label
1 First time buyer
2 Does not own any property at the moment
3 Owns a property but it is currently in a selling process
4 Owns one or more properties

# Example

Only include fields that your system uses. If your system is able to provide information about the listings and/or the properties, include one or both fields if possible. You can provide Keaze Identifiers or your system references if they have been previously updated in Keaze. While there is no need to use both, they have both been included in the JSON to demonstrate what it may look like.

{
  "data": [
    {
      "externalRef": "A-23445",
      "email" : "m.g.scott@mspc.com",
      "sendEmailConfirmation": false,

      "title": "Mr",
      "firstName": "Michael",
      "lastName": "Scott",
      "phone": "07987654321",
        
      "dateOfBirth": "1975-11-21",
      "annualHouseholdIncome": 40000,
      "deposit": 12000,

      "livingCircumstance": 3, // Home owner
      "homePostcode": "D8M 1KE",
      "homeAddress": "17 Condo Lane",
      "dependants": 0,

      "workingCircumstance": 9, // Self employed
      "workPostcode": "SC4 4RN",
      "workAddress": "1725 Slough Avenue",
      "occupation": "Founder, Owner and CEO",
      "employerName": "Michael Scott Paper Company",

      "armedForcesMember": false,
      "keyworker": false,
      "hasDisability": false,
      "housingWaitingList": false,
      "firstTimeBuyer": false,
      "eligibleCitizen": true,
      "homeOwnershipStatus": 3, // Owns a property but it is currently in a selling process
      "additionalInfo": "...",
      
      "listingId": 1234,
      "listingExternalRef": "L-34523",
      
      "propertyId": 12345,
      "propertyExternalRef": "P-67932",
      
      "bedrooms": [2,3]
    },
    { ... },
    { ... }
  ]
}

# Errors

If there's any validation error in any of the leads, no record will be added and the API will respond with HTTP code 422, and an object with attributes message and errors. Message will contain a general description of the error, and errors will contain a collection of objects for every lead that failed, with two fields: customerEmail and errors, the first one with the customer email of the lead, and the second one the list of errors related to each parameter that failed the validation. A successful request will respond with HTTP code 200, but no response body.

# Successful response

Once a successful import request has been received by the API, a response including the total leads that were successfully imported and an array of any leads that were not imported and the reason why.

# Example

{
  "imported": 5,
  "notImported": [
    {
      "data": { Data for the lead that was sent in the request },
      "reason": "An enquiry with the external reference 123456 already exists from this source. Please ensure that each enquiry has a unique external reference."
    },
    { ... },
    { ... }
 ]
}