openapi: 3.1.0
info:
  title: Official Search of Whole with Data
  description: An Official Search of Whole with Data protects agreements between buyers, sellers and lenders. The Official Search of Whole with Data RESTful API expands on the existing Official Search of Whole SOAP API.
  version: 1.0.0
servers:
  - url: https://bgtest.landregistry.gov.uk/bg2test/api
    description: Customer Test Endpoint
  - url: https://businessgateway.landregistry.gov.uk/bg2/api
    description: Live Endpoint
tags:
  - name: Official Search of Whole with Data
paths:
  /v1/official-searches-of-whole:
    post:
      operationId: submitOfficialSearchOfWholeWithPriority
      tags:
        - Official Search of Whole with Data
      summary: Submit an OS1 Official Search of Whole with Priority application
      description: Official search with priority by a purchaser against the whole of a registered title or pending first registration application
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OfficialSearchRequest'
            examples:
              '201 - Successful request returned with data - no adverse entries':
                value:
                  message_id: dfcacc5e-456e-4fd1-88e5-8070e43d6714
                  title_number: PMD100
                  official_search_of_whole_with_priority:
                    priority_type: Purchase
                    property_description: 28a Richmond Avenue, Basingstoke, RG38 8DJ
                    search_from_date: 2022-02-12
                    continue_application_if:
                      - NAME_MISMATCH_ON_REGISTER
                      - DEVELOPER_TITLE
                    registered_proprietors_details_or_applicants_for_first_registration: Smith
                    applicant_party: Joe Bloggs and Jane Bloggs
                  external_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  customer_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  expected_price:
                    gross_price_amount: 3.00
                    net_price_amount: 3
                    vat_amount: 0.75
                    currency_id: GBP
                  contact:
                    - name: John Smith
                      telephone_number: stringstr
              '201 - Successful request returned with data - no adverse entries, proprietor name mismatch':
                value:
                  message_id: dfcacc5e-456e-4fd1-88e5-8070e43d6714
                  title_number: PMD101
                  official_search_of_whole_with_priority:
                    priority_type: Purchase
                    property_description: 28a Richmond Avenue, Basingstoke, RG38 8DJ
                    search_from_date: 2022-02-12
                    continue_application_if:
                      - NAME_MISMATCH_ON_REGISTER
                    registered_proprietors_details_or_applicants_for_first_registration: Bloggs
                    applicant_party: Joe Bloggs and Jane Bloggs
                  external_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  customer_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  expected_price:
                    gross_price_amount: 3.00
                    net_price_amount: 3
                    vat_amount: 0.75
                    currency_id: GBP
                  contact:
                    - name: John Smith
                      telephone_number: stringstr
              '201 - Successful request returned with data - new edition of register, commonhold title':
                value:
                  message_id: dfcacc5e-456e-4fd1-88e5-8070e43d6714
                  title_number: PMD102
                  official_search_of_whole_with_priority:
                    priority_type: Purchase
                    property_description: 28a Richmond Avenue, Basingstoke, RG38 8DJ
                    search_from_date: 2022-02-12
                    continue_application_if:
                      - NAME_MISMATCH_ON_REGISTER
                      - DEVELOPER_TITLE
                    registered_proprietors_details_or_applicants_for_first_registration: Smith
                    applicant_party: Joe Bloggs and Jane Bloggs
                  external_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  customer_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  expected_price:
                    gross_price_amount: 3.00
                    net_price_amount: 3
                    vat_amount: 0.75
                    currency_id: GBP
                  contact:
                    - name: John Smith
                      telephone_number: stringstr
              '201 - Successful request returned with data - new edition of register, prior pending official search, proprietor name mismatch, commonhold title':
                value:
                  message_id: dfcacc5e-456e-4fd1-88e5-8070e43d6714
                  title_number: PMD103
                  official_search_of_whole_with_priority:
                    priority_type: Purchase
                    property_description: 28a Richmond Avenue, Basingstoke, RG38 8DJ
                    search_from_date: 2022-02-12
                    continue_application_if:
                      - NAME_MISMATCH_ON_REGISTER
                    registered_proprietors_details_or_applicants_for_first_registration: Bloggs
                    applicant_party: Joe Bloggs and Jane Bloggs
                  external_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  customer_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  expected_price:
                    gross_price_amount: 3.00
                    net_price_amount: 3
                    vat_amount: 0.75
                    currency_id: GBP
                  contact:
                    - name: John Smith
                      telephone_number: stringstr
              '202 - accepted request - manual processing required':
                value:
                  message_id: dfcacc5e-456e-4fd1-88e5-8070e43d6714
                  title_number: PMD104
                  official_search_of_whole_with_priority:
                    priority_type: Purchase
                    property_description: 28a Richmond Avenue, Basingstoke, RG38 8DJ
                    search_from_date: 2022-02-12
                    continue_application_if:
                      - NAME_MISMATCH_ON_REGISTER
                    registered_proprietors_details_or_applicants_for_first_registration: Smith
                    applicant_party: Joe Bloggs and Jane Bloggs
                  external_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  customer_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  expected_price:
                    gross_price_amount: 3.00
                    net_price_amount: 3
                    vat_amount: 0.75
                    currency_id: GBP
                  contact:
                    - name: John Smith
                      telephone_number: stringstr
              '202 - submission out of hours':
                value:
                  message_id: dfcacc5e-456e-4fd1-88e5-8070e43d6714
                  title_number: PMD105
                  official_search_of_whole_with_priority:
                    priority_type: Purchase
                    property_description: 28a Richmond Avenue, Basingstoke, RG38 8DJ
                    search_from_date: 2022-02-12
                    continue_application_if:
                      - NAME_MISMATCH_ON_REGISTER
                      - DEVELOPER_TITLE
                    registered_proprietors_details_or_applicants_for_first_registration: Smith
                    applicant_party: Joe Bloggs and Jane Bloggs
                  external_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  customer_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  expected_price:
                    gross_price_amount: 3.00
                    net_price_amount: 3
                    vat_amount: 0.75
                    currency_id: GBP
                  contact:
                    - name: John Smith
                      telephone_number: stringstr
              '422 - invalid title':
                value:
                  message_id: dfcacc5e-456e-4fd1-88e5-8070e43d6714
                  title_number: PMD106
                  official_search_of_whole_with_priority:
                    priority_type: Purchase
                    property_description: 28a Richmond Avenue, Basingstoke, RG38 8DJ
                    search_from_date: 2022-02-12
                    continue_application_if:
                      - NAME_MISMATCH_ON_REGISTER
                      - DEVELOPER_TITLE
                    registered_proprietors_details_or_applicants_for_first_registration: Smith
                    applicant_party: Joe Bloggs and Jane Bloggs
                  external_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  customer_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  expected_price:
                    gross_price_amount: 3.00
                    net_price_amount: 3
                    vat_amount: 0.75
                    currency_id: GBP
                  contact:
                    - name: John Smith
                      telephone_number: stringstr
              '422 - caution title':
                value:
                  message_id: dfcacc5e-456e-4fd1-88e5-8070e43d6714
                  title_number: PMD107
                  official_search_of_whole_with_priority:
                    priority_type: Purchase
                    property_description: 28a Richmond Avenue, Basingstoke, RG38 8DJ
                    search_from_date: 2022-02-12
                    continue_application_if:
                      - NAME_MISMATCH_ON_REGISTER
                      - DEVELOPER_TITLE
                    registered_proprietors_details_or_applicants_for_first_registration: Smith
                    applicant_party: Joe Bloggs and Jane Bloggs
                  external_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  customer_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  expected_price:
                    gross_price_amount: 3.00
                    net_price_amount: 3
                    vat_amount: 0.75
                    currency_id: GBP
                  contact:
                    - name: John Smith
                      telephone_number: stringstr
              '422 - closed title':
                value:
                  message_id: dfcacc5e-456e-4fd1-88e5-8070e43d6714
                  title_number: PMD108
                  official_search_of_whole_with_priority:
                    priority_type: Purchase
                    property_description: 28a Richmond Avenue, Basingstoke, RG38 8DJ
                    search_from_date: 2022-02-12
                    continue_application_if:
                      - NAME_MISMATCH_ON_REGISTER
                      - DEVELOPER_TITLE
                    registered_proprietors_details_or_applicants_for_first_registration: Smith
                    applicant_party: Joe Bloggs and Jane Bloggs
                  external_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  customer_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  expected_price:
                    gross_price_amount: 3.00
                    net_price_amount: 3
                    vat_amount: 0.75
                    currency_id: GBP
                  contact:
                    - name: John Smith
                      telephone_number: stringstr
              '422 - future date - not pending first registration':
                value:
                  message_id: dfcacc5e-456e-4fd1-88e5-8070e43d6714
                  title_number: PMD109
                  official_search_of_whole_with_priority:
                    priority_type: Purchase
                    property_description: 28a Richmond Avenue, Basingstoke, RG38 8DJ
                    search_from_date: 2099-02-12
                    continue_application_if:
                      - NAME_MISMATCH_ON_REGISTER
                      - DEVELOPER_TITLE
                    registered_proprietors_details_or_applicants_for_first_registration: Smith
                    applicant_party: Joe Bloggs and Jane Bloggs
                  external_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  customer_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  expected_price:
                    gross_price_amount: 3.00
                    net_price_amount: 3
                    vat_amount: 0.75
                    currency_id: GBP
                  contact:
                    - name: John Smith
                      telephone_number: stringstr
              '422 - developer title - "continue application if" field does not include "developer_title"':
                value:
                  message_id: dfcacc5e-456e-4fd1-88e5-8070e43d6714
                  title_number: PMD110
                  official_search_of_whole_with_priority:
                    priority_type: Purchase
                    property_description: 28a Richmond Avenue, Basingstoke, RG38 8DJ
                    search_from_date: 2022-02-12
                    continue_application_if:
                      - NAME_MISMATCH_ON_REGISTER
                    registered_proprietors_details_or_applicants_for_first_registration: Smith
                    applicant_party: Joe Bloggs and Jane Bloggs
                  external_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  customer_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  expected_price:
                    gross_price_amount: 3.00
                    net_price_amount: 3
                    vat_amount: 0.75
                    currency_id: GBP
                  contact:
                    - name: John Smith
                      telephone_number: stringstr
              '422 - expected fee too low - "continue application if" field does not include "actual_fee_exceeds_expected_fee"':
                value:
                  message_id: dfcacc5e-456e-4fd1-88e5-8070e43d6714
                  title_number: PMD111
                  official_search_of_whole_with_priority:
                    priority_type: Purchase
                    property_description: 28a Richmond Avenue, Basingstoke, RG38 8DJ
                    search_from_date: 2022-02-12
                    continue_application_if:
                      - NAME_MISMATCH_ON_REGISTER
                      - DEVELOPER_TITLE
                    registered_proprietors_details_or_applicants_for_first_registration: Smith
                    applicant_party: Joe Bloggs and Jane Bloggs
                  external_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  customer_reference:
                    reference: GB000123Z
                    allocated_by: AAA Conveyancers
                    description: Reference description
                  expected_price:
                    gross_price_amount: 2.90
                    net_price_amount: 3
                    vat_amount: 0.75
                    currency_id: GBP
                  contact:
                    - name: John Smith
                      telephone_number: stringstr

      responses:
        '201':
          description: Official Search of Whole with Priority completed. Search result enclosed
          content:
            application/json:
              schema:
                type: object
                required:
                  - 'data'
                properties:
                  data:
                    $ref: '#/components/schemas/OfficialSearchCreatedResponseData'
              examples:
                'Successful Request with No Adverse Entries':
                  value:
                    data:
                      id: "001"
                      hmlr_reference: "0000000"
                      external_reference:
                        reference: AA0
                        allocated_by: AA0
                        description: AA0
                      actual_price:
                        gross_price_amount: 3.0
                        currency_id: GBP
                      certificate:
                        type: ATTACHMENT
                        attachment: omitted
                      official_search_data:
                        search_from_date: 2022-04-12
                        has_register_changed: false
                        has_advisory_entries: false
                        official_search_number: 300-A1-AA
                        certificate_timestamp: 2022-11-25T10:03:21
                        priority_period_expiry_date: 2023-01-10
                        title_number: PMD100
                        applicants: Joe Bloggs and Jane Bloggs
                        result_entries:
                          register_status_entry:
                            entry_text: Since 8 April 2022 no adverse entries have been made.
                        key_number: 12345678
                'Successful Response with Proprietor Name Mismatch':
                  value:
                    data:
                      id: "001"
                      hmlr_reference: "0000001"
                      external_reference:
                        reference: AA0
                        allocated_by: AA0
                        description: AA0
                      actual_price:
                        gross_price_amount: 3.0
                        currency_id: GBP
                      certificate:
                        type: ATTACHMENT
                        attachment: omitted
                      official_search_data:
                        search_from_date: 2022-04-12
                        has_register_changed: false
                        has_advisory_entries: true
                        proprietor_names:
                          - "JOHN SMITH"
                          - "JOAN SMITH"
                        official_search_number: 300-A1-AA
                        certificate_timestamp: 2022-11-25T10:03:21
                        priority_period_expiry_date: 2023-01-10
                        title_number: PMD101
                        applicants: Joe Bloggs and Jane Bloggs
                        result_entries:
                          register_status_entry:
                            entry_text: Since 8 April 2022 no adverse entries have been made.
                          advisory_entries:
                            - entry_text: > 
                                Your search has been completed despite the fact that the names of the
                                registered proprietor(s) given in your application do not agree with those shown on the register.
                                The names in the register are John Smith and Joan Smith. Please ensure that the correct names
                                appear in any instrument lodged for registration and where necessary appropriate evidence to account
                                for the discrepancy accompanies the application.
                              name_mismatch:
                                registered_proprietor_names:
                                  - "JOHN SMITH"
                                  - "JOAN SMITH"
                        key_number: 12345678
                'Successful Request with New Edition of Register and Commonhold Title':
                  value:
                    data:
                      id: "001"
                      hmlr_reference: "0000002"
                      external_reference:
                        reference: AA0
                        allocated_by: AA0
                        description: AA0
                      actual_price:
                        gross_price_amount: 3.0
                        currency_id: GBP
                      certificate:
                        type: ATTACHMENT
                        attachment: omitted
                      official_search_data:
                        search_from_date: 2022-04-12
                        has_register_changed: true
                        has_advisory_entries: true
                        official_search_number: 300-A1-AA
                        certificate_timestamp: 2022-11-25T10:03:21
                        priority_period_expiry_date: 2023-01-10
                        title_number: PMD102
                        applicants: Joe Bloggs and Jane Bloggs
                        result_entries:
                          register_status_entry:
                            entry_text: >
                              Since 5 August 2020 a new edition of the register has been opened and an
                              official copy dated 25 November 2022 and timed at 10:03:21 showing the entries
                              subsisting then is enclosed. The result is subject to such entries. If further
                              official search applications are made the 'search from' date to be quoted must
                              be the date of the official copy.
                          advisory_entries:
                            - entry_text: >
                                The title number referred to in the result comprises a commonhold unit
                                within a commonhold development. The development consists of a common parts title
                                registered under title number PMD099 and individual commonhold unit titles. If you
                                wish to obtain a complete list of the commonhold unit titles, you should apply
                                for a search of the index map in form SIM and quote the common parts title number.
                                Under the current Land Registration Fee Order, a fee may be payable for this service.
                                You can obtain Practice Guide 60 Commonhold from any of our offices or from our
                                Internet site www.gov.uk/land-registry. The Practice Guide contains information
                                about commonhold registrations.
                              commonhold_title:
                                commonhold_title_number: PMD099
                          key_number: 12345678
                'Successful Request with New Edition of Register and Prior Pending Official Search and Proprietor Name Mismatch and Commonhold Title':
                  value:
                    data:
                      id: "001"
                      hmlr_reference: "0000003"
                      external_reference:
                        reference: AA0
                        allocated_by: AA0
                        description: AA0
                      actual_price:
                        gross_price_amount: 3.0
                        currency_id: GBP
                      certificate:
                        type: ATTACHMENT
                        attachment: omitted
                      official_search_data:
                        search_from_date: 2022-04-12
                        has_register_changed: true
                        has_advisory_entries: true
                        proprietor_names:
                          - "JOHN SMITH"
                          - "JOAN SMITH"
                        official_search_number: 300-A1-AA
                        certificate_timestamp: 2022-11-25T10:03:21
                        priority_period_expiry_date: 2023-01-10
                        title_number: PMD103
                        applicants: Joe Bloggs and Jane Bloggs
                        result_entries:
                          register_status_entry:
                            entry_text: >
                              Since 5 August 2020 a new edition of the register has been opened and an
                              official copy dated 25 November 2022 and timed at 10:03:21 showing the entries
                              subsisting then is enclosed. The result is subject to such entries. If further
                              official search applications are made the 'search from' date to be quoted must
                              be the date of the official copy.
                          advisory_entries:
                            - entry_text: >
                                Your search has been completed despite the fact that the names of the
                                registered proprietor(s) given in your application do not agree with those
                                shown on the register. The names in the register are John Smith and Joan Smith.
                                Please ensure that the correct names appear in any instrument lodged for
                                registration and where necessary appropriate evidence to account for the
                                discrepancy accompanies the application.
                              name_mismatch:
                                registered_proprietor_names:
                                  - "JOHN SMITH"
                                  - "JOAN SMITH"
                            - entry_text: >
                                An official search certificate dated 15 November 2022 and timed at 12:27:21
                                has been issued to protect an intending CHARGE in favour of SANTANDER PLC
                                affecting the whole of the registered title. The relative priorities conferred
                                by the issue of two or more official search certificates are governed by the
                                provisions of rule 153 of the Land Registration Rules 2003.
                            - entry_text: >
                                The title number referred to in the result comprises a commonhold unit
                                within a commonhold development. The development consists of a common parts
                                title registered under title number PMD099 and individual commonhold unit titles.
                                If you wish to obtain a complete list of the commonhold unit titles, you should
                                apply for a search of the index map in form SIM and quote the common parts title
                                number. Under the current Land Registration Fee Order, a fee may be payable for
                                this service. You can obtain Practice Guide 60 Commonhold from any of our offices
                                or from our Internet site www.gov.uk/land-registry. The Practice Guide contains
                                information about commonhold registrations.
                              commonhold_title:
                                commonhold_title_number: PMD099
                          pending_official_searches_of_whole:
                            - certificate_timestamp: 2022-11-15T12:27:21.152924
                              priority_type: Charge
                              applicant: Santander PLC
                          key_number: 12345678


        '202':
          description: Official Search of Whole with Priority accepted however not completed because manual processing is required
          content:
            application/json:
              schema:
                type: object
                required:
                  - 'data'
                properties:
                  data:
                    $ref: '#/components/schemas/OfficialSearchAcceptedResponseData'
              examples:
                'Manual Processing Required':
                  value:
                    data:
                      id: dfcacc5e-456e-4fd1-88e5-8070e43d6714
                      acknowledgement_message: We have accepted your application for an official search with priority. Priority
                        begins now and expires on 24 May 2022.
                      hmlr_reference: J111AAA
                      acknowledgement_code: BG20001
                'Submission Out of Hours':
                  value:
                    data:
                      id: dfcacc5e-456e-4fd1-88e5-8070e43d6714
                      expected_response_at: 2022-12-12T08:44:30.244Z
                      acknowledgement_message: Service is not currently available. System has queued your request, please poll at
                        specified time
                      acknowledgement_code: BG20002


        '4XX':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                '409 - Existing Message Id':
                  value:
                    errors:
                      - code: BG40011
                        detail: Message ID has already been submitted
                        status: 409
                        trace_id: c62e9b3f-e523-4f04-a941-c6cf0d60c080
                        title: Existing message id
                '422 - Invalid Title':
                  value:
                    errors:
                      - code: bg.title.invalid
                        detail: Title number is invalid
                        status: 422
                        trace_id: c62e9b3f-e523-4f04-a941-c6cf0d60c080
                        title: Invalid title
                '422 - Caution Title':
                  value:
                    errors:
                      - code: bg.title.caution
                        detail: Official Search cannot be lodged against a Caution Title
                        status: 422
                        trace_id: c62e9b3f-e523-4f04-a941-c6cf0d60c080
                        title: Caution title
                '422 - Closed Title':
                  value:
                    errors:
                      - code: bg.title.closed
                        detail: Title number is closed
                        status: 422
                        trace_id: c62e9b3f-e523-4f04-a941-c6cf0d60c080
                        title: Closed title
                '422 - Future Date':
                  value:
                    errors:
                      - code: bg.title.futuredate
                        detail: Search from date is invalid
                        status: 422
                        trace_id: c62e9b3f-e523-4f04-a941-c6cf0d60c080
                        title: Search from date is in the future
                '422 - Developer Title':
                  value:
                    errors:
                      - code: bg.title.developertitle
                        detail: This is a developing title. If you intend to take a registrable disposition of part you should
                          apply for an official search with priority of part.
                        status: 422
                        trace_id: c62e9b3f-e523-4f04-a941-c6cf0d60c080
                        title: Developer title and not continue
                '422 - Fee Mismatch':
                  value:
                    errors:
                      - code: bg.title.feemismatch
                        detail: Fee Amount provided does not match with the fee calculated by Land Registry
                        status: 422
                        trace_id: c62e9b3f-e523-4f04-a941-c6cf0d60c080
                        title: Fee mismatch and not continue.
                        
        '5XX':        
          $ref: '#/components/responses/DefaultErrorResponse'   

