# Publish or unpublish

URL: https://api-docs.vestta.io/properties/publication

Set desired visibility and generate protected public images.

Send `{"published": true}` to publish. The response is `202 Accepted`, with `Location` and `Retry-After: 2`. Follow [publication status](/properties/publication-status) until `published` is true. A property remains private while processing or after an error.

Send `{"published": false}` to remove it from the catalogue immediately (`200`). A pending worker cannot publish it afterwards. This does not guarantee removal of images already downloaded or cached by third parties.

Publication is an explicit choice, independent of commercial status. Save the property before publishing; external API requests also require type, operation, title and city. Each public photo is a permanent copy with an independent random ID. New photos are watermarked; existing photos grandfathered during migration may remain unmarked. No original path, filename or private storage URL is returned.

This endpoint changes visibility in the Vestta catalogue. Manage Idealista separately from the property's **Portales** panel in the CRM.

### PUT /v1/properties/{property_id}/publication

Sets desired visibility. Publishing returns 202 while public copies are prepared; new photos are watermarked. Unpublishing returns 200. Poll Retrieve publication until published or failed. Requires the `properties:publish` scope.

Required scope: `properties:publish`

Path parameters:
- `property_id` (integer, required, ≥ 1)

Request body (PublicationRequest, required, application/json):
- `published` (boolean, required): Desired visibility. Publishing prepares public copies before making the property public; new photos are watermarked.

Response 200: Successful response.
- `status` (string, optional, default ok, values: `ok`)
- `data` (PublicationState, required)
  - `status` (string, required, values: `private` | `pending` | `processing` | `published` | `ready` | `failed`)
  - `published` (boolean, required)
  - `requested` (boolean, required)
  - `images` (array of objects, optional)
    - `id` (string, required)
    - `url` (string, required): Permanent opaque public-copy URL. New photos are watermarked; migrated legacy copies may remain unmarked. Never an original or upload URL.
    - `order` (integer, optional, default 1)
    - `is_primary` (boolean, optional, default false)
    - `title` (string, optional, default )
  - `error` (string, optional, nullable): Safe diagnostic code. Retry the same publication request after correcting the cause.

```json
{
  "status": "ok",
  "data": {
    "status": "private",
    "published": false,
    "requested": false,
    "images": []
  }
}
```

Response 202: Accepted
- `status` (string, optional, default ok, values: `ok`)
- `data` (PublicationState, required)
  - `status` (string, required, values: `private` | `pending` | `processing` | `published` | `ready` | `failed`)
  - `published` (boolean, required)
  - `requested` (boolean, required)
  - `images` (array of objects, optional)
    - `id` (string, required)
    - `url` (string, required): Permanent opaque public-copy URL. New photos are watermarked; migrated legacy copies may remain unmarked. Never an original or upload URL.
    - `order` (integer, optional, default 1)
    - `is_primary` (boolean, optional, default false)
    - `title` (string, optional, default )
  - `error` (string, optional, nullable): Safe diagnostic code. Retry the same publication request after correcting the cause.

```json
{
  "status": "ok",
  "data": {
    "status": "private",
    "published": false,
    "requested": false,
    "images": []
  }
}
```

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 PUT "https://api.vestta.io/v1/properties/1/publication" \
  -H "X-Api-Key: $VESTTA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "published": true
}'
```

#### JavaScript

```javascript
const response = await fetch('https://api.vestta.io/v1/properties/1/publication', {
  method: 'PUT',
  headers: {
    'X-Api-Key': process.env.VESTTA_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "published": true
  }),
})

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

#### Python

```python
import os

import requests

response = requests.put(
    "https://api.vestta.io/v1/properties/1/publication",
    headers={"X-Api-Key": os.environ["VESTTA_API_KEY"]},
    json={
        "published": True,
    },
)
response.raise_for_status()
data = response.json()
```
