openapi: 3.1.0
info:
  title: beantragt.ai Backend API
  version: 1.0.0
  summary: Stable API v1 contract for external and staff clients.
  description: |
    This OpenAPI document is the curated API v1 surface for beantragt.ai.
    It documents only routes that are intended for external API clients or
    explicit staff clients.

    Citizen-facing v1 routes use UUIDs, slugs and public tokens. Admin routes, first-party Nuxt proxies and legacy
    endpoints are outside this contract.
servers:
  - url: https://backend.example.org
    description: Example origin. The internal HTTPS origin of the installation replaces it.
tags:
  - name: Public Auth
    description: Public citizen authentication session helpers.
  - name: Public Config
    description: Public jurisdiction bootstrap configuration.
  - name: Public Content
    description: Public jurisdiction content pages, HTML info sections and editorial downloads such as privacy policy, legal notice and form leaflets.
  - name: Public Forms
    description: Public form catalogue and public FormSchema projection.
  - name: Public Applications
    description: Public application submission, authenticated reads and comments.
  - name: Staff Applications
    description: Scoped staff application reads and casework operations. Integrations use a dedicated staff account (service-account profiles are refused) with HTTP Basic over TLS on the internal network only. List entries expose current status and last update. Detail includes a timeline of visible status changes, collapsing consecutive identical statuses.
  - name: Public Status
    description: Public no-PII status lookup by one-time status token.
x-beantragt-contract:
  status: public-v1
  apiFirstReady: true
  identifiers:
    - jurisdiction slugs
    - organisation slugs
    - FormSchema UUIDs
    - Application UUIDs
    - public status tokens
    - attachment UUIDs
    - comment UUIDs
    - user UUIDs
  excludes:
    - numeric Drupal entity IDs
    - admin routes
    - first-party Nuxt proxy routes
    - legacy non-v1 routes