components:
  responses:
    DefaultErrorResponse:
      description: An error has occurred.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            '504 - Gateway Timeout':
              value:
                errors:
                  - code: BG50004
                    detail: The gateway has timed out.
                    status: '504'
                    trace_id: c62e9b3f-e523-4f04-a941-c6cf0d60c080
                    title: An error has occurred
                    

  schemas:
  # Requests
    OfficialSearchRequest:
      required:
        - "message_id"
        - "title_number"
        - "external_reference"
        - "customer_reference"
        - "contact"
        - "official_search_of_whole_with_priority"
      properties:
        message_id:
          $ref: '#/components/schemas/OfficialSearchId'
        title_number:
          $ref: '#/components/schemas/TitleNumber'
        official_search_of_whole_with_priority:
          $ref: '#/components/schemas/OfficialSearchOfWholeWithPriority'
        external_reference:
          $ref: '#/components/schemas/Reference'
        customer_reference:
          $ref: '#/components/schemas/Reference'
        expected_price:
          $ref: '#/components/schemas/Price'
        contact:
          type: array
          minimum: 1
          items:
            $ref: '#/components/schemas/Contact'

  # Responses
    OfficialSearchCreatedResponseData:
      description: This is the Business Gateway confirmation response to the External System for applications that generate an automatic response including a result PDF
      type: object
      required:
        - "hmlr_reference"
        - "external_reference"
        - "actual_price"
        - "certificate"
      properties: 
        id:
          $ref: '#/components/schemas/OfficialSearchId'
        hmlr_reference: 
          $ref: '#/components/schemas/HMLRReference'
        external_reference:
          $ref: '#/components/schemas/Reference'
        actual_price:
          $ref: '#/components/schemas/Price'
        certificate:
          $ref: '#/components/schemas/Certificate'
        warning_message:
          type: string
          description: The search has been lodged, but supplementary data may not be available.
          example: "Result entries are not available as data. Please read the attached OS1 result."
        acknowledgement_message:
          $ref: '#/components/schemas/AcknowledgementMessage'
        official_search_data:
          $ref: '#/components/schemas/OfficialSearchData'

    OfficialSearchAcceptedResponseData: 
      description: This is the the Business Gateway confirmation response to the External System for applications that did not generate a successful completion response
      type: object
      required:
        - "id"
        - "acknowledgement_message"
      properties:
        id:
          $ref: '#/components/schemas/OfficialSearchId'
        expected_response_at:
          type: string
          format: date-time
          description: The expected time when Business Gateway will try to process the queued request.
        acknowledgement_message:
          $ref: '#/components/schemas/AcknowledgementMessage'
        hmlr_reference: 
          $ref: '#/components/schemas/HMLRReference'
        acknowledgement_code:
          type: string
          example: BG200XX Manual Processing
          description: An acknowledgement code in support of the status of the submitted Official Search

    ErrorResponse:
      description: A response for an unsuccessful result.
      type: object
      properties:
        errors:
          description: A collection of one or more errors as to why the API request failed.
          type: array
          items:
            $ref: '#/components/schemas/Error'

  # Errors        
    Error:
      type: object
      description: An error response for an unsuccessful request.
      required:
        - code
        - detail
      properties:
        code:
          description: The code related to this error, see documentation for more information.
          type: string
        detail:
          description: The descriptive reason behind an error.
          type: string
        status:
          description: The http status code related to this error.
          type: string
          example: '503'
        trace_id:
          type: string
          description: A trace identifier for this request.
          example: c62e9b3f-e523-4f04-a941-c6cf0d60c080
        title:
          type: string
          description: A short summary of the problem that does not change from occurrence to occurrence of the problem.
        source:
          $ref: '#/components/schemas/Source'

  # Other  
    AcknowledgementMessage:
      type: string
      example: "We have accepted your application for an official search with priority. Priority begins now and expires on 24 May 2022."
      description: "An acknowledgement in support of the status of the submitted Official Search"

    AdvisoryEntries:
      type: array
      description: "Advisory entries as shown on the OS1R result"
      minimum: 1
      items:
        $ref: '#/components/schemas/AdvisoryEntry'

    AdvisoryEntry:
      type: object
      description: "An individual advisory entry with unstructured data"
      required:
        - "entry_text"
      properties:
        entry_text:
          type: string
        name_mismatch:
          $ref: '#/components/schemas/NameMismatch'
        commonhold_title:
          $ref: '#/components/schemas/CommonholdTitle'
        warning_message:
          type: string
          description: The search has been lodged, but supplementary data may not be available.
          example: "Advisory entries are not available as data. Please read the attached OS1 result."

