> ## Documentation Index
> Fetch the complete documentation index at: https://docs.newlead.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create or replace a property

> Creates the property with this reference, or replaces it entirely: a field you leave out is removed. 201 when it is created, 200 when it is replaced. Sending the same request again changes nothing, so retry freely: there is no Idempotency-Key. Send one PUT at a time per reference: two concurrent PUTs of the same reference may race on photos.
Up to 50 photos are copied to our storage, in your order. A URL already copied for this property is not downloaded again. A photo that cannot be copied does not fail the request: the property is saved without it and the photo comes back in warnings. If copying takes too long, the rest come back as image_deferred: send the same request again.
These properties live apart from your Idealista catalog: this route never changes a property that comes from Idealista, even with the same reference.



## OpenAPI

````yaml /openapi.yaml put /properties/{reference}
openapi: 3.1.0
info:
  title: NewLead API
  version: 1.0.0
  description: >-
    The NewLead public API. Each API key belongs to one subaccount and can read
    and change only that subaccount's data. Errors, pagination, idempotency and
    rate limits are documented at https://docs.newlead.ai.
servers:
  - url: https://rest.newlead.ai/v1
security:
  - BearerAuth: []
  - ApiKeyHeader: []
tags:
  - name: Specification
    description: This document.
paths:
  /properties/{reference}:
    parameters:
      - $ref: '#/components/parameters/PropertyReference'
    put:
      tags:
        - Properties
      summary: Create or replace a property
      description: >-
        Creates the property with this reference, or replaces it entirely: a
        field you leave out is removed. 201 when it is created, 200 when it is
        replaced. Sending the same request again changes nothing, so retry
        freely: there is no Idempotency-Key. Send one PUT at a time per
        reference: two concurrent PUTs of the same reference may race on photos.

        Up to 50 photos are copied to our storage, in your order. A URL already
        copied for this property is not downloaded again. A photo that cannot be
        copied does not fail the request: the property is saved without it and
        the photo comes back in warnings. If copying takes too long, the rest
        come back as image_deferred: send the same request again.

        These properties live apart from your Idealista catalog: this route
        never changes a property that comes from Idealista, even with the same
        reference.
      operationId: upsertProperty
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PropertyUpsertRequest'
      responses:
        '200':
          description: Replaced.
          headers:
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
            RateLimit-Limit:
              $ref: '#/components/headers/RateLimit-Limit'
            RateLimit-Remaining:
              $ref: '#/components/headers/RateLimit-Remaining'
            RateLimit-Reset:
              $ref: '#/components/headers/RateLimit-Reset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PropertyUpserted'
        '201':
          description: Created.
          headers:
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
            RateLimit-Limit:
              $ref: '#/components/headers/RateLimit-Limit'
            RateLimit-Remaining:
              $ref: '#/components/headers/RateLimit-Remaining'
            RateLimit-Reset:
              $ref: '#/components/headers/RateLimit-Reset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PropertyUpserted'
        '429':
          $ref: '#/components/responses/RateLimited'
        4XX:
          $ref: '#/components/responses/Error'
        5XX:
          $ref: '#/components/responses/Error'
