{
  "openapi": "3.1.0",
  "info": {
    "title": "IA Home Office Integration API",
    "description": "API for setting Home Office statutory timeframe status.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "http://localhost",
      "description": "Generated server url"
    }
  ],
  "tags": [
    {
      "name": "Set Home Office statutory timeframe status controller",
      "description": "Set Home Office statutory timeframe status"
    }
  ],
  "paths": {
    "/home-office-statutory-timeframe-status": {
      "post": {
        "tags": [
          "Set Home Office statutory timeframe status controller"
        ],
        "summary": "Set Home Office statutory timeframe status",
        "operationId": "updateHomeOfficeStatutoryTimeframeStatus",
        "parameters": [
          {
            "name": "ServiceAuthorization",
            "in": "header",
            "required": true,
            "description": "Service-to-service bearer token",
            "schema": {
              "type": "string",
              "example": "Bearer eyJhbGciOi..."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HomeOfficeStatutoryTimeframeDto"
              },
              "example": {
                "hmctsReferenceNumber": "PA/12345/2026",
                "uan": "1234-5678-9012-3456",
                "familyName": "Smith",
                "givenNames": "John Michael",
                "dateOfBirth": "1990-01-01",
                "timeStamp": "2026-06-03T10:15:30Z",
                "stf24weekCohorts": [
                  {
                    "name": "cohort-a",
                    "included": true
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Set Home Office statutory timeframe status successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HomeOfficeStatutoryTimeframeDto"
                }
              }
            }
          },
          "400": {
            "description": "Home Office statutory timeframe status request body failed validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "The 24-week status could not be set. Please check the format of the HTTP headers and message body."
                }
              }
            }
          },
          "401": {
            "description": "This endpoint requires authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Missing ServiceAuthorization header (S2S token required)"
                }
              }
            }
          },
          "403": {
            "description": "Calling service is not authorised to use this endpoint",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Service is not authorised to access endpoint"
                }
              }
            }
          },
          "404": {
            "description": "Case not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "The 24-week status could not be set. The HMCTS appeal reference number does not correspond to any records in HMCTS systems."
                }
              }
            }
          },
          "409": {
            "description": "Statutory timeframe status has already been set for this case",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "410": {
            "description": "Case gone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Case incompatible with supplied 24-week status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "The 24-week status could not be set. Please report this to HMCTS."
                }
              }
            }
          }
        },
        "security": [
          {
            "ServiceAuthorization": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "HomeOfficeStatutoryTimeframeDto": {
        "type": "object",
        "required": [
          "hmctsReferenceNumber",
          "familyName",
          "givenNames",
          "dateOfBirth",
          "timeStamp",
          "stf24weekCohorts"
        ],
        "properties": {
          "hmctsReferenceNumber": {
            "type": "string",
            "description": "HMCTS appeal reference number",
            "pattern": "^(RP|PA|EA|HU|DC|EU|AG)/[0-9]{5}/[0-9]{4}$",
            "example": "PA/12345/2026"
          },
          "uan": {
            "type": "string",
            "description": "Unique Application Number",
            "pattern": "^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}$",
            "example": "1234-5678-9012-3456"
          },
          "familyName": {
            "type": "string",
            "example": "Smith"
          },
          "givenNames": {
            "type": "string",
            "example": "John Michael"
          },
          "dateOfBirth": {
            "type": "string",
            "format": "date",
            "example": "1990-01-01"
          },
          "timeStamp": {
            "type": "string",
            "format": "date-time",
            "example": "2026-06-03T10:15:30Z"
          },
          "stf24weekCohorts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Stf24WeekCohortDto"
            }
          }
        }
      },
      "Stf24WeekCohortDto": {
        "type": "object",
        "required": [
          "name",
          "included"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "STF 24-week cohort name",
            "example": "cohort-a"
          },
          "included": {
            "type": "boolean",
            "description": "Indicates whether the cohort is included",
            "example": true
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "ServiceAuthorization": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "ServiceAuthorization": []
    }
  ]
}
