# The web API, described in OpenAPI 3.1. Kept by hand, beside the views it describes.
#
# tests/test_openapi.py fails when a route or method is missing here, or here and
# not in the API; every JSON answer the web tests receive, and every JSON body they
# send that is accepted, is checked against it as they run (tests/openapi_check.py).
# The documentation site's Web API reference is made from it.
openapi: 3.1.0
info:
  title: FlowAssembly web API
  version: v0
  description: The API the web application uses, and other systems can too. JSON under /api/v0. See the
    API guide for signing in, errors and examples.
security:
- session: []
  csrf: []
tags:
- name: Session
  description: Signing in and out. Every other call needs a session, except health, messages' webhooks
    and the metrics page.
- name: Work
  description: 'Tasks: finding them, opening them, submitting them and passing them on.'
- name: Cases
  description: Starting cases, finding them, following them and controlling them.
- name: Case files and evidence
  description: What people added to a case, and what the case sent.
- name: Messages from other systems
  description: Other systems starting cases and moving them on.
- name: Supervision
  description: Keeping work moving.
- name: Notices and absence
  description: What each person is told, and time out of office.
- name: Reports
  description: How work is going, and finding cases by their fields.
- name: Releases
  description: What is deployed, and moving running cases to a new release.
- name: Build
  description: Templates for new projects.
- name: Admin
  description: People, sign-in, settings, plugins and the instance's health.
- name: Plugins
  description: APIs that installed plugins add.
- name: Health
  description: For probes and load balancers; no session needed.
