# Troubleshooting

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

Fixes for the problems integrations with the Vestta API run into most often.

## Every request returns 401

Read the `detail` of the response — it names the cause. The most common ones:

- **`API key required`** — the header did not reach the API. Check its name (`X-Api-Key`), and that no proxy, gateway or HTTP library drops custom headers. `Authorization: Bearer` is not accepted.
- **`Invalid API key format`** — the value was cut, or includes quotes or whitespace. Environment files often add quotes; print the length of the value you send.
- **`API key expired`** or **`API key is revoked`** — create a new key or reactivate it in **Settings → API**.

## A working key gets 403 "Insufficient scope"

The key is valid but lacks the endpoint's scope. Call [Retrieve key context](/me) to see the scopes it has. Scopes are fixed at creation, so create a new key with the right ones — see [scopes](/authentication#scopes).

## Requests return 429

Wait the number of seconds in `Retry-After`. Check the combined traffic across all services and endpoints that use the key. Reduce repeated catalogue reads by caching results on your server, and space out polling and bulk requests.

## A property is in Vestta but not in the API

The API only returns the **public catalogue**. Check in Vestta that the property:

- is marked as public;
- is not sold, rented or withdrawn;
- belongs to the workspace of the key you are using.

The same rules make [Retrieve a property](/properties/retrieve) return `404`.

## A property has no address

`address`, `postal_code` and the coordinates follow the property's address privacy setting: with a hidden location only `city`, `province` and `country` are returned, and with an approximate location the coordinates are rounded to about 1 km. See [Address privacy](/properties#address-privacy).

## Rent prices are missing or `price` is 0

`price` is the **sale** price. Monthly rent and transfer prices live in `specs.price_calc.price_alq` and `specs.price_calc.price_trasp`. Filter with `operation=alquiler` to make `min_price`, `max_price` and `sort` use the rent. See [Operations and prices](/properties#operations-and-prices).

## A map filter returns nothing, or everything

- If `locations` is not valid JSON, it is ignored and you get every property. Check `filters.locations` in the response: it lists the areas that were applied.
- Areas need a `geometry` (or `"type": "point"`): `{ "name": "Madrid" }` is ignored. Use the `city` filter for names.
- Properties with a hidden location never match an area, and approximate ones are matched by their rounded coordinates.
- Coordinates are `lat`/`lng` in degrees; swapping them puts the area in another part of the world.

## A rental lead returns 200 but does not appear

[Ingest a rental lead](/leads/ingest) does not create a lead when the workspace already has one with the same phone, and still returns `200`. Search for the phone in Vestta: the existing lead is the one the agency will work with.

## Create an inquiry returns 409

A lead with the same primary phone already exists in the workspace. The contact is already in Vestta; do not retry.

## A lead request fails with 422 for the phone

Send numbers in international format, such as `+34600111222`. Numbers without a prefix are read as Spanish, so foreign numbers need their prefix.

## A rental lead has an invalid budget

Check `search.budget`: it must be a whole number (`1200`) or a range of whole numbers (`900-1200`). Unsupported budget formats are rejected; send a numeric amount or supported range.

## The lead did not get a WhatsApp message

The automatic first message is only sent when the workspace has WhatsApp connected in Vestta, and only once per lead. Lead creation does not depend on it.

## Requests from the browser

The API answers cross-origin requests, but calling it from front-end code exposes your key to every visitor. Send requests from your server. For public forms, post to your backend and call [Create an inquiry](/leads/inquiries) from there.