paths:
  /api/v1/auth/request-code:
    post:
      tags:
        - Public Auth
      operationId: requestPasswordlessCodeV1
      summary: Request a passwordless email code.
      description: Starts a citizen passwordless login by sending an OTP code to the provided email address. The response never returns the code itself. It returns a session-bound challengeId that must be submitted from the same cookie session to POST /api/v1/auth/verify-code.
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PublicAuthCodeRequestV1Request"
      responses:
        "200":
          description: Passwordless code request accepted.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicAuthCodeRequestV1Response"
        "400":
          $ref: "#/components/responses/PublicBadRequestNoStore"
        "403":
          $ref: "#/components/responses/PublicForbiddenNoStore"
        "429":
          $ref: "#/components/responses/PublicRateLimitedNoStore"
        "500":
          $ref: "#/components/responses/PublicServerErrorNoStore"
  /api/v1/auth/verify-code:
    post:
      tags:
        - Public Auth
      operationId: verifyPasswordlessCodeV1
      summary: Verify a passwordless email code.
      description: Verifies an OTP code and creates a Drupal citizen session cookie. Clients must send the challengeId returned by POST /api/v1/auth/request-code from the same cookie session. The response projects only external user identifiers and does not include numeric Drupal user or applicant IDs. Staff, administrator and service-account profiles are outside this citizen auth profile.
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PublicAuthVerifyCodeV1Request"
      responses:
        "200":
          description: Passwordless verification succeeded and a citizen session is active.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
            Set-Cookie:
              $ref: "#/components/headers/SessionCookie"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicAuthSessionV1Response"
        "400":
          $ref: "#/components/responses/PublicBadRequestNoStore"
        "401":
          $ref: "#/components/responses/PublicUnauthorizedNoStore"
        "403":
          $ref: "#/components/responses/PublicForbiddenNoStore"
        "429":
          $ref: "#/components/responses/PublicRateLimitedNoStore"
        "500":
          $ref: "#/components/responses/PublicServerErrorNoStore"
  /api/v1/auth/status:
    get:
      tags:
        - Public Auth
      operationId: getAuthSessionV1
      summary: Return the current auth session.
      description: Returns an unauthenticated session envelope without a cookie, or the active citizen profile when a valid session cookie or Basic Auth profile is supplied.
      security:
        - {}
        - CitizenSessionCookie: []
        - CitizenBasicAuth: []
      responses:
        "200":
          description: Current public auth session.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicAuthSessionV1Response"
  /api/v1/auth/logout:
    post:
      tags:
        - Public Auth
      operationId: logoutAuthSessionV1
      summary: End the current cookie auth session.
      description: Logs out the current citizen session. Cookie-session clients must send X-CSRF-Token from Drupal's /session/token endpoint.
      security:
        - CitizenSessionCookie: []
      parameters:
        - $ref: "#/components/parameters/CsrfTokenHeader"
      responses:
        "200":
          description: Session ended. The response expires the Drupal session cookie when present.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
            Set-Cookie:
              $ref: "#/components/headers/SessionCookie"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicAuthSessionV1Response"
        "403":
          $ref: "#/components/responses/PublicForbiddenNoStore"
  /api/v1/jurisdictions/{slug}/config:
    get:
      tags:
        - Public Config
      operationId: getPublicJurisdictionConfigV1
      summary: Return public jurisdiction bootstrap configuration.
      description: Returns a data/meta envelope with public tenant display, theme and language data.
      security: []
      parameters:
        - name: slug
          in: path
          required: true
          schema:
            $ref: "#/components/schemas/PublicSlug"
      responses:
        "200":
          description: Public jurisdiction configuration.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicJurisdictionConfigV1Response"
              examples:
                musterstadt:
                  value:
                    data:
                      jurisdiction:
                        slug: musterstadt
                        uuid: 339d18f8-3b25-4ac9-a2d8-96e9d7d26b39
                        name: Stadt Musterstadt
                      theme:
                        primary: "#16a34a"
                        secondary: null
                        neutral: null
                      languages:
                        default: de
                        available:
                          - de
                          - en
                      general:
                        contactEmail: service@musterstadt.example
                        website: https://musterstadt.example
                        phone: +49 221 000000
                      legal:
                        legalNotice: ""
                        privacyPolicy: ""
                      customCss: ""
                    meta:
                      apiVersion: "1.0"
                      resource: jurisdictionConfig
        "404":
          description: Jurisdiction not found.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
  /api/v1/jurisdictions/{slug}/pages:
    get:
      tags:
        - Public Content
      operationId: listPublicContentPagesV1
      summary: List public jurisdiction content pages.
      description: Returns published content page route metadata such as title, optional page key, localized route slug and footer visibility. Without an organisation query, the list is scoped to the jurisdiction. With an organisation query, organisation pages are returned first and jurisdiction pages fill the gaps. Use this endpoint to build public footer or navigation links. The municipality decides which published pages appear by assigning public slugs and visibility metadata. Body HTML is not included in the list response.
      security: []
      parameters:
        - name: slug
          in: path
          required: true
          schema:
            $ref: "#/components/schemas/PublicSlug"
        - name: lang
          in: query
          required: false
          schema:
            type: string
            enum:
              - de
              - en
          description: Optional localized translation for titles and route slugs. Unsupported languages fall back to the source page.
        - $ref: "#/components/parameters/OrganisationQuery"
      responses:
        "200":
          description: Public content page list.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicContentPageListV1Response"
              examples:
                musterstadt:
                  value:
                    data:
                      - type: page
                        id: 7fd2601c-7b47-4f78-8a1d-e2a8fa372584
                        attributes:
                          key: privacy
                          title: Privacy Policy
                          langcode: en
                          changed: 1781431200
                          slug: privacy
                          path: /pages/privacy
                          footerVisible: true
                          order: 10
                      - type: page
                        id: bdecbf4a-307e-40f3-b173-28bb0d684c78
                        attributes:
                          key: legal_notice
                          title: Legal Notice
                          langcode: en
                          changed: 1781431200
                          slug: legal-notice
                          path: /pages/legal-notice
                          footerVisible: true
                          order: 20
                    meta:
                      apiVersion: "1.0"
                      resource: contentPageList
        "404":
          description: Jurisdiction not found.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
              examples:
                pageNotFound:
                  value:
                    error:
                      code: page.not_found
                      message: Page not found.
                    meta:
                      apiVersion: "1.0"
  /api/v1/jurisdictions/{slug}/pages/{identifier}:
    get:
      tags:
        - Public Content
      operationId: getPublicContentPageV1
      summary: Return one public jurisdiction content page.
      description: Returns a published content page such as privacy policy, legal notice, accessibility statement, contact, easy language or sign language. The identifier accepts the stable page key or the public slug chosen by the municipality. Without an organisation query, the page is scoped to the jurisdiction. With an organisation query, an organisation page is preferred and the jurisdiction page is used as fallback. Numeric Drupal group IDs are not part of the public contract. Body HTML is emitted only from the sanitized basic_html format, and the raw body value is always empty.
      security: []
      parameters:
        - name: slug
          in: path
          required: true
          schema:
            $ref: "#/components/schemas/PublicSlug"
        - name: identifier
          in: path
          required: true
          schema:
            type: string
            pattern: ^[a-z0-9](?:[a-z0-9_-]{0,126}[a-z0-9])?$
          description: Stable page key or public page slug.
        - name: lang
          in: query
          required: false
          schema:
            type: string
            enum:
              - de
              - en
          description: Optional localized translation. Unsupported languages fall back to the source page.
        - $ref: "#/components/parameters/OrganisationQuery"
      responses:
        "200":
          description: Public content page.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicContentPageV1Response"
              examples:
                privacy:
                  value:
                    data:
                      type: page
                      id: 7fd2601c-7b47-4f78-8a1d-e2a8fa372584
                      attributes:
                        key: privacy
                        title: Privacy Policy
                        body:
                          value: ""
                          processed: <p>This privacy policy is demo content.</p>
                          format: basic_html
                        langcode: en
                        changed: 1781431200
                    meta:
                      apiVersion: "1.0"
                      resource: contentPage
        "404":
          description: Page not found or hidden by scope.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
              examples:
                pageNotFound:
                  value:
                    error:
                      code: page.not_found
                      message: Page not found.
                    meta:
                      apiVersion: "1.0"
  /api/v1/jurisdictions/{slug}/documents:
    get:
      tags:
        - Public Content
      operationId: listPublicDocumentsV1
      summary: List public editorial documents.
      description: Returns published public downloads such as form leaflets, fee sheets, instructions or public image files. Documents are editorial content and are intentionally separate from private citizen submission attachments. Without organisation or form query parameters, the list is scoped to jurisdiction-level documents. When organisation or form is supplied, exact scoped documents are returned first and jurisdiction defaults fill the list. File bytes are served through a scope-checked download route, not through a direct webserver file URL.
      security: []
      parameters:
        - name: slug
          in: path
          required: true
          schema:
            $ref: "#/components/schemas/PublicSlug"
        - name: lang
          in: query
          required: false
          schema:
            type: string
            enum:
              - de
              - en
          description: Optional localized translation for titles and descriptions. Unsupported languages fall back to the source document.
        - $ref: "#/components/parameters/OrganisationQuery"
        - $ref: "#/components/parameters/FormQuery"
        - $ref: "#/components/parameters/PublicDocumentPlacementQuery"
      responses:
        "200":
          description: Public document list.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicDocumentListV1Response"
              examples:
                formLeaflet:
                  value:
                    data:
                      - type: publicDocument
                        id: 64b678f2-3804-4129-a69b-7dbb758e50a3
                        attributes:
                          title: Merkblatt Antragstellung
                          description:
                            value: ""
                            processed: <p>Bitte vor dem Ausfüllen lesen.</p>
                            format: basic_html
                          placement: form_sidebar
                          order: 10
                          file:
                            filename: merkblatt.pdf
                            mimeType: application/pdf
                            size: 415
                            url: /api/v1/jurisdictions/musterstadt/documents/64b678f2-3804-4129-a69b-7dbb758e50a3/file?placement=form_sidebar&organisation=citizen-services&form=4ebef1d0-c8d4-49fa-9957-0338b8fcbe17
                          form:
                            id: 4ebef1d0-c8d4-49fa-9957-0338b8fcbe17
                            title: Baugenehmigung beantragen
                          langcode: de
                          changed: 1781431200
                    meta:
                      apiVersion: "1.0"
                      resource: publicDocumentList
        "400":
          description: Invalid query, for example an unsupported placement.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
        "404":
          description: Jurisdiction, organisation or form scope not found.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
        "429":
          description: Rate limit exceeded.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
              examples:
                rateLimited:
                  value:
                    error:
                      code: rate_limit.exceeded
                      message: Too many requests. Please try again later.
                    meta:
                      apiVersion: "1.0"
  /api/v1/jurisdictions/{slug}/documents/{document_uuid}/file:
    get:
      tags:
        - Public Content
      operationId: downloadPublicDocumentFileV1
      summary: Download a public editorial document file.
      description: Streams the file bytes for a published public document through the same jurisdiction, organisation, form and placement scope contract as the public document list. The file is stored outside the public webroot and is never served through a direct `/sites/default/files/...` URL.
      security: []
      parameters:
        - name: slug
          in: path
          required: true
          schema:
            $ref: "#/components/schemas/PublicSlug"
        - name: document_uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Public document UUID from the list response.
        - $ref: "#/components/parameters/OrganisationQuery"
        - $ref: "#/components/parameters/FormQuery"
        - $ref: "#/components/parameters/PublicDocumentPlacementQuery"
      responses:
        "200":
          description: Public document file bytes.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
            Content-Disposition:
              $ref: "#/components/headers/ContentDisposition"
            X-Content-Type-Options:
              $ref: "#/components/headers/XContentTypeOptions"
          content:
            application/pdf:
              schema:
                type: string
                format: binary
            image/jpeg:
              schema:
                type: string
                format: binary
            image/png:
              schema:
                type: string
                format: binary
        "404":
          description: Document or requested scope not found.
        "429":
          description: Rate limit exceeded.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
  /api/v1/jurisdictions/{slug}/sections:
    get:
      tags:
        - Public Content
      operationId: listPublicContentSectionsV1
      summary: List public HTML content sections.
      description: Returns published HTML info sections for organisation start pages, form intros, form sidebars and submission success pages. Sections are editorial content without file bytes. Without organisation or form query parameters, the list is scoped to jurisdiction-level sections. When organisation or form is supplied, exact scoped sections are returned first and jurisdiction defaults fill the list. Body HTML is emitted only from the sanitized basic_html format, and the raw body value is always empty.
      security: []
      parameters:
        - name: slug
          in: path
          required: true
          schema:
            $ref: "#/components/schemas/PublicSlug"
        - name: lang
          in: query
          required: false
          schema:
            type: string
            enum:
              - de
              - en
          description: Optional localized translation for titles and body HTML. Unsupported languages fall back to the source section.
        - $ref: "#/components/parameters/OrganisationQuery"
        - $ref: "#/components/parameters/FormQuery"
        - $ref: "#/components/parameters/PublicSectionPlacementQuery"
      responses:
        "200":
          description: Public content section list.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicContentSectionListV1Response"
              examples:
                formIntro:
                  value:
                    data:
                      - type: contentSection
                        id: 75b678f2-3804-4129-a69b-7dbb758e50a3
                        attributes:
                          title: Vor dem Ausfüllen
                          body:
                            value: ""
                            processed: <p>Bitte lesen Sie die Hinweise vor dem Absenden.</p>
                            format: basic_html
                          placement: form_intro
                          order: 10
                          form:
                            id: 4ebef1d0-c8d4-49fa-9957-0338b8fcbe17
                            title: Baugenehmigung beantragen
                          langcode: de
                          changed: 1781431200
                    meta:
                      apiVersion: "1.0"
                      resource: contentSectionList
        "400":
          description: Invalid query, for example an unsupported placement.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
        "404":
          description: Jurisdiction, organisation or form scope not found.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
        "429":
          description: Rate limit exceeded.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
              examples:
                rateLimited:
                  value:
                    error:
                      code: rate_limit.exceeded
                      message: Too many requests. Please try again later.
                    meta:
                      apiVersion: "1.0"
  /api/v1/jurisdictions/{slug}/forms:
    get:
      tags:
        - Public Forms
      operationId: listPublicFormsV1
      summary: List public forms for a jurisdiction.
      description: Returns published internet forms for a jurisdiction and optional organisation scope.
      security: []
      parameters:
        - name: slug
          in: path
          required: true
          schema:
            $ref: "#/components/schemas/PublicSlug"
        - $ref: "#/components/parameters/OrganisationQuery"
      responses:
        "200":
          description: Public form catalogue.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicFormsV1Response"
        "404":
          description: Jurisdiction or organisation not found.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
        "429":
          description: Rate limit exceeded.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
  /api/v1/forms/{form_schema_uuid}:
    get:
      tags:
        - Public Forms
      operationId: getPublicFormV1
      summary: Return one public form schema.
      description: Returns a public allowlisted FormSchema projection by UUID.
      security: []
      parameters:
        - name: form_schema_uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - $ref: "#/components/parameters/JurisdictionQuery"
        - $ref: "#/components/parameters/OrganisationQuery"
      responses:
        "200":
          description: Public form schema.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicFormV1Response"
        "404":
          description: Form not found or hidden by scope.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
              examples:
                formNotFound:
                  value:
                    error:
                      code: form.not_found
                      message: Form not found.
                    meta:
                      apiVersion: "1.0"
        "429":
          description: Rate limit exceeded.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PublicCachePolicy"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
  /api/v1/attachments:
    post:
      tags:
        - Public Applications
      operationId: uploadPublicApplicationAttachmentV1
      summary: Upload one public application attachment.
      description: Uploads one file for a public form file field before final application submission. The upload is stored privately and scanned before a claim token is issued. FormSchema file fields may define stricter per-file limits via validation.maxSizeBytes or validation.maxFileSizeBytes; the platform cap remains 10 MB per file. Open unclaimed uploads for the same form field are also bounded by the aggregate attachment cap. Quarantined files receive no claim token and cannot be submitted or downloaded.
      security: []
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: "#/components/schemas/PublicApplicationAttachmentUploadV1Request"
      responses:
        "201":
          description: Attachment uploaded and ready to claim during application submission.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApplicationAttachmentCreatedV1Response"
        "400":
          $ref: "#/components/responses/PublicBadRequestNoStore"
        "401":
          $ref: "#/components/responses/PublicUnauthorizedNoStore"
        "404":
          description: Form not found, not public, or field is not a file field.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
              examples:
                formNotFound:
                  value:
                    error:
                      code: form.not_found
                      message: Form not found.
                    meta:
                      apiVersion: "1.0"
        "413":
          description: File or open upload quota is too large.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
              examples:
                fileTooLarge:
                  value:
                    error:
                      code: attachment.file_too_large
                      message: File exceeds the configured maximum size.
                    meta:
                      apiVersion: "1.0"
                totalSizeExceeded:
                  value:
                    error:
                      code: attachment.total_size_exceeded
                      message: Total attachment size exceeds the application limit.
                      details:
                        limit: 52428800
                    meta:
                      apiVersion: "1.0"
        "422":
          description: Unsupported extension, file content mismatch, or malware quarantine.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
              examples:
                mimeMismatch:
                  value:
                    error:
                      code: attachment.mime_mismatch
                      message: File content does not match the file extension.
                    meta:
                      apiVersion: "1.0"
                quarantined:
                  value:
                    error:
                      code: attachment.quarantined
                      message: Attachment was quarantined by malware scanning.
                      details:
                        attachmentId: 84d2566f-b9a9-4240-8a05-127efb25a3dc
                        scanStatus: quarantined
                    meta:
                      apiVersion: "1.0"
        "429":
          $ref: "#/components/responses/PublicRateLimitedNoStore"
        "500":
          $ref: "#/components/responses/PublicServerErrorNoStore"
  /api/v1/applications:
    get:
      tags:
        - Public Applications
      operationId: listOwnApplicationsV1
      summary: List authenticated citizen applications.
      description: Returns applications owned by the authenticated citizen account or claimable through the account's verified email. The endpoint uses only Application UUIDs and redacts protected data by keeping submitted field data out of the list response. Mailbox-based access requires a confirmed anonymous submission of a public form. The currently verified account address must match the first confirmed application revision.
      security:
        - CitizenSessionCookie: []
        - CitizenBasicAuth: []
      parameters:
        - $ref: "#/components/parameters/JurisdictionRequiredQuery"
        - $ref: "#/components/parameters/OrganisationQuery"
        - $ref: "#/components/parameters/LimitQuery"
        - $ref: "#/components/parameters/OffsetQuery"
        - $ref: "#/components/parameters/StaffApplicationSortQuery"
      responses:
        "200":
          description: Authenticated citizen application list.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApplicationsV1Response"
        "400":
          $ref: "#/components/responses/PublicBadRequestNoStore"
        "401":
          $ref: "#/components/responses/PublicUnauthorizedNoStore"
        "403":
          $ref: "#/components/responses/PublicForbiddenNoStore"
        "404":
          $ref: "#/components/responses/PublicNotFoundNoStore"
    post:
      tags:
        - Public Applications
      operationId: createPublicApplicationV1
      summary: Submit a public application.
      description: Creates an application from a published internet form. File fields are submitted as attachment claims produced by POST /api/v1/attachments. Clients may send Idempotency-Key for network retries. Keys are scoped to this endpoint plus caller/form/auth context, accepted for 15 minutes and replay the same 201 response for the same JSON payload. The replay response includes the short-lived escrowed status token. Reusing a key with a different payload returns 409.
      security: []
      parameters:
        - $ref: "#/components/parameters/IdempotencyKeyHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PublicApplicationSubmissionV1Request"
      responses:
        "201":
          description: Application created. The plaintext status token is returned in the create response and, for the 15 minute idempotency window, in same-payload replay responses.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
            Idempotency-Replayed:
              $ref: "#/components/headers/IdempotencyReplayed"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApplicationCreatedV1Response"
        "400":
          $ref: "#/components/responses/PublicBadRequestNoStore"
        "401":
          $ref: "#/components/responses/PublicUnauthorizedNoStore"
        "404":
          $ref: "#/components/responses/PublicNotFoundNoStore"
        "409":
          $ref: "#/components/responses/PublicConflictNoStore"
        "413":
          description: Attachment count, per-file size, or aggregate attachment size exceeds policy.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
              examples:
                tooManyForField:
                  value:
                    error:
                      code: attachment.too_many_for_field
                      message: Too many attachments for one field.
                      details:
                        field: evidence
                    meta:
                      apiVersion: "1.0"
                fileTooLarge:
                  value:
                    error:
                      code: attachment.file_too_large
                      message: Attachment exceeds the field size limit.
                      details:
                        attachmentId: 84d2566f-b9a9-4240-8a05-127efb25a3dc
                        field: evidence
                    meta:
                      apiVersion: "1.0"
                totalSizeExceeded:
                  value:
                    error:
                      code: attachment.total_size_exceeded
                      message: Total attachment size exceeds the application limit.
                      details:
                        limit: 52428800
                    meta:
                      apiVersion: "1.0"
        "422":
          description: Submitted application data is not valid for the public form schema, or an attachment claim was quarantined.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
              examples:
                validationFailed:
                  value:
                    error:
                      code: application.validation_failed
                      message: Application data failed validation.
                      details:
                        field: message
                        issue: too_short
                    meta:
                      apiVersion: "1.0"
                quarantined:
                  value:
                    error:
                      code: attachment.quarantined
                      message: Attachment was quarantined by malware scanning.
                      details:
                        attachmentId: 84d2566f-b9a9-4240-8a05-127efb25a3dc
                    meta:
                      apiVersion: "1.0"
        "429":
          $ref: "#/components/responses/PublicRateLimitedNoStore"
        "500":
          $ref: "#/components/responses/PublicServerErrorNoStore"
  /api/v1/public/applications/confirm:
    post:
      tags:
        - Public Applications
      operationId: confirmPublicApplicationEmailV1
      summary: Confirm the email address for a public application.
      description: |
        Submit the opaque token from the confirmation email. A valid token
        authorises confirmation and returns the confirmation status, application
        reference, stored jurisdiction and optional organisation slugs, and a
        receipt when the stored context is available. A replay returns `already_confirmed` with the same application context
        while the token is valid. The original
        expiry applies to both requests.
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - token
              properties:
                token:
                  type: string
                  pattern: ^[A-Za-z0-9_-]{64,}$
      responses:
        "200":
          description: First confirmation or replay within the token lifetime.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApplicationConfirmationV1Response"
        "404":
          description: The token is invalid, expired or has no matching application.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApplicationConfirmationV1Error"
              example:
                error:
                  code: confirmation.invalid
        "429":
          description: Confirmation request rate limit exceeded.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApplicationConfirmationV1Error"
              example:
                error:
                  code: rate_limit.exceeded
  /api/v1/public/applications/confirm/resend:
    post:
      tags:
        - Public Applications
      operationId: resendPublicApplicationConfirmationV1
      summary: Request a new email confirmation link.
      description: |
        A matching reference and email address for a pending application cause
        a new confirmation token to replace the previous one, including for
        applications with protected data. The generic response reveals neither
        a match nor whether a message was sent. The per-client and per-address
        rate limits are each three requests per hour.
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - reference
                - email
              properties:
                reference:
                  type: string
                email:
                  type: string
                  format: email
      responses:
        "200":
          description: Generic acknowledgement for matching or invalid details.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                type: object
                required:
                  - status
                additionalProperties: false
                properties:
                  status:
                    const: accepted
        "429":
          description: Confirmation resend rate limit exceeded.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApplicationConfirmationV1Error"
              example:
                error:
                  code: rate_limit.exceeded
  /api/v1/applications/{application_uuid}:
    get:
      tags:
        - Public Applications
      operationId: getOwnApplicationV1
      summary: Return one authenticated citizen application.
      description: Returns a detail projection for one application owned by the authenticated citizen account or claimable through the account's verified email. Protected submitted fields are redacted in submittedData and never revealed through this Public-v1 endpoint. Mailbox-based access requires a confirmed anonymous submission of a public form and a currently verified account address matching the first confirmed application revision. The association does not transfer ownership.
      security:
        - CitizenSessionCookie: []
        - CitizenBasicAuth: []
      parameters:
        - name: application_uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - $ref: "#/components/parameters/JurisdictionRequiredQuery"
        - $ref: "#/components/parameters/OrganisationQuery"
      responses:
        "200":
          description: Authenticated citizen application detail.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApplicationV1Response"
        "401":
          $ref: "#/components/responses/PublicUnauthorizedNoStore"
        "403":
          $ref: "#/components/responses/PublicForbiddenNoStore"
        "404":
          $ref: "#/components/responses/PublicNotFoundNoStore"
  /api/v1/applications/{application_uuid}/comments:
    get:
      tags:
        - Public Applications
      operationId: listApplicationCommentsV1
      summary: List authenticated application comments.
      description: Returns visible text comments for one application owned by the authenticated citizen account or claimable through the account's verified email. Requires an explicit jurisdiction scope and uses Comment UUIDs only. Staff accounts use first-party admin flows or a future Staff Partner API, not this citizen profile. The list includes only public comments for mailbox-authorized citizen access.
      security:
        - CitizenSessionCookie: []
        - CitizenBasicAuth: []
      parameters:
        - name: application_uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - $ref: "#/components/parameters/JurisdictionRequiredQuery"
        - $ref: "#/components/parameters/OrganisationQuery"
        - $ref: "#/components/parameters/LimitQuery"
        - $ref: "#/components/parameters/OffsetQuery"
      responses:
        "200":
          description: Authenticated application comments.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApplicationCommentsV1Response"
        "400":
          $ref: "#/components/responses/PublicBadRequestNoStore"
        "401":
          $ref: "#/components/responses/PublicUnauthorizedNoStore"
        "403":
          $ref: "#/components/responses/PublicForbiddenNoStore"
        "404":
          $ref: "#/components/responses/PublicNotFoundNoStore"
    post:
      tags:
        - Public Applications
      operationId: createApplicationCommentV1
      summary: Create an authenticated application comment.
      description: Creates one text comment on an application owned by the authenticated citizen account or claimable through the account's verified email. This mutating comment endpoint currently supports cookie-session clients and requires X-CSRF-Token from Drupal's /session/token endpoint. Optional attachment claims come from POST /api/v1/applications/{application_uuid}/comment-attachments and are consumed exactly once. Staff accounts use first-party admin flows or a future Staff Partner API. Mailbox-authorized citizens with comment permission can reply publicly. Unconfirmed or inaccessible cases return 404.
      security:
        - CitizenSessionCookie: []
      parameters:
        - name: application_uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - $ref: "#/components/parameters/JurisdictionRequiredQuery"
        - $ref: "#/components/parameters/OrganisationQuery"
        - $ref: "#/components/parameters/CsrfTokenHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PublicApplicationCommentCreateV1Request"
      responses:
        "201":
          description: Application comment created.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApplicationCommentV1Response"
        "400":
          $ref: "#/components/responses/PublicBadRequestNoStore"
        "401":
          $ref: "#/components/responses/PublicUnauthorizedNoStore"
        "403":
          $ref: "#/components/responses/PublicForbiddenNoStore"
        "404":
          $ref: "#/components/responses/PublicNotFoundNoStore"
        "409":
          $ref: "#/components/responses/PublicConflictNoStore"
        "413":
          $ref: "#/components/responses/PublicPayloadTooLargeNoStore"
        "422":
          description: Comment body or attachment claim is invalid, expired, or quarantined.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
              examples:
                bodyRequired:
                  value:
                    error:
                      code: comment.body_required
                      message: The comment body is required.
                    meta:
                      apiVersion: "1.0"
                quarantined:
                  value:
                    error:
                      code: attachment.quarantined
                      message: Attachment was quarantined by malware scanning.
                      details:
                        attachmentId: 84d2566f-b9a9-4240-8a05-127efb25a3dc
                    meta:
                      apiVersion: "1.0"
        "429":
          $ref: "#/components/responses/PublicRateLimitedNoStore"
        "500":
          $ref: "#/components/responses/PublicServerErrorNoStore"
  /api/v1/applications/{application_uuid}/comment-attachments:
    post:
      tags:
        - Public Applications
      operationId: uploadApplicationCommentAttachmentV1
      summary: Upload one authenticated comment attachment.
      description: Uploads one PDF, JPG, JPEG or PNG file for a later application comment. This mutating comment endpoint currently supports cookie-session clients, requires the same workspace query as comments and returns a one-time claim token after a private malware scan. Clients attach the file by sending the returned attachment id and claimToken in POST /api/v1/applications/{application_uuid}/comments. Quarantined files receive no claim token and cannot be submitted or downloaded. Mailbox-authorized citizens with comment permission can upload files for public replies. Unconfirmed or inaccessible cases return 404.
      security:
        - CitizenSessionCookie: []
      parameters:
        - name: application_uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - $ref: "#/components/parameters/JurisdictionRequiredQuery"
        - $ref: "#/components/parameters/OrganisationQuery"
        - $ref: "#/components/parameters/CsrfTokenHeader"
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: "#/components/schemas/PublicApplicationCommentAttachmentUploadV1Request"
      responses:
        "201":
          description: Comment attachment uploaded and ready to claim during comment creation.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApplicationCommentAttachmentCreatedV1Response"
        "400":
          $ref: "#/components/responses/PublicBadRequestNoStore"
        "401":
          $ref: "#/components/responses/PublicUnauthorizedNoStore"
        "403":
          $ref: "#/components/responses/PublicForbiddenNoStore"
        "404":
          $ref: "#/components/responses/PublicNotFoundNoStore"
        "413":
          $ref: "#/components/responses/PublicPayloadTooLargeNoStore"
        "422":
          description: Unsupported extension, file content mismatch, or malware quarantine.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
              examples:
                mimeMismatch:
                  value:
                    error:
                      code: attachment.mime_mismatch
                      message: File content does not match the file extension.
                    meta:
                      apiVersion: "1.0"
                quarantined:
                  value:
                    error:
                      code: attachment.quarantined
                      message: Attachment was quarantined by malware scanning.
                      details:
                        attachmentId: 84d2566f-b9a9-4240-8a05-127efb25a3dc
                        scanStatus: quarantined
                    meta:
                      apiVersion: "1.0"
        "429":
          $ref: "#/components/responses/PublicRateLimitedNoStore"
        "500":
          $ref: "#/components/responses/PublicServerErrorNoStore"
  /api/v1/staff/applications:
    get:
      tags:
        - Staff Applications
      operationId: listStaffApplicationsV1
      summary: List scoped staff applications.
      description: Returns confirmed applications visible to the authenticated staff account in an explicit jurisdiction or organisation scope. Organisation staff must provide an organisation scope. Jurisdiction-wide reads require a jurisdiction admin membership or bypass permission. Set `confirmation=unconfirmed` to return only unconfirmed applications in the same scope as read-only summaries. Unconfirmed applications are excluded from staff detail, event counters, counts and reports. The confirmed list includes form, workflow, assignment and safe applicant summary data. Use `include=submittedData` only on the confirmed list with one explicit form UUID. The regular list uses offset pagination. With `unreadMessages=true`, use cursor pagination. External references use UUIDs and slugs only.
      security:
        - StaffSessionCookie: []
        - StaffBasicAuth: []
      parameters:
        - $ref: "#/components/parameters/JurisdictionRequiredQuery"
        - $ref: "#/components/parameters/OrganisationQuery"
        - $ref: "#/components/parameters/StaffApplicationLimitQuery"
        - $ref: "#/components/parameters/OffsetQuery"
        - $ref: "#/components/parameters/FormQuery"
        - $ref: "#/components/parameters/StaffApplicationSortQuery"
        - $ref: "#/components/parameters/StaffApplicationIncludeQuery"
        - $ref: "#/components/parameters/StaffApplicationConfirmationQuery"
        - $ref: "#/components/parameters/StaffApplicationUnreadMessagesQuery"
        - $ref: "#/components/parameters/StaffApplicationAfterQuery"
      responses:
        "200":
          description: Scoped staff application list.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StaffApplicationsV1Response"
        "400":
          description: Invalid staff list query. Unsupported confirmation values produce `confirmation.invalid`. Combining `confirmation=unconfirmed` with `include=submittedData` produces `include.confirmation_conflict`. See the `unreadMessages` and `after` parameters for their validation errors and conflicts.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicApiErrorResponse"
        "401":
          $ref: "#/components/responses/PublicUnauthorizedNoStore"
        "403":
          $ref: "#/components/responses/PublicForbiddenNoStore"
        "404":
          $ref: "#/components/responses/PublicNotFoundNoStore"
  /api/v1/staff/applications/{application_uuid}:
    get:
      tags:
        - Staff Applications
      operationId: getStaffApplicationV1
      summary: Return one scoped staff application.
      description: Returns one application visible to the authenticated staff account in an explicit jurisdiction or organisation scope. Protected submitted fields are redacted unless the account has the protected-data reveal permission. Service accounts must use a future partner API profile, not this staff profile.
      security:
        - StaffSessionCookie: []
        - StaffBasicAuth: []
      parameters:
        - name: application_uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - $ref: "#/components/parameters/JurisdictionRequiredQuery"
        - $ref: "#/components/parameters/OrganisationQuery"
      responses:
        "200":
          description: Scoped staff application detail.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StaffApplicationV1Response"
        "400":
          $ref: "#/components/responses/PublicBadRequestNoStore"
        "401":
          $ref: "#/components/responses/PublicUnauthorizedNoStore"
        "403":
          $ref: "#/components/responses/PublicForbiddenNoStore"
        "404":
          $ref: "#/components/responses/PublicNotFoundNoStore"
  /api/v1/staff/applications/{application_uuid}/events/{kind}/seen:
    post:
      tags:
        - Staff Applications
      operationId: markStaffApplicationEventSeenV1
      summary: Acknowledge loaded application events for this staff account.
      description: Send the tokens from the detail snapshot when opening the case for messages or reaching another event section. The response carries the counts and event IDs from before acknowledgement. Later arrivals retain their unread state. Shared demo accounts do not persist receipts.
      security:
        - StaffSessionCookie: []
      parameters:
        - name: application_uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: kind
          in: path
          required: true
          schema:
            type: string
            enum:
              - message
              - documents
              - reply
              - assigned
              - scan
        - $ref: "#/components/parameters/JurisdictionRequiredQuery"
        - $ref: "#/components/parameters/OrganisationQuery"
        - $ref: "#/components/parameters/CsrfTokenHeader"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - tokens
              additionalProperties: false
              properties:
                tokens:
                  type: array
                  maxItems: 10000
                  items:
                    type: string
                    pattern: ^[a-f0-9]{64}$
      responses:
        "200":
          description: Event snapshot at acknowledgement time.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StaffApplicationEventSeenV1Response"
        "400":
          $ref: "#/components/responses/PublicBadRequestNoStore"
        "403":
          $ref: "#/components/responses/PublicForbiddenNoStore"
        "404":
          $ref: "#/components/responses/PublicNotFoundNoStore"
        "429":
          $ref: "#/components/responses/PublicRateLimitedNoStore"
  /api/v1/status/{public_status_token}:
    get:
      tags:
        - Public Status
      operationId: getStatusByPublicTokenV1
      summary: Return public no-PII status by token.
      description: Uses the public status token returned once by POST /api/v1/applications.
      security: []
      parameters:
        - name: public_status_token
          in: path
          required: true
          schema:
            type: string
            minLength: 32
            maxLength: 96
            pattern: ^[A-Za-z0-9_-]+$
        - name: schemaId
          in: query
          required: true
          schema:
            type: string
            format: uuid
        - $ref: "#/components/parameters/JurisdictionQuery"
        - $ref: "#/components/parameters/OrganisationQuery"
        - $ref: "#/components/parameters/RateLimitIdentifierHeader"
      responses:
        "200":
          description: Public no-PII application status data.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicStatusV1Response"
        "404":
          $ref: "#/components/responses/PublicNotFoundNoStore"
        "429":
          $ref: "#/components/responses/PublicRateLimitedNoStore"
  /api/v1/staff/applications/counts:
    get:
      operationId: getStaffApplicationCountsV1
      tags:
        - Staff Applications
      summary: Return workspace totals and counts by form and form group.
      security:
        - StaffBasicAuth: []
        - StaffSessionCookie: []
      parameters:
        - name: jurisdiction
          in: query
          required: true
          schema:
            $ref: "#/components/schemas/PublicSlug"
          description: Jurisdiction slug for the staff workspace.
        - name: organisation
          in: query
          schema:
            $ref: "#/components/schemas/PublicSlug"
          description: Restrict the workspace to this organisation slug.
      responses:
        "200":
          description: Return workspace totals and counts by form and form group.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - meta
                properties:
                  data:
                    type: object
                    required:
                      - total
                      - applicationsByForm
                      - applicationsByFormGroup
                      - formGroupsByForm
                      - formGroups
                    properties:
                      total:
                        type: integer
                        minimum: 0
                      applicationsByForm:
                        type: object
                        propertyNames:
                          type: string
                          format: uuid
                        additionalProperties:
                          type: integer
                          minimum: 0
                      applicationsByFormGroup:
                        type: object
                        propertyNames:
                          type: string
                          format: uuid
                        additionalProperties:
                          type: integer
                          minimum: 0
                      formGroupsByForm:
                        type: object
                        propertyNames:
                          type: string
                          format: uuid
                        additionalProperties:
                          type: integer
                          minimum: 0
                      formGroups:
                        type: array
                        items:
                          type: object
                          required:
                            - id
                            - label
                            - formIds
                          properties:
                            id:
                              type: string
                              format: uuid
                            label:
                              type: string
                            formIds:
                              type: array
                              items:
                                type: string
                                format: uuid
                  meta:
                    type: object
                    required:
                      - apiVersion
                      - resource
                      - scope
                    properties:
                      apiVersion:
                        type: string
                        const: "1.0"
                      resource:
                        type: string
                        const: staffApplicationCounts
                      scope:
                        type: object
                        required:
                          - jurisdiction
                          - organisation
                        properties:
                          jurisdiction:
                            type:
                              - string
                              - "null"
                          organisation:
                            type:
                              - string
                              - "null"
        "400":
          $ref: "#/components/responses/PublicBadRequestNoStore"
        "401":
          $ref: "#/components/responses/PublicUnauthorizedNoStore"
        "403":
          $ref: "#/components/responses/PublicForbiddenNoStore"
        "404":
          $ref: "#/components/responses/PublicNotFoundNoStore"
  /api/v1/staff/applications/report:
    get:
      operationId: getStaffApplicationReportV1
      tags:
        - Staff Applications
      summary: Return workspace totals, deadlines and breakdowns by status, form and day.
      security:
        - StaffBasicAuth: []
        - StaffSessionCookie: []
      parameters:
        - name: jurisdiction
          in: query
          required: true
          schema:
            $ref: "#/components/schemas/PublicSlug"
          description: Jurisdiction slug for the staff workspace.
        - name: organisation
          in: query
          schema:
            $ref: "#/components/schemas/PublicSlug"
          description: Restrict the workspace to this organisation slug.
        - name: form
          in: query
          schema:
            type: string
            format: uuid
          description: Restrict the report to a form visible in this workspace. The aliases schema and formSchema are also accepted.
        - name: from
          in: query
          schema:
            type: string
          description: Inclusive creation-time boundary. Use a date (YYYY-MM-DD) in the report time zone or an ISO 8601 date-time with offset.
        - name: to
          in: query
          schema:
            type: string
          description: Inclusive creation-time boundary. Use a date (YYYY-MM-DD) in the report time zone or an ISO 8601 date-time with offset.
      responses:
        "200":
          description: Return workspace totals, deadlines and breakdowns by status, form and day.
          headers:
            Cache-Control:
              $ref: "#/components/headers/PrivateNoStore"
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - meta
                properties:
                  data:
                    type: object
                    required:
                      - totals
                      - deadlines
                      - byStatus
                      - byForm
                      - byDay
                    properties:
                      totals:
                        type: object
                        required:
                          - applications
                          - completed
                          - open
                          - followUps
                          - averageProcessingHours
                          - medianProcessingHours
                        properties:
                          applications:
                            type: integer
                            minimum: 0
                          completed:
                            type: integer
                            minimum: 0
                          open:
                            type: integer
                            minimum: 0
                          followUps:
                            type: integer
                            minimum: 0
                          averageProcessingHours:
                            type:
                              - number
                              - "null"
                            minimum: 0
                          medianProcessingHours:
                            type:
                              - number
                              - "null"
                            minimum: 0
                      deadlines:
                        type: object
                        required:
                          - overdue
                          - dueToday
                          - dueSoon
                          - today
                          - horizonDays
                        properties:
                          overdue:
                            type: integer
                            minimum: 0
                          dueToday:
                            type: integer
                            minimum: 0
                          dueSoon:
                            type: integer
                            minimum: 0
                          today:
                            type: string
                            format: date
                          horizonDays:
                            type: integer
                            minimum: 0
                      byStatus:
                        type: array
                        items:
                          type: object
                          required:
                            - key
                            - label
                            - color
                            - completed
                            - count
                          properties:
                            key:
                              type: string
                            label:
                              type: string
                            color:
                              type:
                                - string
                                - "null"
                            completed:
                              type: boolean
                            count:
                              type: integer
                              minimum: 0
                      byForm:
                        type: array
                        items:
                          type: object
                          required:
                            - key
                            - label
                            - count
                            - averageProcessingHours
                            - followUpCount
                          properties:
                            key:
                              type: string
                            label:
                              type: string
                            count:
                              type: integer
                              minimum: 0
                            averageProcessingHours:
                              type:
                                - number
                                - "null"
                              minimum: 0
                            followUpCount:
                              type: integer
                              minimum: 0
                      byDay:
                        type: array
                        items:
                          type: object
                          required:
                            - date
                            - count
                          properties:
                            date:
                              type: string
                              format: date
                            count:
                              type: integer
                              minimum: 0
                  meta:
                    type: object
                    required:
                      - apiVersion
                      - resource
                      - scope
                      - generatedAt
                      - filters
                      - timeZone
                      - dayTimeZone
                      - truncated
                    properties:
                      apiVersion:
                        type: string
                        const: "1.0"
                      resource:
                        type: string
                        const: staffApplicationReport
                      scope:
                        type: object
                        required:
                          - jurisdiction
                          - organisation
                        properties:
                          jurisdiction:
                            type:
                              - string
                              - "null"
                          organisation:
                            type:
                              - string
                              - "null"
                      generatedAt:
                        type: string
                        format: date-time
                      filters:
                        type: object
                        required:
                          - form
                          - from
                          - to
                        properties:
                          form:
                            type:
                              - string
                              - "null"
                            format: uuid
                          from:
                            type:
                              - string
                              - "null"
                            format: date-time
                          to:
                            type:
                              - string
                              - "null"
                            format: date-time
                      timeZone:
                        type: string
                        description: IANA time zone for deadline dates and date-only filters.
                      dayTimeZone:
                        type: string
                        const: UTC
                      truncated:
                        type: boolean
                        const: false
        "400":
          $ref: "#/components/responses/PublicBadRequestNoStore"
        "401":
          $ref: "#/components/responses/PublicUnauthorizedNoStore"
        "403":
          $ref: "#/components/responses/PublicForbiddenNoStore"
        "404":
          $ref: "#/components/responses/PublicNotFoundNoStore"
