# Ingest a rental lead

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

Create a rental-seeking lead from the compact payload used by rental landing forms.

Creates a lead of type `demandante` from a rental form submission, with a readable summary in its notes and a tenant profile. General search forms also create a search request from the criteria sent, even when partial. Forms about a specific property (`propertyId`) save the candidacy without creating a general search request. For full control over the lead, use [Create an inquiry](/leads/inquiries) instead.

## How the payload is used

| Field | What Vestta does with it |
| --- | --- |
| `contact.name` | Lead name. |
| `contact` phone fields | The first value that is a valid phone number becomes the primary phone, in this order: `areaCode` + `phoneNumber`, `phoneE164`, `phone`, `phoneRaw`. |
| `search.budget` | For general searches, the upper bound becomes the maximum monthly rent. `1200` and `900-1200` both mean 1,200 €. Empty means unknown. |
| `search.habs` | For general searches, minimum bedrooms for apartments and houses. Empty means unknown. |
| `search.location` | For general searches, the location used for matching. `{}` means unknown. |
| `source` | Lead source. |
| `sourcePage`, `search.entryDate`, `search.exitDate`, `search.people`, `search.area`, `search.pets`, `search.workSituation`, `search.freeText` | Written into the lead notes for the agent. The ones Vestta can read also fill the tenant profile (see below). |
| `tenant` | Optional. Structured tenant data stored as the contact's tenant profile. |
| `propertyId` | Optional. The property the form was about: the contact becomes a candidate of its open rental, without a general search request. Search criteria remain in the notes. |
| `id`, `createdAt` | Required, but not stored. Use them for your own tracing. |

All new leads have rating 3 and high urgency (`alta-urgencia`). Without `propertyId`, sending a budget, bedroom count or location creates a general residential search with operation `alquiler` and property types `apartamento` and `casa`; missing criteria remain unset. A profile alone (income, employment, pets, occupants or dates) does not create a search request. Leads without a search request start with status `new`; those with one start with `searching_property`.

For general searches, a nonempty `search.budget` must be a whole number or a range of whole numbers, and nonempty `search.habs` must be a non-negative whole number. Invalid numeric values fail with `422`. Leave unknown values empty. Property-specific submissions keep these values in the notes without requiring search criteria.

## Tenant profile and rental applications

Each lead keeps one tenant profile, which Vestta compares with the requirements of every rental the agency is marketing. It is filled from:

- `search.people` (a number of occupants), `search.pets` (`No`, `Sí`, `Sí, un gato`…), `search.workSituation` (`Contrato indefinido`, `Autónomo`, `Estudiante`…), `search.entryDate` and `search.exitDate` (as `YYYY-MM-DD`, for the move-in date and the length of stay). A value Vestta cannot read is left out of the profile, never guessed.
- `tenant`, when you send it. Its fields always win over what was read from `search`, and it is the only way to send the household's net monthly income (`monthlyIncome`), smokers, a guarantor or the contact's consent to hear about other rentals (`benchConsent`).

With `propertyId`, the contact is added as a candidate of that property's open rental and rated against its requirements right away. If the property has no open rental, or the lead cannot be a tenant, the lead is still created and nothing else happens: the request does not fail.

## Duplicates

If the workspace already has a lead with the same primary phone, **nothing is created and the response is still `200`**, without a lead ID. The existing lead is not updated, except for its tenant profile and, with `propertyId`, its rental application: answers are merged into the profile and the contact is added as a candidate unless they already are. This makes retries safe.

If no phone field holds a valid number, the request fails with `422` and the message `Invalid phone number. Use international format, e.g. +34600111222`.

### POST /v1/leads/ingest

Accepts the existing rental landing payload. Duplicate phones are ignored. Requires the `leads:ingest` scope.

Required scope: `leads:ingest`

Request body (RentingLead, required, application/json):
- `id` (string, required): Your identifier for the submission. Required, but not stored by Vestta.
- `createdAt` (string, required): When the form was submitted, ISO 8601. Required, but not stored by Vestta.
- `source` (string, required): Where the lead comes from, e.g. `web`. Stored as the lead source.
- `sourcePage` (string, required): URL of the page with the form. Added to the lead notes.
- `contact` (RentingLeadContact, required)
  - `name` (string, required): Contact's full name. Stored as the lead name.
  - `phone` (string, required): Phone number. Include the international prefix (`+34600111222`); numbers without one are read as Spanish.
  - `phoneRaw` (string, optional, nullable): Phone exactly as typed. Used only when no other phone field can be normalised.
  - `areaCode` (string, optional, nullable): International prefix, e.g. `+34`. Combined with `phoneNumber` and tried first.
  - `phoneNumber` (string, optional, nullable): National number without prefix. Combined with `areaCode`.
  - `phoneE164` (string, optional, nullable): Phone already in E.164 format. Tried after `areaCode` + `phoneNumber`.
