# Leads

URL: https://api-docs.vestta.io/leads

Read the leads of a Vestta workspace and send new leads from your forms and services.

A lead is a contact the agency works with: someone looking to buy or rent (`demandante`), an owner (`propietario`), or a partner such as another agency, a bank or a service provider. Leads carry contact details and, for people searching, **search preferences** that Vestta uses to match them against the property catalogue.

## Endpoints

- `GET /v1/leads` — List contacts (https://api-docs.vestta.io/leads/list)
- `POST /v1/leads` — Create a contact (https://api-docs.vestta.io/leads/create)
- `GET /v1/leads/{lead_id}` — Retrieve a contact (https://api-docs.vestta.io/leads/retrieve)
- `PATCH /v1/leads/{lead_id}` — Update a contact (https://api-docs.vestta.io/leads/update)
- `POST /v1/leads/ingest` — Ingest a rental lead (https://api-docs.vestta.io/leads/ingest)
- `POST /v1/leads/inquiries` — Create an inquiry (https://api-docs.vestta.io/leads/inquiries)
## Choosing an endpoint

[Create a contact](/leads/create) (`POST /v1/leads`, scope `leads:write`) is the canonical endpoint for CRM integrations. It accepts a strict contact model, supports `Idempotency-Key`, returns the ID and does not trigger outreach. Use [retrieve](/leads/retrieve) and [update](/leads/update) for its subsequent lifecycle. Contacts remain private to the workspace.

The two form adapters below preserve their existing outreach behavior:

| | [Ingest a rental lead](/leads/ingest) | [Create an inquiry](/leads/inquiries) |
| --- | --- | --- |
| Payload | Compact rental-form format | Full lead: contact details and structured search preferences |
| Lead type | Always `demandante` | From `type` (`buyer`, `owner`…) |
| Search preferences | Derived: rent an apartment or house, maximum rent from `budget`, minimum bedrooms, one location | Exactly what you send in `search_preferences` |
| Urgency | `alta-urgencia` | `poca-urgencia` unless you send it |
| Phone already in the workspace | Nothing is created; still returns `200` | Completes the existing lead if it has no name; otherwise `409` |
| Returns the lead ID | No | Yes, `lead_id` |
| Follow-up scheduling | No | Yes |
| Scope | `leads:ingest` | `leads:ingest` |

Use Create an inquiry when submitting a form that should trigger matching and outreach. Ingest a rental lead exists for rental landing pages that already send its compact format.

[List leads](/leads/list) is read-only and needs the separate `leads:read` scope.

## What happens after a lead is created

The two form adapters respond as soon as the lead is stored. Then, in the background, Vestta:

1. **Matches** the lead against the property catalogue, using its search preferences.
2. **Contacts the lead on WhatsApp**, if the workspace has WhatsApp connected: one approved template message, sent once per lead, after which the Vestta assistant can carry on the conversation when the lead replies.
3. For inquiries only, **schedules follow-ups**. For people searching, every 30 days if they want to rent and every 90 days if they want to buy or take over a business, based on the operations in `search_preferences`; for other lead types, according to the workspace's follow-up rules.

None of this changes the response. If WhatsApp is not connected, the lead is still created.

## Phone numbers

The primary phone identifies a lead within a workspace: two leads cannot share it. Send numbers in international format, such as `+34600111222`. Numbers without a prefix are read as Spanish, and numbers that are not valid phone numbers are rejected with `422`.

## The lead object

List leads returns lead objects with these fields. Fields without a value are omitted.

- `id` (integer, required): Numeric lead ID.
- `name` (string, optional, nullable)
- `type` (string, optional, nullable): `demandante` (looking for a property), `propietario` (owner), `agencia-inmobiliaria`, `entidad-bancaria` or `proveedor-servicios`.
- `status` (string, optional, nullable): Pipeline status, e.g. `new`, `searching_property`, `active_negotiation`, `closed` or `inactive`.
- `active` (boolean, optional, nullable)
- `source` (string, optional, nullable): Where the lead came from, e.g. `web`, `manual`, or the `source` sent on ingestion.
- `phone_number_1` (string, optional, nullable): Primary phone in E.164 format.
- `phone_number_2` (string, optional, nullable)
- `landline_phone` (string, optional, nullable)
- `personal_email` (string, optional, nullable)
- `professional_email` (string, optional, nullable)
- `preferred_language` (string, optional, nullable): `es`, `gb`, `fr`, `ge` or `it`.
- `search_preferences` (array of objects, optional, nullable): Structured search requests without internal notes.
  - `request_id` (string, optional, nullable)
  - `operations` (array of strings, optional)
  - `property_types` (array of strings, optional)
  - `locations` (array of objects, optional)
  - `apartamento` (ApartmentPreferences, optional)
    - `requireds` (array of strings, optional)
    - `specs` (object, optional, nullable)
    - `views` (array of strings, optional, nullable)
    - `features` (array of strings, optional, nullable)
    - `subtypes` (array of strings, optional, nullable)
    - `size_max` (integer, optional, nullable)
    - `size_min` (integer, optional, nullable)
    - `price_max` (integer, optional, nullable)
    - `price_min` (integer, optional, nullable)
    - `price_rent_max` (integer, optional, nullable)
    - `price_rent_min` (integer, optional, nullable)
    - `bedrooms_min` (integer, optional, nullable)
    - `bathrooms_min` (integer, optional, nullable)
    - `num_terraces_min` (integer, optional, nullable)
    - `size_terraces_min` (integer, optional, nullable)
    - `doble_bedrooms_min` (integer, optional, nullable)
    - `suite_bathrooms_min` (integer, optional, nullable)
  - `casa` (HousePreferences, optional)
    - `requireds` (array of strings, optional)
    - `specs` (object, optional, nullable)
    - `views` (array of strings, optional, nullable)
    - `features` (array of strings, optional, nullable)
    - `subtypes` (array of strings, optional, nullable)
    - `size_max` (integer, optional, nullable)
    - `size_min` (integer, optional, nullable)
    - `price_max` (integer, optional, nullable)
    - `price_min` (integer, optional, nullable)
    - `price_rent_max` (integer, optional, nullable)
    - `price_rent_min` (integer, optional, nullable)
    - `bedrooms_min` (integer, optional, nullable)
    - `bathrooms_min` (integer, optional, nullable)
    - `num_terraces_min` (integer, optional, nullable)
    - `size_terraces_min` (integer, optional, nullable)
    - `doble_bedrooms_min` (integer, optional, nullable)
    - `suite_bathrooms_min` (integer, optional, nullable)
    - `plot_size_min` (integer, optional, nullable)
    - `porch_size_min` (integer, optional, nullable)
  - `local` (LocalPreferences, optional)
    - `requireds` (array of strings, optional)
    - `specs` (object, optional, nullable)
    - `features` (array of strings, optional, nullable)
    - `subtypes` (array of strings, optional, nullable)
    - `size_max` (integer, optional, nullable)
    - `size_min` (integer, optional, nullable)
    - `price_max` (integer, optional, nullable)
    - `price_min` (integer, optional, nullable)
    - `price_rent_max` (integer, optional, nullable)
    - `price_rent_min` (integer, optional, nullable)
    - `height_min` (integer, optional, nullable)
    - `facade_meters_min` (integer, optional, nullable)
    - `showcase_meters_min` (integer, optional, nullable)
    - `bathrooms_min` (integer, optional, nullable)
  - `nave` (NavePreferences, optional)
    - `requireds` (array of strings, optional)
    - `specs` (object, optional, nullable)
    - `features` (array of strings, optional, nullable)
    - `subtypes` (array of strings, optional, nullable)
    - `size_max` (integer, optional, nullable)
    - `size_min` (integer, optional, nullable)
    - `price_max` (integer, optional, nullable)
    - `price_min` (integer, optional, nullable)
    - `price_rent_max` (integer, optional, nullable)
    - `price_rent_min` (integer, optional, nullable)
    - `height_min` (integer, optional, nullable)
    - `facade_meters_min` (integer, optional, nullable)
    - `showcase_meters_min` (integer, optional, nullable)
  - `almacenaje` (StoragePreferences, optional): Preferencias para almacenes y trasteros independientes.
    - `requireds` (array of strings, optional)
    - `features` (array of strings, optional, nullable)
    - `subtypes` (array of strings, optional, nullable)
    - `size_max` (integer, optional, nullable)
    - `size_min` (integer, optional, nullable)
    - `price_max` (integer, optional, nullable)
    - `price_min` (integer, optional, nullable)
    - `price_rent_max` (integer, optional, nullable)
    - `price_rent_min` (integer, optional, nullable)
  - `oficina` (OficinaPreferences, optional)
    - `requireds` (array of strings, optional)
    - `specs` (object, optional, nullable)
    - `features` (array of strings, optional, nullable)
    - `subtypes` (array of strings, optional, nullable)
    - `size_max` (integer, optional, nullable)
    - `size_min` (integer, optional, nullable)
    - `price_max` (integer, optional, nullable)
    - `price_min` (integer, optional, nullable)
    - `price_rent_max` (integer, optional, nullable)
    - `price_rent_min` (integer, optional, nullable)
    - `offices_min` (integer, optional, nullable)
    - `bathrooms_min` (integer, optional, nullable)
    - `meeting_rooms_min` (integer, optional, nullable)
    - `num_terraces_min` (integer, optional, nullable)
    - `size_terraces_min` (integer, optional, nullable)
  - `terreno` (TerrenoPreferences, optional)
    - `requireds` (array of strings, optional)
    - `views` (array of strings, optional, nullable)
    - `features` (array of strings, optional, nullable)
    - `subtypes` (array of strings, optional, nullable)
    - `topography` (array of strings, optional, nullable)
    - `size_max` (integer, optional, nullable)
    - `size_min` (integer, optional, nullable)
    - `price_max` (integer, optional, nullable)
    - `price_min` (integer, optional, nullable)
    - `price_rent_max` (integer, optional, nullable)
    - `price_rent_min` (integer, optional, nullable)
    - `size_built_min` (integer, optional, nullable)
  - `aparcamiento` (AparcamientoPreferences, optional)
    - `requireds` (array of strings, optional)
    - `features` (array of strings, optional, nullable)
    - `subtypes` (array of strings, optional, nullable)
    - `min_seats` (integer, optional, nullable)
    - `price_max` (integer, optional, nullable)
    - `price_min` (integer, optional, nullable)
    - `price_rent_max` (integer, optional, nullable)
    - `price_rent_min` (integer, optional, nullable)
  - `edificio` (BuildingPreferences, optional)
    - `requireds` (array of strings, optional)
    - `specs` (object, optional, nullable)
    - `features` (array of strings, optional, nullable)
    - `size_max` (integer, optional, nullable)
    - `size_min` (integer, optional, nullable)
    - `subtypes` (array of strings, optional, nullable)
    - `price_max` (integer, optional, nullable)
    - `price_min` (integer, optional, nullable)
    - `price_rent_max` (integer, optional, nullable)
    - `price_rent_min` (integer, optional, nullable)
    - `num_floors_min` (integer, optional, nullable)
    - `num_locales_min` (integer, optional, nullable)
    - `usable_area_min` (integer, optional, nullable)
    - `num_parkings_min` (integer, optional, nullable)
    - `num_viviendas_min` (integer, optional, nullable)
  - `title` (string, optional, nullable)
  - `color` (string, optional, nullable)
  - `urgency` (string, optional, nullable)
  - `status` (string, optional, nullable)
- `created_at` (string, optional, nullable): ISO 8601 timestamp with UTC offset. Leads are ordered by this field, newest first.
- `updated_at` (string, optional, nullable): ISO 8601 timestamp with UTC offset.
