# Create an inquiry

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

Create a lead with contact details and structured search preferences, and get its ID back.

Creates a lead from a contact form or any external service, with the contact details and search preferences you provide. This is the recommended way to send leads to Vestta.

## Lead type

`type` accepts Vestta's lead types and a few English and Spanish aliases:

| You send | Stored as |
| --- | --- |
| `buyer`, `tenant`, `comprador`, `inquilino`, `demandante` | `demandante` — looking to buy or rent |
| `owner`, `propietario` | `propietario` — owns a property |
| `agencia-inmobiliaria`, `entidad-bancaria`, `proveedor-servicios` | Unchanged |

Matching is case-insensitive. Any other value fails.

## Search preferences

`search_preferences` is a list of searches. Each entry has the operations and property types the lead wants, optional criteria per property type, and locations:

```json
{
  "operations": ["alquiler"],
  "property_types": ["apartamento", "casa"],
  "apartamento": { "bedrooms_min": 2, "price_rent_max": 1200 },
  "casa": { "bedrooms_min": 3, "price_rent_max": 1500 },
  "locations": [{ "name": "Madrid" }]
}
```

- `operations`: `venta`, `alquiler` and/or `traspaso`.
- `property_types`: `apartamento`, `casa`, `local`, `nave`, `almacenaje`, `oficina`, `terreno`, `aparcamiento`, `edificio`. Criteria for each type go in the object of the same name, such as `apartamento.price_rent_max` or `casa.price_max`.
- `locations`: places by `name`, or map areas in the same shapes as the [`locations` filter](/properties/list#map-areas).

When at least one search has content, the lead is created with status `searching_property`; otherwise with status `new`.

Partial search requests are accepted: no minimum set of criteria is required. If the form only collects contact details, omit `search_preferences` or send `[]`. Empty entries are discarded, and Vestta does not invent criteria or run matching for a contact without a search request.

## Notes

Vestta writes a summary of the inquiry into the lead notes — operations, property types, locations, origin page and your message — so agents can read it at a glance. Your message is taken from `search_preferences[0].internal_notes` if set, otherwise from `notes`.

## Defaults set by Vestta

Inquiries are always stored as **active**, with **rating 3** and captured by `Web`. `profile_category` defaults to `potencial`, `urgency_profile` to `poca-urgencia` and `source` to `manual` — send `"source": "web"` or your site's name so agents know where the lead came from.

## Duplicates

The primary phone is unique within a workspace:

- If a lead with the same phone exists **without a name** (for example, someone who first wrote on WhatsApp), it is **completed** with this inquiry and its `lead_id` is returned.
- If a lead with the same primary phone exists **with a name**, the request fails with `409`. Treat it as "already in Vestta": do not retry.

### POST /v1/leads/inquiries

Accepts structured contact-form inquiries and retains configured outreach. Requires the `leads:ingest` scope.

Required scope: `leads:ingest`

Request body (LeadInquiryRequest, required, application/json):
- `name` (string, required): Contact's full name.
- `dni` (string, optional, nullable): National ID document number.
- `type` (string, required): Lead type. `buyer`, `comprador`, `demandante`, `tenant` and `inquilino` are stored as `demandante`; `owner` and `propietario` as `propietario`. Other values must be a Vestta lead type (`agencia-inmobiliaria`, `entidad-bancaria`, `proveedor-servicios`).
- `profile_category` (string, optional, nullable): `standard` or `potencial`. Defaults to `potencial`.
- `urgency_profile` (string, optional, nullable): `alta-urgencia` or `poca-urgencia`. Defaults to `poca-urgencia`.
- `preferred_language` (string, optional, nullable): `es`, `gb`, `fr`, `ge` or `it`.
- `phone_number_1` (string, required): Primary phone. Normalised to E.164: include the international prefix (`+34600111222`); numbers without one are read as Spanish.
- `phone_number_2` (string, optional, nullable): Secondary phone, normalised to E.164.
- `landline_phone` (string, optional, nullable): Landline, normalised to E.164.
- `personal_email` (string, optional, nullable): Personal email address.
- `professional_email` (string, optional, nullable): Work email address.
- `source` (string, optional, nullable, default manual): Where the inquiry comes from, e.g. `web` or your site's name. Stored as the lead source; defaults to `manual`.
- `sourcePage` (string, optional, nullable): URL of the page where the inquiry was submitted. Added to the lead notes.
- `notes` (string, optional, nullable): Free-text message. Vestta stores a generated summary of the inquiry as the lead notes and includes this text in it, unless `search_preferences[0].internal_notes` is set.
- `search_preferences` (array of objects, optional): What the contact is looking for. All entries are stored and used for property matching; the first one is summarised in the notes.
  - `request_id` (string, optional, nullable)
  - `operations` (array of strings, optional)
  - `property_types` (array of strings, 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)
  - `locations` (array of objects, optional)
  - `internal_notes` (string, optional, nullable)
  - `title` (string, optional, nullable)
  - `color` (string, optional, nullable)
  - `urgency` (string, optional, nullable)
  - `status` (string, optional, nullable)
- `agency_property_ids` (array of integers, optional): Property IDs linked to the contact. Stored only when `type` is `agencia-inmobiliaria`.
- `services` (array of objects, optional): Services offered by the contact. Stored only when `type` is `entidad-bancaria` or `proveedor-servicios`.
  - `name` (string, required, 1–255 chars)
  - `category` (string, optional, nullable, ≤ 80 chars)
  - `approximate_cost` (number, optional, nullable, ≥ 0)
  - `notes` (string, optional, nullable, ≤ 2000 chars)

Accepted but ignored — leave these fields out:
- `rating` (integer, optional, nullable, default 0) — ignored: Ignored: inquiries are stored with rating 3.
- `active` (boolean, optional, nullable) — ignored: Ignored: inquiries are always stored as active.
- `captured_by` (string, optional, nullable) — ignored: Ignored: inquiries are stored as captured by `Web`.
- `agency_id` (integer, optional, nullable, ≥ 1) — ignored: Ignored by this endpoint.
- `agency_client_ids` (array of integers, optional) — ignored: Ignored by this endpoint.
- `time_to_create` (integer, optional, nullable, default 0) — ignored: Ignored by this endpoint.

Response 200: Successful response.
- `status` (string, required, values: `ok`)
- `authenticated_as` (string, optional, nullable): Name of the business that owns the API key.
- `lead_id` (integer, optional, nullable): ID of the created lead, or of the existing unnamed lead that was completed.

```json
{
  "status": "ok",
  "authenticated_as": "Inmobiliaria Ejemplo",
  "lead_id": 228
}
```

Response 401: The API key is missing, malformed, unknown, revoked or expired.

Response 403: The API key lacks the required scope, or the business plan does not include API access.

Response 404: The resource does not exist in this business.

Response 409: Duplicate contact or idempotency key reused with a different payload.

Response 422: A path parameter, query parameter or body field is invalid.

Response 429: The API key reached its request limit. Wait for the number of seconds in `Retry-After` before retrying.

Response 500: Unexpected server error while processing the request.

### Example requests

#### cURL

```bash
curl -X POST "https://api.vestta.io/v1/leads/inquiries" \
  -H "X-Api-Key: $VESTTA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Ana García",
  "type": "demandante",
  "preferred_language": "es",
  "phone_number_1": "+34600111222",
  "personal_email": "ana@example.com",
  "source": "web",
  "sourcePage": "https://example.com/contacto",
  "notes": "Busco piso de dos habitaciones cerca del centro.",
  "search_preferences": [
    {
      "operations": [
        "alquiler"
      ],
      "property_types": [
        "apartamento"
      ],
      "apartamento": {
        "price_rent_max": 1200,
        "bedrooms_min": 2
      },
      "locations": [
        {
          "name": "Madrid"
        }
      ]
    }
  ]
}'
```

#### JavaScript

```javascript
const response = await fetch('https://api.vestta.io/v1/leads/inquiries', {
  method: 'POST',
  headers: {
    'X-Api-Key': process.env.VESTTA_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Ana García",
    "type": "demandante",
    "preferred_language": "es",
    "phone_number_1": "+34600111222",
    "personal_email": "ana@example.com",
    "source": "web",
    "sourcePage": "https://example.com/contacto",
    "notes": "Busco piso de dos habitaciones cerca del centro.",
    "search_preferences": [
      {
        "operations": [
          "alquiler"
        ],
        "property_types": [
          "apartamento"
        ],
        "apartamento": {
          "price_rent_max": 1200,
          "bedrooms_min": 2
        },
        "locations": [
          {
            "name": "Madrid"
          }
        ]
      }
    ]
  }),
})

const data = await response.json()
```

#### Python

```python
import os

import requests

response = requests.post(
    "https://api.vestta.io/v1/leads/inquiries",
    headers={"X-Api-Key": os.environ["VESTTA_API_KEY"]},
    json={
        "name": "Ana García",
        "type": "demandante",
        "preferred_language": "es",
        "phone_number_1": "+34600111222",
        "personal_email": "ana@example.com",
        "source": "web",
        "sourcePage": "https://example.com/contacto",
        "notes": "Busco piso de dos habitaciones cerca del centro.",
        "search_preferences": [
            {
                "operations": [
                    "alquiler",
                ],
                "property_types": [
                    "apartamento",
                ],
                "apartamento": {
                    "price_rent_max": 1200,
                    "bedrooms_min": 2,
                },
                "locations": [
                    {
                        "name": "Madrid",
                    },
                ],
            },
        ],
    },
)
response.raise_for_status()
data = response.json()
```
