openapi: 3.0.3
info:
  title: Cadastrix API
  version: 1.0.0
  description: Spanish Cadastre property resolution and lookup API backed by a versioned official
    Cadastre dataset.
paths:
  /v1/resolve:
    post:
      operationId: resolveProperty
      summary: Resolve, verify, complete, or correct a single property against the active Cadastre snapshot
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ResolvePropertyRequest"
      responses:
        "200":
          description: Deterministic Cadastre resolution outcome
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ResolvePropertyResponse"
        "400":
          description: Invalid resolution request payload
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
        "401":
          description: Missing or invalid API key
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
        "503":
          description: Service is temporarily unavailable.
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
  /v1/properties/{cadastralRef}:
    get:
      operationId: getProperty
      summary: Fetch the official Cadastre property record for a 20-character cadastral reference
      security:
        - BearerAuth: []
      parameters:
        - name: cadastralRef
          in: path
          required: true
          description: 20-character Spanish cadastral reference (trimmed, uppercased, and stripped of
            separators before validation).
          schema:
            type: string
      responses:
        "200":
          description: Official property record from the active Cadastre snapshot
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PropertyResponse"
        "400":
          description: Malformed cadastral reference or invalid check digits
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
        "401":
          description: Missing or invalid API key
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
        "404":
          description: Property not found in the active Cadastre snapshot (or unsupported foral territory)
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
        "503":
          description: Service is temporarily unavailable.
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
  /v1/parcels/{parcelRef14}/units:
    get:
      operationId: listParcelUnits
      summary: List all Cadastre units belonging to a 14-character parcel reference
      security:
        - BearerAuth: []
      parameters:
        - name: parcelRef14
          in: path
          required: true
          description: 14-character Spanish cadastral parcel reference (trimmed, uppercased, and stripped of
            separators before validation).
          schema:
            type: string
      responses:
        "200":
          description: All units belonging to the parcel in the active Cadastre snapshot
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ParcelUnitsResponse"
        "400":
          description: Malformed 14-character parcel reference
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
        "401":
          description: Missing or invalid API key
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
        "404":
          description: Parcel not found in the active Cadastre snapshot (or unsupported foral territory)
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
        "503":
          description: Service is temporarily unavailable.
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: "API key passed via `Authorization: Bearer <api_key>`."
  schemas:
    ResolvePropertyRequest:
      type: object
      properties:
        cadastralRef:
          type: string
          description: Optional 14- or 20-character Spanish cadastral reference.
        address:
          type: string
          description: Street address (structured or unsplit single-line Spanish address).
        postalCode:
          type: string
          description: 5-digit Spanish postal code (4-digit Excel-stripped values are zero-padded).
        municipality:
          type: string
          description: Municipality name (official, bilingual, or common Spanish spelling).
        province:
          type: string
          description: Province name or code.
    ResolutionStatus:
      type: string
      enum:
        - validated
        - completed
        - corrected
        - ambiguous
        - not_found
        - not_applicable
    PropertyClass:
      type: string
      enum:
        - urban
        - rustic
    SurfaceKind:
      type: string
      enum:
        - built
        - land
    Property:
      type: object
      required:
        - cadastralRef
        - parcelRef14
        - propertyClass
        - officialAddress
        - municipality
        - province
      properties:
        cadastralRef:
          type: string
          minLength: 20
          maxLength: 20
        parcelRef14:
          type: string
          minLength: 14
          maxLength: 14
        propertyClass:
          $ref: "#/components/schemas/PropertyClass"
        officialAddress:
          type: string
        postalCode:
          type: string
        municipality:
          type: string
        province:
          type: string
        block:
          type: string
        stair:
          type: string
        floor:
          type: string
        door:
          type: string
        mainUseCode:
          type: string
          description: Official FIN-CAT single-character property use group code (e.g., `V`, `A`, `C`, `O`,
            `I`, `Z`).
          example: V
        mainUse:
          type: string
          description: Human-readable Cadastre property use label corresponding to `mainUseCode`.
          example: Residencial
        surfaceSqm:
          type: number
          format: double
        surfaceKind:
          $ref: "#/components/schemas/SurfaceKind"
        yearBuilt:
          type: integer
          format: int32
    ParcelUnit:
      type: object
      required:
        - cadastralRef
      properties:
        cadastralRef:
          type: string
          minLength: 20
          maxLength: 20
        block:
          type: string
        stair:
          type: string
        floor:
          type: string
        door:
          type: string
        mainUseCode:
          type: string
          description: Official FIN-CAT single-character property use group code.
          example: V
        mainUse:
          type: string
          description: Human-readable Cadastre property use label corresponding to `mainUseCode`.
          example: Residencial
        surfaceSqm:
          type: number
          format: double
        surfaceKind:
          $ref: "#/components/schemas/SurfaceKind"
        yearBuilt:
          type: integer
          format: int32
        officialAddress:
          type: string
    AmbiguityDetail:
      type: object
      required:
        - totalCandidates
        - candidates
      properties:
        parcelRef14:
          type: string
          description: 14-character parcel reference matched by address or input reference.
        inputParcelRef14:
          type: string
          description: 14-character parcel prefix extracted from the request's `cadastralRef` when it
            conflicts with the address parcel.
        officialBuildingAddress:
          type: string
        municipality:
          type: string
        province:
          type: string
        totalCandidates:
          type: integer
          format: int32
          minimum: 0
        candidates:
          type: array
          items:
            $ref: "#/components/schemas/ParcelUnit"
    ResolvePropertyResponse:
      type: object
      required:
        - snapshotDate
        - status
        - reason
      properties:
        snapshotDate:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
          example: 2026-08-14
        status:
          $ref: "#/components/schemas/ResolutionStatus"
        effectiveCadastralRef:
          type: string
          minLength: 20
          maxLength: 20
        reason:
          type: string
        property:
          $ref: "#/components/schemas/Property"
        ambiguity:
          $ref: "#/components/schemas/AmbiguityDetail"
    PropertyResponse:
      type: object
      required:
        - snapshotDate
        - property
      properties:
        snapshotDate:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
          example: 2026-08-14
        property:
          $ref: "#/components/schemas/Property"
    ParcelUnitsResponse:
      type: object
      required:
        - snapshotDate
        - parcelRef14
        - propertyClass
        - municipality
        - province
        - totalUnits
        - units
      properties:
        snapshotDate:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
          example: 2026-08-14
        parcelRef14:
          type: string
          minLength: 14
          maxLength: 14
        propertyClass:
          $ref: "#/components/schemas/PropertyClass"
        officialBuildingAddress:
          type: string
        postalCode:
          type: string
        municipality:
          type: string
        province:
          type: string
        totalUnits:
          type: integer
          format: int32
          minimum: 0
        units:
          type: array
          items:
            $ref: "#/components/schemas/ParcelUnit"
    ProblemDetails:
      type: object
      required:
        - type
        - title
        - status
      properties:
        type:
          type: string
        title:
          type: string
        status:
          type: integer
          format: int32
        detail:
          type: string
        code:
          type: string
servers:
  - url: https://api.cadastrix.com
    description: Production API