paths:
  /healthz:
    get:
      tags:
      - Health
      summary: Is the process alive
      description: Answers while the process runs, without the database. For liveness probes.
      operationId: get_healthz
      responses:
        '200':
          description: Alive
          content:
            application/json:
              schema: &id001
                type: object
                required:
                - status
                properties:
                  status:
                    type: string
        4XX:
          $ref: '#/components/responses/Problem'
      security: []
  /readyz:
    get:
      tags:
      - Health
      summary: Is it ready for work
      description: Answers 200 when the database is reachable, 503 when it is not. For readiness probes
        and load balancers.
      operationId: get_readyz
      responses:
        '200':
          description: Ready
          content:
            application/json:
              schema: *id001
        4XX:
          $ref: '#/components/responses/Problem'
        '503':
          description: 'Not ready: the database cannot be reached'
          content:
            application/json:
              schema: *id001
      security: []
  /api/v0/session:
    get:
      tags:
      - Session
      summary: Who is signed in
      description: The person signed in and what they may do. Signed out, answers 401 with the sign-in
        sources, the organisation's name, any maintenance notice, and a CSRF token to sign in with.
      operationId: get_session
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  absence:
                    type:
                    - 'null'
                    - object
                  configures:
                    type: boolean
                  csrf_token:
                    type: string
                  inspects_releases:
                    type: boolean
                  maintains:
                    type: boolean
                  manages_users:
                    type: boolean
                  organisation:
                    type: object
                    properties:
                      maintenance:
                        type:
                        - 'null'
                        - object
                      name:
                        type: string
                      time_zone:
                        type: string
                    required:
                    - maintenance
                    - name
                    - time_zone
                  platform_roles:
                    type: array
                    items:
                      type: object
                      properties:
                        projects: {}
                        role:
                          type: string
                      required:
                      - projects
                      - role
                  plugins:
                    type: object
                    properties:
                      fields:
                        type: array
                        items:
                          type: object
                          properties:
                            script:
                              type: string
                            title:
                              type: string
                            type:
                              type: string
                          required:
                          - script
                          - title
                          - type
                      pages:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                            plugin:
                              type: string
                            script:
                              type: string
                            section:
                              type: string
                            title:
                              type: string
                          required:
                          - id
                          - plugin
                          - script
                          - section
                          - title
                    required:
                    - fields
                    - pages
                  project_roles:
                    type: object
                    properties:
                      agent-recruitment:
                        type: array
                        items:
                          type: string
                      loan-referral:
                        type: array
                        items:
                          type: string
                  reports_projects:
                    type: array
                    items:
                      type: string
                  sections:
                    type: array
                    items:
                      type: string
                  supervises:
                    type: array
                    items:
                      type: string
                  user:
                    type: object
                    properties:
                      email: {}
                      name:
                        type: string
                      subject:
                        type: string
                    required:
                    - email
                    - name
                    - subject
                  views_projects:
                    type: array
                    items:
                      type: string
                  withheld:
                    type: array
                    items: {}
                required:
                - absence
                - configures
                - csrf_token
                - inspects_releases
                - maintains
                - manages_users
                - organisation
                - platform_roles
                - plugins
                - project_roles
                - reports_projects
                - sections
                - supervises
                - user
                - views_projects
                - withheld
        4XX:
          $ref: '#/components/responses/Problem'
    post:
      tags:
      - Session
      summary: Sign in
      description: Signs in with a username and password at one of the sign-in sources. Needs the CSRF
        token from GET /api/v0/session, and answers with a new one to use from then on. Repeated failures
        from one address are slowed down (429).
      operationId: post_session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                password:
                  type: string
                provider:
                  type: string
                username:
                  type: string
              required:
              - password
              - username
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  absence: {}
                  configures:
                    type: boolean
                  csrf_token:
                    type: string
                  inspects_releases:
                    type: boolean
                  maintains:
                    type: boolean
                  manages_users:
                    type: boolean
                  organisation:
                    type: object
                    properties:
                      maintenance:
                        type:
                        - 'null'
                        - object
                      name:
                        type: string
                      time_zone:
                        type: string
                    required:
                    - maintenance
                    - name
                    - time_zone
                  platform_roles:
                    type: array
                    items:
                      type: object
                      properties:
                        projects: {}
                        role:
                          type: string
                      required:
                      - projects
                      - role
                  plugins:
                    type: object
                    properties:
                      fields:
                        type: array
                        items:
                          type: object
                          properties:
                            script:
                              type: string
                            title:
                              type: string
                            type:
                              type: string
                          required:
                          - script
                          - title
                          - type
                      pages:
                        type: array
                        items: {}
                    required:
                    - fields
                    - pages
                  project_roles:
                    type: object
                    properties:
                      agent-recruitment:
                        type: array
                        items:
                          type: string
                      loan-referral:
                        type: array
                        items:
                          type: string
                      partner-intake:
                        type: array
                        items:
                          type: string
                  reports_projects:
                    type: array
                    items:
                      type: string
                  sections:
                    type: array
                    items:
                      type: string
                  supervises:
                    type: array
                    items:
                      type: string
                  user:
                    type: object
                    properties:
                      email:
                        type:
                        - 'null'
                        - string
                      name:
                        type: string
                      subject:
                        type: string
                    required:
                    - email
                    - name
                    - subject
                  views_projects:
                    type: array
                    items:
                      type: string
                  withheld:
                    type: array
                    items: {}
                required:
                - absence
                - configures
                - csrf_token
                - inspects_releases
                - maintains
                - manages_users
                - organisation
                - platform_roles
                - plugins
                - project_roles
                - reports_projects
                - sections
                - supervises
                - user
                - views_projects
                - withheld
        4XX:
          $ref: '#/components/responses/Problem'
    delete:
      tags:
      - Session
      summary: Sign out
      description: Ends the session everywhere.
      operationId: delete_session
      responses:
        '204':
          description: Signed out
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/inbox:
    get:
      tags:
      - Work
      summary: My tasks and my groups' tasks
      description: Open tasks assigned to me, and tasks waiting for anyone in roles I hold. `limit` (1
        to 200, default 50).
      operationId: get_inbox
      x-permission: runtime.claim
      parameters:
      - name: limit
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  tasks:
                    type: array
                    items:
                      $ref: '#/components/schemas/Task'
                required:
                - tasks
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/startable:
    get:
      tags:
      - Work
      summary: Processes I may start
      description: Each process I may start a case of, with its project and name.
      operationId: get_startable
      x-permission: runtime.start
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  processes:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        process:
                          type: string
                        project:
                          type: string
                        version:
                          type: string
                      required:
                      - name
                      - process
                      - project
                      - version
                required:
                - processes
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/projects/{project}/cases:
    post:
      tags:
      - Cases
      summary: Start a case
      description: Starts a case of `process` in the project's active release, with optional starting
        `data`. Answers with the case id and the tasks it gave me.
      operationId: post_projects_slug_project_cases
      x-permission: runtime.start
      parameters:
      - name: project
        in: path
        required: true
        schema:
          type: string
          pattern: ^[-a-zA-Z0-9_]+$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                process:
                  type: string
              required:
              - process
      responses:
        '201':
          description: Started
          content:
            application/json:
              schema:
                type: object
                properties:
                  case_id:
                    type: string
                  tasks:
                    type: array
                    items:
                      $ref: '#/components/schemas/Task'
                required:
                - case_id
                - tasks
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/projects/{project}/messages/{message}:
    post:
      tags:
      - Messages from other systems
      summary: Send a message to a case
      description: 'A message another system sends: it reaches the case waiting for it (matched by the
        fields the process correlates on), or starts a case if the process starts on it. 201 when it started
        a case, 200 when a case received it, 202 when it is kept until a case is ready for it (`kept_until`).'
      operationId: post_projects_slug_project_messages_str_message
      x-permission: runtime.message
      parameters:
      - name: project
        in: path
        required: true
        schema:
          type: string
          pattern: ^[-a-zA-Z0-9_]+$
      - name: message
        in: path
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - payload
              properties:
                payload:
                  type: object
                  description: The message's fields, as the project's message says.
      responses:
        '200':
          description: A case received it
          content:
            application/json:
              schema: &id003
                type: object
                required:
                - started
                - delivered
                properties:
                  started:
                    type: array
                    items: &id002
                      type: string
                      format: uuid
                    description: The cases it started.
                  delivered:
                    type: array
                    items: *id002
                    description: The cases that received it.
                  kept_until:
                    type: string
                    description: 'With 202: until when it is kept for a case to be ready for it.'
        '201':
          description: It started a case
          content:
            application/json:
              schema: *id003
        '202':
          description: Kept until a case is ready for it
          content:
            application/json:
              schema: *id003
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/projects/{project}/webhooks/{message}:
    post:
      tags:
      - Messages from other systems
      summary: Post a signed webhook
      description: For systems that sign their posts rather than sign in. The body is the system's own
        JSON; the webhook named in the project says which fields to take, the secret it is signed with
        and how the signature is sent. A post repeated with the same id gets the first answer. 404 when
        no webhook is set up for this message here.
      operationId: post_projects_slug_project_webhooks_str_message
      parameters:
      - name: project
        in: path
        required: true
        schema:
          type: string
          pattern: ^[-a-zA-Z0-9_]+$
      - name: message
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: A case received it
          content:
            application/json:
              schema: &id004
                type: object
                properties:
                  started:
                    type: boolean
                  case_id:
                    type:
                    - string
                    - 'null'
                  repeat:
                    type: boolean
                    description: 'The same post again: the first answer, and nothing done again.'
        4XX:
          $ref: '#/components/responses/Problem'
        '201':
          description: Started a case
          content:
            application/json:
              schema: *id004
        '202':
          description: Kept until a case is ready for it
          content:
            application/json:
              schema: *id004
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: The other system's own JSON; the webhook says which fields to take.
  /api/v0/cases:
    get:
      tags:
      - Cases
      summary: Find cases
      description: 'One page of the cases I may view, newest first: searched by the start of a case id
        or part of a title (`q`), and narrowed by `project`, `status`, and `started_after`/`started_before`.
        `limit` and `after` page through them.'
      operationId: get_cases
      x-permission: runtime.view
      parameters:
      - name: q
        in: query
        required: false
        schema:
          type: string
      - name: project
        in: query
        required: false
        schema:
          type: string
      - name: status
        in: query
        required: false
        schema:
          type: string
      - name: started_after
        in: query
        required: false
        schema:
          type: string
      - name: started_before
        in: query
        required: false
        schema:
          type: string
      - name: limit
        in: query
        required: false
        schema:
          type: string
      - name: after
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  cases:
                    type: array
                    items:
                      type: object
                      properties:
                        case_id:
                          type: string
                        now:
                          type: array
                          items:
                            type: object
                            properties:
                              kind:
                                type: string
                              step:
                                type: string
                              with:
                                type: string
                            required:
                            - kind
                            - step
                            - with
                        outcome:
                          type:
                          - 'null'
                          - string
                        owner:
                          type: string
                        owner_name:
                          type: string
                        process:
                          type: string
                        process_name:
                          type: string
                        project:
                          type: string
                        started_at:
                          type: string
                        status:
                          type: string
                        title:
                          type: string
                        updated_at:
                          type: string
                        version:
                          type: string
                      required:
                      - case_id
                      - now
                      - outcome
                      - owner
                      - owner_name
                      - process
                      - process_name
                      - project
                      - started_at
                      - status
                      - title
                      - updated_at
                      - version
                  next:
                    type:
                    - 'null'
                    - string
                required:
                - cases
                - next
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}:
    get:
      tags:
      - Cases
      summary: A case
      description: A case's data, status and progress, for someone who may view it.
      operationId: get_cases_uuid_case_id
      x-permission: runtime.view
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  can:
                    type: object
                    properties:
                      cancel:
                        type: boolean
                      suspend:
                        type: boolean
                    required:
                    - cancel
                    - suspend
                  case_id:
                    type: string
                  data:
                    type: object
                    properties:
                      agent_code:
                        type: string
                      agent_code_confirmed:
                        type: boolean
                      approval_note:
                        type: string
                      assessment_band:
                        type: string
                      assessment_score:
                        type: integer
                      candidate_email:
                        type: string
                      candidate_name:
                        type: string
                      candidate_phone:
                        type: string
                      documents_complete:
                        type: boolean
                      expectations_met:
                        type: boolean
                      licence_status:
                        type: string
                      location:
                        type: string
                      notification_id:
                        type: string
                      policies_registered:
                        type: integer
                      policy_number:
                        type: string
                  end_event:
                    type:
                    - 'null'
                    - string
                  hold: {}
                  now:
                    type: object
                    properties:
                      jobs:
                        type: array
                        items: {}
                      tasks:
                        type: array
                        items:
                          type: object
                          properties:
                            action_label:
                              type: string
                            assignee: {}
                            assignee_name: {}
                            due_at: {}
                            escalated_at: {}
                            name:
                              type: string
                            role:
                              type: string
                            role_title:
                              type: string
                            task_id:
                              type: string
                            yours:
                              type: boolean
                          required:
                          - action_label
                          - assignee
                          - assignee_name
                          - due_at
                          - escalated_at
                          - name
                          - role
                          - role_title
                          - task_id
                          - yours
                      waits:
                        type: array
                        items: {}
                    required:
                    - jobs
                    - tasks
                    - waits
                  open_tasks:
                    type: array
                    items:
                      $ref: '#/components/schemas/Task'
                  outcome:
                    type:
                    - 'null'
                    - object
                  owner:
                    type: string
                  owner_name:
                    type: string
                  process:
                    type: string
                  process_name:
                    type: string
                  project:
                    type: string
                  started_at:
                    type: string
                  status:
                    type: string
                  steps:
                    type: array
                    items:
                      type: object
                      properties:
                        element:
                          type: string
                        kind:
                          type: string
                        name:
                          type: string
                        times:
                          type: integer
                      required:
                      - element
                      - kind
                      - name
                      - times
                  title:
                    type: string
                  updated_at:
                    type: string
                  version:
                    type: string
                required:
                - can
                - case_id
                - data
                - end_event
                - hold
                - now
                - open_tasks
                - outcome
                - owner
                - owner_name
                - process
                - process_name
                - project
                - started_at
                - status
                - steps
                - title
                - updated_at
                - version
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}/status:
    get:
      tags:
      - Cases
      summary: Where a case has got to
      description: The steps done, the work open now and who has it, and what may be done to the case
        (suspend, resume, cancel).
      operationId: get_cases_uuid_case_id_status
      x-permission: runtime.view
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  can:
                    type: object
                    properties:
                      cancel:
                        type: boolean
                      suspend:
                        type: boolean
                    required:
                    - cancel
                    - suspend
                  case_id:
                    type: string
                  hold: {}
                  now:
                    type: object
                    properties:
                      jobs:
                        type: array
                        items:
                          type: object
                          properties:
                            attempts:
                              type: integer
                            error:
                              type: string
                            job_id:
                              type: string
                            name:
                              type: string
                            state:
                              type: string
                          required:
                          - attempts
                          - error
                          - job_id
                          - name
                          - state
                      tasks:
                        type: array
                        items:
                          type: object
                          properties:
                            action_label:
                              type: string
                            assignee: {}
                            assignee_name: {}
                            due_at:
                              type:
                              - string
                              - 'null'
                            escalated_at: {}
                            name:
                              type: string
                            role:
                              type: string
                            role_title:
                              type: string
                            task_id:
                              type: string
                            yours:
                              type: boolean
                          required:
                          - action_label
                          - assignee
                          - assignee_name
                          - due_at
                          - escalated_at
                          - name
                          - role
                          - role_title
                          - task_id
                          - yours
                      waits:
                        type: array
                        items:
                          type: object
                          properties:
                            due_at: {}
                            kind:
                              type: string
                            message:
                              type: string
                            name:
                              type: string
                          required:
                          - due_at
                          - kind
                          - message
                          - name
                    required:
                    - jobs
                    - tasks
                    - waits
                  outcome: {}
                  owner:
                    type: string
                  owner_name:
                    type: string
                  process:
                    type: string
                  process_name:
                    type: string
                  project:
                    type: string
                  started_at:
                    type: string
                  status:
                    type: string
                  steps:
                    type: array
                    items:
                      type: object
                      properties:
                        element:
                          type: string
                        kind:
                          type: string
                        name:
                          type: string
                        times:
                          type: integer
                      required:
                      - element
                      - kind
                      - name
                      - times
                  title:
                    type: string
                  updated_at:
                    type: string
                  version:
                    type: string
                required:
                - can
                - case_id
                - hold
                - now
                - outcome
                - owner
                - owner_name
                - process
                - process_name
                - project
                - started_at
                - status
                - title
                - updated_at
                - version
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}/audit:
    get:
      tags:
      - Cases
      summary: A case's history
      description: Everything that happened to the case, oldest first, each in plain words with who did
        it. `after` and `limit` page through it.
      operationId: get_cases_uuid_case_id_audit
      x-permission: assurance.audit
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: after
        in: query
        required: false
        schema:
          type: string
      - name: limit
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  events:
                    type: array
                    items:
                      type: object
                      properties:
                        action:
                          type: string
                        actor:
                          type: string
                        actor_name:
                          type: string
                        at:
                          type: string
                        detail:
                          type: object
                          properties:
                            attempt:
                              type: integer
                            cases:
                              type: array
                              items:
                                type: string
                            decision:
                              type: string
                            end_event:
                              type: string
                            error:
                              type: string
                            explanation:
                              type: string
                            field:
                              type: string
                            fields:
                              type: array
                              items:
                                type: string
                            file:
                              type: string
                            from:
                              type:
                              - 'null'
                              - string
                            implementation:
                              type: string
                            inputs:
                              type: object
                              properties:
                                assessment_score:
                                  type: integer
                              required:
                              - assessment_score
                            message:
                              type: string
                            name:
                              type: string
                            outcome:
                              type: string
                            outputs:
                              type: object
                              properties:
                                assessment_band:
                                  type: string
                              required:
                              - assessment_band
                            project:
                              type: string
                            reason:
                              type:
                              - string
                              - 'null'
                            role:
                              type: string
                            rules:
                              type: array
                              items:
                                type: integer
                            to:
                              type:
                              - 'null'
                              - string
                        id:
                          type: integer
                        kind:
                          type: string
                        subject:
                          type: string
                        text:
                          type: string
                      required:
                      - action
                      - actor
                      - actor_name
                      - at
                      - detail
                      - id
                      - kind
                      - subject
                      - text
                  next:
                    type:
                    - integer
                    - 'null'
                required:
                - events
                - next
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}/control:
    post:
      tags:
      - Cases
      summary: Suspend, resume or cancel a case
      description: '`action` is suspend, resume or cancel; `reason` is shown to everyone who follows the
        case and kept in its history. Answers with the case''s status.'
      operationId: post_cases_uuid_case_id_control
      x-permission: runtime.suspend or runtime.cancel
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - action
              properties:
                action:
                  enum:
                  - suspend
                  - resume
                  - cancel
                reason:
                  type: string
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  can:
                    type: object
                    properties:
                      cancel:
                        type: boolean
                      suspend:
                        type: boolean
                    required:
                    - cancel
                    - suspend
                  case_id:
                    type: string
                  hold:
                    type:
                    - object
                    - 'null'
                    properties:
                      at:
                        type: string
                      by:
                        type: string
                      by_name:
                        type: string
                      reason:
                        type: string
                    required:
                    - at
                    - by
                    - by_name
                    - reason
                  now:
                    type: object
                    properties:
                      jobs:
                        type: array
                        items: {}
                      tasks:
                        type: array
                        items:
                          type: object
                          properties:
                            action_label:
                              type: string
                            assignee: {}
                            assignee_name: {}
                            due_at: {}
                            escalated_at: {}
                            name:
                              type: string
                            role:
                              type: string
                            role_title:
                              type: string
                            task_id:
                              type: string
                            yours:
                              type: boolean
                          required:
                          - action_label
                          - assignee
                          - assignee_name
                          - due_at
                          - escalated_at
                          - name
                          - role
                          - role_title
                          - task_id
                          - yours
                      waits:
                        type: array
                        items: {}
                    required:
                    - jobs
                    - tasks
                    - waits
                  outcome: {}
                  owner:
                    type: string
                  owner_name:
                    type: string
                  process:
                    type: string
                  process_name:
                    type: string
                  project:
                    type: string
                  started_at:
                    type: string
                  status:
                    type: string
                  steps:
                    type: array
                    items: {}
                  title:
                    type: string
                  updated_at:
                    type: string
                  version:
                    type: string
                required:
                - can
                - case_id
                - hold
                - now
                - outcome
                - owner
                - owner_name
                - process
                - process_name
                - project
                - started_at
                - status
                - steps
                - title
                - updated_at
                - version
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}/comments:
    get:
      tags:
      - Cases
      summary: A case's comments
      description: Comments on the case and its tasks, oldest first.
      operationId: get_cases_uuid_case_id_comments
      x-permission: runtime.view, or a role in one of its tasks
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  comments:
                    type: array
                    items:
                      type: object
                      properties:
                        at:
                          type: string
                        by:
                          type: string
                        by_name:
                          type: string
                        id:
                          type: integer
                        task_id: {}
                        task_name: {}
                        text:
                          type: string
                      required:
                      - at
                      - by
                      - by_name
                      - id
                      - task_id
                      - task_name
                      - text
                required:
                - comments
        4XX:
          $ref: '#/components/responses/Problem'
    post:
      tags:
      - Cases
      summary: Comment on a case
      description: Adds `text` to the case, or to one of its open tasks with `task_id`. Answers with every
        comment.
      operationId: post_cases_uuid_case_id_comments
      x-permission: runtime.view, or a role in one of its tasks
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - text
              properties:
                text:
                  type: string
                task_id:
                  type:
                  - string
                  - 'null'
                  format: uuid
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  comments:
                    type: array
                    items:
                      type: object
                      properties:
                        at:
                          type: string
                        by:
                          type: string
                        by_name:
                          type: string
                        id:
                          type: integer
                        task_id: {}
                        task_name: {}
                        text:
                          type: string
                      required:
                      - at
                      - by
                      - by_name
                      - id
                      - task_id
                      - task_name
                      - text
                required:
                - comments
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}/tasks/{task_id}:
    get:
      tags:
      - Work
      summary: A task, with its form
      description: The task, its form, the data to show in it, and whether I may submit it or pass it
        on.
      operationId: get_cases_uuid_case_id_tasks_uuid_task_id
      x-permission: a role the task is for
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: task_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  action_label:
                    type: string
                  assigned_at:
                    type:
                    - 'null'
                    - string
                  assignee:
                    type:
                    - 'null'
                    - string
                  assignee_name:
                    type:
                    - 'null'
                    - string
                  can_pass_on:
                    type: boolean
                  can_submit:
                    type: boolean
                  case_id:
                    type: string
                  case_owner:
                    type: string
                  case_owner_name:
                    type: string
                  case_started_at:
                    type: string
                  case_title:
                    type: string
                  created_at:
                    type: string
                  data:
                    type: object
                    properties:
                      applicant_name:
                        type: string
                      assessment_band:
                        type: string
                      assessment_score:
                        type: integer
                      candidate_name:
                        type: string
                      credit_band:
                        type: string
                      location:
                        type: string
                  delegated_at:
                    type: string
                  due_at: {}
                  element:
                    type: string
                  escalated_at: {}
                  form:
                    type: object
                    properties:
                      components:
                        type: array
                        items:
                          type: object
                          properties:
                            allowAddRemove:
                              type: boolean
                            components:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: string
                                  key:
                                    type: string
                                  label:
                                    type: string
                                  readonly:
                                    type: boolean
                                  type:
                                    type: string
                                  validate:
                                    type: object
                                    properties:
                                      maxLength:
                                        type: integer
                                      minLength:
                                        type: integer
                                      pattern:
                                        type: string
                                      patternErrorMessage:
                                        type: string
                                      required:
                                        type: boolean
                                required:
                                - id
                                - key
                                - label
                                - type
                                - validate
                            conditional:
                              type: object
                              properties:
                                hide:
                                  type: string
                              required:
                              - hide
                            decimalDigits:
                              type: integer
                            defaultRepetitions:
                              type: integer
                            description:
                              type: string
                            id:
                              type: string
                            isRepeating:
                              type: boolean
                            key:
                              type: string
                            label:
                              type: string
                            path:
                              type: string
                            properties:
                              type: object
                              properties:
                                decision:
                                  type: string
                              required:
                              - decision
                            readonly:
                              type: boolean
                            showOutline:
                              type: boolean
                            type:
                              type: string
                            validate:
                              type: object
                              properties:
                                max:
                                  type: integer
                                maxLength:
                                  type: integer
                                min:
                                  type: integer
                                minLength:
                                  type: integer
                                pattern:
                                  type: string
                                patternErrorMessage:
                                  type: string
                                required:
                                  type: boolean
                            values:
                              type: array
                              items:
                                type: object
                                properties:
                                  label:
                                    type: string
                                  value:
                                    type: string
                                required:
                                - label
                                - value
                          required:
                          - id
                          - label
                          - type
                      id:
                        type: string
                      schemaVersion:
                        type: integer
                      type:
                        type: string
                    required:
                    - components
                    - id
                    - schemaVersion
                    - type
                  held:
                    type: boolean
                  lists:
                    type: object
                    properties:
                      referees:
                        type: object
                        properties:
                          label:
                            type: string
                          max:
                            type: integer
                          min:
                            type: integer
                        required:
                        - label
                        - max
                        - min
                  name:
                    type: string
                  project:
                    type: string
                  role:
                    type: string
                  role_title:
                    type: string
                  task_id:
                    type: string
                  version:
                    type: string
                required:
                - action_label
                - assigned_at
                - assignee
                - assignee_name
                - can_pass_on
                - can_submit
                - case_id
                - case_owner
                - case_owner_name
                - case_started_at
                - case_title
                - created_at
                - data
                - delegated_at
                - due_at
                - element
                - escalated_at
                - form
                - held
                - lists
                - name
                - project
                - role
                - role_title
                - task_id
                - version
        4XX:
          $ref: '#/components/responses/Problem'
    post:
      tags:
      - Work
      summary: Submit a task
      description: Submits the form's values as `data`. Each value is checked against the form and the
        case's data; 422 lists each field that needs attention. Answers with the case's progress and the
        tasks it gave me next.
      operationId: post_cases_uuid_case_id_tasks_uuid_task_id
      x-permission: a role the task is for
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: task_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    agent_code_confirmed:
                      type: boolean
                    amount:
                      type: integer
                    applicant_name:
                      type: string
                    application_ref:
                      type: string
                    approval_note:
                      type: string
                    approved:
                      type: boolean
                    assessment_band:
                      type: string
                    assessment_score:
                      type: integer
                    candidate_email:
                      type: string
                    candidate_name:
                      type: string
                    candidate_phone:
                      type: string
                    credit_band:
                      type: string
                    documents_complete:
                      type: boolean
                    expectations_met:
                      type: boolean
                    licence_copy:
                      type: array
                      items:
                        type: object
                        properties:
                          id:
                            type: string
                        required:
                        - id
                    licence_status:
                      type: string
                    location:
                      type: string
                    policy_number:
                      type: string
                    referees:
                      type: array
                      items:
                        type: object
                        properties:
                          name:
                            type: string
                          phone:
                            type: string
                        required:
                        - name
                        - phone
              required:
              - data
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  case_id:
                    type: string
                  progress:
                    type: object
                    properties:
                      can:
                        type: object
                        properties:
                          cancel:
                            type: boolean
                          suspend:
                            type: boolean
                        required:
                        - cancel
                        - suspend
                      case_id:
                        type: string
                      hold: {}
                      now:
                        type: object
                        properties:
                          jobs:
                            type: array
                            items:
                              type: object
                              properties:
                                attempts:
                                  type: integer
                                name:
                                  type: string
                                state:
                                  type: string
                              required:
                              - attempts
                              - name
                              - state
                          tasks:
                            type: array
                            items:
                              type: object
                              properties:
                                action_label:
                                  type: string
                                assignee: {}
                                assignee_name: {}
                                due_at: {}
                                escalated_at: {}
                                name:
                                  type: string
                                role:
                                  type: string
                                role_title:
                                  type: string
                                task_id:
                                  type: string
                                yours:
                                  type: boolean
                              required:
                              - action_label
                              - assignee
                              - assignee_name
                              - due_at
                              - escalated_at
                              - name
                              - role
                              - role_title
                              - task_id
                              - yours
                          waits:
                            type: array
                            items:
                              type: object
                              properties:
                                due_at:
                                  type:
                                  - string
                                  - 'null'
                                kind:
                                  type: string
                                message:
                                  type:
                                  - 'null'
                                  - string
                                name:
                                  type: string
                              required:
                              - due_at
                              - kind
                              - message
                              - name
                        required:
                        - jobs
                        - tasks
                        - waits
                      outcome:
                        type:
                        - 'null'
                        - object
                      owner:
                        type: string
                      owner_name:
                        type: string
                      process:
                        type: string
                      process_name:
                        type: string
                      project:
                        type: string
                      started_at:
                        type: string
                      status:
                        type: string
                      steps:
                        type: array
                        items:
                          type: object
                          properties:
                            element:
                              type: string
                            kind:
                              type: string
                            name:
                              type: string
                            times:
                              type: integer
                          required:
                          - element
                          - kind
                          - name
                          - times
                      title:
                        type: string
                      updated_at:
                        type: string
                      version:
                        type: string
                    required:
                    - can
                    - case_id
                    - hold
                    - now
                    - outcome
                    - owner
                    - owner_name
                    - process
                    - process_name
                    - project
                    - started_at
                    - status
                    - title
                    - updated_at
                    - version
                  status:
                    type: string
                  tasks:
                    type: array
                    items:
                      $ref: '#/components/schemas/Task'
                required:
                - case_id
                - progress
                - status
                - tasks
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}/tasks/{task_id}/assignment:
    post:
      tags:
      - Work
      summary: Take, hand back or pass on a task
      description: '`action` is take (I take it), hand_back (back to the group), pass_on (to someone else
        in the role, `to`) or reassign (a supervisor gives it to `to`).'
      operationId: post_cases_uuid_case_id_tasks_uuid_task_id_assignment
      x-permission: runtime.claim, runtime.delegate or runtime.supervise
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: task_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                action:
                  type: string
                to:
                  type:
                  - 'null'
                  - string
              required:
              - action
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  assigned_at:
                    type:
                    - 'null'
                    - string
                  assignee:
                    type:
                    - 'null'
                    - string
                  case_id:
                    type: string
                  created_at:
                    type: string
                  delegated_at:
                    type: string
                  due_at:
                    type:
                    - 'null'
                    - string
                  element:
                    type: string
                  escalated_at: {}
                  form:
                    type: string
                  name:
                    type: string
                  project:
                    type: string
                  role:
                    type: string
                  task_id:
                    type: string
                required:
                - assigned_at
                - assignee
                - case_id
                - created_at
                - delegated_at
                - due_at
                - element
                - escalated_at
                - form
                - name
                - project
                - role
                - task_id
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}/tasks/{task_id}/candidates:
    get:
      tags:
      - Work
      summary: Who a task can be passed to
      description: People in the task's role, and whether each is out of office.
      operationId: get_cases_uuid_case_id_tasks_uuid_task_id_candidates
      x-permission: runtime.delegate or runtime.supervise
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: task_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  people:
                    type: array
                    items:
                      type: object
                      properties:
                        away_until:
                          type:
                          - 'null'
                          - string
                        name:
                          type: string
                        subject:
                          type: string
                      required:
                      - away_until
                      - name
                      - subject
                required:
                - people
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}/tasks/{task_id}/files:
    post:
      tags:
      - Case files and evidence
      summary: Add a file to a task
      description: The body is the file itself, with the form field it is for in `?field=`, its name in
        `?name=` and its type in Content-Type. It is checked for viruses and against the form's limits
        before it is kept. 413 when it is too large.
      operationId: post_cases_uuid_case_id_tasks_uuid_task_id_files
      x-permission: a role the task is for
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: task_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: field
        in: query
        required: false
        schema:
          type: string
      - name: name
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  file:
                    type: object
                    properties:
                      added_at:
                        type: string
                      added_by:
                        type: string
                      added_by_name:
                        type: string
                      field:
                        type: string
                      id:
                        type: string
                      name:
                        type: string
                      part_of_case:
                        type: boolean
                      size:
                        type: integer
                      source:
                        type: string
                      type:
                        type: string
                    required:
                    - added_at
                    - added_by
                    - added_by_name
                    - field
                    - id
                    - name
                    - part_of_case
                    - size
                    - source
                    - type
                required:
                - file
        4XX:
          $ref: '#/components/responses/Problem'
      requestBody:
        required: true
        content:
          '*/*':
            schema:
              type: string
              format: binary
  /api/v0/cases/{case_id}/tasks/{task_id}/worked-out:
    post:
      tags:
      - Work
      summary: Work out a form's decided fields
      description: Given the form's values so far as `data`, the fields a decision table fills in, as
        the form shows them before it is submitted.
      operationId: post_cases_uuid_case_id_tasks_uuid_task_id_worked_out
      x-permission: a role the task is for
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: task_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    assessment_score:
                      type: integer
              required:
              - data
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  values:
                    type: object
                    properties:
                      assessment_band:
                        type:
                        - 'null'
                        - string
                    required:
                    - assessment_band
                required:
                - values
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}/files:
    get:
      tags:
      - Case files and evidence
      summary: A case's files
      description: Every file added to the case, with who added it and when.
      operationId: get_cases_uuid_case_id_files
      x-permission: runtime.view
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  files:
                    type: array
                    items:
                      type: object
                      properties:
                        added_at:
                          type: string
                        added_by:
                          type: string
                        added_by_name:
                          type: string
                        field:
                          type: string
                        id:
                          type: string
                        name:
                          type: string
                        part_of_case:
                          type: boolean
                        size:
                          type: integer
                        source:
                          type: string
                        type:
                          type: string
                      required:
                      - added_at
                      - added_by
                      - added_by_name
                      - field
                      - id
                      - name
                      - part_of_case
                      - size
                      - source
                      - type
                required:
                - files
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}/files/{file_id}:
    get:
      tags:
      - Case files and evidence
      summary: Download a case file
      description: The file, as it was added. Each download is recorded.
      operationId: get_cases_uuid_case_id_files_uuid_file_id
      x-permission: runtime.view
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: file_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: The file, with its own type, as an attachment
          content:
            '*/*':
              schema:
                type: string
                format: binary
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}/emails:
    get:
      tags:
      - Case files and evidence
      summary: Emails the case sent
      description: Each email the case's process sent, and whether it went.
      operationId: get_cases_uuid_case_id_emails
      x-permission: runtime.view
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  can_open_evidence:
                    type: boolean
                  emails:
                    type: array
                    items:
                      type: object
                      properties:
                        attempts:
                          type: integer
                        case_id:
                          type: string
                        evidence: {}
                        first_at:
                          type: string
                        id:
                          type: integer
                        kind:
                          type: string
                        last_at:
                          type: string
                        project:
                          type: string
                        reason:
                          type:
                          - 'null'
                          - string
                        recipients:
                          type: array
                          items:
                            type: string
                        sha256: {}
                        size: {}
                        status:
                          type: string
                        subject:
                          type: string
                        template:
                          type: string
                      required:
                      - attempts
                      - case_id
                      - evidence
                      - first_at
                      - id
                      - kind
                      - last_at
                      - project
                      - reason
                      - recipients
                      - sha256
                      - size
                      - status
                      - subject
                      - template
                required:
                - can_open_evidence
                - emails
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}/messages:
    get:
      tags:
      - Case files and evidence
      summary: Messages the case sent to other systems
      description: Each call the case made to another system that the system acknowledged, with its answer.
      operationId: get_cases_uuid_case_id_messages
      x-permission: runtime.view
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  can_open_evidence:
                    type: boolean
                  messages:
                    type: array
                    items:
                      type: object
                      properties:
                        answer:
                          type: string
                        attempts:
                          type: integer
                        connector:
                          type: string
                        destination:
                          type: string
                        evidence:
                          type: string
                        first_at:
                          type: string
                        id:
                          type: integer
                        kind:
                          type: string
                        last_at:
                          type: string
                        operation:
                          type: string
                        reason: {}
                        sha256:
                          type: string
                        size:
                          type: integer
                        status:
                          type: string
                      required:
                      - answer
                      - attempts
                      - connector
                      - destination
                      - evidence
                      - first_at
                      - id
                      - kind
                      - last_at
                      - operation
                      - reason
                      - sha256
                      - size
                      - status
                required:
                - can_open_evidence
                - messages
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}/evidence/{evidence}:
    get:
      tags:
      - Case files and evidence
      summary: Exactly what was sent
      description: The exact content of an email or message, as it was sent. Each opening is recorded.
      operationId: get_cases_uuid_case_id_evidence_uuid_evidence
      x-permission: assurance.audit
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: evidence
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: 'What was sent: an email as message/rfc822, a message as it was sent'
          content:
            '*/*':
              schema:
                type: string
                format: binary
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/cases/{case_id}/jobs/{job_id}/retry:
    post:
      tags:
      - Supervision
      summary: Try a failed step again
      description: Puts a step that failed (a call to another system, a script) back in the queue.
      operationId: post_cases_uuid_case_id_jobs_uuid_job_id_retry
      x-permission: platform.maintenance or runtime.supervise
      parameters:
      - name: case_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: job_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  case_id:
                    type: string
                  job_id:
                    type: string
                  status:
                    type: string
                required:
                - case_id
                - job_id
                - status
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/supervision:
    get:
      tags:
      - Supervision
      summary: Work that needs a supervisor
      description: 'For the projects I supervise: steps that failed, and the open tasks waiting longest
        (`limit`, 1 to 500, default 100) with how many are open in all.'
      operationId: get_supervision
      x-permission: runtime.supervise
      parameters:
      - name: limit
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  failed_jobs:
                    type: array
                    items:
                      type: object
                      properties:
                        attempts:
                          type: integer
                        case_id:
                          type: string
                        error:
                          type: string
                        failed_at:
                          type: string
                        job_id:
                          type: string
                        name:
                          type: string
                        operation:
                          type: string
                        project:
                          type: string
                      required:
                      - attempts
                      - case_id
                      - error
                      - failed_at
                      - job_id
                      - name
                      - operation
                      - project
                  open_count:
                    type: integer
                  open_tasks:
                    type: array
                    items:
                      $ref: '#/components/schemas/Task'
                  projects:
                    type: array
                    items:
                      type: string
                required:
                - failed_jobs
                - open_count
                - open_tasks
                - projects
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/notices:
    get:
      tags:
      - Notices and absence
      summary: My notices
      description: Notices for me, newest first, and how many I have not seen.
      operationId: get_notices
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  notices:
                    type: array
                    items:
                      type: object
                      properties:
                        action:
                          type: string
                        actor_name:
                          type: string
                        at:
                          type: string
                        case_id:
                          type: string
                        case_title:
                          type: string
                        id:
                          type: integer
                        kind:
                          type: string
                        other_name:
                          type: string
                        seen:
                          type: boolean
                        task_id:
                          type: string
                        task_name:
                          type: string
                        yours:
                          type: boolean
                      required:
                      - action
                      - actor_name
                      - at
                      - case_id
                      - case_title
                      - id
                      - kind
                      - other_name
                      - seen
                      - task_id
                      - task_name
                      - yours
                  unseen:
                    type: integer
                required:
                - notices
                - unseen
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/notices/seen:
    post:
      tags:
      - Notices and absence
      summary: Mark notices seen
      description: Marks every notice up to `upto`, the newest notice seen, as seen. Answers with how
        many are still unseen.
      operationId: post_notices_seen
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                upto:
                  type: integer
              required:
              - upto
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  unseen:
                    type: integer
                required:
                - unseen
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/notices/preferences:
    get:
      tags:
      - Notices and absence
      summary: Which notices are emailed to me
      description: Notices are always shown in the web application; these say which are also emailed.
      operationId: get_notices_preferences
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  email_while_away:
                    type: boolean
                  emailed:
                    type: object
                    properties:
                      moved:
                        type: boolean
                      overdue:
                        type: boolean
                      received:
                        type: boolean
                    required:
                    - moved
                    - overdue
                    - received
                  sent:
                    type: boolean
                required:
                - email_while_away
                - emailed
                - sent
        4XX:
          $ref: '#/components/responses/Problem'
    post:
      tags:
      - Notices and absence
      summary: Choose which notices are emailed
      description: '`emailed`: whether each kind of notice is also emailed to me; `email_while_away`:
        whether they are emailed while I am out of office.'
      operationId: post_notices_preferences
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email_while_away:
                  type: boolean
                emailed:
                  type: object
                  properties:
                    moved:
                      type: boolean
                  required:
                  - moved
              required:
              - email_while_away
              - emailed
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  email_while_away:
                    type: boolean
                  emailed:
                    type: object
                    properties:
                      moved:
                        type: boolean
                      overdue:
                        type: boolean
                      received:
                        type: boolean
                    required:
                    - moved
                    - overdue
                    - received
                  sent:
                    type: boolean
                required:
                - email_while_away
                - emailed
                - sent
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/absence:
    get:
      tags:
      - Notices and absence
      summary: Time out of office
      description: My time out of office, or with platform.identity someone else's (`?subject=`).
      operationId: get_absence
      parameters:
      - name: subject
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  absence: {}
                  colleagues:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        subject:
                          type: string
                      required:
                      - name
                      - subject
                  name:
                    type: string
                  subject:
                    type: string
                required:
                - absence
                - colleagues
                - name
                - subject
        4XX:
          $ref: '#/components/responses/Problem'
    post:
      tags:
      - Notices and absence
      summary: Set time out of office
      description: '`from` and `back` (dates in the organisation''s time zone), and `delegate`, who takes
        my tasks meanwhile. With platform.identity, `?subject=` sets someone else''s.'
      operationId: post_absence
      parameters:
      - name: subject
        in: query
        required: false
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                back:
                  type: string
                delegate:
                  type: string
                from:
                  type: string
              required:
              - back
              - delegate
              - from
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  absence:
                    type: object
                    properties:
                      current:
                        type: boolean
                      delegate:
                        type: string
                      delegate_name:
                        type: string
                      ends_at:
                        type: string
                      set_by:
                        type: string
                      set_by_name:
                        type: string
                      starts_at:
                        type: string
                    required:
                    - current
                    - delegate
                    - delegate_name
                    - ends_at
                    - set_by
                    - set_by_name
                    - starts_at
                  colleagues:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        subject:
                          type: string
                      required:
                      - name
                      - subject
                  name:
                    type: string
                  subject:
                    type: string
                required:
                - absence
                - colleagues
                - name
                - subject
        4XX:
          $ref: '#/components/responses/Problem'
    delete:
      tags:
      - Notices and absence
      summary: End time out of office
      description: Ends it now.
      operationId: delete_absence
      parameters:
      - name: subject
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  absence: {}
                  colleagues:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        subject:
                          type: string
                      required:
                      - name
                      - subject
                  name:
                    type: string
                  subject:
                    type: string
                required:
                - absence
                - colleagues
                - name
                - subject
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/reports:
    get:
      tags:
      - Reports
      summary: How work is going
      description: Cases started and finished, tasks waiting and how long, by project, over `days` (and
        for `project`).
      operationId: get_reports
      x-permission: assurance.reports
      parameters:
      - name: days
        in: query
        required: false
        schema:
          type: string
      - name: project
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  activity:
                    type: array
                    items:
                      type: object
                      properties:
                        cancelled:
                          type: integer
                        completed:
                          type: integer
                        longest_days: {}
                        median_days: {}
                        name:
                          type: string
                        oldest_open_days:
                          type: number
                        open:
                          type: integer
                        process:
                          type: string
                        project:
                          type: string
                        started:
                          type: integer
                      required:
                      - cancelled
                      - completed
                      - longest_days
                      - median_days
                      - name
                      - oldest_open_days
                      - open
                      - process
                      - project
                      - started
                  days:
                    type: integer
                  overview:
                    type: object
                    properties:
                      series:
                        type: array
                        items:
                          type: object
                          properties:
                            completed:
                              type: integer
                            from:
                              type: string
                            started:
                              type: integer
                          required:
                          - completed
                          - from
                          - started
                      series_step_days:
                        type: integer
                      totals:
                        type: object
                        properties:
                          cancelled:
                            type: integer
                          completed:
                            type: integer
                          median_days_to_complete: {}
                          open:
                            type: integer
                          started:
                            type: integer
                          suspended:
                            type: integer
                          tasks_overdue:
                            type: integer
                          tasks_waiting:
                            type: integer
                        required:
                        - cancelled
                        - completed
                        - median_days_to_complete
                        - open
                        - started
                        - suspended
                        - tasks_overdue
                        - tasks_waiting
                    required:
                    - series
                    - series_step_days
                    - totals
                  partial:
                    type: boolean
                  project: {}
                  projects:
                    type: array
                    items:
                      type: string
                  since:
                    type: string
                  waiting:
                    type: array
                    items:
                      type: object
                      properties:
                        held:
                          type: integer
                        longest_wait_days:
                          type: number
                        median_wait_days:
                          type: number
                        name:
                          type: string
                        overdue:
                          type: integer
                        project:
                          type: string
                        role:
                          type: string
                        role_title:
                          type: string
                        step:
                          type: string
                        taken:
                          type: integer
                        waiting:
                          type: integer
                      required:
                      - held
                      - longest_wait_days
                      - median_wait_days
                      - name
                      - overdue
                      - project
                      - role
                      - role_title
                      - step
                      - taken
                      - waiting
                required:
                - activity
                - days
                - overview
                - partial
                - project
                - projects
                - since
                - waiting
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/reports/export:
    get:
      tags:
      - Reports
      summary: Export a report
      description: Case activity (`which=cases`) or task waiting (`which=tasks`) as CSV, over `days` (and
        for `project`). Each export is recorded.
      operationId: get_reports_export
      x-permission: assurance.reports
      parameters:
      - name: which
        in: query
        required: false
        schema:
          type: string
      - name: days
        in: query
        required: false
        schema:
          type: string
      - name: project
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: The report as CSV
          content:
            text/csv:
              schema:
                type: string
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/reports/fields:
    get:
      tags:
      - Reports
      summary: Fields cases can be found by
      description: For each process I may report on, the case fields it lets people search by, with their
        kinds.
      operationId: get_reports_fields
      x-permission: assurance.reports
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  processes:
                    type: array
                    items:
                      type: object
                      properties:
                        fields:
                          type: array
                          items:
                            type: object
                            properties:
                              kind:
                                type: string
                              name:
                                type: string
                              title:
                                type: string
                            required:
                            - kind
                            - name
                            - title
                        name:
                          type: string
                        process:
                          type: string
                        project:
                          type: string
                      required:
                      - fields
                      - name
                      - process
                      - project
                required:
                - processes
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/reports/query:
    post:
      tags:
      - Reports
      summary: Find cases by their fields
      description: Cases of `process` in `project` whose fields match every condition in `where` ({field,
        operator, value}), optionally with `status`. `?format=csv` exports them.
      operationId: post_reports_query
      x-permission: assurance.reports
      parameters:
      - name: format
        in: query
        required: false
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - project
              - process
              properties:
                project:
                  type: string
                process:
                  type: string
                where:
                  type: array
                  items:
                    type: object
                    required:
                    - field
                    - operator
                    properties:
                      field:
                        type: string
                      operator:
                        type: string
                        description: is or contains for text; is, at_least or at_most for numbers and
                          dates
                      value: {}
                status:
                  type:
                  - string
                  - 'null'
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  cases:
                    type: array
                    items:
                      type: object
                      properties:
                        case_id:
                          type: string
                        started_at:
                          type: string
                        status:
                          type: string
                        title: {}
                        values:
                          type: object
                          properties:
                            assessment_band:
                              type: string
                            assessment_score:
                              type: integer
                            documents_complete: {}
                            location:
                              type: string
                          required:
                          - assessment_band
                          - assessment_score
                          - documents_complete
                          - location
                      required:
                      - case_id
                      - started_at
                      - status
                      - title
                      - values
                  fields:
                    type: array
                    items:
                      type: object
                      properties:
                        kind:
                          type: string
                        name:
                          type: string
                        title:
                          type: string
                      required:
                      - kind
                      - name
                      - title
                  more:
                    type: boolean
                required:
                - cases
                - fields
                - more
            text/csv:
              schema:
                type: string
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/deployments:
    get:
      tags:
      - Releases
      summary: What is deployed
      description: 'Each project''s deployments in this environment: which release, who deployed and approved
        it, and the evidence it was approved on.'
      operationId: get_deployments
      x-permission: release.inspect
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  projects:
                    type: array
                    items:
                      type: object
                      properties:
                        deployments:
                          type: array
                          items:
                            type: object
                            properties:
                              active:
                                type: boolean
                              approval: {}
                              builder: {}
                              built_at: {}
                              bundle_digest: {}
                              checks: {}
                              deployed_at:
                                type: string
                              deployed_by:
                                type: string
                              deployed_by_name:
                                type: string
                              environment:
                                type: string
                              id:
                                type: integer
                              kind:
                                type: string
                              previous_version: {}
                              release_id:
                                type: string
                              rolled_back_version: {}
                              signed_by: {}
                              smoke: {}
                              source: {}
                              version:
                                type: string
                            required:
                            - active
                            - approval
                            - builder
                            - built_at
                            - bundle_digest
                            - checks
                            - deployed_at
                            - deployed_by
                            - deployed_by_name
                            - environment
                            - id
                            - kind
                            - previous_version
                            - release_id
                            - rolled_back_version
                            - signed_by
                            - smoke
                            - source
                            - version
                        live:
                          type: object
                          properties:
                            active:
                              type: boolean
                            approval: {}
                            builder: {}
                            built_at: {}
                            bundle_digest: {}
                            checks: {}
                            deployed_at:
                              type: string
                            deployed_by:
                              type: string
                            deployed_by_name:
                              type: string
                            environment:
                              type: string
                            id:
                              type: integer
                            kind:
                              type: string
                            previous_version: {}
                            release_id:
                              type: string
                            rolled_back_version: {}
                            signed_by: {}
                            smoke: {}
                            source: {}
                            version:
                              type: string
                          required:
                          - active
                          - approval
                          - builder
                          - built_at
                          - bundle_digest
                          - checks
                          - deployed_at
                          - deployed_by
                          - deployed_by_name
                          - environment
                          - id
                          - kind
                          - previous_version
                          - release_id
                          - rolled_back_version
                          - signed_by
                          - smoke
                          - source
                          - version
                        project:
                          type: string
                      required:
                      - deployments
                      - live
                      - project
                  refused:
                    type: array
                    items:
                      type: object
                      properties:
                        at:
                          type: string
                        bundle_digest:
                          type: string
                        by:
                          type: string
                        by_name:
                          type: string
                        environment:
                          type: string
                        project:
                          type: string
                        reason:
                          type: string
                        version:
                          type: string
                      required:
                      - at
                      - bundle_digest
                      - by
                      - by_name
                      - environment
                      - project
                      - reason
                      - version
                required:
                - projects
                - refused
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/deployments/{project}/cases:
    get:
      tags:
      - Releases
      summary: Cases that could move to the active release
      description: Running cases on earlier releases of the project, what moving them would change, and
        earlier moves.
      operationId: get_deployments_str_project_cases
      x-permission: release.inspect
      parameters:
      - name: project
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  may_move:
                    type: boolean
                  moves:
                    type: array
                    items: {}
                  open_elsewhere:
                    type: integer
                  releases:
                    type: array
                    items:
                      type: object
                      properties:
                        can_move:
                          type: integer
                        cannot:
                          type: array
                          items: {}
                        checked:
                          type: integer
                        open:
                          type: integer
                        processes:
                          type: object
                          properties:
                            agent_recruitment:
                              type: object
                              properties:
                                data:
                                  type: array
                                  items: {}
                                steps_added:
                                  type: array
                                  items: {}
                                steps_changed:
                                  type: array
                                  items:
                                    type: string
                                steps_removed:
                                  type: array
                                  items: {}
                              required:
                              - data
                              - steps_added
                              - steps_changed
                              - steps_removed
                          required:
                          - agent_recruitment
                        release_id:
                          type: string
                        version:
                          type: string
                      required:
                      - can_move
                      - cannot
                      - checked
                      - open
                      - processes
                      - release_id
                      - version
                  to_version:
                    type: string
                required:
                - may_move
                - moves
                - open_elsewhere
                - releases
                - to_version
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/deployments/{project}/cases/move:
    post:
      tags:
      - Releases
      summary: Move cases to the active release
      description: Moves the cases on `from_release_id` (or only `case_ids`) to the project's active release.
        `dry_run` says what would happen without moving anything.
      operationId: post_deployments_str_project_cases_move
      x-permission: release.deploy
      parameters:
      - name: project
        in: path
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - from_release_id
              properties:
                from_release_id:
                  type: string
                case_ids:
                  type: array
                  items:
                    type: string
                dry_run:
                  type: boolean
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  cases:
                    type: array
                    items:
                      type: object
                      properties:
                        at:
                          type: array
                          items:
                            type: string
                        case_id:
                          type: string
                        changes:
                          type: array
                          items: {}
                        from_version:
                          type: string
                        migration: {}
                        moves:
                          type: boolean
                        process_id:
                          type: string
                        reason: {}
                        title: {}
                      required:
                      - at
                      - case_id
                      - changes
                      - from_version
                      - migration
                      - moves
                      - process_id
                      - reason
                      - title
                  move_id:
                    type:
                    - integer
                    - 'null'
                  moved:
                    type: integer
                  to_version:
                    type: string
                required:
                - cases
                - move_id
                - moved
                - to_version
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/deployments/{project}/cases/moves/{move_id}/undo:
    post:
      tags:
      - Releases
      summary: Undo a move
      description: Moves back the cases of an earlier move that have not changed since.
      operationId: post_deployments_str_project_cases_moves_int_move_id_undo
      x-permission: release.deploy
      parameters:
      - name: project
        in: path
        required: true
        schema:
          type: string
      - name: move_id
        in: path
        required: true
        schema:
          type: integer
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  cases:
                    type: array
                    items:
                      type: object
                      properties:
                        at:
                          type: array
                          items: {}
                        case_id:
                          type: string
                        changes:
                          type: array
                          items: {}
                        from_version:
                          type: string
                        migration: {}
                        moves:
                          type: boolean
                        process_id:
                          type: string
                        reason: {}
                        title: {}
                      required:
                      - at
                      - case_id
                      - changes
                      - from_version
                      - migration
                      - moves
                      - process_id
                      - reason
                      - title
                required:
                - cases
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/build/templates:
    get:
      tags:
      - Build
      summary: Templates for new projects
      description: 'The templates a new project can start from: FlowAssembly''s and the organisation''s
        own.'
      operationId: get_build_templates
      x-permission: the Build section
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  templates:
                    type: array
                    items:
                      type: object
                      properties:
                        built_in:
                          type: boolean
                        command:
                          type: string
                        description:
                          type: string
                        id:
                          type: string
                        title:
                          type: string
                      required:
                      - built_in
                      - command
                      - description
                      - id
                      - title
                required:
                - templates
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/build/templates/{template_id}/file:
    get:
      tags:
      - Build
      summary: Download a template
      description: A template as an exported project, to import with `fa import`.
      operationId: get_build_templates_slug_template_id_file
      x-permission: the Build section
      parameters:
      - name: template_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^[-a-zA-Z0-9_]+$
      responses:
        '200':
          description: The project, as a .faproject file
          content:
            application/zip:
              schema:
                type: string
                format: binary
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/admin/access:
    get:
      tags:
      - Admin
      summary: The access policy
      description: Roles, what each may do, and who holds them, with the policy's history.
      operationId: get_admin_access
      x-permission: platform.identity
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  catalogue:
                    type: object
                    properties:
                      assurance:
                        type: array
                        items:
                          type: string
                      integration:
                        type: array
                        items:
                          type: string
                      platform:
                        type: array
                        items:
                          type: string
                      project:
                        type: array
                        items:
                          type: string
                      release:
                        type: array
                        items:
                          type: string
                      runtime:
                        type: array
                        items:
                          type: string
                    required:
                    - assurance
                    - integration
                    - platform
                    - project
                    - release
                    - runtime
                  document:
                    type: object
                    properties:
                      apiVersion:
                        type: string
                      grants:
                        type: array
                        items:
                          type: object
                          properties:
                            groups:
                              type: array
                              items:
                                type: string
                            role:
                              type: string
                            users:
                              type: array
                              items:
                                type: string
                          required:
                          - role
                      kind:
                        type: string
                      projects:
                        type: object
                        properties:
                          agent-recruitment:
                            type: object
                            properties:
                              agency_admin:
                                type: object
                                properties:
                                  groups:
                                    type: array
                                    items:
                                      type: string
                                required:
                                - groups
                              learning_development:
                                type: object
                                properties:
                                  groups:
                                    type: array
                                    items:
                                      type: string
                                required:
                                - groups
                              location_manager:
                                type: object
                                properties:
                                  groups:
                                    type: array
                                    items:
                                      type: string
                                required:
                                - groups
                              recruiter:
                                type: object
                                properties:
                                  groups:
                                    type: array
                                    items:
                                      type: string
                                required:
                                - groups
                            required:
                            - agency_admin
                            - learning_development
                            - location_manager
                            - recruiter
                        required:
                        - agent-recruitment
                      roles:
                        type: object
                        properties:
                          administrator:
                            type: array
                            items:
                              type: string
                          approver:
                            type: array
                            items:
                              type: string
                          auditor:
                            type: array
                            items:
                              type: string
                          supervisor:
                            type: array
                            items:
                              type: string
                        required:
                        - administrator
                        - approver
                        - auditor
                        - supervisor
                    required:
                    - apiVersion
                    - grants
                    - kind
                    - projects
                    - roles
                  editable:
                    type: boolean
                  history:
                    type: array
                    items:
                      type: object
                      properties:
                        changed_at:
                          type: string
                        changed_by:
                          type: string
                        changed_by_name:
                          type: string
                        summary:
                          type: string
                        version:
                          type: integer
                      required:
                      - changed_at
                      - changed_by
                      - changed_by_name
                      - summary
                      - version
                  projects:
                    type: object
                    properties:
                      agent-recruitment:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                            title:
                              type: string
                          required:
                          - id
                          - title
                    required:
                    - agent-recruitment
                  providers:
                    type: array
                    items:
                      type: string
                  sections:
                    type: array
                    items:
                      type: string
                  version:
                    type: integer
                required:
                - catalogue
                - document
                - editable
                - history
                - projects
                - providers
                - sections
                - version
        4XX:
          $ref: '#/components/responses/Problem'
    put:
      tags:
      - Admin
      summary: Change the access policy
      description: Saves a new version of the policy, given the `version` it was based on (409 when someone
        else saved one since).
      operationId: put_admin_access
      x-permission: platform.identity
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                document:
                  type: object
                  properties:
                    apiVersion:
                      type: string
                    grants:
                      type: array
                      items:
                        type: object
                        properties:
                          groups:
                            type: array
                            items:
                              type: string
                          role:
                            type: string
                          users:
                            type: array
                            items:
                              type: string
                        required:
                        - role
                    kind:
                      type: string
                    projects:
                      type: object
                      properties:
                        agent-recruitment:
                          type: object
                          properties:
                            agency_admin:
                              type: object
                              properties:
                                groups:
                                  type: array
                                  items:
                                    type: string
                                users:
                                  type: array
                                  items:
                                    type: string
                              required:
                              - groups
                            learning_development:
                              type: object
                              properties:
                                groups:
                                  type: array
                                  items:
                                    type: string
                              required:
                              - groups
                            location_manager:
                              type: object
                              properties:
                                groups:
                                  type: array
                                  items:
                                    type: string
                              required:
                              - groups
                            recruiter:
                              type: object
                              properties:
                                groups:
                                  type: array
                                  items:
                                    type: string
                              required:
                              - groups
                          required:
                          - agency_admin
                          - learning_development
                          - location_manager
                          - recruiter
                      required:
                      - agent-recruitment
                    roles:
                      type: object
                      properties:
                        administrator:
                          type: array
                          items:
                            type: string
                        analyst:
                          type: object
                          properties:
                            permissions:
                              type: array
                              items:
                                type: string
                            sections:
                              type: array
                              items:
                                type: string
                          required:
                          - permissions
                          - sections
                        approver:
                          type: array
                          items:
                            type: string
                        auditor:
                          type: array
                          items:
                            type: string
                        supervisor:
                          type: array
                          items:
                            type: string
                      required:
                      - administrator
                      - approver
                      - auditor
                      - supervisor
                  required:
                  - apiVersion
                  - grants
                  - kind
                  - projects
                  - roles
                version:
                  type: integer
              required:
              - document
              - version
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  catalogue:
                    type: object
                    properties:
                      assurance:
                        type: array
                        items:
                          type: string
                      integration:
                        type: array
                        items:
                          type: string
                      platform:
                        type: array
                        items:
                          type: string
                      project:
                        type: array
                        items:
                          type: string
                      release:
                        type: array
                        items:
                          type: string
                      runtime:
                        type: array
                        items:
                          type: string
                    required:
                    - assurance
                    - integration
                    - platform
                    - project
                    - release
                    - runtime
                  document:
                    type: object
                    properties:
                      apiVersion:
                        type: string
                      grants:
                        type: array
                        items:
                          type: object
                          properties:
                            groups:
                              type: array
                              items:
                                type: string
                            role:
                              type: string
                            users:
                              type: array
                              items:
                                type: string
                          required:
                          - role
                      kind:
                        type: string
                      projects:
                        type: object
                        properties:
                          agent-recruitment:
                            type: object
                            properties:
                              agency_admin:
                                type: object
                                properties:
                                  groups:
                                    type: array
                                    items:
                                      type: string
                                  users:
                                    type: array
                                    items:
                                      type: string
                                required:
                                - groups
                              learning_development:
                                type: object
                                properties:
                                  groups:
                                    type: array
                                    items:
                                      type: string
                                required:
                                - groups
                              location_manager:
                                type: object
                                properties:
                                  groups:
                                    type: array
                                    items:
                                      type: string
                                required:
                                - groups
                              recruiter:
                                type: object
                                properties:
                                  groups:
                                    type: array
                                    items:
                                      type: string
                                required:
                                - groups
                            required:
                            - agency_admin
                            - learning_development
                            - location_manager
                            - recruiter
                        required:
                        - agent-recruitment
                      roles:
                        type: object
                        properties:
                          administrator:
                            type: array
                            items:
                              type: string
                          analyst:
                            type: object
                            properties:
                              permissions:
                                type: array
                                items:
                                  type: string
                              sections:
                                type: array
                                items:
                                  type: string
                            required:
                            - permissions
                            - sections
                          approver:
                            type: array
                            items:
                              type: string
                          auditor:
                            type: array
                            items:
                              type: string
                          supervisor:
                            type: array
                            items:
                              type: string
                        required:
                        - administrator
                        - approver
                        - auditor
                        - supervisor
                    required:
                    - apiVersion
                    - grants
                    - kind
                    - projects
                    - roles
                  editable:
                    type: boolean
                  history:
                    type: array
                    items:
                      type: object
                      properties:
                        changed_at:
                          type: string
                        changed_by:
                          type: string
                        changed_by_name:
                          type: string
                        summary:
                          type: string
                        version:
                          type: integer
                      required:
                      - changed_at
                      - changed_by
                      - changed_by_name
                      - summary
                      - version
                  projects:
                    type: object
                    properties:
                      agent-recruitment:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                            title:
                              type: string
                          required:
                          - id
                          - title
                    required:
                    - agent-recruitment
                  providers:
                    type: array
                    items:
                      type: string
                  sections:
                    type: array
                    items:
                      type: string
                  version:
                    type: integer
                required:
                - catalogue
                - document
                - editable
                - history
                - projects
                - providers
                - sections
                - version
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/admin/users:
    get:
      tags:
      - Admin
      summary: People who can sign in
      description: Local accounts and people from directories who have signed in, with their roles and
        teams.
      operationId: get_admin_users
      x-permission: platform.identity
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  local_sources:
                    type: array
                    items:
                      type: string
                  users:
                    type: array
                    items:
                      type: object
                      properties:
                        disabled:
                          type: boolean
                        email:
                          type:
                          - 'null'
                          - string
                        local:
                          type: boolean
                        locked:
                          type: boolean
                        name:
                          type: string
                        roles:
                          type: array
                          items:
                            type: string
                        source:
                          type: string
                        subject:
                          type: string
                        teams:
                          type: array
                          items:
                            type: string
                      required:
                      - disabled
                      - email
                      - local
                      - locked
                      - name
                      - roles
                      - source
                      - subject
                      - teams
                required:
                - local_sources
                - users
        4XX:
          $ref: '#/components/responses/Problem'
    post:
      tags:
      - Admin
      summary: Add a local account
      description: Adds an account to FlowAssembly's own users (`provider`, `username`, `name`, `email`).
        Answers with its first password, shown this once, for the person to change.
      operationId: post_admin_users
      x-permission: platform.identity
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                name:
                  type: string
                provider:
                  type: string
                username:
                  type: string
              required:
              - email
              - name
              - provider
              - username
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  password:
                    type: string
                  user:
                    type: string
                required:
                - password
                - user
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/admin/users/{provider}/{username}:
    post:
      tags:
      - Admin
      summary: Change an account
      description: Disables or enables a local account (`disabled`), or gives it a new password (`new_password`),
        shown this once.
      operationId: post_admin_users_slug_provider_str_username
      x-permission: platform.identity
      parameters:
      - name: provider
        in: path
        required: true
        schema:
          type: string
          pattern: ^[-a-zA-Z0-9_]+$
      - name: username
        in: path
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                disabled:
                  type: boolean
                new_password:
                  type: boolean
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  disabled:
                    type: boolean
                  password:
                    type: string
                  user:
                    type: string
                required:
                - user
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/admin/sources:
    get:
      tags:
      - Admin
      summary: Sign-in sources
      description: The directories and local accounts people sign in with, and their history.
      operationId: get_admin_sources
      x-permission: platform.identity
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  document:
                    type: object
                    properties:
                      apiVersion:
                        type: string
                      defaultProvider:
                        type: string
                      kind:
                        type: string
                      providers:
                        type: object
                        properties:
                          local:
                            type: object
                            properties:
                              type:
                                type: string
                            required:
                            - type
                        required:
                        - local
                    required:
                    - apiVersion
                    - defaultProvider
                    - kind
                    - providers
                  editable:
                    type: boolean
                  history:
                    type: array
                    items:
                      type: object
                      properties:
                        changed_at:
                          type: string
                        changed_by_name:
                          type: string
                        summary:
                          type: string
                        version:
                          type: integer
                      required:
                      - changed_at
                      - changed_by_name
                      - summary
                      - version
                  secret_names:
                    type: array
                    items:
                      type: string
                  version:
                    type: integer
                required:
                - document
                - editable
                - history
                - secret_names
                - version
        4XX:
          $ref: '#/components/responses/Problem'
    put:
      tags:
      - Admin
      summary: Change the sign-in sources
      description: Saves a new version, given the `version` it was based on. Each directory is checked
        first; 422 says which step failed.
      operationId: put_admin_sources
      x-permission: platform.identity
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                document:
                  type: object
                  properties:
                    apiVersion:
                      type: string
                    defaultProvider:
                      type: string
                    kind:
                      type: string
                    providers:
                      type: object
                      properties:
                        corp:
                          type: object
                          properties:
                            bindDn:
                              type: string
                            bindPasswordSecret:
                              type: string
                            caFile:
                              type: string
                            enabled:
                              type: boolean
                            groups:
                              type: object
                              properties:
                                base:
                                  type: string
                              required:
                              - base
                            type:
                              type: string
                            url:
                              type: string
                            users:
                              type: object
                              properties:
                                base:
                                  type: string
                              required:
                              - base
                          required:
                          - bindDn
                          - bindPasswordSecret
                          - caFile
                          - enabled
                          - groups
                          - type
                          - url
                          - users
                        local:
                          type: object
                          properties:
                            type:
                              type: string
                          required:
                          - type
                      required:
                      - corp
                      - local
                  required:
                  - apiVersion
                  - defaultProvider
                  - kind
                  - providers
                version:
                  type: integer
              required:
              - document
              - version
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  document:
                    type: object
                    properties:
                      apiVersion:
                        type: string
                      defaultProvider:
                        type: string
                      kind:
                        type: string
                      providers:
                        type: object
                        properties:
                          corp:
                            type: object
                            properties:
                              bindDn:
                                type: string
                              bindPasswordSecret:
                                type: string
                              caFile:
                                type: string
                              enabled:
                                type: boolean
                              groups:
                                type: object
                                properties:
                                  base:
                                    type: string
                                required:
                                - base
                              type:
                                type: string
                              url:
                                type: string
                              users:
                                type: object
                                properties:
                                  base:
                                    type: string
                                required:
                                - base
                            required:
                            - bindDn
                            - bindPasswordSecret
                            - caFile
                            - enabled
                            - groups
                            - type
                            - url
                            - users
                          local:
                            type: object
                            properties:
                              type:
                                type: string
                            required:
                            - type
                        required:
                        - corp
                        - local
                    required:
                    - apiVersion
                    - defaultProvider
                    - kind
                    - providers
                  editable:
                    type: boolean
                  history:
                    type: array
                    items:
                      type: object
                      properties:
                        changed_at:
                          type: string
                        changed_by_name:
                          type: string
                        summary:
                          type: string
                        version:
                          type: integer
                      required:
                      - changed_at
                      - changed_by_name
                      - summary
                      - version
                  secret_names:
                    type: array
                    items:
                      type: string
                  version:
                    type: integer
                required:
                - document
                - editable
                - history
                - secret_names
                - version
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/admin/sources/check:
    post:
      tags:
      - Admin
      summary: Check a sign-in source
      description: 'Tries a source with someone''s username, step by step: reaching it, signing in as
        the service account, finding the person and their groups.'
      operationId: post_admin_sources_check
      x-permission: platform.identity
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: string
                settings:
                  type: object
                  properties:
                    bindDn:
                      type: string
                    bindPasswordSecret:
                      type: string
                    caFile:
                      type: string
                    enabled:
                      type: boolean
                    groups:
                      type: object
                      properties:
                        base:
                          type: string
                      required:
                      - base
                    type:
                      type: string
                    url:
                      type: string
                    users:
                      type: object
                      properties:
                        base:
                          type: string
                      required:
                      - base
                  required:
                  - bindDn
                  - bindPasswordSecret
                  - caFile
                  - enabled
                  - groups
                  - type
                  - url
                  - users
                username:
                  type: string
              required:
              - id
              - settings
              - username
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  passed:
                    type: boolean
                  steps:
                    type: array
                    items:
                      type: object
                      properties:
                        detail:
                          type: string
                        passed:
                          type: boolean
                        step:
                          type: string
                      required:
                      - detail
                      - passed
                      - step
                required:
                - passed
                - steps
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/admin/email/deliveries:
    get:
      tags:
      - Admin
      summary: Every email sent
      description: Every email FlowAssembly sent or tried to, newest first, and what became of it.
      operationId: get_admin_email_deliveries
      x-permission: platform.configure
      parameters:
      - name: limit
        in: query
        required: false
        schema:
          type: string
      - name: after
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  emails:
                    type: array
                    items:
                      type: object
                      properties:
                        attempts:
                          type: integer
                        case_id:
                          type: string
                        case_title:
                          type: string
                        evidence: {}
                        first_at:
                          type: string
                        id:
                          type: integer
                        kind:
                          type: string
                        last_at:
                          type: string
                        project:
                          type: string
                        reason:
                          type:
                          - 'null'
                          - string
                        recipients:
                          type: array
                          items:
                            type: string
                        sha256: {}
                        size: {}
                        status:
                          type: string
                        subject:
                          type: string
                        template:
                          type: string
                      required:
                      - attempts
                      - case_id
                      - case_title
                      - evidence
                      - first_at
                      - id
                      - kind
                      - last_at
                      - project
                      - reason
                      - recipients
                      - sha256
                      - size
                      - status
                      - subject
                      - template
                  more:
                    type: boolean
                required:
                - emails
                - more
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/admin/email/templates:
    get:
      tags:
      - Admin
      summary: The emails FlowAssembly sends
      description: Its own notices, with their wording, and each deployed project's emails.
      operationId: get_admin_email_templates
      x-permission: platform.configure
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  notices:
                    type: array
                    items:
                      type: object
                      properties:
                        body:
                          type: string
                        kind:
                          type: string
                        own:
                          type: boolean
                        subject:
                          type: string
                      required:
                      - body
                      - kind
                      - own
                      - subject
                  notices_sent:
                    type: boolean
                  project_emails:
                    type: array
                    items:
                      type: object
                      properties:
                        connection:
                          type: string
                        operation:
                          type: string
                        project:
                          type: string
                        subject:
                          type: string
                        template:
                          type: string
                        to:
                          type: string
                        version:
                          type: string
                      required:
                      - connection
                      - operation
                      - project
                      - subject
                      - template
                      - to
                      - version
                  wording:
                    type: object
                    properties:
                      received:
                        type: object
                        properties:
                          body:
                            type: string
                          subject:
                            type: string
                        required:
                        - body
                        - subject
                required:
                - notices
                - notices_sent
                - project_emails
                - wording
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/admin/settings:
    get:
      tags:
      - Admin
      summary: The organisation's settings
      description: Its name, time zone, working days and holidays, notice wording and retention, with
        their history.
      operationId: get_admin_settings
      x-permission: platform.configure
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  document:
                    type: object
                    properties:
                      calendar:
                        type: object
                        properties:
                          holidays:
                            type: array
                            items: {}
                          hours:
                            type: object
                            properties: {}
                          workingDays:
                            type: array
                            items:
                              type: string
                        required:
                        - holidays
                        - hours
                        - workingDays
                      maintenance:
                        type: object
                        properties: {}
                      notices:
                        type: object
                        properties: {}
                      organisation:
                        type: object
                        properties:
                          name:
                            type: string
                          timeZone:
                            type: string
                        required:
                        - name
                        - timeZone
                      plugins:
                        type: object
                        properties:
                          enabled:
                            type: array
                            items:
                              type: string
                          settings:
                            type: object
                            properties:
                              example-signature:
                                type: object
                                properties:
                                  heading:
                                    type: string
                                required:
                                - heading
                        required:
                        - enabled
                        - settings
                      retention:
                        type: object
                        properties:
                          auditDays: {}
                          caseDays: {}
                          noticeDays:
                            type: integer
                        required:
                        - auditDays
                        - caseDays
                        - noticeDays
                    required:
                    - calendar
                    - maintenance
                    - notices
                    - organisation
                    - plugins
                    - retention
                  editable:
                    type: boolean
                  history:
                    type: array
                    items:
                      type: object
                      properties:
                        changed_at:
                          type: string
                        changed_by_name:
                          type: string
                        summary:
                          type: string
                        version:
                          type: integer
                      required:
                      - changed_at
                      - changed_by_name
                      - summary
                      - version
                  version:
                    type: integer
                  web_address: {}
                required:
                - document
                - editable
                - history
                - version
                - web_address
        4XX:
          $ref: '#/components/responses/Problem'
    put:
      tags:
      - Admin
      summary: Change the organisation's settings
      description: Saves a new version, given the `version` it was based on.
      operationId: put_admin_settings
      x-permission: platform.configure
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                document:
                  type: object
                  properties:
                    calendar:
                      type: object
                      properties:
                        holidays:
                          type: array
                          items: {}
                        hours:
                          type: object
                          properties: {}
                        workingDays:
                          type: array
                          items:
                            type: string
                      required:
                      - holidays
                      - hours
                      - workingDays
                    maintenance:
                      type: object
                      properties: {}
                    notices:
                      type: object
                      properties:
                        received:
                          type: object
                          properties:
                            body:
                              type: string
                            subject:
                              type: string
                          required:
                          - body
                          - subject
                    organisation:
                      type: object
                      properties:
                        name:
                          type: string
                        timeZone:
                          type: string
                      required:
                      - name
                      - timeZone
                    plugins:
                      type: object
                      properties:
                        enabled:
                          type: array
                          items: {}
                        settings:
                          type: object
                          properties: {}
                      required:
                      - enabled
                      - settings
                    retention:
                      type: object
                      properties:
                        auditDays: {}
                        caseDays: {}
                        noticeDays:
                          type: integer
                      required:
                      - auditDays
                      - caseDays
                      - noticeDays
                  required:
                  - calendar
                  - maintenance
                  - notices
                  - organisation
                  - plugins
                  - retention
                version:
                  type: integer
              required:
              - document
              - version
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  document:
                    type: object
                    properties:
                      calendar:
                        type: object
                        properties:
                          holidays:
                            type: array
                            items: {}
                          hours:
                            type: object
                            properties: {}
                          workingDays:
                            type: array
                            items:
                              type: string
                        required:
                        - holidays
                        - hours
                        - workingDays
                      maintenance:
                        type: object
                        properties: {}
                      notices:
                        type: object
                        properties:
                          received:
                            type: object
                            properties:
                              body:
                                type: string
                              subject:
                                type: string
                            required:
                            - body
                            - subject
                      organisation:
                        type: object
                        properties:
                          name:
                            type: string
                          timeZone:
                            type: string
                        required:
                        - name
                        - timeZone
                      plugins:
                        type: object
                        properties:
                          enabled:
                            type: array
                            items: {}
                          settings:
                            type: object
                            properties: {}
                        required:
                        - enabled
                        - settings
                      retention:
                        type: object
                        properties:
                          auditDays: {}
                          caseDays: {}
                          noticeDays:
                            type: integer
                        required:
                        - auditDays
                        - caseDays
                        - noticeDays
                    required:
                    - calendar
                    - maintenance
                    - notices
                    - organisation
                    - plugins
                    - retention
                  editable:
                    type: boolean
                  history:
                    type: array
                    items:
                      type: object
                      properties:
                        changed_at:
                          type: string
                        changed_by_name:
                          type: string
                        summary:
                          type: string
                        version:
                          type: integer
                      required:
                      - changed_at
                      - changed_by_name
                      - summary
                      - version
                  version:
                    type: integer
                  web_address: {}
                required:
                - document
                - editable
                - history
                - version
                - web_address
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/admin/plugins:
    get:
      tags:
      - Admin
      summary: Plugins
      description: The plugins installed here, whether the organisation's review record lets each run,
        which are switched on, and their settings.
      operationId: get_admin_plugins
      x-permission: platform.configure
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  editable:
                    type: boolean
                  plugins:
                    type: array
                    items:
                      type: object
                      properties:
                        description:
                          type: string
                        enabled:
                          type: boolean
                        name:
                          type: string
                        package:
                          type: string
                        provides:
                          type: object
                          properties:
                            connector types:
                              type: array
                              items:
                                type: string
                            form fields:
                              type: array
                              items:
                                type: string
                            pages:
                              type: array
                              items:
                                type: string
                            settings:
                              type: array
                              items:
                                type: string
                          required:
                          - connector types
                          - form fields
                          - pages
                          - settings
                        publisher:
                          type: string
                        refusal:
                          type:
                          - string
                          - 'null'
                        review:
                          type: object
                          properties:
                            publisher:
                              type: string
                            purpose:
                              type: string
                            record:
                              type: string
                            review:
                              type: string
                            reviewed:
                              type: string
                            version:
                              type: string
                          required:
                          - publisher
                          - purpose
                          - record
                          - review
                          - reviewed
                          - version
                        settings:
                          type: object
                          properties: {}
                        settings_schema:
                          type: object
                          properties:
                            additionalProperties:
                              type: boolean
                            properties:
                              type: object
                              properties:
                                heading:
                                  type: object
                                  properties:
                                    maxLength:
                                      type: integer
                                    type:
                                      type: string
                                  required:
                                  - maxLength
                                  - type
                              required:
                              - heading
                            type:
                              type: string
                          required:
                          - additionalProperties
                          - properties
                          - type
                        title:
                          type: string
                        version:
                          type: string
                      required:
                      - description
                      - enabled
                      - name
                      - package
                      - provides
                      - publisher
                      - refusal
                      - review
                      - settings
                      - settings_schema
                      - title
                      - version
                  reviewed_record:
                    type: boolean
                  version:
                    type: integer
                required:
                - editable
                - plugins
                - reviewed_record
                - version
        4XX:
          $ref: '#/components/responses/Problem'
    put:
      tags:
      - Admin
      summary: Switch plugins on or off
      description: Saves which plugins are on and their settings, given the `version` it was based on.
      operationId: put_admin_plugins
      x-permission: platform.configure
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                enabled:
                  type: array
                  items:
                    type: string
                settings:
                  type: object
                  properties:
                    example-signature:
                      type: object
                      properties:
                        heading:
                          type: string
                      required:
                      - heading
                  required:
                  - example-signature
                version:
                  type: integer
              required:
              - enabled
              - settings
              - version
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  editable:
                    type: boolean
                  plugins:
                    type: array
                    items:
                      type: object
                      properties:
                        description:
                          type: string
                        enabled:
                          type: boolean
                        name:
                          type: string
                        package:
                          type: string
                        provides:
                          type: object
                          properties:
                            connector types:
                              type: array
                              items:
                                type: string
                            form fields:
                              type: array
                              items:
                                type: string
                            pages:
                              type: array
                              items:
                                type: string
                            settings:
                              type: array
                              items:
                                type: string
                          required:
                          - connector types
                          - form fields
                          - pages
                          - settings
                        publisher:
                          type: string
                        refusal: {}
                        review:
                          type: object
                          properties:
                            publisher:
                              type: string
                            purpose:
                              type: string
                            record:
                              type: string
                            review:
                              type: string
                            reviewed:
                              type: string
                            version:
                              type: string
                          required:
                          - publisher
                          - purpose
                          - record
                          - review
                          - reviewed
                          - version
                        settings:
                          type: object
                          properties:
                            heading:
                              type: string
                          required:
                          - heading
                        settings_schema:
                          type: object
                          properties:
                            additionalProperties:
                              type: boolean
                            properties:
                              type: object
                              properties:
                                heading:
                                  type: object
                                  properties:
                                    maxLength:
                                      type: integer
                                    type:
                                      type: string
                                  required:
                                  - maxLength
                                  - type
                              required:
                              - heading
                            type:
                              type: string
                          required:
                          - additionalProperties
                          - properties
                          - type
                        title:
                          type: string
                        version:
                          type: string
                      required:
                      - description
                      - enabled
                      - name
                      - package
                      - provides
                      - publisher
                      - refusal
                      - review
                      - settings
                      - settings_schema
                      - title
                      - version
                  reviewed_record:
                    type: boolean
                  version:
                    type: integer
                required:
                - editable
                - plugins
                - reviewed_record
                - version
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/admin/system:
    get:
      tags:
      - Admin
      summary: The instance as it runs
      description: Each service and the version it runs, storage, and the settings in use (never secrets).
      operationId: get_admin_system
      x-permission: platform.configure or platform.maintenance
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  database:
                    type: object
                    properties:
                      kind:
                        type: string
                      migration:
                        type: string
                      server:
                        type: string
                      size:
                        type: string
                    required:
                    - kind
                  email_servers:
                    type: array
                    items:
                      type: object
                      properties:
                        from:
                          type: string
                        host: {}
                        port: {}
                        secret:
                          type: string
                        tls:
                          type: string
                        used_for:
                          type: string
                      required:
                      - from
                      - host
                      - port
                      - secret
                      - tls
                      - used_for
                  health:
                    type: array
                    items:
                      type: object
                      properties:
                        instance:
                          type: string
                        last_pass_ok:
                          type: boolean
                        running:
                          type: boolean
                        seen_at:
                          type: string
                        service:
                          type: string
                        started_at:
                          type: string
                        version:
                          type:
                          - string
                          - 'null'
                      required:
                      - instance
                      - last_pass_ok
                      - running
                      - seen_at
                      - service
                      - started_at
                      - version
                  projects:
                    type: array
                    items:
                      type: object
                      properties:
                        project:
                          type: string
                        version:
                          type: string
                      required:
                      - project
                      - version
                  python:
                    type: string
                  retention:
                    type: array
                    items:
                      type: object
                      properties:
                        kept:
                          type: string
                        what:
                          type: string
                      required:
                      - kept
                      - what
                  settings_file: {}
                  sign_in_sources:
                    type: array
                    items:
                      type: string
                  storage:
                    type: object
                    properties:
                      bytes:
                        type: integer
                      files:
                        type: integer
                      largest_tables:
                        type: array
                        items:
                          type: object
                          properties:
                            size:
                              type: string
                            table:
                              type: string
                          required:
                          - size
                          - table
                    required:
                    - bytes
                    - files
                  version:
                    type: string
                required:
                - database
                - email_servers
                - health
                - projects
                - python
                - retention
                - settings_file
                - sign_in_sources
                - storage
                - version
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/admin/queues:
    get:
      tags:
      - Admin
      summary: Queues
      description: 'Per project: tasks waiting for people, steps waiting to run and steps that failed,
        and every failed step.'
      operationId: get_admin_queues
      x-permission: platform.configure or platform.maintenance
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  can_retry:
                    type: boolean
                  failed_jobs:
                    type: array
                    items: {}
                  kept_messages:
                    type: array
                    items: {}
                  projects:
                    type: array
                    items:
                      type: object
                      properties:
                        failed_jobs:
                          type: integer
                        oldest_task_at:
                          type: string
                        open_tasks:
                          type: integer
                        pending_jobs:
                          type: integer
                        project:
                          type: string
                      required:
                      - failed_jobs
                      - oldest_task_at
                      - open_tasks
                      - pending_jobs
                      - project
                required:
                - can_retry
                - failed_jobs
                - kept_messages
                - projects
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/admin/maintenance:
    put:
      tags:
      - Admin
      summary: Announce maintenance
      description: '`maintenance`: when FlowAssembly will be unavailable and what to tell people, shown
        to everyone, at sign-in too; null stops telling them. Given the settings `version` it was based
        on.'
      operationId: put_admin_maintenance
      x-permission: platform.maintenance
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                maintenance:
                  type:
                  - 'null'
                  - object
                version:
                  type: integer
              required:
              - maintenance
              - version
      responses:
        '200':
          description: Done
          content:
            application/json:
              schema:
                type: object
                properties:
                  maintenance:
                    type: object
                    properties:
                      from:
                        type: string
                      message:
                        type: string
                      until:
                        type: string
                  version:
                    type: integer
                required:
                - maintenance
                - version
        4XX:
          $ref: '#/components/responses/Problem'
  /api/v0/plugins/{name}/{path}:
    get:
      tags:
      - Plugins
      summary: A plugin's own API
      description: What a running plugin answers, for its own pages; open to people who may open one of
        them.
      operationId: get_plugins_slug_name_path_path
      x-permission: as the plugin's pages say
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
          pattern: ^[-a-zA-Z0-9_]+$
      - name: path
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: What the plugin answers
          content:
            '*/*': {}
        4XX:
          $ref: '#/components/responses/Problem'
    post:
      tags:
      - Plugins
      summary: A plugin's own API
      description: As GET.
      operationId: post_plugins_slug_name_path_path
      x-permission: as the plugin's pages say
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
          pattern: ^[-a-zA-Z0-9_]+$
      - name: path
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: What the plugin answers
          content:
            '*/*': {}
        4XX:
          $ref: '#/components/responses/Problem'
      requestBody:
        required: true
        content:
          application/json:
            schema: {}
    put:
      tags:
      - Plugins
      summary: A plugin's own API
      description: As GET.
      operationId: put_plugins_slug_name_path_path
      x-permission: as the plugin's pages say
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
          pattern: ^[-a-zA-Z0-9_]+$
      - name: path
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: What the plugin answers
          content:
            '*/*': {}
        4XX:
          $ref: '#/components/responses/Problem'
      requestBody:
        required: true
        content:
          application/json:
            schema: {}
    delete:
      tags:
      - Plugins
      summary: A plugin's own API
      description: As GET.
      operationId: delete_plugins_slug_name_path_path
      x-permission: as the plugin's pages say
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
          pattern: ^[-a-zA-Z0-9_]+$
      - name: path
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: What the plugin answers
          content:
            '*/*': {}
        4XX:
          $ref: '#/components/responses/Problem'
      requestBody:
        required: true
        content:
          application/json:
            schema: {}
