# Create a contact

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

Create a private CRM contact without initiating outreach.

Requires `leads:write`. The canonical contact types are `demandante`, `propietario`, `agencia-inmobiliaria`, `entidad-bancaria` and `proveedor-servicios`. Phone numbers are normalized to international E.164; email addresses are validated.

Use `notes` for general CRM contact notes (up to 50,000 characters) and `rating` for an integer star rating from `0` to `5`; `0` means unrated and is the default. Both fields are optional and remain private: lead reads do not return them.

`search_preferences[].internal_notes` holds notes about an individual search request. It remains supported independently of the contact's `notes` and is also excluded from lead reads.

The response is `201` with the new `id`. Contacts and their personal data are private to the workspace; this operation does not publish them on the property portal or start automated outreach. Use [Create an inquiry](/leads/inquiries) for a form with configured follow-up.

The optional `Idempotency-Key` header has the same 24-hour replay and conflict rules as property creation.

### POST /v1/leads

Creates a CRM contact without initiating outreach. Requires the `leads:write` scope. Supports `Idempotency-Key`.

Required scope: `leads:write`

Request headers:
- `idempotency-key` (string, optional, nullable, 1–200 chars)

Request body (LeadCreateRequest, required, application/json):
- `name` (string, required, 1–200 chars)
- `type` (string, required, values: `demandante` | `propietario` | `agencia-inmobiliaria` | `entidad-bancaria` | `proveedor-servicios`)
- `phone_number_1` (string, required, 5–30 chars)
- `phone_number_2` (string, optional, nullable, ≤ 30 chars)
- `landline_phone` (string, optional, nullable, ≤ 30 chars)
- `personal_email` (string, optional, nullable, ≤ 254 chars)
- `professional_email` (string, optional, nullable, ≤ 254 chars)
- `preferred_language` (string, optional, default es, values: `es` | `gb` | `fr` | `ge` | `it`)
- `active` (boolean, optional, default true)
- `source` (string, optional, 1–100 chars, default external_api)
- `notes` (string, optional, nullable, ≤ 50000 chars): Private CRM contact notes. Not returned by lead reads.
- `rating` (integer, optional, ≥ 0, ≤ 5, default 0): CRM star rating from 0 (unrated) to 5. Not returned by lead reads.
- `search_preferences` (array of objects, optional)
  - `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)

Response 201: Successful response.
- `status` (string, optional, default ok, values: `ok`)
- `id` (integer, required)

```json
{
  "status": "ok",
  "id": 1355
}
```

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" \
  -H "X-Api-Key: $VESTTA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Ana García",
  "type": "demandante",
  "phone_number_1": "+34600111222",
  "source": "integration",
  "notes": "Prefiere visitas por la tarde.",
  "rating": 4
}'
```

#### JavaScript

```javascript
const response = await fetch('https://api.vestta.io/v1/leads', {
  method: 'POST',
  headers: {
    'X-Api-Key': process.env.VESTTA_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Ana García",
    "type": "demandante",
    "phone_number_1": "+34600111222",
    "source": "integration",
    "notes": "Prefiere visitas por la tarde.",
    "rating": 4
  }),
})

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

#### Python

```python
import os

import requests

response = requests.post(
    "https://api.vestta.io/v1/leads",
    headers={"X-Api-Key": os.environ["VESTTA_API_KEY"]},
    json={
        "name": "Ana García",
        "type": "demandante",
        "phone_number_1": "+34600111222",
        "source": "integration",
        "notes": "Prefiere visitas por la tarde.",
        "rating": 4,
    },
)
response.raise_for_status()
data = response.json()
```
