• VillaSlotDocumentation
  • Introduction
  • Getting Started
  • API
    • Discovery
      • GETGet my context
    • Villas
      • GETList villas
      • POSTCreate a villa
      • GETGet a villa
      • PATCHRename a villa
      • POSTArchive a villa
      • POSTUpload a villa photo
      • GETGet opening hours
      • PUTReplace opening hours
      • GETGet the rate grid
      • PUTReplace the rate grid
      • GETGet availability
    • Bookings
      • GETList bookings over a period
      • POSTCreate a booking
      • GETGet a booking
      • POSTConfirm a booking
      • POSTComplete a booking
      • POSTCancel a booking
      • POSTReschedule a booking
    • Customers
      • GETList customers
      • POSTCreate a customer
      • POSTImport a batch of customers
      • GETGet a customer
      • PATCHUpdate a customer
    • Booking settings
      • GETGet booking settings
      • PATCHUpdate booking settings
  1. Documentation
  2. API
  3. Villas
  4. Upload a villa photo
Buydocschangelogsdemocommunity

Upload a villa photo

PreviousArchive a villaNextGet opening hours
On this page
AuthorizationForm fieldsExampleResponseWhat it refusesNotes

POST /api/v1/properties/{propertyId}/photo

Uploads a photo and attaches it to the villa. The body is multipart/form-data.

The image is compressed server-side, at the same tiers the app applies in the browser. A call coming from a script has been through no browser: without this pass, the API would store a full-resolution original where the screen would have stored a light one.

Authorization

Role in the organizationThis endpoint
ownerAllowed
adminAllowed
memberRefused — 403

Form fields

FieldTypeRequiredDescription
filefileyesimage/jpeg, image/png or image/webp
levelenumnolight (1600px, q82), balanced (1200px, q72, default), strong (900px, q60)

Example

bash
curl -X POST -H "x-api-key: $VILLASLOT_API_KEY" \
  -F "file=@villa-suar.jpg" -F "level=balanced" \
  "https://villaslot.app/api/v1/properties/1f0a…/photo"

Response

  • 200 OK — the villa, with its new photoUrl.

What it refuses

  • 403 Forbidden — the key bearer is a member.
  • 422 Unprocessable Entity — no file field, an empty file, or an unknown level.
  • 401 Unauthorized — missing or invalid key, or a key whose bearer left the organization.
  • 404 Not Found — unknown id, or an id belonging to another organization. The two are deliberately indistinguishable.
  • 429 Too Many Requests — over 120 requests in a minute for this key.

Notes

  • A file that cannot be re-encoded, or whose re-encoding would be heavier than the original, is stored as received. The upload never fails because of compression.
  • A PNG or WebP with transparency keeps its format; anything else is re-encoded to JPEG.