components:
  parameters:
    PropertyReference:
      name: reference
      in: path
      required: true
      description: >-
        Your reference for the property, the one in your CRM: 1 to 50 letters,
        digits, dots, hyphens or underscores, and not only dots. Case-sensitive.
      schema:
        type: string
        minLength: 1
        maxLength: 50
        pattern: ^(?!\.+$)[A-Za-z0-9._-]{1,50}$
        examples:
          - SH-0042
  schemas:
    PropertyUpsertRequest:
      type: object
      additionalProperties: false
      required:
        - type
        - listings
      properties:
        type:
          type: string
          enum:
            - flat
            - house
            - countryhouse
            - garage
            - office
            - commercial
            - land
            - storage
            - building
            - room
        listings:
          type: array
          minItems: 1
          maxItems: 2
          description: 'One per operation: a sale, a rent, or both.'
          items:
            $ref: '#/components/schemas/PropertyListingInput'
        address:
          $ref: '#/components/schemas/PropertyAddressInput'
        bedrooms:
          type:
            - integer
            - 'null'
          minimum: 0
          maximum: 99
          description: >-
            Kept for flats, houses, country houses, rooms and commercial
            premises; ignored for other types.
        bathrooms:
          type:
            - integer
            - 'null'
          minimum: 0
          maximum: 99
          description: Ignored for garages, land, storage rooms and buildings.
        built_m2:
          type:
            - integer
            - 'null'
          minimum: 1
          maximum: 999999
          description: Ignored for land.
        description:
          type:
            - string
            - 'null'
          maxLength: 4000
          description: 'In Spanish: it is what your agents read.'
        features:
          type: array
          uniqueItems: true
          items:
            $ref: '#/components/schemas/PropertyFeature'
        agent_notes:
          type:
            - string
            - 'null'
          maxLength: 2000
          description: Internal notes for your agents.
        images:
          type: array
          maxItems: 50
          description: 'In order: the first one is the cover.'
          items:
            $ref: '#/components/schemas/PropertyImageInput'
    PropertyUpserted:
      description: The property as saved, with warnings (empty if every photo was copied).
      allOf:
        - $ref: '#/components/schemas/Property'
        - type: object
          required:
            - warnings
          properties:
            warnings:
              type: array
              items:
                $ref: '#/components/schemas/PropertyWarning'
    PropertyListingInput:
      type: object
      additionalProperties: false
      required:
        - operation
        - price
        - available
      properties:
        operation:
          type: string
          enum:
            - sale
            - rent
        price:
          type: number
          exclusiveMinimum: 0
          maximum: 9999999999
          description: In euros; for rent, per month.
          examples:
            - 198000
        available:
          type: boolean
          description: >-
            true to offer it: GET /properties lists it and your agents offer it.
            false keeps it for searches by reference, as no longer available.
    PropertyAddressInput:
      type: object
      additionalProperties: false
      properties:
        street:
          type:
            - string
            - 'null'
          maxLength: 200
        street_number:
          type:
            - string
            - 'null'
          maxLength: 10
        postal_code:
          type:
            - string
            - 'null'
          pattern: ^[0-9]{5}$
          description: >-
            Spanish postal code. Gives the province when the city is not a
            province name.
        city:
          type:
            - string
            - 'null'
          maxLength: 50
        visibility:
          type: string
          enum:
            - full
            - street
            - hidden
          description: >-
            What GET /properties and your agents show: street and number (full),
            the street only, or neither (hidden). If you leave it out, hidden.
    PropertyFeature:
      type: string
      enum:
        - terrace
        - balcony
        - lift
        - parking
        - pool
        - garden
        - air_conditioning
        - storage_room
        - fitted_wardrobes
        - pets_allowed
    PropertyImageInput:
      type: object
      additionalProperties: false
      required:
        - url
      properties:
        url:
          type: string
          format: uri
          pattern: ^https?://
          maxLength: 2048
          description: A JPG, PNG or GIF at a public URL that answers without redirects.
        label:
          type:
            - string
            - 'null'
          maxLength: 40
          description: 'What the photo shows: kitchen, bathroom...'
    Property:
      type: object
      additionalProperties: false
      required:
        - object
        - id
        - reference
        - internal_reference
        - type
        - type_label
        - available
        - matched_operation
        - summary
        - listings
        - city
        - province
        - address
        - bedrooms
        - bathrooms
        - built_m2
        - features
        - description
        - visit_hours
        - sales_agent
        - agent_notes
        - images
        - url
      properties:
        object:
          type: string
          const: property
        id:
          type: string
          format: uuid
        reference:
          type:
            - string
            - 'null'
          description: >-
            The Idealista code of the listing that matched your search;
            otherwise the first published listing's; with no code, your internal
            reference.
        internal_reference:
          type:
            - string
            - 'null'
          description: Your internal reference for the property.
        type:
          type: string
          enum:
            - flat
            - house
            - countryhouse
            - garage
            - office
            - commercial
            - land
            - storage
            - building
            - room
        type_label:
          type: string
          description: 'The type as labeled in Spanish: Piso, Ático, Chalet...'
        available:
          type: boolean
          description: >-
            Has at least one published listing: on Idealista, or sent with
            available: true in PUT /properties/{reference}.
        matched_operation:
          type:
            - string
            - 'null'
          enum:
            - sale
            - rent
            - null
          description: >-
            The operation of the listing whose code you searched. null if the
            search does not say: your internal reference on a property listed
            for both sale and rent, or several matches.
        summary:
          type: string
          description: >-
            One line in Spanish, ready to drop into a message: "Piso de 3
            habitaciones en Calle La Colina, 5 (Córdoba), en alquiler por 720 €
            al mes".
        listings:
          type: array
          description: >-
            Its listings, published ones first: on Idealista, or the ones sent
            with PUT /properties/{reference}.
          items:
            $ref: '#/components/schemas/PropertyListing'
        city:
          type:
            - string
            - 'null'
        province:
          type:
            - string
            - 'null'
          description: >-
            From its city when the city is a province name ("CORDOBA" is
            Córdoba); otherwise from its postal code (Fuengirola, 29640, is
            Málaga).
        address:
          type:
            - string
            - 'null'
          description: >-
            Depends on the listing's visibility: street and number, street only,
            or null if hidden.
        bedrooms:
          type:
            - integer
            - 'null'
        bathrooms:
          type:
            - integer
            - 'null'
        built_m2:
          type:
            - integer
            - 'null'
        features:
          type:
            - string
            - 'null'
          description: 'Highlights on one line: "Terraza, ascensor, garaje".'
        description:
          type:
            - string
            - 'null'
          description: The listing description, in Spanish if available.
        visit_hours:
          type:
            - string
            - 'null'
        sales_agent:
          type:
            - object
            - 'null'
          additionalProperties: false
          required:
            - name
            - phone
          description: The listing's sales agent.
          properties:
            name:
              type:
                - string
                - 'null'
            phone:
              type:
                - string
                - 'null'
              pattern: ^\+[1-9]\d{6,14}$
              description: In E.164; null if the listing has no country prefix.
        agent_notes:
          type:
            - string
            - 'null'
          description: The internal notes you wrote for the agent.
        images:
          type: array
          description: Its photos, in the listing's order.
          items:
            $ref: '#/components/schemas/PropertyImage'
        url:
          type:
            - string
            - 'null'
          description: >-
            The reference listing on Idealista. Only with the production
            connection.
        warnings:
          type: array
          description: >-
            Only in the PUT /properties/{reference} response: the photos that
            were not copied. Empty if there were none.
          items:
            $ref: '#/components/schemas/PropertyWarning'
    PropertyWarning:
      type: object
      additionalProperties: false
      required:
        - code
        - param
        - message
      properties:
        code:
          type: string
          enum:
            - image_not_copied
            - image_deferred
          description: >-
            image_not_copied: the photo could not be copied. The URL is not
            valid or redirects (send the final address of the image), the
            download took more than 15 seconds, the file is not a JPG, PNG or
            GIF, it is larger than 20 MB, or the server answered with an error.
            image_deferred: the photo was not copied in time, or we had a
            storage problem on our side; send the same request again to copy it.
        param:
          type: string
          description: The photo, as images.<index>.url.
          examples:
            - images.3.url
        message:
          type: string
    ErrorResponse:
      type: object
      additionalProperties: false
      required:
        - error
      properties:
        error:
          type: object
          additionalProperties: false
          required:
            - type
            - code
            - message
            - param
            - request_id
            - doc_url
          properties:
            type:
              $ref: '#/components/schemas/ErrorType'
            code:
              $ref: '#/components/schemas/ErrorCode'
            message:
              type: string
              description: 'A human-readable explanation. It can change: never match on it.'
            param:
              type:
                - string
                - 'null'
              description: The offending field, dot-separated (variables.city), or null.
            request_id:
              type: string
              description: The same value as the x-request-id header.
            doc_url:
              type: string
              format: uri
            details:
              type: object
              additionalProperties: true
              description: >-
                On agent_not_ready, carries blockers. On send_outcome_unknown
                from POST /calls, carries call_id if the call is known.
      examples:
        - error:
            type: invalid_request_error
            code: parameter_invalid
            message: phone must match pattern "^\+[1-9]\d{6,14}$".
            param: phone
            request_id: req_m3k2a9_4f1c2b7e
            doc_url: https://docs.newlead.ai/errors#parameter_invalid
    PropertyListing:
      type: object
      additionalProperties: false
      required:
        - operation
        - price
        - currency
        - idealista_code
        - url
        - available
      properties:
        operation:
          type: string
          enum:
            - sale
            - rent
        price:
          type: number
          description: In euros; for rent, per month.
          examples:
            - 720
        currency:
          type: string
          const: EUR
          description: The currency of price, ISO 4217. Always EUR.
        idealista_code:
          type:
            - string
            - 'null'
          description: >-
            The listing code on Idealista. null for properties sent with PUT
            /properties/{reference}.
          examples:
            - '100000001'
        url:
          type:
            - string
            - 'null'
          description: The listing on Idealista. Only with the production connection.
        available:
          type: boolean
          description: false if the listing is no longer published.
    PropertyImage:
      type: object
      additionalProperties: false
      required:
        - url
        - label
        - ai_generated
      properties:
        url:
          type: string
          format: uri
          description: A public URL you can display directly.
          examples:
            - https://images.example.com/property/kitchen.jpg
        label:
          type:
            - string
            - 'null'
          description: 'What the photo shows: kitchen, bathroom... null if it has no label.'
        ai_generated:
          type: boolean
          description: true if Idealista marks the photo as generated with AI.
    ErrorType:
      type: string
      enum:
        - invalid_request_error
        - authentication_error
        - billing_error
        - permission_error
        - not_found_error
        - conflict_error
        - rate_limit_error
        - api_error
        - provider_error
    ErrorCode:
      type: string
      description: >-
        The closed list of error causes. The table is at
        https://docs.newlead.ai/errors.
      enum:
        - parameter_missing
        - parameter_invalid
        - parameter_unknown
        - body_invalid_json
        - recipient_invalid
        - api_key_missing
        - api_key_invalid
        - insufficient_balance
        - subscription_inactive
        - api_key_forbidden
        - feature_disabled
        - resource_not_found
        - route_not_found
        - agent_not_ready
        - lead_do_not_contact
        - lead_ai_paused
        - lead_ai_not_paused
        - messaging_window_closed
        - template_not_approved
        - outside_initiation_hours
        - voice_number_missing
        - webhook_endpoint_limit_reached
        - webhook_endpoint_disabled
        - idempotency_key_reused
        - idempotency_key_in_use
        - rate_limit_exceeded
        - internal_error
        - provider_unavailable
        - send_outcome_unknown
  headers:
    X-Request-ID:
      description: The id of this request. Quote it when you contact support.
      schema:
        type: string
    RateLimit-Limit:
      description: Requests allowed per minute for this API key.
      schema:
        type: integer
    RateLimit-Remaining:
      description: Requests left in the current minute.
      schema:
        type: integer
    RateLimit-Reset:
      description: Seconds until the counter resets.
      schema:
        type: integer
    Retry-After:
      description: Seconds to wait before repeating the request.
      schema:
        type: integer
    Idempotent-Replayed:
      description: true when the response is the stored one for a repeated Idempotency-Key.
      schema:
        type: string
        const: 'true'
  responses:
    RateLimited:
      description: Too many requests for this API key. Wait for Retry-After and repeat.
      headers:
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        Retry-After:
          $ref: '#/components/headers/Retry-After'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Error:
      description: An error. type is the family and code is the cause.
      headers:
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
        RateLimit-Limit:
          $ref: '#/components/headers/RateLimit-Limit'
        RateLimit-Remaining:
          $ref: '#/components/headers/RateLimit-Remaining'
        RateLimit-Reset:
          $ref: '#/components/headers/RateLimit-Reset'
        Retry-After:
          $ref: '#/components/headers/Retry-After'
        Idempotent-Replayed:
          $ref: '#/components/headers/Idempotent-Replayed'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        The API key, created in Settings › API, in the header Authorization:
        Bearer <key>. The default.
    ApiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: The same key, in the x-api-key header. Still accepted.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.