components:
  schemas:
    Error:
      type: object
      required:
      - error
      - message
      properties:
        error:
          type: string
          description: 'A code that stays the same: not_signed_in, forbidden, not_found, conflict, form_invalid,
            bad_request, ...'
        message:
          type: string
          description: What went wrong, in words to show people.
        fields:
          type: object
          description: 'With form_invalid: each field that needs attention, and why.'
          additionalProperties: true
    Task:
      type: object
      properties:
        action_label:
          type: string
        assigned_at:
          type:
          - 'null'
          - string
        assignee:
          type:
          - 'null'
          - string
        assignee_name:
          type:
          - 'null'
          - string
        case_id:
          type: string
        case_owner:
          type: string
        case_owner_name:
          type: string
        case_started_at:
          type: string
        case_title:
          type: string
        created_at:
          type: string
        delegated_at:
          type: string
        due_at:
          type:
          - 'null'
          - string
        element:
          type: string
        escalated_at: {}
        form:
          type: string
        name:
          type: string
        project:
          type: string
        role:
          type: string
        role_title:
          type: string
        task_id:
          type: string
      required:
      - action_label
      - assigned_at
      - assignee
      - assignee_name
      - case_id
      - case_owner
      - case_owner_name
      - case_started_at
      - case_title
      - created_at
      - delegated_at
      - due_at
      - element
      - escalated_at
      - form
      - name
      - project
      - role
      - role_title
      - task_id
  responses:
    Problem:
      description: Refused or failed; `error` says why (400 bad request, 401 not signed in, 403 not allowed,
        404 not found, 409 conflict, 413 too large, 415 not JSON, 422 form invalid, 429 too many attempts).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    session:
      type: apiKey
      in: cookie
      name: fa_session
      description: Set by signing in (POST /api/v0/session). Every change also sends the CSRF token in
        the X-CSRFToken header.
    csrf:
      type: apiKey
      in: header
      name: X-CSRFToken
      description: From GET /api/v0/session, and again from signing in.