# Unable to use one of as openapi-generator does not support. Using abstract class with discriminator 
    Certificate:
      type: object
      description: Object holding either link or byte string of the certificate. If type is 'link' there will be a ling to download the certificate . If the type is 'attachment' there will be a base64 encoded string which has the contents of the certificate.
      required:
        - type
        - attachment
      properties:
        type: 
          type: string
          enum:
            - LINK
            - ATTACHMENT
        link: 
          type: string
          description: 'S3 link to download pdf certificate'
        attachment:
          type: string
          format: byte
          description: Base64-encoded contents of the pdf certificate

    CertificateTimestamp:
      description: "The certificate date and time of a pending official search of whole"
      type: string
      format: date-time

    CommonholdTitle:
      type: object
      description: "Provided if the searched for title number is part of a commonhold title"
      required:
        - "commonhold_title_number"
      properties:
        commonhold_title_number:
          $ref: '#/components/schemas/TitleNumber'

    Contact:
      type: object
      description: The information relevant to a person or organization that acts as a point of contact with another person or organization
      required:
        - "name"
        - "telephone_number"
      properties:
        name: 
          type: string
          description: The name of this contact person or department
          minLength: 1
          maxLength: 100
          example: John Smith
        telephone_number:
          $ref: '#/components/schemas/PhoneNumber'
    
    CurrencyCode:
        type: string
        description: The currency code to be used inline with standard ISO 4217 code identifying a currency.
        minLength: 3
        maxLength: 3
        example: GBP

    HMLRReference:
      description: A unique reference given to identify a particular request, order or instruction in the system of the organisation allocating it
      type: string
      maxLength: 7
      example: J111AAA

    NameMismatch:
      type: object
      description: "Provided if the value of request object registered_proprietors_details_or_applicants_for_first_registration does not match with Land Registry's proprietorship register"
      required:
        - "registered_proprietor_names"
      properties:
        registered_proprietor_names:
          type: array
          minimum: 1
          maximum: 4
          items:
            type: string
          example: ["John Smith","Jane Smith"]

    OfficialCopyTimestamp:
      description: "The date and time of an official copy of a register"
      type: string
      format: date-time

    OfficialSearchData:
      type: object
      required:
        - "search_from_date"
        - "title_number"
        - "applicants"
      properties:
        search_from_date:
          type: string
          format: date
          description: The date falling within the definition of search from date in rule 131 of the Land Registration Rules 2003
        has_register_changed:
          type: boolean
          description: Indicates if the register has changed since the Search from date supplied in the request
        has_advisory_entries:
          type: boolean
          description: Indicates if the response has any advisory entries
        proprietor_names:
          type: array
          minimum: 0
          maximum: 4
          description: Provided if the value of request object registered_proprietors_details_or_applicants_for_first_registration does not match with Land Registry's proprietorship register
          items: 
            type: string
        official_search_number:
          type: string
          example: "124-A0-B8"
          description: "The Official Search Number, also known as Certificate Number, as shown in the result PDF certificate"
        certificate_timestamp:
          $ref: '#/components/schemas/CertificateTimestamp'
        priority_period_expiry_date:
          type: string
          format: date
          description: The date at which the priority period ends as defined in rule 131 of the Land Registration Rules 2003
        title_number:
          $ref: '#/components/schemas/TitleNumber'
        applicants:
          type: string
          example: "John Smith and Jane Smith"
          description: The full name(s) of the registered proprietor(s) of the registered estate in the title, or the person(s) applying for first registration of the property
        result_entries:
          $ref: '#/components/schemas/ResultEntries'
          description: Unstructured text from the OS1R PDF, in case of partial success it may be missing.
        pending_official_searches_of_whole:
          type: array
          items:
            $ref: '#/components/schemas/PendingOfficialSearchesOfWhole'
        key_number:
          type: string
          example: "1234567"
          description: A unique identifier for a user account
        
    OfficialSearchId:
      type: string
      minLength: 5
      maxLength: 50
      pattern: ^([a-zA-Z0-9][a-zA-Z0-9\-]*)$
      example:
        dfcacc5e-456e-4fd1-88e5-8070e43d6714
      description: A unique character string, (i.e. a finite set of characters) generally in the form of words of a language, used by end user to get the status update of their request.

    OfficialSearchOfWholeWithPriority:
      type: object
      required:
        - "priority_type"
        - "property_description"
        - "registered_proprietors_details_or_applicants_for_first_registration"
        - "continue_application_if"
        - "applicant_party"
      properties:
        priority_type:
          $ref: '#/components/schemas/PriorityType'
        property_description:
          type: string
          minLength: 1
          maxLength: 130
          pattern: ^(.*\S.*)$
          description: This will be used if the proprietor names do not match and the CMS System wants to continue with manual  investigation without warning. This will also be used if Title is not computerised and the CMS System wants to continue with manual  investigation without warning
          example: 28a Richmond Avenue, Basingstoke, RG38 8DJ 
        search_from_date:
          type: string
          format: date
          description: If the Is First Registration = FALSE the Search From Date is mandatory and is the date falling within the defintition of search from date in rule 131 of the Land Registration rules 2003. Search From Date restricts dates prior to 1800-01-01.
          example: 2022-02-12
        continue_application_if: 
          type: array
          minimum: 0
          examples:
            - ["NAME_MISMATCH_ON_REGISTER", "DEVELOPER_TITLE"]
            - []
          items:
            type: string
            enum:
              - NAME_MISMATCH_ON_REGISTER
              - ACTUAL_FEE_EXCEEDS_EXPECTED_FEE
              - PENDING_SEARCHES_OF_PART
              - DEVELOPER_TITLE
            description: >
              Cases to allow the application to continue without warning. Available values:
               * 'NAME_MISMATCH_ON_REGISTER' - Used if the proprietor names do not match and the CMS System wants to continue without warning
               * 'ACTUAL_FEE_EXCEEDS_EXPECTED_FEE' - Used if the actual fee exceeds the expected fee and the CMS System wants to continue without warning
               * 'PENDING_SEARCHES_OF_PART' - Used if there are pending searches of part against the quoted title number and the CMS System wants to continue without warning
               * 'DEVELOPER_TITLE' - Used if the quoted title number is a developer title and the CMS System wants to continue without warning
               * If none of the above cases apply, simply use an empty array [].
        registered_proprietors_details_or_applicants_for_first_registration:
          type: string
          description: Name(s) of the registered proprietor(s) as on the register required for OS1 OR the person who is applying for first registration, e.g. the owner (NOT the conveyancer sending the application)
          minLength: 1
          maxLength: 100
          pattern: ^(.*\S.*)$
          example: Smith
        applicant_party:
          type: string
          description: The full name(s) of the registered proprietor(s) of the registered estate in the title, or the person(s) applying for first registration of the property. If there are more than two, enter the first two only
          minLength: 1
          maxLength: 100
          pattern: ^(.*\S.*)$
          example: Acme Bank PLC
    
    PendingOfficialSearchesOfWhole:
      type: object
      required:
        - "certificate_timestamp"
        - "priority_type"
        - "applicant"
      properties:
        certificate_timestamp:
          $ref: '#/components/schemas/CertificateTimestamp'
        priority_type:
          $ref: '#/components/schemas/PriorityType'
        applicant:
          type: string
          description: The name of the applicants from the applicant_pending_search
       
    PhoneNumber:
      type: string
      description: Contact phone number
      minLength: 9
      maxLength: 50

    Price:
      type: object
      description: Information about price
      properties:
        gross_price_amount:
          type: number
          description: The gross price is the price including the VAT. If the VAT is zero then the Gross and Net Price will be the same
          minimum: 0
          example: 3.75
        net_price_amount:
          type: number
          description: The Net Price is the amount before the VAT is added on. If the VAT is zero then the Gross and Net Price will be the same
          minimum: 0
          example: 3.0
        vat_amount:
          type: number
          description: This is the amount of the VAT
          minimum: 0
          example: 0.75
        currency_id:
          $ref: '#/components/schemas/CurrencyCode'
   
    PriorityType:
      type: string
      enum: ["Purchase", "Lease", "Charge"]
      description: The disposition that the search is intended to protect, namely, purchase, lease or charge

    Reference:
      type: object
      required:
        - "reference"
      description: A unique reference given to identify a particular request, order or instruction in the system of the organisation allocating it with the ability to associate the name of the Company that has allocated it
      properties:
        reference:
          type: string
          description: A unique reference given to identify a particular request, order or instruction in the system of the organisation allocating it.
          minLength: 1
          maxLength: 25
          pattern: ^([A-Za-z0-9\s~!''@#$%\(\)\*\+,\-\./:;<\?\[\]\{\}\^£;&]*)$
          example: GB000123Z
        allocated_by:
          type: string
          description: The name of the organisation that has allocated the Reference
          minLength: 1
          maxLength: 100
          pattern: ^(.*\S.*)$
          example: AAA Conveyancers
        description: 
          type: string
          description: This field can be used to provide reference description
          minLength: 1
          maxLength: 130
          pattern: ^(.*\S.*)$
          example: Reference description

    RegisterStatusEntry:
      type: object
      description: "Entry that describes the status of the register as shown in the OS1R result"
      required:
        - "entry_text"
      properties:
        entry_text:
          type: string
          description: The text of the entry as it appears in the official search certificate
        official_copy_timestamp:
          $ref: '#/components/schemas/OfficialCopyTimestamp'

    ResultEntries:
      type: object
      description: "The Result section of the OS1R document"
      required:
        - "register_status_entry"
      properties:
        register_status_entry:
          $ref: '#/components/schemas/RegisterStatusEntry'
        advisory_entries:
          $ref: '#/components/schemas/AdvisoryEntries'
    
    Source:
      type: object
      description: An object containing references to the primary source of the error.
      properties:
        pointer:
          type: string
          description: JSON Pointer to the value in the request document that caused the error
        parameter:
          type: string
          description: A string indicating which URI query parameter caused the error
        header:
          type: string
          description: A string indicating the name of a single request header which caused the error


    TitleNumber:
      description: Provides the subject property title number which is the subject of the transaction, or on which a search is being prepared
      type: string
      minLength: 1
      maxLength: 9
      pattern: ^([a-zA-Z]{0,3}[1-9][0-9]{0,5}|[a-zA-Z]{1,3}[1-9][0-9]{0,3}[zZ])$
      example: DN958744      
      