{
  "openapi": "3.0.1",
  "info": {
    "title": "Feel The Benefit Workforce API",
    "description": "Invoice-backed payroll deductions and agreement history for one client-bound company.",
    "version": "v1"
  },
  "servers": [
    {
      "url": "{apiBaseUrl}",
      "description": "Environment base URL supplied during onboarding.",
      "variables": {
        "apiBaseUrl": {
          "default": "https://api.example.com",
          "description": "Replace with the base URL supplied in your secure integration handoff."
        }
      }
    }
  ],
  "paths": {
    "/api/v1/employers/{employerId}/salary-sacrifice": {
      "get": {
        "tags": [
          "Workforce API"
        ],
        "summary": "Get invoice-backed payroll deductions",
        "description": "Requires the Payroll.Read application role. Returns invoiced salary-sacrifice deductions for the client-bound employer.",
        "operationId": "GetSalarySacrifice",
        "parameters": [
          {
            "name": "employerId",
            "in": "path",
            "description": "Admin-issued company identifier. It must match the company bound to the calling client.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "10000000-0000-0000-0000-000000000001"
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Inclusive start date in yyyy-MM-dd format.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-10-01"
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Inclusive end date in yyyy-MM-dd format. The date window cannot span more than 12 months.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-10-31"
          },
          {
            "name": "page",
            "in": "query",
            "description": "One-based page number. Defaults to 1.",
            "schema": {
              "minimum": 1,
              "type": "integer",
              "format": "int32",
              "default": 1
            },
            "example": 1
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Number of rows per page. Defaults to 50; maximum 1000.",
            "schema": {
              "maximum": 1000,
              "minimum": 1,
              "type": "integer",
              "format": "int32",
              "default": 50
            },
            "example": 50
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkforcePayrollRowWorkforceApiPage"
                },
                "example": {
                  "data": [
                    {
                      "employeeId": "#10042",
                      "employeeName": "Alex Morgan",
                      "payrollReference": "PAY-1042",
                      "agreementReference": "#870021",
                      "invoiceNumber": "INV-2026-0042",
                      "invoiceDate": "2026-09-09",
                      "feeMonth": "2026-10",
                      "deductionAmount": 905.05,
                      "currency": "GBP"
                    }
                  ],
                  "page": 1,
                  "pageSize": 50,
                  "total": 1
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/employers/{employerId}/agreements": {
      "get": {
        "tags": [
          "Workforce API"
        ],
        "summary": "Get invoice-backed agreement history",
        "description": "Requires the HR.Read application role. Returns agreements having invoiced deductions in the requested window.",
        "operationId": "GetAgreements",
        "parameters": [
          {
            "name": "employerId",
            "in": "path",
            "description": "Admin-issued company identifier. It must match the company bound to the calling client.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "10000000-0000-0000-0000-000000000001"
          },
          {
            "name": "startDate",
            "in": "query",
            "description": "Inclusive start date in yyyy-MM-dd format.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-10-01"
          },
          {
            "name": "endDate",
            "in": "query",
            "description": "Inclusive end date in yyyy-MM-dd format. The date window cannot span more than 12 months.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-10-31"
          },
          {
            "name": "page",
            "in": "query",
            "description": "One-based page number. Defaults to 1.",
            "schema": {
              "minimum": 1,
              "type": "integer",
              "format": "int32",
              "default": 1
            },
            "example": 1
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "Number of rows per page. Defaults to 50; maximum 1000.",
            "schema": {
              "maximum": 1000,
              "minimum": 1,
              "type": "integer",
              "format": "int32",
              "default": 50
            },
            "example": 50
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkforceHrRowWorkforceApiPage"
                },
                "example": {
                  "data": [
                    {
                      "employeeId": "#10042",
                      "employeeName": "Alex Morgan",
                      "payrollReference": "PAY-1042",
                      "agreementReference": "#870021",
                      "startDate": "2026-01-15",
                      "scheduledEndDate": "2027-01-14",
                      "status": "Active",
                      "monthlyDeductions": [
                        {
                          "feeMonth": "2026-10",
                          "amount": 905.05
                        }
                      ],
                      "currency": "GBP"
                    }
                  ],
                  "page": 1,
                  "pageSize": 50,
                  "total": 1
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": {}
      },
      "WorkforceHrRow": {
        "type": "object",
        "properties": {
          "employeeId": {
            "type": "string",
            "nullable": true
          },
          "employeeName": {
            "type": "string",
            "nullable": true
          },
          "payrollReference": {
            "type": "string",
            "nullable": true
          },
          "agreementReference": {
            "type": "string",
            "nullable": true
          },
          "startDate": {
            "type": "string",
            "nullable": true
          },
          "scheduledEndDate": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "monthlyDeductions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkforceMonthlyDeduction"
            },
            "nullable": true
          },
          "currency": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "WorkforceHrRowWorkforceApiPage": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkforceHrRow"
            },
            "nullable": true
          },
          "page": {
            "type": "integer",
            "format": "int32"
          },
          "pageSize": {
            "type": "integer",
            "format": "int32"
          },
          "total": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "WorkforceMonthlyDeduction": {
        "type": "object",
        "properties": {
          "feeMonth": {
            "type": "string",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "format": "double"
          }
        },
        "additionalProperties": false
      },
      "WorkforcePayrollRow": {
        "type": "object",
        "properties": {
          "employeeId": {
            "type": "string",
            "nullable": true
          },
          "employeeName": {
            "type": "string",
            "nullable": true
          },
          "payrollReference": {
            "type": "string",
            "nullable": true
          },
          "agreementReference": {
            "type": "string",
            "nullable": true
          },
          "invoiceNumber": {
            "type": "string",
            "nullable": true
          },
          "invoiceDate": {
            "type": "string",
            "nullable": true
          },
          "feeMonth": {
            "type": "string",
            "nullable": true
          },
          "deductionAmount": {
            "type": "number",
            "format": "double"
          },
          "currency": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "WorkforcePayrollRowWorkforceApiPage": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkforcePayrollRow"
            },
            "nullable": true
          },
          "page": {
            "type": "integer",
            "format": "int32"
          },
          "pageSize": {
            "type": "integer",
            "format": "int32"
          },
          "total": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "description": "Microsoft Entra application-only OAuth 2.0. Request the API's /.default scope; delegated user tokens are rejected.",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token",
            "scopes": {
              "api://{apiApplicationId}/.default": "Application roles assigned to this client (Payroll.Read and/or HR.Read)."
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "oauth2": [
        "api://{apiApplicationId}/.default"
      ]
    }
  ]
}
