openapi: 3.1.0
info:
  title: FörderNavi API
  version: 1.0.0
  description: REST API for calculating, evaluating, and managing German public
    funding (Fördermittel).
  contact:
    name: NextGen IT Solutions GmbH
    url: https://foerdernavi.nextgenitsolutions.de
    email: support@nextgenitsolutions.de
  license:
    name: Proprietary
servers:
  - url: https://app.foerdernavi.nextgenitsolutions.de/api/v1
    description: Production
  - url: http://localhost:3000/api/v1
    description: Local development
security:
  - bearerAuth: []
tags:
  - name: Programs
    description: Funding program catalogue
  - name: Calculations
    description: Subsidy calculation engine
  - name: Matching
    description: Program matching for applicant profiles
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API-Key
      description: "API key issued via /settings/api-keys. Pass as `Authorization:
        Bearer <key>` or as `X-API-Key` header."
    apiKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
  schemas:
    Program:
      type: object
      properties:
        id:
          type: string
          minLength: 1
        name:
          type: string
          minLength: 1
        shortName:
          type: string
        provider:
          type: string
          enum:
            - BAFA
            - KFW
            - BMBF
            - BMWK
            - EU
            - Bundesland
            - Sonstige
          description: Funding body / Fördertraeger
          example: BAFA
        category:
          type: string
          enum: &a1
            - zuschuss
            - darlehen
            - buergschaft
            - steuervorteil
            - beteiligung
            - kredit
            - beratung
          description: Type of funding instrument
          example: zuschuss
        level:
          type: string
          enum: &a2
            - bundesweit
            - landesweit
            - regional
            - eu
          description: Geographic level of the funding program
          example: bundesweit
        description:
          type: string
        maxAmount:
          type: number
          minimum: 0
        minAmount:
          type: number
          minimum: 0
        subsidyRateMax:
          type: number
          minimum: 0
          maximum: 1
        deminimis:
          type: boolean
        targetGroups:
          type: array
          items:
            type: string
          default: []
        eligibleRegions:
          type: array
          items:
            type: string
          default: []
        phases:
          type: array
          items:
            type: string
          default: []
        applicationDeadline:
          type:
            - string
            - "null"
          format: date-time
        status:
          type: string
          enum:
            - aktiv
            - inaktiv
            - geplant
            - ausgelaufen
        lastUpdated:
          type: string
      required:
        - id
        - name
        - provider
        - category
        - description
        - maxAmount
        - status
        - lastUpdated
      description: A single funding program (Förderprogramm).
    ListProgramsQuery:
      type: object
      properties:
        category:
          type: string
          enum: *a1
          description: Type of funding instrument
          example: zuschuss
        level:
          type: string
          enum: *a2
          description: Geographic level of the funding program
          example: bundesweit
        region:
          type: string
          minLength: 2
          maxLength: 32
          description: Bundesland code or "bundesweit"
        limit:
          type: integer
          minimum: 1
          maximum: 100
          default: 20
        offset:
          type:
            - integer
            - "null"
          minimum: 0
          default: 0
    ListProgramsResponse:
      type: object
      properties:
        programs:
          type: array
          items:
            $ref: "#/components/schemas/Program"
        total:
          type: integer
          minimum: 0
        limit:
          type: integer
          minimum: 1
          maximum: 100
        offset:
          type: integer
          minimum: 0
      required:
        - programs
        - total
        - limit
        - offset
    ApplicantProfile:
      type: object
      properties:
        employeeCount:
          type: integer
          minimum: 0
        revenueEur:
          type: number
          minimum: 0
        balanceSheetEur:
          type: number
          minimum: 0
        federalState:
          type: string
          minLength: 2
          maxLength: 32
        industryCode:
          type: string
          minLength: 1
          maxLength: 16
        companySize:
          type: string
          enum:
            - micro
            - small
            - medium
            - large
          description: EU SME classification (Commission Recommendation 2003/361/EC)
          example: small
        isKmu:
          type: boolean
        companyAgeYears:
          type: number
          minimum: 0
        deminimisUsedEur:
          type: number
          minimum: 0
          default: 0
      required:
        - employeeCount
        - revenueEur
        - federalState
        - industryCode
      description: Applicant profile used for eligibility and matching.
    CalculationRequest:
      type: object
      properties:
        programId:
          type: string
          minLength: 1
        projectBudgetEur:
          type: number
          exclusiveMinimum: 0
        applicantProfile:
          $ref: "#/components/schemas/ApplicantProfile"
      required:
        - programId
        - projectBudgetEur
        - applicantProfile
    CumulationWarning:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        severity:
          type: string
          enum:
            - info
            - warning
            - error
      required:
        - code
        - message
        - severity
    CalculationResponse:
      type: object
      properties:
        calculationId:
          type: string
          format: uuid
        programId:
          type: string
        estimatedSubsidyEur:
          type: number
          minimum: 0
        effectiveSubsidyRate:
          type: number
          minimum: 0
          maximum: 1
        cumulationWarnings:
          type: array
          items:
            $ref: "#/components/schemas/CumulationWarning"
          default: []
        computedAt:
          type: string
          format: date-time
      required:
        - calculationId
        - programId
        - estimatedSubsidyEur
        - effectiveSubsidyRate
        - computedAt
    MatchRequest:
      type: object
      properties:
        profile:
          $ref: "#/components/schemas/ApplicantProfile"
        categories:
          type: array
          items:
            type: string
            enum: *a1
            description: Type of funding instrument
            example: zuschuss
        limit:
          type: integer
          minimum: 1
          maximum: 50
          default: 10
      required:
        - profile
    MatchEntry:
      type: object
      properties:
        programId:
          type: string
        programName:
          type: string
        score:
          type: number
          minimum: 0
          maximum: 100
        reasons:
          type: array
          items:
            type: string
          default: []
      required:
        - programId
        - programName
        - score
    MatchResponse:
      type: object
      properties:
        matches:
          type: array
          items:
            $ref: "#/components/schemas/MatchEntry"
        total:
          type: integer
          minimum: 0
      required:
        - matches
        - total
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message (German)
        code:
          type: string
        details: {}
      required:
        - error
    ValidationErrorResponse:
      allOf:
        - $ref: "#/components/schemas/ErrorResponse"
        - type: object
          properties:
            issues:
              type: array
              items:
                type: object
                properties:
                  path:
                    type: array
                    items:
                      anyOf:
                        - type: string
                        - type: number
                  message:
                    type: string
                required:
                  - path
                  - message
    XTenantId:
      type: string
      minLength: 1
      description: Tenant identifier for multi-tenant isolation
      example: t_abc123
  parameters:
    XTenantId:
      schema:
        $ref: "#/components/schemas/XTenantId"
      required: false
      name: X-Tenant-Id
      in: header
paths:
  /programs:
    get:
      operationId: listPrograms
      summary: List funding programs
      description: Paginated list of German funding programs (Förderprogramme).
      tags:
        - Programs
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            enum: *a1
            description: Type of funding instrument
            example: zuschuss
          required: false
          name: category
          in: query
        - schema:
            type: string
            enum: *a2
            description: Geographic level of the funding program
            example: bundesweit
          required: false
          name: level
          in: query
        - schema:
            type: string
            minLength: 2
            maxLength: 32
            description: Bundesland code or "bundesweit"
          required: false
          name: region
          in: query
        - schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
          required: false
          name: limit
          in: query
        - schema:
            type:
              - integer
              - "null"
            minimum: 0
            default: 0
          required: false
          name: offset
          in: query
        - $ref: "#/components/parameters/XTenantId"
      responses:
        "200":
          description: Paginated list of programs
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ListProgramsResponse"
        "400":
          description: Invalid query parameters
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ValidationErrorResponse"
        "401":
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /programs/{id}:
    get:
      operationId: getProgramById
      summary: Get a single funding program
      tags:
        - Programs
      security:
        - bearerAuth: []
      parameters:
        - schema:
            type: string
            minLength: 1
            example: zim-innovation
          required: true
          name: id
          in: path
        - $ref: "#/components/parameters/XTenantId"
      responses:
        "200":
          description: The requested program
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Program"
        "404":
          description: Program not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /calculations:
    post:
      operationId: createCalculation
      summary: Calculate subsidy for a program
      description: Runs the kalkulation engine against the supplied applicant profile
        and program.
      tags:
        - Calculations
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/XTenantId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CalculationRequest"
      responses:
        "200":
          description: Calculation result
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CalculationResponse"
        "400":
          description: Invalid request body
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ValidationErrorResponse"
        "401":
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /matches:
    post:
      operationId: findMatches
      summary: Find matching funding programs for a profile
      tags:
        - Matching
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/XTenantId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MatchRequest"
      responses:
        "200":
          description: Ranked list of matching programs
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MatchResponse"
        "400":
          description: Invalid request body
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ValidationErrorResponse"
        "429":
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
webhooks: {}