- `search` (RentingLeadSearch, required)
  - `budget` (string, required): Monthly budget in euros: a whole number (`1200`), a range (`900-1200`), or empty when unknown. For general searches, the upper bound becomes the maximum rent. With `propertyId`, kept only in the notes.
  - `entryDate` (string, required): Desired move-in date. Free text, added to the lead notes; `YYYY-MM-DD` recommended.
  - `exitDate` (string, required): Desired move-out date. Free text, added to the lead notes.
  - `people` (string, required): Number of occupants. Added to the lead notes.
  - `area` (string, required): Preferred area, as free text. Added to the lead notes.
  - `habs` (string, required): Minimum bedrooms as a whole number, or empty when unknown. For general searches, stored for apartments and houses. With `propertyId`, kept only in the notes.
  - `pets` (string, required): Whether the occupants have pets. Added to the lead notes.
  - `workSituation` (string, required): Employment situation. Added to the lead notes.
  - `location` (object, required): Location for a general search, e.g. `{"name": "Madrid"}`, or a map area with `geometry`. Use `{}` when unknown. With `propertyId`, kept only in the notes.
  - `freeText` (string, required): Free-text message from the contact. Added to the lead notes.
- `tenant` (RentingLeadTenant, optional, nullable): Structured tenant data. Stored as the contact's tenant profile, which rates them against each rental's requirements.
  - `occupants` (integer, optional, nullable, ≥ 1, ≤ 20): People who would live in the home.
  - `monthlyIncome` (number, optional, nullable, ≥ 0, ≤ 1000000): Net monthly income of the whole household, in euros.
  - `employment` (string, optional, nullable, values: `indefinido` | `temporal` | `funcionario` | `autonomo` | `pensionista` | `estudiante` | `desempleado` | `otro`): Employment situation: permanent contract (`indefinido`), temporary, civil servant, self-employed, pensioner, student, unemployed or other.
  - `pets` (boolean, optional, nullable): Whether they have pets.
  - `petsDetail` (string, optional, nullable, ≤ 120 chars): Which pets, e.g. `a small dog`.
  - `smoker` (boolean, optional, nullable): Whether anyone smokes.
  - `guarantor` (boolean, optional, nullable): Whether they have a guarantor or can add a guarantee.
  - `moveIn` (string, optional, nullable): Desired move-in date.
  - `stayMonths` (integer, optional, nullable, ≥ 1, ≤ 600): How many months they want to stay.
  - `benchConsent` (boolean, optional, nullable): They agree to hear about other rentals that fit them.
- `propertyId` (integer, optional, nullable, ≥ 1): Vestta property the form was about. When it has an open rental, the contact becomes a candidate of it. No general search request is created for a property-specific submission, even without an open rental.

Response 200: Successful response.
- `status` (string, required, values: `ok`)
- `authenticated_as` (string, optional, nullable): Name of the business that owns the API key.

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

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/ingest" \
  -H "X-Api-Key: $VESTTA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "id": "web-123",
  "createdAt": "2026-09-22T10:30:00Z",
  "source": "web",
  "sourcePage": "https://example.com/alquiler",
  "contact": {
    "name": "Ana García",
    "phone": "+34600111222"
  },
  "search": {
    "budget": "900-1200",
    "entryDate": "2026-10-01",
    "exitDate": "2027-09-30",
    "people": "2",
    "area": "Madrid centro",
    "habs": "2",
    "pets": "No",
    "workSituation": "Contrato indefinido",
    "location": {
      "name": "Madrid"
    },
    "freeText": "Preferimos una vivienda amueblada"
  }
}'
```

#### JavaScript

```javascript
const response = await fetch('https://api.vestta.io/v1/leads/ingest', {
  method: 'POST',
  headers: {
    'X-Api-Key': process.env.VESTTA_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "id": "web-123",
    "createdAt": "2026-09-22T10:30:00Z",
    "source": "web",
    "sourcePage": "https://example.com/alquiler",
    "contact": {
      "name": "Ana García",
      "phone": "+34600111222"
    },
    "search": {
      "budget": "900-1200",
      "entryDate": "2026-10-01",
      "exitDate": "2027-09-30",
      "people": "2",
      "area": "Madrid centro",
      "habs": "2",
      "pets": "No",
      "workSituation": "Contrato indefinido",
      "location": {
        "name": "Madrid"
      },
      "freeText": "Preferimos una vivienda amueblada"
    }
  }),
})

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

#### Python

```python
import os

import requests

response = requests.post(
    "https://api.vestta.io/v1/leads/ingest",
    headers={"X-Api-Key": os.environ["VESTTA_API_KEY"]},
    json={
        "id": "web-123",
        "createdAt": "2026-09-22T10:30:00Z",
        "source": "web",
        "sourcePage": "https://example.com/alquiler",
        "contact": {
            "name": "Ana García",
            "phone": "+34600111222",
        },
        "search": {
            "budget": "900-1200",
            "entryDate": "2026-10-01",
            "exitDate": "2027-09-30",
            "people": "2",
            "area": "Madrid centro",
            "habs": "2",
            "pets": "No",
            "workSituation": "Contrato indefinido",
            "location": {
                "name": "Madrid",
            },
            "freeText": "Preferimos una vivienda amueblada",
        },
    },
)
response.raise_for_status()
data = response.json()
```
