{"openapi":"3.1.0","info":{"title":"QSL CRM — Site API","version":"1.0.0","description":"Server-to-server API for a real estate agency's own website. The agency creates a site connection in QSL (Settings → Integrations → Connect my site) and generates a site key (`ck_site_...`). The key identifies both the agency and the site; never send an agency id. **Keep the key on your server** (environment variable); never ship it in browser JavaScript. Only properties the agency published to this site are returned, with public fields only. Data is refreshed when the agency or the catalog sync changes it — poll `/changes`; this API is not real-time push."},"servers":[{"url":"/api/v1/site"}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"Authorization: Bearer ck_site_..."}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}}}},"Price":{"type":"object","properties":{"amount":{"type":["number","null"]},"kind":{"type":"string","enum":["exact","from"],"description":"`from` = starting price of a typology/development (cheapest unit in stock). Show as \"from R$ …\". Never present it as the price of a specific unit."},"currency":{"type":"string","enum":["BRL"]}}},"Media":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"alt":{"type":["string","null"]},"is_cover":{"type":"boolean"}}},"Property":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Stable id. Use it as your primary key."},"code":{"type":"string"},"slug":{"type":"string"},"title":{"type":"string"},"description":{"type":["string","null"]},"type":{"type":"string","enum":["apartment","house","penthouse","gated_house","land","commercial","flat"]},"purpose":{"type":"string","enum":["sale","rent"]},"status":{"type":"string","enum":["available","reserved"]},"price":{"$ref":"#/components/schemas/Price"},"condo_fee":{"type":["number","null"]},"iptu_year":{"type":["number","null"]},"area_m2":{"type":["number","null"]},"bedrooms":{"type":["integer","null"]},"suites":{"type":["integer","null"]},"bathrooms":{"type":["integer","null"]},"parking":{"type":["integer","null"]},"features":{"type":"array","items":{"type":"string"}},"location":{"type":"object","properties":{"neighborhood":{"type":["string","null"]},"city":{"type":["string","null"]}},"description":"No street address is exposed."},"development":{"type":["object","null"],"properties":{"name":{"type":["string","null"]},"stage":{"type":["string","null"],"enum":["launch","under_construction","ready","used",null]}}},"source":{"type":"string","enum":["own","catalog"]},"featured":{"type":"boolean"},"published_at":{"type":["string","null"],"format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"media":{"type":"array","items":{"$ref":"#/components/schemas/Media"}}}},"Removed":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"removed":{"type":"boolean","const":true},"updated_at":{"type":"string","format":"date-time"}}},"NewLead":{"type":"object","required":["name","phone","consent"],"properties":{"name":{"type":"string","minLength":2,"maxLength":120},"phone":{"type":"string","description":"Brazilian phone number, any common format"},"email":{"type":"string","maxLength":160},"message":{"type":"string","maxLength":2000},"kind":{"type":"string","enum":["buyer","owner"],"default":"buyer"},"property_id":{"type":"string","description":"Property of interest (id or code). Must be published on this site."},"consent":{"type":"object","required":["text_version"],"properties":{"text_version":{"type":"string","description":"Version of the privacy/contact consent text the person accepted on your form"}}},"attribution":{"type":"object","description":"Optional, only if your site collects it lawfully","properties":{"page_url":{"type":"string"},"referrer":{"type":"string"},"utm_source":{"type":"string"},"utm_medium":{"type":"string"},"utm_campaign":{"type":"string"},"utm_content":{"type":"string"},"utm_term":{"type":"string"},"gclid":{"type":"string"},"fbclid":{"type":"string"}}}}}}},"paths":{"/properties":{"get":{"summary":"Properties published on this site (scope site:read)","parameters":[{"name":"city","in":"query","schema":{"type":"string"}},{"name":"neighborhood","in":"query","schema":{"type":"string"}},{"name":"q","in":"query","schema":{"type":"string"}},{"name":"type","in":"query","schema":{"type":"string","enum":["apartment","house","penthouse","gated_house","land","commercial","flat"]}},{"name":"purpose","in":"query","schema":{"type":"string","enum":["sale","rent"]}},{"name":"min_price","in":"query","schema":{"type":"number"}},{"name":"max_price","in":"query","schema":{"type":"number"}},{"name":"min_bedrooms","in":"query","schema":{"type":"number"}},{"name":"featured","in":"query","schema":{"type":"boolean"}},{"name":"sort","in":"query","schema":{"type":"string","enum":["recent","price_asc","price_desc","updated"],"default":"recent"}},{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"per_page","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Property"}},"page":{"type":"integer"},"per_page":{"type":"integer"},"total":{"type":"integer"},"total_pages":{"type":"integer"}}}}}},"401":{"description":"Missing, invalid, revoked or expired site key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Site access paused by the agency, or key without this scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit per minute exceeded (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/properties/{ref}":{"get":{"summary":"One property published on this site, by id, code or slug (scope site:read)","parameters":[{"name":"ref","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Property"}}}}}},"401":{"description":"Missing, invalid, revoked or expired site key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Site access paused by the agency, or key without this scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not published on this site (anymore). Remove it from your site.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit per minute exceeded (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/changes":{"get":{"summary":"Change feed to keep a local copy in sync (scope site:read)","description":"Ordered by change time. Published items come complete; items no longer on this site come as `{id, removed: true}`. Store `next_cursor` and call again with `after=` until it is null.","parameters":[{"name":"after","in":"query","schema":{"type":"string"},"description":"Cursor from a previous next_cursor. Omit for a full initial load."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"oneOf":[{"$ref":"#/components/schemas/Property"},{"$ref":"#/components/schemas/Removed"}]}},"next_cursor":{"type":["string","null"]}}}}}},"401":{"description":"Missing, invalid, revoked or expired site key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Site access paused by the agency, or key without this scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit per minute exceeded (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/leads":{"post":{"summary":"Send a contact from the site's form (scope site:leads)","description":"Persisted before the 201 response. Resending with the same Idempotency-Key returns the same lead (200, header Idempotent-Replayed). A known person with an open conversation becomes a new interaction on the same lead. Do not send WhatsApp button clicks: only forms the person filled in and consented to. Protect your form against bots (captcha, honeypot, rate limit) on your server before calling this endpoint.","parameters":[{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":120},"description":"Unique per form submission (e.g. a UUID generated when the form loads)."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NewLead"}}}},"responses":{"200":{"description":"Same Idempotency-Key and body: the original result"},"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"protocol":{"type":"string"},"property_id":{"type":["string","null"]},"contact":{"type":"string","enum":["new","existing"]}}}}}}}},"400":{"description":"Missing Idempotency-Key or invalid JSON","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid, revoked or expired site key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Site access paused by the agency, or key without this scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency-Key reused with a different body","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Invalid data (phone, consent) or property not published on this site","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit per minute exceeded (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}