{
  "openapi": "3.0.4",
  "info": {
    "title": "UKPIMS Integration API",
    "description": "UKPIMS - Integration API",
    "version": "v1"
  },
  "paths": {
    "/api/providers": {
      "get": {
        "tags": [
          "ProviderExport"
        ],
        "summary": "Streams providers filtered by the specified criteria as NDJSON.",
        "description": "Returns newline-delimited JSON. Each non-empty line is a complete ProviderExportResponse object and must be parsed independently. A normal line currently contains one provider in MatchingProviderRecords. Validation failures and searches with no matches are returned as a line with ErrorMessage populated in the 200 response.",
        "parameters": [
          {
            "name": "UpdatedSince",
            "in": "query",
            "description": "Returns providers updated on or after this date and time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-01-01T00:00:00Z"
          },
          {
            "name": "VerifiedAfter",
            "in": "query",
            "description": "Returns providers verified after this date and time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-01-01T00:00:00Z"
          },
          {
            "name": "VerifiedBefore",
            "in": "query",
            "description": "Returns providers verified before this date and time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-12-31T23:59:59Z"
          },
          {
            "name": "UKPRNStatus",
            "in": "query",
            "description": "Filters by provider status. Values are matched case-insensitively. If omitted, providers of all statuses are returned.",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "deactivated"
              ]
            }
          },
          {
            "name": "UKPRNS",
            "in": "query",
            "description": "Filters by one or more numeric UKPRNs. Repeat the parameter for multiple values, for example UKPRNS=10000001&UKPRNS=10000002.",
            "style": "form",
            "explode": true,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "pattern": "^[0-9]+$"
              }
            }
          },
          {
            "name": "PageNumber",
            "in": "query",
            "description": "Optional page number. Paging starts at 1; values below 1 are normalised to 1.",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "PageSize",
            "in": "query",
            "description": "Optional number of providers per page. When paging is requested, the configured default is 500 and the maximum is 5,000. Values below 1 use the default; values above the maximum are capped.",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "An NDJSON stream. Each line conforms to ProviderExportResponse.",
            "content": {
              "application/x-ndjson": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderExportResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ProviderExportResponse": {
        "type": "object",
        "description": "The JSON object written on each line of the NDJSON response.",
        "properties": {
          "ErrorMessage": {
            "type": "string",
            "nullable": true,
            "description": "An application-level validation or no-results message. This property is omitted when no error occurred."
          },
          "MatchingProviderRecords": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProviderRecord"
            }
          }
        }
      },
      "ProviderRecord": {
        "type": "object",
        "properties": {
          "UKPRN": {
            "type": "string"
          },
          "ProviderName": {
            "type": "string",
            "nullable": true
          },
          "ProviderStatus": {
            "type": "string",
            "enum": [
              "active",
              "deactivated"
            ]
          },
          "VerificationDate": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "LastUpdated": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "ICOReference": {
            "type": "string",
            "nullable": true
          },
          "SoleTrader": {
            "type": "boolean",
            "nullable": true
          },
          "LegalAddress": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ProviderAddress"
              }
            ],
            "nullable": true
          },
          "TradingAddresses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProviderAddress"
            }
          },
          "PrimaryContact": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ProviderContact"
              }
            ],
            "nullable": true
          },
          "ProviderAliases": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TradingName"
            }
          },
          "VerificationDetails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VerificationDetails"
            }
          }
        }
      },
      "ProviderAddress": {
        "type": "object",
        "properties": {
          "AddressType": {
            "type": "string",
            "nullable": true
          },
          "Address1": {
            "type": "string",
            "nullable": true
          },
          "Address2": {
            "type": "string",
            "nullable": true
          },
          "Address3": {
            "type": "string",
            "nullable": true
          },
          "Address4": {
            "type": "string",
            "nullable": true
          },
          "Town": {
            "type": "string",
            "nullable": true
          },
          "County": {
            "type": "string",
            "nullable": true
          },
          "Postcode": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "ProviderContact": {
        "type": "object",
        "properties": {
          "ContactPersonalDetails": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ContactPersonalDetails"
              }
            ],
            "nullable": true
          },
          "ContactRole": {
            "type": "string",
            "nullable": true
          },
          "ContactTelephone1": {
            "type": "string",
            "nullable": true
          },
          "ContactTelephone2": {
            "type": "string",
            "nullable": true
          },
          "ContactEmail": {
            "type": "string",
            "format": "email",
            "nullable": true
          },
          "Url": {
            "type": "string",
            "description": "An empty string is returned when no website address is available."
          }
        }
      },
      "ContactPersonalDetails": {
        "type": "object",
        "properties": {
          "PersonNameTitle": {
            "type": "string",
            "nullable": true
          },
          "PersonGivenName": {
            "type": "string",
            "nullable": true
          },
          "PersonFamilyName": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "TradingName": {
        "type": "object",
        "properties": {
          "Name": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "VerificationDetails": {
        "type": "object",
        "properties": {
          "VerificationAuthority": {
            "type": "string",
            "nullable": true
          },
          "VerificationID": {
            "type": "string",
            "nullable": true
          },
          "PrimaryVerificationSource": {
            "type": "boolean"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "ProviderExport"
    }
  ]
}
