# Complete image uploads

URL: https://api-docs.vestta.io/properties/complete-uploads

Verify uploaded originals and attach them to the property.

Use the returned `session_id` as the path's `upload_id`. Supply each accepted `file_id`, title, order and primary flag after its PUT succeeds. The session is bound to the property and workspace.

Completion validates the stored bytes before attaching them. Repeating completion with the same session and metadata is safe while the session remains valid. The response contains image references, never original download URLs.

New static images larger than 1 MiB are gently optimized during completion: up to 2560 pixels on the longest side and JPEG quality 90. Opaque photographs may change to JPEG; transparency is retained as PNG. No WebP is generated. A smaller result is adopted; 1 MiB is the processing threshold, not a final size limit. Images at or below the threshold retain their exact bytes, as do animated or multi-page images. The returned filename, content type and file size describe the stored result.

Next: [publish](/properties/publication) to generate public marked copies.

If the property is already configured to send its photos to Idealista, completing an upload can queue synchronization of the configured gallery. Check the property's **Portales** panel for the result.

### POST /v1/properties/{property_id}/images/uploads/{upload_id}/complete

Verifies uploaded originals and attaches them to the property. Publish to generate the public copies. Properties already configured to send their photos to Idealista can be queued for synchronization. Requires the `properties:write` scope.

Required scope: `properties:write`

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

Request body (ImageUploadCompleteRequest, required, application/json):
- `images` (array of objects, required)
  - `file_id` (string, required, 1–100 chars)
  - `title` (string, optional, ≤ 200 chars, default )
  - `is_primary` (boolean, optional, default false)
  - `order` (integer, optional, nullable, ≥ 1)

Response 200: Successful response.
- `status` (string, optional, default ok, values: `ok`)
- `property_id` (integer, required)
- `images` (array of objects, required)
  - `id` (string, required)
  - `title` (string, optional, default )
  - `order` (integer, optional, default 1)
  - `is_primary` (boolean, optional, default false)

```json
{
  "status": "ok",
  "property_id": 1355,
  "images": [
    {
      "id": "1234567890ABCDEF",
      "title": "Living room",
      "order": 1,
      "is_primary": true
    }
  ]
}
```

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/properties/1/images/uploads/session-id-from-upload-response/complete" \
  -H "X-Api-Key: $VESTTA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "images": [
    {
      "file_id": "photo-1",
      "title": "Living room",
      "is_primary": true,
      "order": 1
    }
  ]
}'
```

#### JavaScript

```javascript
const response = await fetch('https://api.vestta.io/v1/properties/1/images/uploads/session-id-from-upload-response/complete', {
  method: 'POST',
  headers: {
    'X-Api-Key': process.env.VESTTA_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "images": [
      {
        "file_id": "photo-1",
        "title": "Living room",
        "is_primary": true,
        "order": 1
      }
    ]
  }),
})

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

#### Python

```python
import os

import requests

response = requests.post(
    "https://api.vestta.io/v1/properties/1/images/uploads/session-id-from-upload-response/complete",
    headers={"X-Api-Key": os.environ["VESTTA_API_KEY"]},
    json={
        "images": [
            {
                "file_id": "photo-1",
                "title": "Living room",
                "is_primary": True,
                "order": 1,
            },
        ],
    },
)
response.raise_for_status()
data = response.json()
```