components:
  securitySchemes:
    CitizenSessionCookie:
      type: apiKey
      in: header
      name: Cookie
      description: Authenticated Drupal citizen session cookie, for example the secure `SSESS...` cookie returned by the passwordless flow. The exact cookie name is deployment-specific. The account must have the endpoint-specific citizen permission and must not be a service account.
    CitizenBasicAuth:
      type: http
      scheme: basic
      description: Optional deployment profile. HTTP Basic can satisfy the same authenticated citizen context when enabled by Drupal and backed by a non-service-account user with the endpoint-specific citizen permission.
    StaffSessionCookie:
      type: apiKey
      in: header
      name: Cookie
      description: Authenticated Drupal staff session cookie. The account must have the operation-specific staff permissions and workspace access. Cookie-session mutations require X-CSRF-Token. Service accounts are excluded.
    StaffBasicAuth:
      type: http
      scheme: basic
      description: Optional deployment profile for operations that declare StaffBasicAuth. Drupal must enable HTTP Basic for a non-service account with the operation-specific staff permissions and workspace access.
  parameters:
    JurisdictionQuery:
      name: jurisdiction
      in: query
      required: false
      schema:
        $ref: "#/components/schemas/PublicSlug"
    JurisdictionRequiredQuery:
      name: jurisdiction
      in: query
      required: true
      schema:
        $ref: "#/components/schemas/PublicSlug"
      description: Required tenant scope for authenticated citizen application reads.
    OrganisationQuery:
      name: organisation
      in: query
      required: false
      schema:
        $ref: "#/components/schemas/PublicSlug"
      description: Optional organisation slug that narrows a jurisdiction-scoped resource to one organisation. When supported by a resource, organisation-specific content overrides or complements jurisdiction defaults.
    FormQuery:
      name: form
      in: query
      required: false
      schema:
        type: string
        format: uuid
      description: Optional public FormSchema UUID used by public content resources that can attach content to one form.
    PublicDocumentPlacementQuery:
      name: placement
      in: query
      required: false
      schema:
        type: string
        enum:
          - org_start
          - form_intro
          - form_downloads
          - form_sidebar
          - submission_success
      description: Optional display placement for public documents. Unsupported values including the retired `footer` return HTTP 400 with `document.invalid_query` on the list and HTTP 404 on the download.
    PublicSectionPlacementQuery:
      name: placement
      in: query
      required: false
      schema:
        type: string
        enum:
          - org_start
          - form_intro
          - form_sidebar
          - submission_success
      description: Optional display placement for public HTML content sections. Invalid values return `section.invalid_query`.
    LimitQuery:
      name: limit
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 20
      description: Page size for authenticated application lists.
    StaffApplicationLimitQuery:
      name: limit
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 500
        default: 20
      description: Page size for the consolidated Staff application list.
    OffsetQuery:
      name: offset
      in: query
      required: false
      schema:
        type: integer
        minimum: 0
        maximum: 10000
        default: 0
      description: Zero-based application list offset.
    StaffApplicationSortQuery:
      name: sort
      in: query
      required: false
      schema:
        type: string
        enum:
          - updated
          - created
        default: updated
      description: Sort order for Staff application lists. `updated` sorts by changed time descending, then created time descending. `created` aligns first-party admin list projections with created time descending, then changed time descending.
    StaffApplicationIncludeQuery:
      name: include
      in: query
      required: false
      schema:
        type: string
        enum:
          - submittedData
      description: Includes redacted submitted form data in the confirmed list projection. This value is accepted only together with the `form` query parameter and limits the page size to 100 records.
    StaffApplicationConfirmationQuery:
      name: confirmation
      in: query
      required: false
      schema:
        type: string
        enum:
          - unconfirmed
      description: Omit the parameter for confirmed applications. Set it to `unconfirmed` for read-only summaries of applications awaiting email confirmation.
    StaffApplicationUnreadMessagesQuery:
      name: unreadMessages
      in: query
      required: false
      schema:
        type: boolean
        default: false
      description: |
        Use `true` to select applications with unread published public applicant
        messages for the authenticated staff account. Messages with attachments
        count once. The filter respects application and message access and is
        applied within the selected workspace and optional form. Start without
        `after`, then follow `meta.page.nextCursor` until `hasMore` is false,
        including after a page with no matches. Omit `offset` or use zero.
        A positive offset returns HTTP 400 with
        `pagination.offset_with_unread_messages`. Combining with
        `confirmation=unconfirmed` returns HTTP 400 with
        `unread_messages.confirmation_conflict`. Omit the parameter or use
        `false` for the regular offset-paginated list. Other values return
        HTTP 400 with `unread_messages.invalid`.
    StaffApplicationAfterQuery:
      name: after
      in: query
      required: false
      schema:
        type: string
        minLength: 1
        maxLength: 128
        pattern: ^[A-Za-z0-9_-]+$
      description: |
        Opaque cursor from the previous unread-filter response. Reuse it
        verbatim with the same staff account, workspace, optional form and
        sort. The cursor continues a live list in descending timestamp order
        with application ID as the final tie-breaker. Scope and form access
        are checked first. An invalid, modified or mismatched cursor returns
        HTTP 400 with `pagination.cursor_invalid`.
        Supplying `after` without `unreadMessages=true` returns HTTP 400 with
        `pagination.cursor_requires_unread_messages`.
    RateLimitIdentifierHeader:
      name: X-Beantragt-Rate-Limit-Identifier
      in: header
      required: false
      schema:
        type: string
        pattern: ^[a-f0-9]{32}$
        minLength: 32
        maxLength: 32
      description: First-party proxy rate-limit identifier. Ignored unless the service authorization header is valid.
    IdempotencyKeyHeader:
      name: Idempotency-Key
      in: header
      required: false
      schema:
        type: string
        pattern: ^[A-Za-z0-9._:-]{32,128}$
        minLength: 32
        maxLength: 128
        example: retry-550e8400-e29b-41d4-a716-446655440000
      description: Optional high-entropy client-supplied key for retrying POST /api/v1/applications without creating duplicates. Treat it as a temporary secret retry credential. The key is scoped to this endpoint plus caller/form/auth context and kept for 15 minutes.
    StaffMutationCsrfTokenHeader:
      name: X-CSRF-Token
      in: header
      required: false
      description: Required for authenticated requests carrying a session cookie. Use the token from /session/token for that session.
      schema:
        type: string
    CsrfTokenHeader:
      name: X-CSRF-Token
      in: header
      required: true
      schema:
        type: string
        minLength: 16
      description: CSRF token for cookie-session mutations. Cookie clients fetch it from Drupal's /session/token endpoint after authentication.
  headers:
    PrivateNoStore:
      description: Response is private and not cacheable.
      schema:
        type: string
        example: private, no-store
    IdempotencyReplayed:
      description: Present with value true when a response was replayed from an Idempotency-Key record.
      schema:
        type: string
        enum:
          - "true"
    PublicCachePolicy:
      description: Public endpoints attach Drupal cache metadata.
      schema:
        type: string
        example: public, max-age=300
    ContentDisposition:
      description: Attachment disposition with a sanitized filename.
      schema:
        type: string
        example: attachment; filename="merkblatt.pdf"
    XContentTypeOptions:
      description: Browser MIME-sniffing protection.
      schema:
        type: string
        enum:
          - nosniff
        example: nosniff
    SessionCookie:
      description: Drupal session cookie. Name and attributes are deployment-specific.
      schema:
        type: string
        example: SSESSabc=...; Path=/; Secure; HttpOnly; SameSite=Lax
  responses:
    PublicBadRequestNoStore:
      description: Invalid request body, path, query parameter or consent state.
      headers:
        Cache-Control:
          $ref: "#/components/headers/PrivateNoStore"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiErrorResponse"
          examples:
            statusNotFound:
              value:
                error:
                  code: status.not_found
                  message: Status not found.
                meta:
                  apiVersion: "1.0"
            formNotFound:
              value:
                error:
                  code: form.not_found
                  message: Form not found.
                meta:
                  apiVersion: "1.0"
            pageNotFound:
              value:
                error:
                  code: page.not_found
                  message: Page not found.
                meta:
                  apiVersion: "1.0"
    PublicUnauthorizedNoStore:
      description: The request requires an authenticated API profile.
      headers:
        Cache-Control:
          $ref: "#/components/headers/PrivateNoStore"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiErrorResponse"
    PublicForbiddenNoStore:
      description: The authenticated account is not allowed to use this v1 resource.
      headers:
        Cache-Control:
          $ref: "#/components/headers/PrivateNoStore"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiErrorResponse"
    PublicNotFoundNoStore:
      description: Resource not found or hidden by scope.
      headers:
        Cache-Control:
          $ref: "#/components/headers/PrivateNoStore"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiErrorResponse"
    PublicConflictNoStore:
      description: Attachment claim is already being processed, an idempotent submission is still in progress or an Idempotency-Key was reused with a different payload.
      headers:
        Cache-Control:
          $ref: "#/components/headers/PrivateNoStore"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiErrorResponse"
          examples:
            idempotencyConflict:
              value:
                error:
                  code: idempotency.conflict
                  message: Idempotency-Key was already used with a different request payload.
                meta:
                  apiVersion: "1.0"
            idempotencyInProgress:
              value:
                error:
                  code: idempotency.in_progress
                  message: An application submission with this idempotency key is still in progress.
                meta:
                  apiVersion: "1.0"
    PublicPayloadTooLargeNoStore:
      description: Request body, file or field value exceeds public v1 limits.
      headers:
        Cache-Control:
          $ref: "#/components/headers/PrivateNoStore"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiErrorResponse"
    PublicUnprocessableNoStore:
      description: Submitted application data or attachment content is not valid.
      headers:
        Cache-Control:
          $ref: "#/components/headers/PrivateNoStore"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiErrorResponse"
    PublicRateLimitedNoStore:
      description: Rate limit exceeded.
      headers:
        Cache-Control:
          $ref: "#/components/headers/PrivateNoStore"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiErrorResponse"
    PublicServerErrorNoStore:
      description: Server-side processing failed.
      headers:
        Cache-Control:
          $ref: "#/components/headers/PrivateNoStore"
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/PublicApiErrorResponse"
  schemas:
    PublicSlug:
      type: string
      pattern: ^(?=.*[a-z])[a-z0-9](?:[a-z0-9-]{0,126}[a-z0-9])?$
      example: musterstadt
    ApiV1Meta:
      type: object
      required:
        - apiVersion
        - resource
      properties:
        apiVersion:
          type: string
          example: "1.0"
        resource:
          type: string
          example: jurisdictionConfig
      additionalProperties: false
    ApiV1ListMeta:
      type: object
      required:
        - apiVersion
        - resource
        - count
      properties:
        apiVersion:
          type: string
          example: "1.0"
        resource:
          type: string
          example: forms
        count:
          type: integer
          minimum: 0
      additionalProperties: false
    PublicAuthCodeRequestMetaV1:
      type: object
      required:
        - apiVersion
        - resource
      properties:
        apiVersion:
          type: string
          example: "1.0"
        resource:
          type: string
          enum:
            - authCodeRequest
      additionalProperties: false
    PublicAuthSessionMetaV1:
      type: object
      required:
        - apiVersion
        - resource
      properties:
        apiVersion:
          type: string
          example: "1.0"
        resource:
          type: string
          enum:
            - authSession
      additionalProperties: false
    PublicAuthCodeRequestV1Request:
      type: object
      required:
        - email
      properties:
        email:
          type: string
          format: email
          maxLength: 254
        langcode:
          type: string
          minLength: 2
          maxLength: 12
          example: de
      additionalProperties: false
    PublicAuthCodeRequestV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          $ref: "#/components/schemas/PublicAuthCodeRequestV1"
        meta:
          $ref: "#/components/schemas/PublicAuthCodeRequestMetaV1"
      additionalProperties: false
    PublicAuthCodeRequestV1:
      type: object
      required:
        - type
        - delivery
        - expiresIn
        - codeLength
        - challengeId
      properties:
        type:
          type: string
          enum:
            - auth_code_request
        delivery:
          type: string
          enum:
            - email
        expiresIn:
          type: integer
          minimum: 1
          description: Seconds until the OTP code expires.
        codeLength:
          type: integer
          minimum: 4
          maximum: 9
        challengeId:
          type: string
          pattern: ^[a-f0-9]{64}$
          description: Server-side session-bound challenge. Submit this value from the same cookie session when verifying the OTP code.
      additionalProperties: false
    PublicAuthVerifyCodeV1Request:
      type: object
      required:
        - email
        - code
        - challengeId
      properties:
        email:
          type: string
          format: email
          maxLength: 254
        code:
          type: string
          pattern: ^[0-9]{4,9}$
        challengeId:
          type: string
          pattern: ^[a-f0-9]{64}$
      additionalProperties: false
    PublicAuthSessionV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          $ref: "#/components/schemas/PublicAuthSessionV1"
        meta:
          $ref: "#/components/schemas/PublicAuthSessionMetaV1"
      additionalProperties: false
    PublicAuthSessionV1:
      type: object
      required:
        - type
        - authenticated
        - user
      properties:
        type:
          type: string
          enum:
            - auth_session
        authenticated:
          type: boolean
        user:
          oneOf:
            - $ref: "#/components/schemas/PublicAuthUserV1"
            - type: "null"
      additionalProperties: false
    PublicAuthUserV1:
      type: object
      required:
        - type
        - id
        - name
        - email
        - roles
        - authProvider
        - assuranceLevel
      properties:
        type:
          type: string
          enum:
            - user
        id:
          oneOf:
            - type: string
              format: uuid
            - type: "null"
        name:
          type: string
        email:
          type: string
          format: email
        roles:
          type: array
          items:
            type: string
        authProvider:
          type: string
          pattern: ^[A-Za-z0-9_-]+$
          example: passwordless
        assuranceLevel:
          type:
            - string
            - "null"
      additionalProperties: false
    PublicPaginationV1:
      type: object
      required:
        - limit
        - offset
        - hasMore
      properties:
        limit:
          type: integer
          minimum: 1
          maximum: 100
        offset:
          type: integer
          minimum: 0
          maximum: 10000
        hasMore:
          type: boolean
        nextOffset:
          type: integer
          minimum: 1
      additionalProperties: false
    StaffPaginationV1:
      type: object
      required:
        - limit
        - offset
        - hasMore
      properties:
        limit:
          type: integer
          minimum: 1
          maximum: 500
        offset:
          type: integer
          minimum: 0
          maximum: 10000
        hasMore:
          type: boolean
        nextOffset:
          type: integer
          minimum: 1
      additionalProperties: false
    StaffUnreadMessagePaginationV1:
      type: object
      required:
        - limit
        - hasMore
      properties:
        limit:
          type: integer
          minimum: 1
          maximum: 500
        hasMore:
          type: boolean
          description: True if the scan stopped at a full page or reached its candidate budget and further candidates remain. A later page may be empty.
        nextCursor:
          type: string
          minLength: 1
          maxLength: 128
          pattern: ^[A-Za-z0-9_-]+$
          description: Present exactly when hasMore is true. Pass this value as after to resume after the last scanned candidate.
      if:
        properties:
          hasMore:
            const: true
      then:
        required:
          - nextCursor
      else:
        properties:
          nextCursor: false
      additionalProperties: false
    PublicApplicationListMetaV1:
      type: object
      required:
        - apiVersion
        - resource
        - count
        - page
      properties:
        apiVersion:
          type: string
          example: "1.0"
        resource:
          type: string
          enum:
            - applications
        count:
          type: integer
          minimum: 0
        page:
          $ref: "#/components/schemas/PublicPaginationV1"
      additionalProperties: false
    PublicApplicationDetailMetaV1:
      type: object
      required:
        - apiVersion
        - resource
        - protectedDataRedacted
      properties:
        apiVersion:
          type: string
          example: "1.0"
        resource:
          type: string
          enum:
            - application
        protectedDataRedacted:
          type: boolean
          description: True when the submitted schema contains protected fields or the schema could not be resolved fail-closed.
      additionalProperties: false
    StaffApplicationListMetaV1:
      type: object
      required:
        - apiVersion
        - resource
        - count
        - page
        - workflowStatuses
        - events
      properties:
        apiVersion:
          type: string
          example: "1.0"
        resource:
          type: string
          enum:
            - staffApplications
        count:
          type: integer
          minimum: 0
          description: Number of applications returned on this page.
        page:
          oneOf:
            - $ref: "#/components/schemas/StaffPaginationV1"
            - $ref: "#/components/schemas/StaffUnreadMessagePaginationV1"
        workflowStatuses:
          type: array
          description: Render-ready workflow statuses referenced by this result page. Empty for the unconfirmed list.
          items:
            $ref: "#/components/schemas/StaffWorkflowStatusV1"
        events:
          type: object
          description: Sparse event counts by confirmed application UUID and event kind. An empty object for the unconfirmed list.
          additionalProperties:
            $ref: "#/components/schemas/StaffApplicationEventCountsV1"
      additionalProperties: false
    StaffApplicationDetailMetaV1:
      type: object
      required:
        - apiVersion
        - resource
        - protectedDataRedacted
        - events
      properties:
        apiVersion:
          type: string
          example: "1.0"
        resource:
          type: string
          enum:
            - staffApplication
        protectedDataRedacted:
          type: boolean
          description: True when protected submitted fields were redacted for this staff account.
        events:
          $ref: "#/components/schemas/StaffApplicationEventsV1"
      additionalProperties: false
    StaffApplicationEventCountsV1:
      type: object
      description: Only accessible kinds with positive counts are included. The message count is personal and covers published public applicant messages.
      additionalProperties:
        type: integer
        minimum: 1
    StaffApplicationEventsV1:
      type: object
      required:
        - counts
        - previousSeenAt
        - seenAt
        - newEventIds
        - newMessageIds
        - seenTokens
      properties:
        counts:
          $ref: "#/components/schemas/StaffApplicationEventCountsV1"
        previousSeenAt:
          type: object
          additionalProperties:
            type:
              - integer
              - "null"
          description: Prior section visit times as Unix timestamps, keyed by event kind.
        seenAt:
          type: object
          additionalProperties:
            type:
              - integer
              - "null"
        newEventIds:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
        newMessageIds:
          type: array
          items:
            type: string
            format: uuid
        seenTokens:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
              pattern: ^[a-f0-9]{64}$
      additionalProperties: false
    StaffApplicationEventSeenV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          type: object
          required:
            - id
            - kind
          properties:
            id:
              type: string
              format: uuid
            kind:
              type: string
              enum:
                - message
                - documents
                - reply
                - assigned
                - scan
          additionalProperties: false
        meta:
          type: object
          required:
            - apiVersion
            - resource
            - events
          properties:
            apiVersion:
              type: string
              example: "1.0"
            resource:
              type: string
              enum:
                - staffApplicationEvents
            events:
              $ref: "#/components/schemas/StaffApplicationEventsV1"
          additionalProperties: false
      additionalProperties: false
    PublicApplicationCommentListMetaV1:
      type: object
      required:
        - apiVersion
        - resource
        - count
        - page
      properties:
        apiVersion:
          type: string
          example: "1.0"
        resource:
          type: string
          enum:
            - applicationComments
        count:
          type: integer
          minimum: 0
        page:
          $ref: "#/components/schemas/PublicPaginationV1"
      additionalProperties: false
    PublicApplicationCommentMetaV1:
      type: object
      required:
        - apiVersion
        - resource
      properties:
        apiVersion:
          type: string
          example: "1.0"
        resource:
          type: string
          enum:
            - applicationComment
      additionalProperties: false
    PublicApiErrorResponse:
      type: object
      required:
        - error
        - meta
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              example: jurisdiction.not_found
            message:
              type: string
              example: Jurisdiction not found.
            details:
              type: object
              additionalProperties: true
          additionalProperties: false
        meta:
          type: object
          required:
            - apiVersion
          properties:
            apiVersion:
              type: string
              example: "1.0"
          additionalProperties: false
      additionalProperties: false
    PublicJurisdictionConfigV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          $ref: "#/components/schemas/PublicJurisdictionConfigV1"
        meta:
          $ref: "#/components/schemas/ApiV1Meta"
      additionalProperties: false
    PublicJurisdictionConfigV1:
      type: object
      required:
        - jurisdiction
        - theme
        - languages
        - general
        - legal
        - customCss
      properties:
        jurisdiction:
          type: object
          required:
            - slug
            - uuid
            - name
          properties:
            slug:
              $ref: "#/components/schemas/PublicSlug"
            uuid:
              type: string
              format: uuid
            name:
              type: string
          additionalProperties: false
        theme:
          type: object
          properties:
            primary:
              type:
                - string
                - "null"
            secondary:
              type:
                - string
                - "null"
            neutral:
              type:
                - string
                - "null"
            logoDataUrl:
              type:
                - string
                - "null"
              description: Base64 data URL for the public workspace logo, if configured.
            logoAlt:
              type:
                - string
                - "null"
              description: Alternative text for the public workspace logo.
          additionalProperties: false
        languages:
          type: object
          required:
            - default
            - available
          properties:
            default:
              type: string
              example: de
            available:
              type: array
              items:
                type: string
          additionalProperties: false
        general:
          type: object
          required:
            - contactEmail
            - website
            - phone
          properties:
            contactEmail:
              type: string
            website:
              type: string
            phone:
              type: string
          additionalProperties: false
        legal:
          type: object
          required:
            - legalNotice
            - privacyPolicy
          properties:
            legalNotice:
              type: string
            privacyPolicy:
              type: string
          additionalProperties: false
        customCss:
          type: string
        applicantProfile:
          $ref: "#/components/schemas/PublicApplicantProfileConfigV1"
      additionalProperties: false
    PublicApplicantProfileConfigV1:
      type: object
      description: Applicant profile switch of the jurisdiction and the backend-owned consent texts. The templates contain the placeholder `{stelle}`, which a client replaces literally with the label of the organisation or jurisdiction the consent names. The response is publicly cached for up to 3600 seconds, so switching the profile off may reach clients late; the backend stops profile synchronisation immediately.
      required:
        - enabled
        - scope
        - bankConsent
        - consentTextVersion
        - consentText
        - bankConsentTextVersion
        - bankConsentText
      properties:
        enabled:
          type: boolean
          description: Whether the jurisdiction offers the applicant profile. Default false.
        bankConsent:
          type: boolean
          description: Whether the jurisdiction also offers the separate bank details checkbox. Default false; only effective together with `enabled`. While false, a submitted `bankConsent` is not stored and no bank details reach a profile.
        scope:
          type: string
          enum:
            - organisation
            - jurisdiction
          description: Profile scope. Only `organisation` has an effect today; `jurisdiction` is stored but reserved.
        consentTextVersion:
          type: string
          example: 2026-11-20
          description: Current version of the contact consent text.
        consentText:
          type: object
          description: Legacy jurisdiction-wide contact template with the `{stelle}` placeholder. Use the form detail offer to collect consent.
          additionalProperties:
            type: string
        bankConsentTextVersion:
          type: string
          example: 2026-11-20
          description: Current version of the bank consent text.
        bankConsentText:
          type: object
          description: Legacy jurisdiction-wide bank template with the `{stelle}` placeholder. Use the form detail offer to collect consent.
          additionalProperties:
            type: string
      additionalProperties: false
    PublicContentPageV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          $ref: "#/components/schemas/PublicContentPageV1"
        meta:
          $ref: "#/components/schemas/ApiV1Meta"
      additionalProperties: false
    PublicContentPageListV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicContentPageSummaryV1"
        meta:
          $ref: "#/components/schemas/ApiV1Meta"
      additionalProperties: false
    PublicContentPageSummaryV1:
      type: object
      required:
        - type
        - id
        - attributes
      properties:
        type:
          type: string
          enum:
            - page
        id:
          type: string
          format: uuid
        attributes:
          $ref: "#/components/schemas/PublicContentPageSummaryAttributesV1"
      additionalProperties: false
    PublicContentPageSummaryAttributesV1:
      type: object
      required:
        - title
        - langcode
        - changed
        - slug
        - path
        - footerVisible
        - order
      properties:
        key:
          type:
            - string
            - "null"
          pattern: ^[a-z][a-z0-9_]{0,63}$
        title:
          type: string
        langcode:
          type: string
          example: en
        changed:
          type: integer
          minimum: 0
        slug:
          type: string
          pattern: ^[a-z0-9](?:[a-z0-9-]{0,126}[a-z0-9])?$
        path:
          type: string
          pattern: ^/pages/[a-z0-9](?:[a-z0-9-]{0,126}[a-z0-9])?$
        footerVisible:
          type: boolean
        order:
          type: integer
      additionalProperties: false
    PublicContentPageV1:
      type: object
      required:
        - type
        - id
        - attributes
      properties:
        type:
          type: string
          enum:
            - page
        id:
          type: string
          format: uuid
        attributes:
          $ref: "#/components/schemas/PublicContentPageAttributesV1"
      additionalProperties: false
    PublicContentPageAttributesV1:
      type: object
      required:
        - title
        - body
        - langcode
        - changed
      properties:
        key:
          type:
            - string
            - "null"
          pattern: ^[a-z][a-z0-9_]{0,63}$
        slug:
          type:
            - string
            - "null"
          pattern: ^[a-z0-9](?:[a-z0-9-]{0,126}[a-z0-9])?$
        path:
          type:
            - string
            - "null"
          pattern: ^/pages/[a-z0-9](?:[a-z0-9-]{0,126}[a-z0-9])?$
        title:
          type: string
        body:
          $ref: "#/components/schemas/PublicContentPageBodyV1"
        langcode:
          type: string
          example: en
        changed:
          type: integer
          minimum: 0
      additionalProperties: false
    PublicContentPageBodyV1:
      type: object
      required:
        - value
        - processed
        - format
      properties:
        value:
          type: string
          enum:
            - ""
          description: Raw body values are intentionally never emitted.
        processed:
          type: string
          description: Sanitized HTML. Empty when the stored field format is not allowed for public output.
        format:
          type:
            - string
            - "null"
          example: basic_html
      additionalProperties: false
    PublicDocumentListV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicDocumentV1"
        meta:
          $ref: "#/components/schemas/ApiV1Meta"
      additionalProperties: false
    PublicContentSectionListV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicContentSectionV1"
        meta:
          $ref: "#/components/schemas/ApiV1Meta"
      additionalProperties: false
    PublicContentSectionV1:
      type: object
      required:
        - type
        - id
        - attributes
      properties:
        type:
          type: string
          enum:
            - contentSection
        id:
          type: string
          format: uuid
        attributes:
          $ref: "#/components/schemas/PublicContentSectionAttributesV1"
      additionalProperties: false
    PublicContentSectionAttributesV1:
      type: object
      required:
        - title
        - body
        - placement
        - order
        - form
        - langcode
        - changed
      properties:
        title:
          type: string
        body:
          $ref: "#/components/schemas/PublicContentPageBodyV1"
        placement:
          type: string
          enum:
            - org_start
            - form_intro
            - form_downloads
            - form_sidebar
            - submission_success
        order:
          type: integer
        form:
          oneOf:
            - $ref: "#/components/schemas/PublicDocumentFormReferenceV1"
            - type: "null"
        langcode:
          type: string
          example: de
        changed:
          type: integer
          minimum: 0
      additionalProperties: false
    PublicDocumentV1:
      type: object
      required:
        - type
        - id
        - attributes
      properties:
        type:
          type: string
          enum:
            - publicDocument
        id:
          type: string
          format: uuid
        attributes:
          $ref: "#/components/schemas/PublicDocumentAttributesV1"
      additionalProperties: false
    PublicDocumentAttributesV1:
      type: object
      required:
        - title
        - description
        - placement
        - order
        - file
        - form
        - langcode
        - changed
      properties:
        title:
          type: string
        description:
          $ref: "#/components/schemas/PublicContentPageBodyV1"
        placement:
          type: string
          enum:
            - org_start
            - form_intro
            - form_downloads
            - form_sidebar
            - submission_success
        order:
          type: integer
        file:
          $ref: "#/components/schemas/PublicDocumentFileV1"
        form:
          oneOf:
            - $ref: "#/components/schemas/PublicDocumentFormReferenceV1"
            - type: "null"
        langcode:
          type: string
          example: de
        changed:
          type: integer
          minimum: 0
      additionalProperties: false
    PublicDocumentFileV1:
      type: object
      required:
        - filename
        - mimeType
        - size
        - url
      properties:
        filename:
          type: string
        mimeType:
          type: string
          enum:
            - application/pdf
            - image/jpeg
            - image/png
        size:
          type: integer
          minimum: 0
        url:
          type: string
          description: Relative scope-checked download URL for the public document file. Private submission attachments are never exposed through this resource.
          pattern: ^/api/v1/jurisdictions/[a-z0-9](?:[a-z0-9-]{0,126}[a-z0-9])?/documents/[0-9a-f-]{36}/file
      additionalProperties: false
    PublicDocumentFormReferenceV1:
      type: object
      required:
        - id
        - title
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
      additionalProperties: false
    PublicFormsV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicFormSummaryV1"
        meta:
          $ref: "#/components/schemas/ApiV1ListMeta"
      additionalProperties: false
    PublicFormV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          $ref: "#/components/schemas/PublicFormV1"
        meta:
          $ref: "#/components/schemas/ApiV1Meta"
      additionalProperties: false
    PublicFormSummaryV1:
      type: object
      required:
        - id
        - type
        - title
        - description
        - status
        - publicationScope
        - version
        - jurisdiction
        - organisation
        - path
        - keywords
      properties:
        id:
          type: string
          format: uuid
        type:
          type: string
          enum:
            - form
        title:
          type: string
        description:
          type: string
        status:
          type: string
          enum:
            - published
        publicationScope:
          type: string
          enum:
            - internet
        version:
          type: integer
          minimum: 1
        jurisdiction:
          oneOf:
            - $ref: "#/components/schemas/PublicGroupRefV1"
            - type: "null"
        organisation:
          oneOf:
            - $ref: "#/components/schemas/PublicGroupRefV1"
            - type: "null"
        path:
          type: string
        keywords:
          type: array
          items:
            type: string
      additionalProperties: false
    PublicFormV1:
      allOf:
        - $ref: "#/components/schemas/PublicFormSummaryV1"
        - type: object
          required:
            - schema
            - deliveryOffer
            - profileConsentOffers
          properties:
            schema:
              $ref: "#/components/schemas/PublicFormSchemaV1"
            deliveryOffer:
              $ref: "#/components/schemas/DeliveryOfferV1"
            profileConsentOffers:
              description: Current form-specific optional offers, available before login. Null when the application module is unavailable.
              oneOf:
                - $ref: "#/components/schemas/PublicFormProfileConsentOffersV1"
                - type: "null"
    PublicFormProfileConsentOffersV1:
      type: object
      required:
        - de
        - en
      additionalProperties: false
      properties:
        de:
          $ref: "#/components/schemas/PublicFormProfileConsentLocaleV1"
        en:
          $ref: "#/components/schemas/PublicFormProfileConsentLocaleV1"
    PublicFormProfileConsentLocaleV1:
      type: object
      required:
        - contact
        - bank
      additionalProperties: false
      properties:
        contact:
          oneOf:
            - $ref: "#/components/schemas/PublicFormProfileConsentOfferV1"
            - type: "null"
        bank:
          description: Available only when the form also offers contact consent and bank data reuse is enabled.
          oneOf:
            - $ref: "#/components/schemas/PublicFormProfileConsentOfferV1"
            - type: "null"
    PublicFormProfileConsentOfferV1:
      type: object
      required:
        - id
        - textVersion
        - text
        - fields
      additionalProperties: false
      properties:
        id:
          type: string
          pattern: ^[0-9a-f]{64}$
          description: Opaque offer ID bound to consent kind, form revision, office, locale, field list and wording.
        textVersion:
          type: string
          example: 2026-11-20
        text:
          type: string
          description: Rendered plain text. Display verbatim before accepting consent.
        fields:
          type: array
          minItems: 1
          uniqueItems: true
          description: Ordered applicant CRM keys covered by the offer. Contains no submitted values.
          items:
            type: string
    DeliveryRouteV1:
      type: string
      enum:
        - portal
        - postal
        - bundid
      description: "How the authority answers: `portal` in the citizen portal with an email notice, `postal` by post, `bundid` into the BundID postbox. Decisions always go by post in this version; a copy stays in the citizen portal."
    DeliveryOfferV1:
      type: object
      description: "Delivery routes the citizen may choose on this form and the preselected one. Only routes that work today are offered: `bundid` appears only once a BundID postbox is connected. A form without an offer (`configured: false`) asks nothing; its applications use the citizen portal. Clients show a choice only when more than one route is offered."
      required:
        - configured
      properties:
        configured:
          type: boolean
        routes:
          type: array
          minItems: 1
          uniqueItems: true
          items:
            $ref: "#/components/schemas/DeliveryRouteV1"
        default:
          $ref: "#/components/schemas/DeliveryRouteV1"
      additionalProperties: false
      examples:
        - configured: true
          routes:
            - portal
            - postal
          default: portal
        - configured: false
    PublicGroupRefV1:
      type: object
      required:
        - slug
        - name
        - uuid
      properties:
        slug:
          oneOf:
            - $ref: "#/components/schemas/PublicSlug"
            - type: "null"
        name:
          type: string
        uuid:
          type: string
          format: uuid
      additionalProperties: false
    PublicFormSchemaV1:
      type: object
      required:
        - title
        - sections
      properties:
        id:
          type: string
        title:
          type: string
        description:
          type: string
        version:
          oneOf:
            - type: integer
            - type: number
        auth:
          $ref: "#/components/schemas/PublicFormAuthV1"
        sections:
          type: array
          minItems: 1
          items:
            $ref: "#/components/schemas/PublicFormSectionV1"
      additionalProperties: false
    PublicFormSectionV1:
      type: object
      required:
        - id
        - title
        - fields
      properties:
        id:
          type: string
        title:
          type: string
        description:
          type: string
        repeatable:
          type: boolean
        maxInstances:
          oneOf:
            - type: integer
            - type: number
        fields:
          type: array
          minItems: 1
          items:
            $ref: "#/components/schemas/PublicFormFieldV1"
      additionalProperties: false
    PublicFormFieldV1:
      type: object
      required:
        - id
        - type
        - label
      properties:
        id:
          type: string
        type:
          type: string
          enum:
            - text
            - textarea
            - email
            - tel
            - number
            - date
            - select
            - radio
            - checkbox
            - file
        label:
          type: string
        placeholder:
          type: string
        format:
          type: string
          enum:
            - postal_code
            - iban
            - bic
            - tax_id
            - currency
            - reference_number
            - url
        required:
          type: boolean
        defaultValue:
          description: Optional published initial answer. Textual fields use strings, choices must match an option, single checkboxes use booleans, and number fields use finite numbers or unambiguous decimal strings (comma or dot). Invalid types, choices, calendar dates, email/telephone and built-in formats, trimmed lengths and numeric bounds are omitted. Required fields receive no empty default. Defaults with custom patterns are omitted; only bounded built-in patterns are evaluated. Every positive step is checked relative to min (default 0), using the submission tolerance. Currency defaults use an implicit minimum of 0 and step of 0.01 unless explicitly configured. An integral step with an integral minimum additionally requires an integer. JSON integers outside plus or minus (2^53 - 1) are omitted; larger exact values require validated numeric strings, which retain their spelling. File, address and checkbox-group defaults are omitted. The client applies defaults only to absent answers. A later profile may replace untouched defaults, never edited, cleared or deliberately re-entered answers. On logout or profile disable, values still equal to the applied profile value are reverted, even if retyped. Origin metadata is never submitted.
          oneOf:
            - type: string
              maxLength: 10000
            - type: number
              minimum: -9007199254740991
              maximum: 9007199254740991
            - type: boolean
        crm_key:
          type: string
          enum:
            - person.full_name
            - person.email
        options:
          type: array
          items:
            type: string
        validation:
          $ref: "#/components/schemas/PublicFieldValidationV1"
        conditionalOn:
          $ref: "#/components/schemas/PublicFieldConditionalV1"
      additionalProperties: false
    PublicFieldValidationV1:
      type: object
      properties:
        minLength:
          oneOf:
            - type: integer
            - type: number
        maxLength:
          oneOf:
            - type: integer
            - type: number
        min:
          oneOf:
            - type: integer
            - type: number
        max:
          oneOf:
            - type: integer
            - type: number
        step:
          oneOf:
            - type: integer
            - type: number
      additionalProperties: false
    PublicFieldConditionalV1:
      type: object
      required:
        - fieldId
      properties:
        fieldId:
          type: string
        value:
          oneOf:
            - type: string
            - type: boolean
      additionalProperties: false
    PublicFormAuthV1:
      type: object
      properties:
        mode:
          type: string
          enum:
            - anonymous
            - optional
            - required
        providers:
          type: array
          items:
            type: string
            enum:
              - passwordless
              - bundid
        collect:
          type: object
          properties:
            fullName:
              $ref: "#/components/schemas/PublicIdentityRequirementV1"
            email:
              $ref: "#/components/schemas/PublicIdentityRequirementV1"
          additionalProperties: false
      additionalProperties: false
    PublicIdentityRequirementV1:
      oneOf:
        - type: boolean
        - type: string
          enum:
            - required
            - optional
            - none
    PublicApplicationsV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicApplicationSummaryV1"
        meta:
          $ref: "#/components/schemas/PublicApplicationListMetaV1"
      additionalProperties: false
    PublicApplicationV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          $ref: "#/components/schemas/PublicApplicationDetailV1"
        meta:
          $ref: "#/components/schemas/PublicApplicationDetailMetaV1"
      additionalProperties: false
    PublicApplicationCommentsV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/PublicApplicationCommentV1"
        meta:
          $ref: "#/components/schemas/PublicApplicationCommentListMetaV1"
      additionalProperties: false
    PublicApplicationCommentV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          $ref: "#/components/schemas/PublicApplicationCommentV1"
        meta:
          $ref: "#/components/schemas/PublicApplicationCommentMetaV1"
      additionalProperties: false
    StaffApplicationsV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          type: array
          items:
            oneOf:
              - $ref: "#/components/schemas/StaffApplicationSummaryV1"
              - $ref: "#/components/schemas/StaffUnconfirmedApplicationSummaryV1"
        meta:
          $ref: "#/components/schemas/StaffApplicationListMetaV1"
      additionalProperties: false
    StaffApplicationV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          $ref: "#/components/schemas/StaffApplicationDetailV1"
        meta:
          $ref: "#/components/schemas/StaffApplicationDetailMetaV1"
      additionalProperties: false
    StaffApplicationSummaryV1:
      type: object
      required:
        - type
        - id
        - referenceNumber
        - form
        - workspace
        - status
        - assignmentVisible
        - submittedAt
        - updatedAt
        - emailConfirmed
      properties:
        type:
          type: string
          enum:
            - staff_application
        id:
          type: string
          format: uuid
        referenceNumber:
          type: string
          example: MS-BB-2026-00042
        form:
          $ref: "#/components/schemas/PublicApplicationFormRefV1"
        workspace:
          $ref: "#/components/schemas/StaffApplicationWorkspaceV1"
        status:
          $ref: "#/components/schemas/StaffApplicationWorkflowStatusV1"
        assignmentVisible:
          type: boolean
          description: True when the authenticated account may view assignment relationships. An allowed but currently unassigned application has this value set to true and may omit `assignment`.
        assignment:
          $ref: "#/components/schemas/StaffApplicationAssignmentV1"
        applicant:
          $ref: "#/components/schemas/StaffApplicationApplicantV1"
        crmData:
          type: object
          description: Allowlisted CRM summary values visible to this staff account.
          additionalProperties:
            type: string
        dueDate:
          type: string
          format: date
        submittedAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        emailConfirmed:
          type: boolean
          const: true
        submittedData:
          type: object
          description: Present only when `include=submittedData` is combined with an explicit form filter. Protected fields remain redacted unless the account has reveal permission.
          additionalProperties:
            $ref: "#/components/schemas/StaffApplicationSubmittedFieldValueV1"
      additionalProperties: false
    StaffUnconfirmedApplicationSummaryV1:
      type: object
      required:
        - id
        - referenceNumber
        - form
        - workspace
        - submittedAt
        - applicantName
        - confirmationEmail
        - emailConfirmed
      properties:
        id:
          type: string
          format: uuid
        referenceNumber:
          type: string
        form:
          $ref: "#/components/schemas/PublicApplicationFormRefV1"
        workspace:
          $ref: "#/components/schemas/StaffApplicationWorkspaceV1"
        submittedAt:
          type: string
          format: date-time
        applicantName:
          type:
            - string
            - "null"
          description: Name from the staff CRM projection, or null when missing or protected.
        confirmationEmail:
          type:
            - string
            - "null"
          format: email
          description: Address recorded for the confirmation email, or null when missing or protected.
        emailConfirmed:
          type: boolean
          const: false
      additionalProperties: false
    StaffApplicationDetailV1:
      type: object
      required:
        - type
        - id
        - referenceNumber
        - form
        - workspace
        - status
        - assignmentVisible
        - submittedAt
        - updatedAt
        - submittedData
        - timeline
      properties:
        type:
          type: string
          enum:
            - staff_application
        id:
          type: string
          format: uuid
        referenceNumber:
          type: string
          example: MS-BB-2026-00042
        form:
          $ref: "#/components/schemas/PublicApplicationFormRefV1"
        workspace:
          $ref: "#/components/schemas/StaffApplicationWorkspaceV1"
        status:
          $ref: "#/components/schemas/StaffApplicationWorkflowStatusV1"
        assignmentVisible:
          type: boolean
          description: True when the authenticated account may view assignment relationships.
        assignment:
          $ref: "#/components/schemas/StaffApplicationAssignmentV1"
        applicant:
          $ref: "#/components/schemas/StaffApplicationApplicantV1"
        crmData:
          type: object
          description: Allowlisted CRM values visible to this staff account.
          additionalProperties:
            type: string
        dueDate:
          type: string
          format: date
        submittedAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        submittedData:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/StaffApplicationSubmittedFieldValueV1"
        timeline:
          type: array
          items:
            $ref: "#/components/schemas/PublicApplicationTimelineEventV1"
        workflowAttributes:
          type: object
          description: Allowlisted workflow metadata for the Staff detail view.
          additionalProperties:
            type: string
        profileConsent:
          $ref: "#/components/schemas/ApplicationConsentSummaryV1"
        bankConsent:
          $ref: "#/components/schemas/ApplicationConsentSummaryV1"
      additionalProperties: false
    ApplicationConsentSummaryV1:
      type: object
      description: Consent stored on the application for the applicant profile. Text and hash of the consent record are not part of the projection.
      required:
        - given
        - at
        - textVersion
        - scopeLabel
      properties:
        given:
          type: boolean
        at:
          type:
            - string
            - "null"
          format: date-time
        textVersion:
          type:
            - string
            - "null"
          example: 2026-10-20.3
        scopeLabel:
          type:
            - string
            - "null"
          description: Organisation or jurisdiction named in the consent text.
      additionalProperties: false
    StaffApplicationWorkflowStatusV1:
      type: object
      required:
        - code
        - semanticFlags
        - allowedNextIds
      properties:
        id:
          type: string
          format: uuid
        code:
          type: string
          example: in_review
        label:
          type: string
          example: In Prüfung
        color:
          type: string
          example: blue
        icon:
          type: string
          example: hourglass
        weight:
          type: integer
        semanticFlags:
          type: array
          items:
            type: string
        allowedNextIds:
          type: array
          description: Effective transition target UUIDs available without additional runtime input for this application, resolved from the form's current published workflow. Empty while reviewCode is present.
          items:
            type: string
            format: uuid
        reviewCode:
          type: string
          enum:
            - status_not_in_workflow
          description: Present only when the application needs a person to look at it. status_not_in_workflow means the current status is no longer part of the form's current published workflow and is not terminal, so no transition leads on from it. The system never moves the application by itself; staff set a valid status. Absent otherwise.
      additionalProperties: false
    StaffWorkflowStatusV1:
      type: object
      required:
        - id
        - machineName
        - label
        - semanticFlags
      properties:
        id:
          type: string
          format: uuid
        machineName:
          type: string
        label:
          type: string
        color:
          type: string
        icon:
          type: string
        weight:
          type: integer
        semanticFlags:
          type: array
          items:
            type: string
      additionalProperties: false
    StaffApplicationAssignmentV1:
      type: object
      properties:
        assigneeId:
          type: string
          format: uuid
        teamId:
          type: string
          format: uuid
      additionalProperties: false
    StaffApplicationApplicantV1:
      type: object
      properties:
        email:
          type: string
          format: email
      additionalProperties: false
    StaffApplicationWorkspaceV1:
      type: object
      required:
        - jurisdiction
      properties:
        jurisdiction:
          $ref: "#/components/schemas/StaffApplicationWorkspaceRefV1"
        organisation:
          $ref: "#/components/schemas/StaffApplicationWorkspaceRefV1"
      additionalProperties: false
    StaffApplicationWorkspaceRefV1:
      type: object
      required:
        - id
        - slug
        - label
      properties:
        id:
          type: string
          format: uuid
        slug:
          $ref: "#/components/schemas/PublicSlug"
        label:
          type: string
      additionalProperties: false
    StaffApplicationSubmittedFieldValueV1:
      oneOf:
        - type: string
        - type: number
        - type: boolean
        - type: array
          items: {}
        - type: object
          additionalProperties: true
        - type: "null"
    PublicApplicationSummaryV1:
      type: object
      required:
        - type
        - id
        - referenceNumber
        - form
        - status
        - submittedAt
        - updatedAt
      properties:
        type:
          type: string
          enum:
            - application
        id:
          type: string
          format: uuid
        referenceNumber:
          type: string
          example: MS-BAU-2026-00005
        form:
          $ref: "#/components/schemas/PublicApplicationFormRefV1"
        status:
          $ref: "#/components/schemas/PublicApplicationWorkflowStatusV1"
        submittedAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      additionalProperties: false
    PublicApplicationDetailV1:
      type: object
      required:
        - type
        - id
        - referenceNumber
        - form
        - status
        - submittedAt
        - updatedAt
        - submittedData
        - timeline
        - delivery
      properties:
        type:
          type: string
          enum:
            - application
        id:
          type: string
          format: uuid
        referenceNumber:
          type: string
          example: MS-BAU-2026-00005
        form:
          $ref: "#/components/schemas/PublicApplicationFormRefV1"
        status:
          $ref: "#/components/schemas/PublicApplicationWorkflowStatusV1"
        submittedAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        submittedData:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/PublicApplicationSubmittedFieldValueV1"
        timeline:
          type: array
          items:
            $ref: "#/components/schemas/PublicApplicationTimelineEventV1"
        delivery:
          $ref: "#/components/schemas/PublicApplicationDeliveryV1"
      additionalProperties: false
    PublicApplicationDeliveryV1:
      type: object
      description: Current delivery route of the application, where it came from and when it was set. Only in the application detail; the record of route changes stays with the authority. All three keys are always present; `source` and `chosenAt` are `null` without a record.
      required:
        - route
        - source
        - chosenAt
      properties:
        route:
          $ref: "#/components/schemas/DeliveryRouteV1"
        source:
          type:
            - string
            - "null"
          enum:
            - public_submit
            - manifest
            - form_default
            - staff
            - null
          description: "`public_submit` chosen when applying, `manifest` from a batch manifest, `form_default` the form's preselection, `staff` changed by the authority on request. `null` for applications without a record (submitted before delivery routes existed)."
        chosenAt:
          type:
            - string
            - "null"
          format: date-time
          description: When the current route was set; `null` without a record.
      additionalProperties: false
    PublicApplicationFormRefV1:
      type: object
      required:
        - title
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
      additionalProperties: false
    PublicApplicationWorkflowStatusV1:
      type: object
      required:
        - code
      properties:
        code:
          type: string
          example: in_review
        label:
          type: string
          example: In Pruefung
        color:
          type: string
          example: blue
        icon:
          type: string
          example: hourglass
      additionalProperties: false
    PublicApplicationSubmittedFieldValueV1:
      oneOf:
        - type: string
        - type: number
        - type: boolean
        - type: array
          items: {}
        - $ref: "#/components/schemas/PublicApplicationRedactedValueV1"
        - type: "null"
    PublicApplicationRedactedValueV1:
      type: object
      required:
        - __beantragt_redacted
      properties:
        __beantragt_redacted:
          type: boolean
          enum:
            - true
      additionalProperties: false
    PublicApplicationTimelineEventV1:
      type: object
      required:
        - status
        - timestamp
      properties:
        status:
          type: string
        timestamp:
          type: string
          format: date-time
        label:
          type: string
        color:
          type: string
        icon:
          type: string
        actor:
          type: string
          enum:
            - staff
      additionalProperties: false
    PublicApplicationCommentV1:
      type: object
      required:
        - type
        - id
        - body
        - authorRole
        - visibility
        - createdAt
        - attachments
      properties:
        type:
          type: string
          enum:
            - application_comment
        id:
          type: string
          format: uuid
        body:
          type: string
          maxLength: 5000
        authorRole:
          type: string
          enum:
            - citizen
            - staff
        visibility:
          type: string
          enum:
            - public
          description: Citizen-v1 exposes only public citizen communication. Internal staff notes are first-party admin data and are not emitted by this endpoint.
        createdAt:
          type: string
          format: date-time
        attachments:
          type: array
          description: Safe metadata for comment attachments. Public-v1 exposes no file entity ids or private file URLs.
          items:
            $ref: "#/components/schemas/PublicApplicationCommentAttachmentV1"
      additionalProperties: false
    PublicApplicationCommentAttachmentV1:
      type: object
      required:
        - filename
        - size
      properties:
        filename:
          type: string
          maxLength: 255
        size:
          type: integer
          minimum: 0
      additionalProperties: false
    PublicApplicationCommentCreateV1Request:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          required:
            - type
            - attributes
          properties:
            type:
              type: string
              enum:
                - application_comment
            attributes:
              $ref: "#/components/schemas/PublicApplicationCommentCreateAttributesV1"
          additionalProperties: false
      additionalProperties: false
    PublicApplicationCommentCreateAttributesV1:
      type: object
      required:
        - body
      properties:
        body:
          type: string
          minLength: 1
          maxLength: 5000
        attachments:
          type: array
          maxItems: 5
          description: One-time attachment claims returned by POST /api/v1/applications/{application_uuid}/comment-attachments.
          items:
            $ref: "#/components/schemas/PublicApplicationCommentAttachmentClaimV1"
      additionalProperties: false
    PublicApplicationCommentAttachmentClaimV1:
      type: object
      required:
        - attachmentId
        - claimToken
      properties:
        attachmentId:
          type: string
          format: uuid
        claimToken:
          type: string
          minLength: 32
          maxLength: 128
      additionalProperties: false
    PublicApplicationCommentAttachmentUploadV1Request:
      type: object
      required:
        - file
      properties:
        file:
          type: string
          format: binary
          description: PDF, JPG, JPEG or PNG. The platform cap is 10 MB per file; a FormSchema file field may define a stricter byte limit.
      additionalProperties: false
    PublicApplicationCommentAttachmentCreatedV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          $ref: "#/components/schemas/PublicApplicationCommentAttachmentCreatedV1"
        meta:
          $ref: "#/components/schemas/PublicApplicationCommentAttachmentMetaV1"
      additionalProperties: false
    PublicApplicationCommentAttachmentCreatedV1:
      type: object
      required:
        - type
        - id
        - applicationId
        - claimToken
        - filename
        - mimeType
        - size
        - scanStatus
        - expiresAt
      properties:
        type:
          type: string
          enum:
            - comment_attachment
        id:
          type: string
          format: uuid
        applicationId:
          type: string
          format: uuid
        claimToken:
          type: string
          minLength: 32
          maxLength: 128
        filename:
          type: string
          maxLength: 255
        mimeType:
          type: string
          enum:
            - application/pdf
            - image/jpeg
            - image/png
        size:
          type: integer
          minimum: 0
          maximum: 10485760
        scanStatus:
          type: string
          enum:
            - clean
          description: Malware scan result. Only clean uploads receive a claim token; quarantined uploads return 422 attachment.quarantined instead.
        expiresAt:
          type: string
          format: date-time
      additionalProperties: false
    PublicApplicationCommentAttachmentMetaV1:
      type: object
      required:
        - apiVersion
        - resource
      properties:
        apiVersion:
          type: string
          example: "1.0"
        resource:
          type: string
          enum:
            - commentAttachment
      additionalProperties: false
    PublicApplicationConfirmationV1Response:
      type: object
      required:
        - status
        - referenceNumber
        - jurisdictionSlug
        - receipt
      additionalProperties: false
      properties:
        status:
          type: string
          enum:
            - confirmed
            - already_confirmed
        referenceNumber:
          type:
            - string
            - "null"
          description: Application reference. Null if missing from the stored application.
          example: MST-2026-00001
        jurisdictionSlug:
          type:
            - string
            - "null"
          description: Stored jurisdiction slug. Null if no usable slug is available.
          pattern: ^[a-z0-9](?:[a-z0-9-]{0,126}[a-z0-9])?$
          example: musterstadt
        organisationSlug:
          type: string
          description: Omitted if no usable organisation slug belongs to the jurisdiction.
          pattern: ^[a-z0-9](?:[a-z0-9-]{0,126}[a-z0-9])?$
          example: musteramt
        receipt:
          $ref: "#/components/schemas/PublicSubmissionReceipt"
    PublicApplicationConfirmationV1Error:
      type: object
      required:
        - error
      additionalProperties: false
      properties:
        error:
          type: object
          required:
            - code
          additionalProperties: false
          properties:
            code:
              type: string
              enum:
                - confirmation.invalid
                - rate_limit.exceeded
    PublicApplicationSubmissionV1Request:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          required:
            - type
            - attributes
          properties:
            type:
              type: string
              enum:
                - application
            attributes:
              $ref: "#/components/schemas/PublicApplicationSubmissionAttributesV1"
          additionalProperties: false
      additionalProperties: false
    PublicApplicationSubmissionAttributesV1:
      type: object
      required:
        - formId
        - data
        - consentAccepted
      properties:
        formId:
          type: string
          format: uuid
        data:
          type: object
          maxProperties: 200
          additionalProperties:
            $ref: "#/components/schemas/PublicSubmittedFieldValueV1"
        identity:
          type: object
          properties:
            fullName:
              type: string
              maxLength: 200
            email:
              type: string
              format: email
              maxLength: 254
          additionalProperties: false
        attachments:
          type: array
          maxItems: 20
          items:
            $ref: "#/components/schemas/PublicApplicationAttachmentClaimV1"
        consentAccepted:
          type: boolean
          enum:
            - true
        profileConsent:
          type: boolean
          description: Store approved applicant data in the profile after email verification. Counts only when true and profileConsentOfferId matches the current contact offer in the submission locale. Stale or missing consent does not prevent application creation.
        bankConsent:
          type: boolean
          description: Separately approve reuse of the bank fields in the current bank offer. Counts only when true, bankConsentOfferId matches and contact consent was accepted.
        profileConsentOfferId:
          type: string
          pattern: ^[0-9a-f]{64}$
          description: Echo data.profileConsentOffers[locale].contact.id from the displayed form detail.
        bankConsentOfferId:
          type: string
          pattern: ^[0-9a-f]{64}$
          description: Echo data.profileConsentOffers[locale].bank.id from the displayed form detail.
        consentTextVersion:
          type: string
          deprecated: true
          description: Legacy echo accepted on input for compatibility. It grants no consent.
        bankConsentTextVersion:
          type: string
          deprecated: true
          description: Legacy echo accepted on input for compatibility. It grants no consent.
        consentStelle:
          type: string
          deprecated: true
          description: Legacy echo accepted on input for compatibility. It grants no consent.
        deliveryRoute:
          $ref: "#/components/schemas/DeliveryRouteV1"
          description: Optional delivery route the citizen chose from the form's `deliveryOffer`. Falls back to the form default when absent or not offered; never causes a 400. The choice is recorded on the application (`delivery` in the detail).
        locale:
          type: string
          enum:
            - de
            - en
          description: "Submission language. It must be the language of the consent texts the client showed: the consent record stores the text rendered in this language, together with its hash. Without `locale` the backend uses German; another value is rejected with `400 locale.invalid`. A client that switches the language after a checkbox was ticked must clear the checkbox, because the text changed."
      additionalProperties: false
    PublicSubmittedFieldValueV1:
      oneOf:
        - type: string
          maxLength: 50000
        - type: number
        - type: boolean
        - type: array
          maxItems: 100
          items:
            type: string
            maxLength: 1000
    PublicApplicationAttachmentClaimV1:
      type: object
      required:
        - fieldId
        - attachmentId
        - claimToken
      properties:
        fieldId:
          type: string
          pattern: ^[a-z][a-z0-9_]{0,127}$
        attachmentId:
          type: string
          format: uuid
        claimToken:
          type: string
          minLength: 32
          maxLength: 96
          pattern: ^[A-Za-z0-9_-]+$
      additionalProperties: false
    PublicApplicationAttachmentUploadV1Request:
      type: object
      required:
        - formId
        - fieldId
        - file
      properties:
        formId:
          type: string
          format: uuid
        fieldId:
          type: string
          pattern: ^[a-z][a-z0-9_]{0,127}$
        file:
          type: string
          format: binary
          description: PDF, JPG, JPEG or PNG. Maximum 10 MB.
      additionalProperties: false
    PublicApplicationAttachmentCreatedV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          $ref: "#/components/schemas/PublicApplicationAttachmentCreatedV1"
        meta:
          $ref: "#/components/schemas/ApiV1Meta"
      additionalProperties: false
    PublicApplicationAttachmentCreatedV1:
      type: object
      required:
        - id
        - type
        - formId
        - fieldId
        - claimToken
        - filename
        - mimeType
        - size
        - scanStatus
        - analysisStatus
        - expiresAt
      properties:
        id:
          type: string
          format: uuid
        type:
          type: string
          enum:
            - application_attachment
        formId:
          type: string
          format: uuid
        fieldId:
          type: string
        claimToken:
          type: string
          minLength: 32
          maxLength: 96
          pattern: ^[A-Za-z0-9_-]+$
        filename:
          type: string
          maxLength: 180
        mimeType:
          type: string
          enum:
            - application/pdf
            - image/jpeg
            - image/png
        size:
          type: integer
          minimum: 1
          maximum: 10485760
        scanStatus:
          type: string
          enum:
            - clean
          description: Malware scan result. Only clean uploads receive a claim token; quarantined uploads return 422 attachment.quarantined instead.
        analysisStatus:
          type: string
          enum:
            - not_requested
            - pending
            - complete
            - failed
        expiresAt:
          type: string
          format: date-time
      additionalProperties: false
    PublicApplicationCreatedV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          $ref: "#/components/schemas/PublicApplicationCreatedV1"
        meta:
          $ref: "#/components/schemas/PublicApplicationCreatedV1Meta"
        confirmation:
          type: object
          description: Confirmation requirement recorded when the application was created.
          required:
            - required
          properties:
            required:
              type: boolean
          additionalProperties: false
      additionalProperties: false
    PublicApplicationCreatedV1Meta:
      type: object
      required:
        - apiVersion
        - resource
      properties:
        apiVersion:
          type: string
          example: "1.0"
        resource:
          type: string
          example: application
        idempotency:
          type: object
          required:
            - replayed
          properties:
            replayed:
              type: boolean
              enum:
                - true
          additionalProperties: false
      additionalProperties: false
    PublicApplicationCreatedV1:
      type: object
      required:
        - id
        - type
        - formId
        - referenceNumber
        - statusToken
        - statusUrl
        - receipt
      properties:
        id:
          type: string
          format: uuid
        type:
          type: string
          enum:
            - application
        formId:
          type: string
          format: uuid
        referenceNumber:
          type: string
          example: MS-BB-2026-00001
        statusToken:
          type: string
          minLength: 32
          maxLength: 96
          pattern: ^[A-Za-z0-9_-]+$
        statusUrl:
          type: string
          example: /api/v1/status/eyJ...abc?schemaId=8fd3a0b2-4495-4efb-b7ef-5d331ee9b7c6
        receipt:
          $ref: "#/components/schemas/PublicSubmissionReceipt"
      additionalProperties: false
    PublicSubmissionReceipt:
      type:
        - object
        - "null"
      description: Public receipt from the saved submission. Null if the stored context cannot be resolved.
      required:
        - referenceNumber
        - formTitle
        - submittedAt
        - jurisdictionName
        - organisationName
      properties:
        referenceNumber:
          type: string
        formTitle:
          type: string
          description: Form title saved at submission.
        submittedAt:
          type: string
          format: date-time
        jurisdictionName:
          type:
            - string
            - "null"
        organisationName:
          type:
            - string
            - "null"
      additionalProperties: false
    PublicStatusV1Response:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          $ref: "#/components/schemas/PublicStatusV1"
        meta:
          $ref: "#/components/schemas/ApiV1Meta"
      additionalProperties: false
    PublicStatusV1:
      type: object
      required:
        - referenceNumber
        - status
        - formTitle
        - organisationName
        - submittedAt
        - updatedAt
        - timeline
      properties:
        referenceNumber:
          type: string
        status:
          type: string
        formTitle:
          type: string
        organisationName:
          type:
            - string
            - "null"
        submittedAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        timeline:
          type: array
          items:
            $ref: "#/components/schemas/PublicStatusTimelineEventV1"
      additionalProperties: false
    PublicStatusTimelineEventV1:
      type: object
      required:
        - status
        - timestamp
      properties:
        status:
          type: string
        timestamp:
          type: string
          format: date-time
        actor:
          type:
            - string
            - "null"
          enum:
            - staff
            - null
      additionalProperties: false
